babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765
  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 shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2874. * @param p defines the middle point
  2875. * @param segA defines one point of the segment
  2876. * @param segB defines the other point of the segment
  2877. * @returns the shortest distance
  2878. */
  2879. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2880. }
  2881. /**
  2882. * Class used to store (x,y,z) vector representation
  2883. * A Vector3 is the main object used in 3D geometry
  2884. * It can represent etiher the coordinates of a point the space, either a direction
  2885. * Reminder: js uses a left handed forward facing system
  2886. */
  2887. export class Vector3 {
  2888. private static _UpReadOnly;
  2889. private static _ZeroReadOnly;
  2890. /** @hidden */
  2891. _x: number;
  2892. /** @hidden */
  2893. _y: number;
  2894. /** @hidden */
  2895. _z: number;
  2896. /** @hidden */
  2897. _isDirty: boolean;
  2898. /** Gets or sets the x coordinate */
  2899. get x(): number;
  2900. set x(value: number);
  2901. /** Gets or sets the y coordinate */
  2902. get y(): number;
  2903. set y(value: number);
  2904. /** Gets or sets the z coordinate */
  2905. get z(): number;
  2906. set z(value: number);
  2907. /**
  2908. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2909. * @param x defines the first coordinates (on X axis)
  2910. * @param y defines the second coordinates (on Y axis)
  2911. * @param z defines the third coordinates (on Z axis)
  2912. */
  2913. constructor(x?: number, y?: number, z?: number);
  2914. /**
  2915. * Creates a string representation of the Vector3
  2916. * @returns a string with the Vector3 coordinates.
  2917. */
  2918. toString(): string;
  2919. /**
  2920. * Gets the class name
  2921. * @returns the string "Vector3"
  2922. */
  2923. getClassName(): string;
  2924. /**
  2925. * Creates the Vector3 hash code
  2926. * @returns a number which tends to be unique between Vector3 instances
  2927. */
  2928. getHashCode(): number;
  2929. /**
  2930. * Creates an array containing three elements : the coordinates of the Vector3
  2931. * @returns a new array of numbers
  2932. */
  2933. asArray(): number[];
  2934. /**
  2935. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2936. * @param array defines the destination array
  2937. * @param index defines the offset in the destination array
  2938. * @returns the current Vector3
  2939. */
  2940. toArray(array: FloatArray, index?: number): Vector3;
  2941. /**
  2942. * Update the current vector from an array
  2943. * @param array defines the destination array
  2944. * @param index defines the offset in the destination array
  2945. * @returns the current Vector3
  2946. */
  2947. fromArray(array: FloatArray, index?: number): Vector3;
  2948. /**
  2949. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2950. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2951. */
  2952. toQuaternion(): Quaternion;
  2953. /**
  2954. * Adds the given vector to the current Vector3
  2955. * @param otherVector defines the second operand
  2956. * @returns the current updated Vector3
  2957. */
  2958. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2959. /**
  2960. * Adds the given coordinates to the current Vector3
  2961. * @param x defines the x coordinate of the operand
  2962. * @param y defines the y coordinate of the operand
  2963. * @param z defines the z coordinate of the operand
  2964. * @returns the current updated Vector3
  2965. */
  2966. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2967. /**
  2968. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2969. * @param otherVector defines the second operand
  2970. * @returns the resulting Vector3
  2971. */
  2972. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2975. * @param otherVector defines the second operand
  2976. * @param result defines the Vector3 object where to store the result
  2977. * @returns the current Vector3
  2978. */
  2979. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2980. /**
  2981. * Subtract the given vector from the current Vector3
  2982. * @param otherVector defines the second operand
  2983. * @returns the current updated Vector3
  2984. */
  2985. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2986. /**
  2987. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2988. * @param otherVector defines the second operand
  2989. * @returns the resulting Vector3
  2990. */
  2991. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2994. * @param otherVector defines the second operand
  2995. * @param result defines the Vector3 object where to store the result
  2996. * @returns the current Vector3
  2997. */
  2998. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3001. * @param x defines the x coordinate of the operand
  3002. * @param y defines the y coordinate of the operand
  3003. * @param z defines the z coordinate of the operand
  3004. * @returns the resulting Vector3
  3005. */
  3006. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3007. /**
  3008. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  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. * @param result defines the Vector3 object where to store the result
  3013. * @returns the current Vector3
  3014. */
  3015. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3016. /**
  3017. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3018. * @returns a new Vector3
  3019. */
  3020. negate(): Vector3;
  3021. /**
  3022. * Negate this vector in place
  3023. * @returns this
  3024. */
  3025. negateInPlace(): Vector3;
  3026. /**
  3027. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3028. * @param result defines the Vector3 object where to store the result
  3029. * @returns the current Vector3
  3030. */
  3031. negateToRef(result: Vector3): Vector3;
  3032. /**
  3033. * Multiplies the Vector3 coordinates by the float "scale"
  3034. * @param scale defines the multiplier factor
  3035. * @returns the current updated Vector3
  3036. */
  3037. scaleInPlace(scale: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3040. * @param scale defines the multiplier factor
  3041. * @returns a new Vector3
  3042. */
  3043. scale(scale: number): Vector3;
  3044. /**
  3045. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3046. * @param scale defines the multiplier factor
  3047. * @param result defines the Vector3 object where to store the result
  3048. * @returns the current Vector3
  3049. */
  3050. scaleToRef(scale: number, result: Vector3): Vector3;
  3051. /**
  3052. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3053. * @param scale defines the scale factor
  3054. * @param result defines the Vector3 object where to store the result
  3055. * @returns the unmodified current Vector3
  3056. */
  3057. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3058. /**
  3059. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3060. * @param origin defines the origin of the projection ray
  3061. * @param plane defines the plane to project to
  3062. * @returns the projected vector3
  3063. */
  3064. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3065. /**
  3066. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3067. * @param origin defines the origin of the projection ray
  3068. * @param plane defines the plane to project to
  3069. * @param result defines the Vector3 where to store the result
  3070. */
  3071. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3072. /**
  3073. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3074. * @param otherVector defines the second operand
  3075. * @returns true if both vectors are equals
  3076. */
  3077. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3078. /**
  3079. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3080. * @param otherVector defines the second operand
  3081. * @param epsilon defines the minimal distance to define values as equals
  3082. * @returns true if both vectors are distant less than epsilon
  3083. */
  3084. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3085. /**
  3086. * Returns true if the current Vector3 coordinates equals the given floats
  3087. * @param x defines the x coordinate of the operand
  3088. * @param y defines the y coordinate of the operand
  3089. * @param z defines the z coordinate of the operand
  3090. * @returns true if both vectors are equals
  3091. */
  3092. equalsToFloats(x: number, y: number, z: number): boolean;
  3093. /**
  3094. * Multiplies the current Vector3 coordinates by the given ones
  3095. * @param otherVector defines the second operand
  3096. * @returns the current updated Vector3
  3097. */
  3098. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3099. /**
  3100. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3101. * @param otherVector defines the second operand
  3102. * @returns the new Vector3
  3103. */
  3104. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3105. /**
  3106. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3107. * @param otherVector defines the second operand
  3108. * @param result defines the Vector3 object where to store the result
  3109. * @returns the current Vector3
  3110. */
  3111. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3112. /**
  3113. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3114. * @param x defines the x coordinate of the operand
  3115. * @param y defines the y coordinate of the operand
  3116. * @param z defines the z coordinate of the operand
  3117. * @returns the new Vector3
  3118. */
  3119. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3120. /**
  3121. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3122. * @param otherVector defines the second operand
  3123. * @returns the new Vector3
  3124. */
  3125. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3126. /**
  3127. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3128. * @param otherVector defines the second operand
  3129. * @param result defines the Vector3 object where to store the result
  3130. * @returns the current Vector3
  3131. */
  3132. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3133. /**
  3134. * Divides the current Vector3 coordinates by the given ones.
  3135. * @param otherVector defines the second operand
  3136. * @returns the current updated Vector3
  3137. */
  3138. divideInPlace(otherVector: Vector3): Vector3;
  3139. /**
  3140. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3141. * @param other defines the second operand
  3142. * @returns the current updated Vector3
  3143. */
  3144. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3147. * @param other defines the second operand
  3148. * @returns the current updated Vector3
  3149. */
  3150. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3151. /**
  3152. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3153. * @param x defines the x coordinate of the operand
  3154. * @param y defines the y coordinate of the operand
  3155. * @param z defines the z coordinate of the operand
  3156. * @returns the current updated Vector3
  3157. */
  3158. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3159. /**
  3160. * Updates the current Vector3 with the maximal 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. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3167. /**
  3168. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3169. * Check if is non uniform within a certain amount of decimal places to account for this
  3170. * @param epsilon the amount the values can differ
  3171. * @returns if the the vector is non uniform to a certain number of decimal places
  3172. */
  3173. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3174. /**
  3175. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3176. */
  3177. get isNonUniform(): boolean;
  3178. /**
  3179. * Gets a new Vector3 from current Vector3 floored values
  3180. * @returns a new Vector3
  3181. */
  3182. floor(): Vector3;
  3183. /**
  3184. * Gets a new Vector3 from current Vector3 floored values
  3185. * @returns a new Vector3
  3186. */
  3187. fract(): Vector3;
  3188. /**
  3189. * Gets the length of the Vector3
  3190. * @returns the length of the Vector3
  3191. */
  3192. length(): number;
  3193. /**
  3194. * Gets the squared length of the Vector3
  3195. * @returns squared length of the Vector3
  3196. */
  3197. lengthSquared(): number;
  3198. /**
  3199. * Normalize the current Vector3.
  3200. * Please note that this is an in place operation.
  3201. * @returns the current updated Vector3
  3202. */
  3203. normalize(): Vector3;
  3204. /**
  3205. * Reorders the x y z properties of the vector in place
  3206. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3207. * @returns the current updated vector
  3208. */
  3209. reorderInPlace(order: string): this;
  3210. /**
  3211. * Rotates the vector around 0,0,0 by a quaternion
  3212. * @param quaternion the rotation quaternion
  3213. * @param result vector to store the result
  3214. * @returns the resulting vector
  3215. */
  3216. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3217. /**
  3218. * Rotates a vector around a given point
  3219. * @param quaternion the rotation quaternion
  3220. * @param point the point to rotate around
  3221. * @param result vector to store the result
  3222. * @returns the resulting vector
  3223. */
  3224. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3225. /**
  3226. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3227. * The cross product is then orthogonal to both current and "other"
  3228. * @param other defines the right operand
  3229. * @returns the cross product
  3230. */
  3231. cross(other: Vector3): Vector3;
  3232. /**
  3233. * Normalize the current Vector3 with the given input length.
  3234. * Please note that this is an in place operation.
  3235. * @param len the length of the vector
  3236. * @returns the current updated Vector3
  3237. */
  3238. normalizeFromLength(len: number): Vector3;
  3239. /**
  3240. * Normalize the current Vector3 to a new vector
  3241. * @returns the new Vector3
  3242. */
  3243. normalizeToNew(): Vector3;
  3244. /**
  3245. * Normalize the current Vector3 to the reference
  3246. * @param reference define the Vector3 to update
  3247. * @returns the updated Vector3
  3248. */
  3249. normalizeToRef(reference: Vector3): Vector3;
  3250. /**
  3251. * Creates a new Vector3 copied from the current Vector3
  3252. * @returns the new Vector3
  3253. */
  3254. clone(): Vector3;
  3255. /**
  3256. * Copies the given vector coordinates to the current Vector3 ones
  3257. * @param source defines the source Vector3
  3258. * @returns the current updated Vector3
  3259. */
  3260. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * Copies the given floats to the current Vector3 coordinates
  3263. * @param x defines the x coordinate of the operand
  3264. * @param y defines the y coordinate of the operand
  3265. * @param z defines the z coordinate of the operand
  3266. * @returns the current updated Vector3
  3267. */
  3268. copyFromFloats(x: number, y: number, z: number): 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. set(x: number, y: number, z: number): Vector3;
  3277. /**
  3278. * Copies the given float to the current Vector3 coordinates
  3279. * @param v defines the x, y and z coordinates of the operand
  3280. * @returns the current updated Vector3
  3281. */
  3282. setAll(v: number): Vector3;
  3283. /**
  3284. * Get the clip factor between two vectors
  3285. * @param vector0 defines the first operand
  3286. * @param vector1 defines the second operand
  3287. * @param axis defines the axis to use
  3288. * @param size defines the size along the axis
  3289. * @returns the clip factor
  3290. */
  3291. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3292. /**
  3293. * Get angle between two vectors
  3294. * @param vector0 angle between vector0 and vector1
  3295. * @param vector1 angle between vector0 and vector1
  3296. * @param normal direction of the normal
  3297. * @return the angle between vector0 and vector1
  3298. */
  3299. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3300. /**
  3301. * Returns a new Vector3 set from the index "offset" of the given array
  3302. * @param array defines the source array
  3303. * @param offset defines the offset in the source array
  3304. * @returns the new Vector3
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3307. /**
  3308. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3309. * @param array defines the source array
  3310. * @param offset defines the offset in the source array
  3311. * @returns the new Vector3
  3312. * @deprecated Please use FromArray instead.
  3313. */
  3314. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3315. /**
  3316. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3317. * @param array defines the source array
  3318. * @param offset defines the offset in the source array
  3319. * @param result defines the Vector3 where to store the result
  3320. */
  3321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3322. /**
  3323. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3324. * @param array defines the source array
  3325. * @param offset defines the offset in the source array
  3326. * @param result defines the Vector3 where to store the result
  3327. * @deprecated Please use FromArrayToRef instead.
  3328. */
  3329. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3330. /**
  3331. * Sets the given vector "result" with the given floats.
  3332. * @param x defines the x coordinate of the source
  3333. * @param y defines the y coordinate of the source
  3334. * @param z defines the z coordinate of the source
  3335. * @param result defines the Vector3 where to store the result
  3336. */
  3337. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3338. /**
  3339. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3340. * @returns a new empty Vector3
  3341. */
  3342. static Zero(): Vector3;
  3343. /**
  3344. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3345. * @returns a new unit Vector3
  3346. */
  3347. static One(): Vector3;
  3348. /**
  3349. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3350. * @returns a new up Vector3
  3351. */
  3352. static Up(): Vector3;
  3353. /**
  3354. * Gets a up Vector3 that must not be updated
  3355. */
  3356. static get UpReadOnly(): DeepImmutable<Vector3>;
  3357. /**
  3358. * Gets a zero Vector3 that must not be updated
  3359. */
  3360. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3361. /**
  3362. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3363. * @returns a new down Vector3
  3364. */
  3365. static Down(): Vector3;
  3366. /**
  3367. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3368. * @param rightHandedSystem is the scene right-handed (negative z)
  3369. * @returns a new forward Vector3
  3370. */
  3371. static Forward(rightHandedSystem?: boolean): Vector3;
  3372. /**
  3373. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3374. * @param rightHandedSystem is the scene right-handed (negative-z)
  3375. * @returns a new forward Vector3
  3376. */
  3377. static Backward(rightHandedSystem?: boolean): Vector3;
  3378. /**
  3379. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3380. * @returns a new right Vector3
  3381. */
  3382. static Right(): Vector3;
  3383. /**
  3384. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3385. * @returns a new left Vector3
  3386. */
  3387. static Left(): Vector3;
  3388. /**
  3389. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3390. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3391. * @param vector defines the Vector3 to transform
  3392. * @param transformation defines the transformation matrix
  3393. * @returns the transformed Vector3
  3394. */
  3395. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3396. /**
  3397. * Sets the given vector "result" coordinates 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. * @param result defines the Vector3 where to store the result
  3402. */
  3403. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3404. /**
  3405. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3406. * This method computes tranformed coordinates only, not transformed direction vectors
  3407. * @param x define the x coordinate of the source vector
  3408. * @param y define the y coordinate of the source vector
  3409. * @param z define the z coordinate of the source vector
  3410. * @param transformation defines the transformation matrix
  3411. * @param result defines the Vector3 where to store the result
  3412. */
  3413. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3414. /**
  3415. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3416. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3417. * @param vector defines the Vector3 to transform
  3418. * @param transformation defines the transformation matrix
  3419. * @returns the new Vector3
  3420. */
  3421. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3422. /**
  3423. * Sets the given vector "result" 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. * @param result defines the Vector3 where to store the result
  3428. */
  3429. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3432. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3433. * @param x define the x coordinate of the source vector
  3434. * @param y define the y coordinate of the source vector
  3435. * @param z define the z coordinate of the source vector
  3436. * @param transformation defines the transformation matrix
  3437. * @param result defines the Vector3 where to store the result
  3438. */
  3439. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3440. /**
  3441. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3442. * @param value1 defines the first control point
  3443. * @param value2 defines the second control point
  3444. * @param value3 defines the third control point
  3445. * @param value4 defines the fourth control point
  3446. * @param amount defines the amount on the spline to use
  3447. * @returns the new Vector3
  3448. */
  3449. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3450. /**
  3451. * 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"
  3452. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3453. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3454. * @param value defines the current value
  3455. * @param min defines the lower range value
  3456. * @param max defines the upper range value
  3457. * @returns the new Vector3
  3458. */
  3459. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3460. /**
  3461. * 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"
  3462. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3463. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3464. * @param value defines the current value
  3465. * @param min defines the lower range value
  3466. * @param max defines the upper range value
  3467. * @param result defines the Vector3 where to store the result
  3468. */
  3469. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3470. /**
  3471. * Checks if a given vector is inside a specific range
  3472. * @param v defines the vector to test
  3473. * @param min defines the minimum range
  3474. * @param max defines the maximum range
  3475. */
  3476. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3477. /**
  3478. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3479. * @param value1 defines the first control point
  3480. * @param tangent1 defines the first tangent vector
  3481. * @param value2 defines the second control point
  3482. * @param tangent2 defines the second tangent vector
  3483. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3484. * @returns the new Vector3
  3485. */
  3486. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3487. /**
  3488. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3489. * @param start defines the start value
  3490. * @param end defines the end value
  3491. * @param amount max defines amount between both (between 0 and 1)
  3492. * @returns the new Vector3
  3493. */
  3494. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3495. /**
  3496. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "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. * @param result defines the Vector3 where to store the result
  3501. */
  3502. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3503. /**
  3504. * Returns the dot product (float) between the vectors "left" and "right"
  3505. * @param left defines the left operand
  3506. * @param right defines the right operand
  3507. * @returns the dot product
  3508. */
  3509. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3510. /**
  3511. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3512. * The cross product is then orthogonal to both "left" and "right"
  3513. * @param left defines the left operand
  3514. * @param right defines the right operand
  3515. * @returns the cross product
  3516. */
  3517. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3518. /**
  3519. * Sets the given vector "result" with the cross product of "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. * @param result defines the Vector3 where to store the result
  3524. */
  3525. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3526. /**
  3527. * Returns a new Vector3 as the normalization of the given vector
  3528. * @param vector defines the Vector3 to normalize
  3529. * @returns the new Vector3
  3530. */
  3531. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3532. /**
  3533. * Sets the given vector "result" with the normalization of the given first vector
  3534. * @param vector defines the Vector3 to normalize
  3535. * @param result defines the Vector3 where to store the result
  3536. */
  3537. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3538. /**
  3539. * Project a Vector3 onto screen space
  3540. * @param vector defines the Vector3 to project
  3541. * @param world defines the world matrix to use
  3542. * @param transform defines the transform (view x projection) matrix to use
  3543. * @param viewport defines the screen viewport to use
  3544. * @returns the new Vector3
  3545. */
  3546. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3547. /**
  3548. * Project a Vector3 onto screen space to reference
  3549. * @param vector defines the Vector3 to project
  3550. * @param world defines the world matrix to use
  3551. * @param transform defines the transform (view x projection) matrix to use
  3552. * @param viewport defines the screen viewport to use
  3553. * @param result the vector in which the screen space will be stored
  3554. * @returns the new Vector3
  3555. */
  3556. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3557. /** @hidden */
  3558. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3559. /**
  3560. * Unproject from screen space to object space
  3561. * @param source defines the screen space Vector3 to use
  3562. * @param viewportWidth defines the current width of the viewport
  3563. * @param viewportHeight defines the current height of the viewport
  3564. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3565. * @param transform defines the transform (view x projection) matrix to use
  3566. * @returns the new Vector3
  3567. */
  3568. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3569. /**
  3570. * Unproject from screen space to object space
  3571. * @param source defines the screen space Vector3 to use
  3572. * @param viewportWidth defines the current width of the viewport
  3573. * @param viewportHeight defines the current height of the viewport
  3574. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3575. * @param view defines the view matrix to use
  3576. * @param projection defines the projection matrix to use
  3577. * @returns the new Vector3
  3578. */
  3579. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3580. /**
  3581. * Unproject from screen space to object space
  3582. * @param source defines the screen space Vector3 to use
  3583. * @param viewportWidth defines the current width of the viewport
  3584. * @param viewportHeight defines the current height of the viewport
  3585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3586. * @param view defines the view matrix to use
  3587. * @param projection defines the projection matrix to use
  3588. * @param result defines the Vector3 where to store the result
  3589. */
  3590. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3591. /**
  3592. * Unproject from screen space to object space
  3593. * @param sourceX defines the screen space x coordinate to use
  3594. * @param sourceY defines the screen space y coordinate to use
  3595. * @param sourceZ defines the screen space z coordinate to use
  3596. * @param viewportWidth defines the current width of the viewport
  3597. * @param viewportHeight defines the current height of the viewport
  3598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3599. * @param view defines the view matrix to use
  3600. * @param projection defines the projection matrix to use
  3601. * @param result defines the Vector3 where to store the result
  3602. */
  3603. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3604. /**
  3605. * Gets the minimal coordinate values between two Vector3
  3606. * @param left defines the first operand
  3607. * @param right defines the second operand
  3608. * @returns the new Vector3
  3609. */
  3610. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3611. /**
  3612. * Gets the maximal coordinate values between two Vector3
  3613. * @param left defines the first operand
  3614. * @param right defines the second operand
  3615. * @returns the new Vector3
  3616. */
  3617. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3618. /**
  3619. * Returns the distance between the vectors "value1" and "value2"
  3620. * @param value1 defines the first operand
  3621. * @param value2 defines the second operand
  3622. * @returns the distance
  3623. */
  3624. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3625. /**
  3626. * Returns the squared distance between the vectors "value1" and "value2"
  3627. * @param value1 defines the first operand
  3628. * @param value2 defines the second operand
  3629. * @returns the squared distance
  3630. */
  3631. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3632. /**
  3633. * Returns a new Vector3 located at the center between "value1" and "value2"
  3634. * @param value1 defines the first operand
  3635. * @param value2 defines the second operand
  3636. * @returns the new Vector3
  3637. */
  3638. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3639. /**
  3640. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3641. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3642. * to something in order to rotate it from its local system to the given target system
  3643. * Note: axis1, axis2 and axis3 are normalized during this operation
  3644. * @param axis1 defines the first axis
  3645. * @param axis2 defines the second axis
  3646. * @param axis3 defines the third axis
  3647. * @returns a new Vector3
  3648. */
  3649. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3650. /**
  3651. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3652. * @param axis1 defines the first axis
  3653. * @param axis2 defines the second axis
  3654. * @param axis3 defines the third axis
  3655. * @param ref defines the Vector3 where to store the result
  3656. */
  3657. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3658. }
  3659. /**
  3660. * Vector4 class created for EulerAngle class conversion to Quaternion
  3661. */
  3662. export class Vector4 {
  3663. /** x value of the vector */
  3664. x: number;
  3665. /** y value of the vector */
  3666. y: number;
  3667. /** z value of the vector */
  3668. z: number;
  3669. /** w value of the vector */
  3670. w: number;
  3671. /**
  3672. * Creates a Vector4 object from the given floats.
  3673. * @param x x value of the vector
  3674. * @param y y value of the vector
  3675. * @param z z value of the vector
  3676. * @param w w value of the vector
  3677. */
  3678. constructor(
  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. * Returns the string with the Vector4 coordinates.
  3689. * @returns a string containing all the vector values
  3690. */
  3691. toString(): string;
  3692. /**
  3693. * Returns the string "Vector4".
  3694. * @returns "Vector4"
  3695. */
  3696. getClassName(): string;
  3697. /**
  3698. * Returns the Vector4 hash code.
  3699. * @returns a unique hash code
  3700. */
  3701. getHashCode(): number;
  3702. /**
  3703. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3704. * @returns the resulting array
  3705. */
  3706. asArray(): number[];
  3707. /**
  3708. * Populates the given array from the given index with the Vector4 coordinates.
  3709. * @param array array to populate
  3710. * @param index index of the array to start at (default: 0)
  3711. * @returns the Vector4.
  3712. */
  3713. toArray(array: FloatArray, index?: number): Vector4;
  3714. /**
  3715. * Update the current vector from an array
  3716. * @param array defines the destination array
  3717. * @param index defines the offset in the destination array
  3718. * @returns the current Vector3
  3719. */
  3720. fromArray(array: FloatArray, index?: number): Vector4;
  3721. /**
  3722. * Adds the given vector to the current Vector4.
  3723. * @param otherVector the vector to add
  3724. * @returns the updated Vector4.
  3725. */
  3726. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3727. /**
  3728. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3729. * @param otherVector the vector to add
  3730. * @returns the resulting vector
  3731. */
  3732. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3733. /**
  3734. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3735. * @param otherVector the vector to add
  3736. * @param result the vector to store the result
  3737. * @returns the current Vector4.
  3738. */
  3739. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3740. /**
  3741. * Subtract in place the given vector from the current Vector4.
  3742. * @param otherVector the vector to subtract
  3743. * @returns the updated Vector4.
  3744. */
  3745. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3746. /**
  3747. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3748. * @param otherVector the vector to add
  3749. * @returns the new vector with the result
  3750. */
  3751. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3752. /**
  3753. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3754. * @param otherVector the vector to subtract
  3755. * @param result the vector to store the result
  3756. * @returns the current Vector4.
  3757. */
  3758. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3759. /**
  3760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3761. */
  3762. /**
  3763. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3764. * @param x value to subtract
  3765. * @param y value to subtract
  3766. * @param z value to subtract
  3767. * @param w value to subtract
  3768. * @returns new vector containing the result
  3769. */
  3770. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3771. /**
  3772. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3773. * @param x value to subtract
  3774. * @param y value to subtract
  3775. * @param z value to subtract
  3776. * @param w value to subtract
  3777. * @param result the vector to store the result in
  3778. * @returns the current Vector4.
  3779. */
  3780. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3781. /**
  3782. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3783. * @returns a new vector with the negated values
  3784. */
  3785. negate(): Vector4;
  3786. /**
  3787. * Negate this vector in place
  3788. * @returns this
  3789. */
  3790. negateInPlace(): Vector4;
  3791. /**
  3792. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3793. * @param result defines the Vector3 object where to store the result
  3794. * @returns the current Vector4
  3795. */
  3796. negateToRef(result: Vector4): Vector4;
  3797. /**
  3798. * Multiplies the current Vector4 coordinates by scale (float).
  3799. * @param scale the number to scale with
  3800. * @returns the updated Vector4.
  3801. */
  3802. scaleInPlace(scale: number): Vector4;
  3803. /**
  3804. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3805. * @param scale the number to scale with
  3806. * @returns a new vector with the result
  3807. */
  3808. scale(scale: number): Vector4;
  3809. /**
  3810. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3811. * @param scale the number to scale with
  3812. * @param result a vector to store the result in
  3813. * @returns the current Vector4.
  3814. */
  3815. scaleToRef(scale: number, result: Vector4): Vector4;
  3816. /**
  3817. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3818. * @param scale defines the scale factor
  3819. * @param result defines the Vector4 object where to store the result
  3820. * @returns the unmodified current Vector4
  3821. */
  3822. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3823. /**
  3824. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3825. * @param otherVector the vector to compare against
  3826. * @returns true if they are equal
  3827. */
  3828. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3829. /**
  3830. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3831. * @param otherVector vector to compare against
  3832. * @param epsilon (Default: very small number)
  3833. * @returns true if they are equal
  3834. */
  3835. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3836. /**
  3837. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3838. * @param x x value to compare against
  3839. * @param y y value to compare against
  3840. * @param z z value to compare against
  3841. * @param w w value to compare against
  3842. * @returns true if equal
  3843. */
  3844. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3845. /**
  3846. * Multiplies in place the current Vector4 by the given one.
  3847. * @param otherVector vector to multiple with
  3848. * @returns the updated Vector4.
  3849. */
  3850. multiplyInPlace(otherVector: Vector4): Vector4;
  3851. /**
  3852. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3853. * @param otherVector vector to multiple with
  3854. * @returns resulting new vector
  3855. */
  3856. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3857. /**
  3858. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3859. * @param otherVector vector to multiple with
  3860. * @param result vector to store the result
  3861. * @returns the current Vector4.
  3862. */
  3863. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3864. /**
  3865. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3866. * @param x x value multiply with
  3867. * @param y y value multiply with
  3868. * @param z z value multiply with
  3869. * @param w w value multiply with
  3870. * @returns resulting new vector
  3871. */
  3872. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3873. /**
  3874. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3875. * @param otherVector vector to devide with
  3876. * @returns resulting new vector
  3877. */
  3878. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3879. /**
  3880. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3881. * @param otherVector vector to devide with
  3882. * @param result vector to store the result
  3883. * @returns the current Vector4.
  3884. */
  3885. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3886. /**
  3887. * Divides the current Vector3 coordinates by the given ones.
  3888. * @param otherVector vector to devide with
  3889. * @returns the updated Vector3.
  3890. */
  3891. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3892. /**
  3893. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3894. * @param other defines the second operand
  3895. * @returns the current updated Vector4
  3896. */
  3897. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3898. /**
  3899. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3900. * @param other defines the second operand
  3901. * @returns the current updated Vector4
  3902. */
  3903. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3904. /**
  3905. * Gets a new Vector4 from current Vector4 floored values
  3906. * @returns a new Vector4
  3907. */
  3908. floor(): Vector4;
  3909. /**
  3910. * Gets a new Vector4 from current Vector3 floored values
  3911. * @returns a new Vector4
  3912. */
  3913. fract(): Vector4;
  3914. /**
  3915. * Returns the Vector4 length (float).
  3916. * @returns the length
  3917. */
  3918. length(): number;
  3919. /**
  3920. * Returns the Vector4 squared length (float).
  3921. * @returns the length squared
  3922. */
  3923. lengthSquared(): number;
  3924. /**
  3925. * Normalizes in place the Vector4.
  3926. * @returns the updated Vector4.
  3927. */
  3928. normalize(): Vector4;
  3929. /**
  3930. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3931. * @returns this converted to a new vector3
  3932. */
  3933. toVector3(): Vector3;
  3934. /**
  3935. * Returns a new Vector4 copied from the current one.
  3936. * @returns the new cloned vector
  3937. */
  3938. clone(): Vector4;
  3939. /**
  3940. * Updates the current Vector4 with the given one coordinates.
  3941. * @param source the source vector to copy from
  3942. * @returns the updated Vector4.
  3943. */
  3944. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3945. /**
  3946. * Updates the current Vector4 coordinates with the given floats.
  3947. * @param x float to copy from
  3948. * @param y float to copy from
  3949. * @param z float to copy from
  3950. * @param w float to copy from
  3951. * @returns the updated Vector4.
  3952. */
  3953. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3954. /**
  3955. * Updates the current Vector4 coordinates with the given floats.
  3956. * @param x float to set from
  3957. * @param y float to set from
  3958. * @param z float to set from
  3959. * @param w float to set from
  3960. * @returns the updated Vector4.
  3961. */
  3962. set(x: number, y: number, z: number, w: number): Vector4;
  3963. /**
  3964. * Copies the given float to the current Vector3 coordinates
  3965. * @param v defines the x, y, z and w coordinates of the operand
  3966. * @returns the current updated Vector3
  3967. */
  3968. setAll(v: number): Vector4;
  3969. /**
  3970. * Returns a new Vector4 set from the starting index of the given array.
  3971. * @param array the array to pull values from
  3972. * @param offset the offset into the array to start at
  3973. * @returns the new vector
  3974. */
  3975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3976. /**
  3977. * Updates the given vector "result" from the starting index of the given array.
  3978. * @param array the array to pull values from
  3979. * @param offset the offset into the array to start at
  3980. * @param result the vector to store the result in
  3981. */
  3982. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3983. /**
  3984. * Updates the given vector "result" from the starting index of the given Float32Array.
  3985. * @param array the array to pull values from
  3986. * @param offset the offset into the array to start at
  3987. * @param result the vector to store the result in
  3988. */
  3989. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3990. /**
  3991. * Updates the given vector "result" coordinates from the given floats.
  3992. * @param x float to set from
  3993. * @param y float to set from
  3994. * @param z float to set from
  3995. * @param w float to set from
  3996. * @param result the vector to the floats in
  3997. */
  3998. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3999. /**
  4000. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4001. * @returns the new vector
  4002. */
  4003. static Zero(): Vector4;
  4004. /**
  4005. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4006. * @returns the new vector
  4007. */
  4008. static One(): Vector4;
  4009. /**
  4010. * Returns a new normalized Vector4 from the given one.
  4011. * @param vector the vector to normalize
  4012. * @returns the vector
  4013. */
  4014. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4015. /**
  4016. * Updates the given vector "result" from the normalization of the given one.
  4017. * @param vector the vector to normalize
  4018. * @param result the vector to store the result in
  4019. */
  4020. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4021. /**
  4022. * Returns a vector with the minimum values from the left and right vectors
  4023. * @param left left vector to minimize
  4024. * @param right right vector to minimize
  4025. * @returns a new vector with the minimum of the left and right vector values
  4026. */
  4027. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4028. /**
  4029. * Returns a vector with the maximum values from the left and right vectors
  4030. * @param left left vector to maximize
  4031. * @param right right vector to maximize
  4032. * @returns a new vector with the maximum of the left and right vector values
  4033. */
  4034. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4035. /**
  4036. * Returns the distance (float) between the vectors "value1" and "value2".
  4037. * @param value1 value to calulate the distance between
  4038. * @param value2 value to calulate the distance between
  4039. * @return the distance between the two vectors
  4040. */
  4041. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4042. /**
  4043. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4044. * @param value1 value to calulate the distance between
  4045. * @param value2 value to calulate the distance between
  4046. * @return the distance between the two vectors squared
  4047. */
  4048. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4049. /**
  4050. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4051. * @param value1 value to calulate the center between
  4052. * @param value2 value to calulate the center between
  4053. * @return the center between the two vectors
  4054. */
  4055. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4056. /**
  4057. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4058. * This methods computes transformed normalized direction vectors only.
  4059. * @param vector the vector to transform
  4060. * @param transformation the transformation matrix to apply
  4061. * @returns the new vector
  4062. */
  4063. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4064. /**
  4065. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4066. * This methods computes transformed normalized direction vectors only.
  4067. * @param vector the vector to transform
  4068. * @param transformation the transformation matrix to apply
  4069. * @param result the vector to store the result in
  4070. */
  4071. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4072. /**
  4073. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4074. * This methods computes transformed normalized direction vectors only.
  4075. * @param x value to transform
  4076. * @param y value to transform
  4077. * @param z value to transform
  4078. * @param w value to transform
  4079. * @param transformation the transformation matrix to apply
  4080. * @param result the vector to store the results in
  4081. */
  4082. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4083. /**
  4084. * Creates a new Vector4 from a Vector3
  4085. * @param source defines the source data
  4086. * @param w defines the 4th component (default is 0)
  4087. * @returns a new Vector4
  4088. */
  4089. static FromVector3(source: Vector3, w?: number): Vector4;
  4090. }
  4091. /**
  4092. * Class used to store quaternion data
  4093. * @see https://en.wikipedia.org/wiki/Quaternion
  4094. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4095. */
  4096. export class Quaternion {
  4097. /** @hidden */
  4098. _x: number;
  4099. /** @hidden */
  4100. _y: number;
  4101. /** @hidden */
  4102. _z: number;
  4103. /** @hidden */
  4104. _w: number;
  4105. /** @hidden */
  4106. _isDirty: boolean;
  4107. /** Gets or sets the x coordinate */
  4108. get x(): number;
  4109. set x(value: number);
  4110. /** Gets or sets the y coordinate */
  4111. get y(): number;
  4112. set y(value: number);
  4113. /** Gets or sets the z coordinate */
  4114. get z(): number;
  4115. set z(value: number);
  4116. /** Gets or sets the w coordinate */
  4117. get w(): number;
  4118. set w(value: number);
  4119. /**
  4120. * Creates a new Quaternion from the given floats
  4121. * @param x defines the first component (0 by default)
  4122. * @param y defines the second component (0 by default)
  4123. * @param z defines the third component (0 by default)
  4124. * @param w defines the fourth component (1.0 by default)
  4125. */
  4126. constructor(x?: number, y?: number, z?: number, w?: number);
  4127. /**
  4128. * Gets a string representation for the current quaternion
  4129. * @returns a string with the Quaternion coordinates
  4130. */
  4131. toString(): string;
  4132. /**
  4133. * Gets the class name of the quaternion
  4134. * @returns the string "Quaternion"
  4135. */
  4136. getClassName(): string;
  4137. /**
  4138. * Gets a hash code for this quaternion
  4139. * @returns the quaternion hash code
  4140. */
  4141. getHashCode(): number;
  4142. /**
  4143. * Copy the quaternion to an array
  4144. * @returns a new array populated with 4 elements from the quaternion coordinates
  4145. */
  4146. asArray(): number[];
  4147. /**
  4148. * Check if two quaternions are equals
  4149. * @param otherQuaternion defines the second operand
  4150. * @return true if the current quaternion and the given one coordinates are strictly equals
  4151. */
  4152. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4153. /**
  4154. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4155. * @param otherQuaternion defines the other quaternion
  4156. * @param epsilon defines the minimal distance to consider equality
  4157. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4158. */
  4159. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4160. /**
  4161. * Clone the current quaternion
  4162. * @returns a new quaternion copied from the current one
  4163. */
  4164. clone(): Quaternion;
  4165. /**
  4166. * Copy a quaternion to the current one
  4167. * @param other defines the other quaternion
  4168. * @returns the updated current quaternion
  4169. */
  4170. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4171. /**
  4172. * Updates the current quaternion with the given float coordinates
  4173. * @param x defines the x coordinate
  4174. * @param y defines the y coordinate
  4175. * @param z defines the z coordinate
  4176. * @param w defines the w coordinate
  4177. * @returns the updated current quaternion
  4178. */
  4179. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4180. /**
  4181. * Updates the current quaternion from the given float coordinates
  4182. * @param x defines the x coordinate
  4183. * @param y defines the y coordinate
  4184. * @param z defines the z coordinate
  4185. * @param w defines the w coordinate
  4186. * @returns the updated current quaternion
  4187. */
  4188. set(x: number, y: number, z: number, w: number): Quaternion;
  4189. /**
  4190. * Adds two quaternions
  4191. * @param other defines the second operand
  4192. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4193. */
  4194. add(other: DeepImmutable<Quaternion>): Quaternion;
  4195. /**
  4196. * Add a quaternion to the current one
  4197. * @param other defines the quaternion to add
  4198. * @returns the current quaternion
  4199. */
  4200. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4201. /**
  4202. * Subtract two quaternions
  4203. * @param other defines the second operand
  4204. * @returns a new quaternion as the subtraction result of the given one from the current one
  4205. */
  4206. subtract(other: Quaternion): Quaternion;
  4207. /**
  4208. * Multiplies the current quaternion by a scale factor
  4209. * @param value defines the scale factor
  4210. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4211. */
  4212. scale(value: number): Quaternion;
  4213. /**
  4214. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4215. * @param scale defines the scale factor
  4216. * @param result defines the Quaternion object where to store the result
  4217. * @returns the unmodified current quaternion
  4218. */
  4219. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4220. /**
  4221. * Multiplies in place the current quaternion by a scale factor
  4222. * @param value defines the scale factor
  4223. * @returns the current modified quaternion
  4224. */
  4225. scaleInPlace(value: number): Quaternion;
  4226. /**
  4227. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4228. * @param scale defines the scale factor
  4229. * @param result defines the Quaternion object where to store the result
  4230. * @returns the unmodified current quaternion
  4231. */
  4232. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4233. /**
  4234. * Multiplies two quaternions
  4235. * @param q1 defines the second operand
  4236. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4237. */
  4238. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4239. /**
  4240. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4241. * @param q1 defines the second operand
  4242. * @param result defines the target quaternion
  4243. * @returns the current quaternion
  4244. */
  4245. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4246. /**
  4247. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4248. * @param q1 defines the second operand
  4249. * @returns the currentupdated quaternion
  4250. */
  4251. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4252. /**
  4253. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4254. * @param ref defines the target quaternion
  4255. * @returns the current quaternion
  4256. */
  4257. conjugateToRef(ref: Quaternion): Quaternion;
  4258. /**
  4259. * Conjugates in place (1-q) the current quaternion
  4260. * @returns the current updated quaternion
  4261. */
  4262. conjugateInPlace(): Quaternion;
  4263. /**
  4264. * Conjugates in place (1-q) the current quaternion
  4265. * @returns a new quaternion
  4266. */
  4267. conjugate(): Quaternion;
  4268. /**
  4269. * Gets length of current quaternion
  4270. * @returns the quaternion length (float)
  4271. */
  4272. length(): number;
  4273. /**
  4274. * Normalize in place the current quaternion
  4275. * @returns the current updated quaternion
  4276. */
  4277. normalize(): Quaternion;
  4278. /**
  4279. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4280. * @param order is a reserved parameter and is ignored for now
  4281. * @returns a new Vector3 containing the Euler angles
  4282. */
  4283. toEulerAngles(order?: string): Vector3;
  4284. /**
  4285. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4286. * @param result defines the vector which will be filled with the Euler angles
  4287. * @returns the current unchanged quaternion
  4288. */
  4289. toEulerAnglesToRef(result: Vector3): Quaternion;
  4290. /**
  4291. * Updates the given rotation matrix with the current quaternion values
  4292. * @param result defines the target matrix
  4293. * @returns the current unchanged quaternion
  4294. */
  4295. toRotationMatrix(result: Matrix): Quaternion;
  4296. /**
  4297. * Updates the current quaternion from the given rotation matrix values
  4298. * @param matrix defines the source matrix
  4299. * @returns the current updated quaternion
  4300. */
  4301. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4302. /**
  4303. * Creates a new quaternion from a rotation matrix
  4304. * @param matrix defines the source matrix
  4305. * @returns a new quaternion created from the given rotation matrix values
  4306. */
  4307. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4308. /**
  4309. * Updates the given quaternion with the given rotation matrix values
  4310. * @param matrix defines the source matrix
  4311. * @param result defines the target quaternion
  4312. */
  4313. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4314. /**
  4315. * Returns the dot product (float) between the quaternions "left" and "right"
  4316. * @param left defines the left operand
  4317. * @param right defines the right operand
  4318. * @returns the dot product
  4319. */
  4320. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4321. /**
  4322. * Checks if the two quaternions are close to each other
  4323. * @param quat0 defines the first quaternion to check
  4324. * @param quat1 defines the second quaternion to check
  4325. * @returns true if the two quaternions are close to each other
  4326. */
  4327. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4328. /**
  4329. * Creates an empty quaternion
  4330. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4331. */
  4332. static Zero(): Quaternion;
  4333. /**
  4334. * Inverse a given quaternion
  4335. * @param q defines the source quaternion
  4336. * @returns a new quaternion as the inverted current quaternion
  4337. */
  4338. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4339. /**
  4340. * Inverse a given quaternion
  4341. * @param q defines the source quaternion
  4342. * @param result the quaternion the result will be stored in
  4343. * @returns the result quaternion
  4344. */
  4345. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4346. /**
  4347. * Creates an identity quaternion
  4348. * @returns the identity quaternion
  4349. */
  4350. static Identity(): Quaternion;
  4351. /**
  4352. * Gets a boolean indicating if the given quaternion is identity
  4353. * @param quaternion defines the quaternion to check
  4354. * @returns true if the quaternion is identity
  4355. */
  4356. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4357. /**
  4358. * Creates a quaternion from a rotation around an axis
  4359. * @param axis defines the axis to use
  4360. * @param angle defines the angle to use
  4361. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4362. */
  4363. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4364. /**
  4365. * Creates a rotation around an axis and stores it into the given quaternion
  4366. * @param axis defines the axis to use
  4367. * @param angle defines the angle to use
  4368. * @param result defines the target quaternion
  4369. * @returns the target quaternion
  4370. */
  4371. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4372. /**
  4373. * Creates a new quaternion from data stored into an array
  4374. * @param array defines the data source
  4375. * @param offset defines the offset in the source array where the data starts
  4376. * @returns a new quaternion
  4377. */
  4378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4379. /**
  4380. * Updates the given quaternion "result" from the starting index of the given array.
  4381. * @param array the array to pull values from
  4382. * @param offset the offset into the array to start at
  4383. * @param result the quaternion to store the result in
  4384. */
  4385. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4386. /**
  4387. * Create a quaternion from Euler rotation angles
  4388. * @param x Pitch
  4389. * @param y Yaw
  4390. * @param z Roll
  4391. * @returns the new Quaternion
  4392. */
  4393. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4394. /**
  4395. * Updates a quaternion from Euler rotation angles
  4396. * @param x Pitch
  4397. * @param y Yaw
  4398. * @param z Roll
  4399. * @param result the quaternion to store the result
  4400. * @returns the updated quaternion
  4401. */
  4402. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4403. /**
  4404. * Create a quaternion from Euler rotation vector
  4405. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4406. * @returns the new Quaternion
  4407. */
  4408. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4409. /**
  4410. * Updates a quaternion from Euler rotation vector
  4411. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4412. * @param result the quaternion to store the result
  4413. * @returns the updated quaternion
  4414. */
  4415. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4416. /**
  4417. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4418. * @param yaw defines the rotation around Y axis
  4419. * @param pitch defines the rotation around X axis
  4420. * @param roll defines the rotation around Z axis
  4421. * @returns the new quaternion
  4422. */
  4423. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4424. /**
  4425. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4426. * @param yaw defines the rotation around Y axis
  4427. * @param pitch defines the rotation around X axis
  4428. * @param roll defines the rotation around Z axis
  4429. * @param result defines the target quaternion
  4430. */
  4431. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4432. /**
  4433. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4434. * @param alpha defines the rotation around first axis
  4435. * @param beta defines the rotation around second axis
  4436. * @param gamma defines the rotation around third axis
  4437. * @returns the new quaternion
  4438. */
  4439. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4440. /**
  4441. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4442. * @param alpha defines the rotation around first axis
  4443. * @param beta defines the rotation around second axis
  4444. * @param gamma defines the rotation around third axis
  4445. * @param result defines the target quaternion
  4446. */
  4447. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4448. /**
  4449. * 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)
  4450. * @param axis1 defines the first axis
  4451. * @param axis2 defines the second axis
  4452. * @param axis3 defines the third axis
  4453. * @returns the new quaternion
  4454. */
  4455. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4456. /**
  4457. * 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
  4458. * @param axis1 defines the first axis
  4459. * @param axis2 defines the second axis
  4460. * @param axis3 defines the third axis
  4461. * @param ref defines the target quaternion
  4462. */
  4463. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4464. /**
  4465. * Interpolates between two quaternions
  4466. * @param left defines first quaternion
  4467. * @param right defines second quaternion
  4468. * @param amount defines the gradient to use
  4469. * @returns the new interpolated quaternion
  4470. */
  4471. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4472. /**
  4473. * Interpolates between two quaternions and stores it into a target quaternion
  4474. * @param left defines first quaternion
  4475. * @param right defines second quaternion
  4476. * @param amount defines the gradient to use
  4477. * @param result defines the target quaternion
  4478. */
  4479. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4480. /**
  4481. * Interpolate between two quaternions using Hermite interpolation
  4482. * @param value1 defines first quaternion
  4483. * @param tangent1 defines the incoming tangent
  4484. * @param value2 defines second quaternion
  4485. * @param tangent2 defines the outgoing tangent
  4486. * @param amount defines the target quaternion
  4487. * @returns the new interpolated quaternion
  4488. */
  4489. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4490. }
  4491. /**
  4492. * Class used to store matrix data (4x4)
  4493. */
  4494. export class Matrix {
  4495. /**
  4496. * Gets the precision of matrix computations
  4497. */
  4498. static get Use64Bits(): boolean;
  4499. private static _updateFlagSeed;
  4500. private static _identityReadOnly;
  4501. private _isIdentity;
  4502. private _isIdentityDirty;
  4503. private _isIdentity3x2;
  4504. private _isIdentity3x2Dirty;
  4505. /**
  4506. * Gets the update flag of the matrix which is an unique number for the matrix.
  4507. * It will be incremented every time the matrix data change.
  4508. * You can use it to speed the comparison between two versions of the same matrix.
  4509. */
  4510. updateFlag: number;
  4511. private readonly _m;
  4512. /**
  4513. * Gets the internal data of the matrix
  4514. */
  4515. get m(): DeepImmutable<Float32Array | Array<number>>;
  4516. /** @hidden */
  4517. _markAsUpdated(): void;
  4518. /** @hidden */
  4519. private _updateIdentityStatus;
  4520. /**
  4521. * Creates an empty matrix (filled with zeros)
  4522. */
  4523. constructor();
  4524. /**
  4525. * Check if the current matrix is identity
  4526. * @returns true is the matrix is the identity matrix
  4527. */
  4528. isIdentity(): boolean;
  4529. /**
  4530. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4531. * @returns true is the matrix is the identity matrix
  4532. */
  4533. isIdentityAs3x2(): boolean;
  4534. /**
  4535. * Gets the determinant of the matrix
  4536. * @returns the matrix determinant
  4537. */
  4538. determinant(): number;
  4539. /**
  4540. * Returns the matrix as a Float32Array or Array<number>
  4541. * @returns the matrix underlying array
  4542. */
  4543. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4544. /**
  4545. * Returns the matrix as a Float32Array or Array<number>
  4546. * @returns the matrix underlying array.
  4547. */
  4548. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4549. /**
  4550. * Inverts the current matrix in place
  4551. * @returns the current inverted matrix
  4552. */
  4553. invert(): Matrix;
  4554. /**
  4555. * Sets all the matrix elements to zero
  4556. * @returns the current matrix
  4557. */
  4558. reset(): Matrix;
  4559. /**
  4560. * Adds the current matrix with a second one
  4561. * @param other defines the matrix to add
  4562. * @returns a new matrix as the addition of the current matrix and the given one
  4563. */
  4564. add(other: DeepImmutable<Matrix>): Matrix;
  4565. /**
  4566. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4567. * @param other defines the matrix to add
  4568. * @param result defines the target matrix
  4569. * @returns the current matrix
  4570. */
  4571. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4572. /**
  4573. * Adds in place the given matrix to the current matrix
  4574. * @param other defines the second operand
  4575. * @returns the current updated matrix
  4576. */
  4577. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4578. /**
  4579. * Sets the given matrix to the current inverted Matrix
  4580. * @param other defines the target matrix
  4581. * @returns the unmodified current matrix
  4582. */
  4583. invertToRef(other: Matrix): Matrix;
  4584. /**
  4585. * add a value at the specified position in the current Matrix
  4586. * @param index the index of the value within the matrix. between 0 and 15.
  4587. * @param value the value to be added
  4588. * @returns the current updated matrix
  4589. */
  4590. addAtIndex(index: number, value: number): Matrix;
  4591. /**
  4592. * mutiply the specified position in the current Matrix by a value
  4593. * @param index the index of the value within the matrix. between 0 and 15.
  4594. * @param value the value to be added
  4595. * @returns the current updated matrix
  4596. */
  4597. multiplyAtIndex(index: number, value: number): Matrix;
  4598. /**
  4599. * Inserts the translation vector (using 3 floats) in the current matrix
  4600. * @param x defines the 1st component of the translation
  4601. * @param y defines the 2nd component of the translation
  4602. * @param z defines the 3rd component of the translation
  4603. * @returns the current updated matrix
  4604. */
  4605. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4606. /**
  4607. * Adds the translation vector (using 3 floats) in the current matrix
  4608. * @param x defines the 1st component of the translation
  4609. * @param y defines the 2nd component of the translation
  4610. * @param z defines the 3rd component of the translation
  4611. * @returns the current updated matrix
  4612. */
  4613. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4614. /**
  4615. * Inserts the translation vector in the current matrix
  4616. * @param vector3 defines the translation to insert
  4617. * @returns the current updated matrix
  4618. */
  4619. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4620. /**
  4621. * Gets the translation value of the current matrix
  4622. * @returns a new Vector3 as the extracted translation from the matrix
  4623. */
  4624. getTranslation(): Vector3;
  4625. /**
  4626. * Fill a Vector3 with the extracted translation from the matrix
  4627. * @param result defines the Vector3 where to store the translation
  4628. * @returns the current matrix
  4629. */
  4630. getTranslationToRef(result: Vector3): Matrix;
  4631. /**
  4632. * Remove rotation and scaling part from the matrix
  4633. * @returns the updated matrix
  4634. */
  4635. removeRotationAndScaling(): Matrix;
  4636. /**
  4637. * Multiply two matrices
  4638. * @param other defines the second operand
  4639. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4640. */
  4641. multiply(other: DeepImmutable<Matrix>): Matrix;
  4642. /**
  4643. * Copy the current matrix from the given one
  4644. * @param other defines the source matrix
  4645. * @returns the current updated matrix
  4646. */
  4647. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4648. /**
  4649. * Populates the given array from the starting index with the current matrix values
  4650. * @param array defines the target array
  4651. * @param offset defines the offset in the target array where to start storing values
  4652. * @returns the current matrix
  4653. */
  4654. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4655. /**
  4656. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4657. * @param other defines the second operand
  4658. * @param result defines the matrix where to store the multiplication
  4659. * @returns the current matrix
  4660. */
  4661. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4662. /**
  4663. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4664. * @param other defines the second operand
  4665. * @param result defines the array where to store the multiplication
  4666. * @param offset defines the offset in the target array where to start storing values
  4667. * @returns the current matrix
  4668. */
  4669. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4670. /**
  4671. * Check equality between this matrix and a second one
  4672. * @param value defines the second matrix to compare
  4673. * @returns true is the current matrix and the given one values are strictly equal
  4674. */
  4675. equals(value: DeepImmutable<Matrix>): boolean;
  4676. /**
  4677. * Clone the current matrix
  4678. * @returns a new matrix from the current matrix
  4679. */
  4680. clone(): Matrix;
  4681. /**
  4682. * Returns the name of the current matrix class
  4683. * @returns the string "Matrix"
  4684. */
  4685. getClassName(): string;
  4686. /**
  4687. * Gets the hash code of the current matrix
  4688. * @returns the hash code
  4689. */
  4690. getHashCode(): number;
  4691. /**
  4692. * Decomposes the current Matrix into a translation, rotation and scaling components
  4693. * @param scale defines the scale vector3 given as a reference to update
  4694. * @param rotation defines the rotation quaternion given as a reference to update
  4695. * @param translation defines the translation vector3 given as a reference to update
  4696. * @returns true if operation was successful
  4697. */
  4698. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4699. /**
  4700. * Gets specific row of the matrix
  4701. * @param index defines the number of the row to get
  4702. * @returns the index-th row of the current matrix as a new Vector4
  4703. */
  4704. getRow(index: number): Nullable<Vector4>;
  4705. /**
  4706. * Sets the index-th row of the current matrix to the vector4 values
  4707. * @param index defines the number of the row to set
  4708. * @param row defines the target vector4
  4709. * @returns the updated current matrix
  4710. */
  4711. setRow(index: number, row: Vector4): Matrix;
  4712. /**
  4713. * Compute the transpose of the matrix
  4714. * @returns the new transposed matrix
  4715. */
  4716. transpose(): Matrix;
  4717. /**
  4718. * Compute the transpose of the matrix and store it in a given matrix
  4719. * @param result defines the target matrix
  4720. * @returns the current matrix
  4721. */
  4722. transposeToRef(result: Matrix): Matrix;
  4723. /**
  4724. * Sets the index-th row of the current matrix with the given 4 x float values
  4725. * @param index defines the row index
  4726. * @param x defines the x component to set
  4727. * @param y defines the y component to set
  4728. * @param z defines the z component to set
  4729. * @param w defines the w component to set
  4730. * @returns the updated current matrix
  4731. */
  4732. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4733. /**
  4734. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4735. * @param scale defines the scale factor
  4736. * @returns a new matrix
  4737. */
  4738. scale(scale: number): Matrix;
  4739. /**
  4740. * Scale the current matrix values by a factor to a given result matrix
  4741. * @param scale defines the scale factor
  4742. * @param result defines the matrix to store the result
  4743. * @returns the current matrix
  4744. */
  4745. scaleToRef(scale: number, result: Matrix): Matrix;
  4746. /**
  4747. * Scale the current matrix values by a factor and add the result to a given matrix
  4748. * @param scale defines the scale factor
  4749. * @param result defines the Matrix to store the result
  4750. * @returns the current matrix
  4751. */
  4752. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4753. /**
  4754. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4755. * @param ref matrix to store the result
  4756. */
  4757. toNormalMatrix(ref: Matrix): void;
  4758. /**
  4759. * Gets only rotation part of the current matrix
  4760. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4761. */
  4762. getRotationMatrix(): Matrix;
  4763. /**
  4764. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4765. * @param result defines the target matrix to store data to
  4766. * @returns the current matrix
  4767. */
  4768. getRotationMatrixToRef(result: Matrix): Matrix;
  4769. /**
  4770. * Toggles model matrix from being right handed to left handed in place and vice versa
  4771. */
  4772. toggleModelMatrixHandInPlace(): void;
  4773. /**
  4774. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4775. */
  4776. toggleProjectionMatrixHandInPlace(): void;
  4777. /**
  4778. * Creates a matrix from an array
  4779. * @param array defines the source array
  4780. * @param offset defines an offset in the source array
  4781. * @returns a new Matrix set from the starting index of the given array
  4782. */
  4783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4784. /**
  4785. * Copy the content of an array into a given matrix
  4786. * @param array defines the source array
  4787. * @param offset defines an offset in the source array
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4791. /**
  4792. * Stores an array into a matrix after having multiplied each component by a given factor
  4793. * @param array defines the source array
  4794. * @param offset defines the offset in the source array
  4795. * @param scale defines the scaling factor
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4799. /**
  4800. * Gets an identity matrix that must not be updated
  4801. */
  4802. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4803. /**
  4804. * Stores a list of values (16) inside a given matrix
  4805. * @param initialM11 defines 1st value of 1st row
  4806. * @param initialM12 defines 2nd value of 1st row
  4807. * @param initialM13 defines 3rd value of 1st row
  4808. * @param initialM14 defines 4th value of 1st row
  4809. * @param initialM21 defines 1st value of 2nd row
  4810. * @param initialM22 defines 2nd value of 2nd row
  4811. * @param initialM23 defines 3rd value of 2nd row
  4812. * @param initialM24 defines 4th value of 2nd row
  4813. * @param initialM31 defines 1st value of 3rd row
  4814. * @param initialM32 defines 2nd value of 3rd row
  4815. * @param initialM33 defines 3rd value of 3rd row
  4816. * @param initialM34 defines 4th value of 3rd row
  4817. * @param initialM41 defines 1st value of 4th row
  4818. * @param initialM42 defines 2nd value of 4th row
  4819. * @param initialM43 defines 3rd value of 4th row
  4820. * @param initialM44 defines 4th value of 4th row
  4821. * @param result defines the target matrix
  4822. */
  4823. 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;
  4824. /**
  4825. * Creates new matrix from a list of values (16)
  4826. * @param initialM11 defines 1st value of 1st row
  4827. * @param initialM12 defines 2nd value of 1st row
  4828. * @param initialM13 defines 3rd value of 1st row
  4829. * @param initialM14 defines 4th value of 1st row
  4830. * @param initialM21 defines 1st value of 2nd row
  4831. * @param initialM22 defines 2nd value of 2nd row
  4832. * @param initialM23 defines 3rd value of 2nd row
  4833. * @param initialM24 defines 4th value of 2nd row
  4834. * @param initialM31 defines 1st value of 3rd row
  4835. * @param initialM32 defines 2nd value of 3rd row
  4836. * @param initialM33 defines 3rd value of 3rd row
  4837. * @param initialM34 defines 4th value of 3rd row
  4838. * @param initialM41 defines 1st value of 4th row
  4839. * @param initialM42 defines 2nd value of 4th row
  4840. * @param initialM43 defines 3rd value of 4th row
  4841. * @param initialM44 defines 4th value of 4th row
  4842. * @returns the new matrix
  4843. */
  4844. 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;
  4845. /**
  4846. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4847. * @param scale defines the scale vector3
  4848. * @param rotation defines the rotation quaternion
  4849. * @param translation defines the translation vector3
  4850. * @returns a new matrix
  4851. */
  4852. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4853. /**
  4854. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4855. * @param scale defines the scale vector3
  4856. * @param rotation defines the rotation quaternion
  4857. * @param translation defines the translation vector3
  4858. * @param result defines the target matrix
  4859. */
  4860. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4861. /**
  4862. * Creates a new identity matrix
  4863. * @returns a new identity matrix
  4864. */
  4865. static Identity(): Matrix;
  4866. /**
  4867. * Creates a new identity matrix and stores the result in a given matrix
  4868. * @param result defines the target matrix
  4869. */
  4870. static IdentityToRef(result: Matrix): void;
  4871. /**
  4872. * Creates a new zero matrix
  4873. * @returns a new zero matrix
  4874. */
  4875. static Zero(): Matrix;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the X axis
  4878. * @param angle defines the angle (in radians) to use
  4879. * @return the new matrix
  4880. */
  4881. static RotationX(angle: number): Matrix;
  4882. /**
  4883. * Creates a new matrix as the invert of a given matrix
  4884. * @param source defines the source matrix
  4885. * @returns the new matrix
  4886. */
  4887. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4888. /**
  4889. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4890. * @param angle defines the angle (in radians) to use
  4891. * @param result defines the target matrix
  4892. */
  4893. static RotationXToRef(angle: number, result: Matrix): void;
  4894. /**
  4895. * Creates a new rotation matrix for "angle" radians around the Y axis
  4896. * @param angle defines the angle (in radians) to use
  4897. * @return the new matrix
  4898. */
  4899. static RotationY(angle: number): Matrix;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4902. * @param angle defines the angle (in radians) to use
  4903. * @param result defines the target matrix
  4904. */
  4905. static RotationYToRef(angle: number, result: Matrix): void;
  4906. /**
  4907. * Creates a new rotation matrix for "angle" radians around the Z axis
  4908. * @param angle defines the angle (in radians) to use
  4909. * @return the new matrix
  4910. */
  4911. static RotationZ(angle: number): Matrix;
  4912. /**
  4913. * Creates a new rotation matrix for "angle" radians around the Z 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 RotationZToRef(angle: number, result: Matrix): void;
  4918. /**
  4919. * Creates a new rotation matrix for "angle" radians around the given axis
  4920. * @param axis defines the axis to use
  4921. * @param angle defines the angle (in radians) to use
  4922. * @return the new matrix
  4923. */
  4924. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4925. /**
  4926. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4927. * @param axis defines the axis to use
  4928. * @param angle defines the angle (in radians) to use
  4929. * @param result defines the target matrix
  4930. */
  4931. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4932. /**
  4933. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4934. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4935. * @param from defines the vector to align
  4936. * @param to defines the vector to align to
  4937. * @param result defines the target matrix
  4938. */
  4939. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4940. /**
  4941. * Creates a rotation matrix
  4942. * @param yaw defines the yaw angle in radians (Y axis)
  4943. * @param pitch defines the pitch angle in radians (X axis)
  4944. * @param roll defines the roll angle in radians (Z axis)
  4945. * @returns the new rotation matrix
  4946. */
  4947. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4948. /**
  4949. * Creates a rotation matrix and stores it in a given matrix
  4950. * @param yaw defines the yaw angle in radians (Y axis)
  4951. * @param pitch defines the pitch angle in radians (X axis)
  4952. * @param roll defines the roll angle in radians (Z axis)
  4953. * @param result defines the target matrix
  4954. */
  4955. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4956. /**
  4957. * Creates a scaling matrix
  4958. * @param x defines the scale factor on X axis
  4959. * @param y defines the scale factor on Y axis
  4960. * @param z defines the scale factor on Z axis
  4961. * @returns the new matrix
  4962. */
  4963. static Scaling(x: number, y: number, z: number): Matrix;
  4964. /**
  4965. * Creates a scaling matrix and stores it in a given matrix
  4966. * @param x defines the scale factor on X axis
  4967. * @param y defines the scale factor on Y axis
  4968. * @param z defines the scale factor on Z axis
  4969. * @param result defines the target matrix
  4970. */
  4971. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4972. /**
  4973. * Creates a translation matrix
  4974. * @param x defines the translation on X axis
  4975. * @param y defines the translation on Y axis
  4976. * @param z defines the translationon Z axis
  4977. * @returns the new matrix
  4978. */
  4979. static Translation(x: number, y: number, z: number): Matrix;
  4980. /**
  4981. * Creates a translation matrix and stores it in a given matrix
  4982. * @param x defines the translation on X axis
  4983. * @param y defines the translation on Y axis
  4984. * @param z defines the translationon Z axis
  4985. * @param result defines the target matrix
  4986. */
  4987. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4988. /**
  4989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4990. * @param startValue defines the start value
  4991. * @param endValue defines the end value
  4992. * @param gradient defines the gradient factor
  4993. * @returns the new matrix
  4994. */
  4995. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4996. /**
  4997. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4998. * @param startValue defines the start value
  4999. * @param endValue defines the end value
  5000. * @param gradient defines the gradient factor
  5001. * @param result defines the Matrix object where to store data
  5002. */
  5003. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5004. /**
  5005. * Builds a new matrix whose values are computed by:
  5006. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5007. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5008. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5009. * @param startValue defines the first matrix
  5010. * @param endValue defines the second matrix
  5011. * @param gradient defines the gradient between the two matrices
  5012. * @returns the new matrix
  5013. */
  5014. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5015. /**
  5016. * Update a matrix to values which are computed by:
  5017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5020. * @param startValue defines the first matrix
  5021. * @param endValue defines the second matrix
  5022. * @param gradient defines the gradient between the two matrices
  5023. * @param result defines the target matrix
  5024. */
  5025. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5026. /**
  5027. * 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"
  5028. * This function works in left handed mode
  5029. * @param eye defines the final position of the entity
  5030. * @param target defines where the entity should look at
  5031. * @param up defines the up vector for the entity
  5032. * @returns the new matrix
  5033. */
  5034. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5035. /**
  5036. * 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".
  5037. * This function works in left handed mode
  5038. * @param eye defines the final position of the entity
  5039. * @param target defines where the entity should look at
  5040. * @param up defines the up vector for the entity
  5041. * @param result defines the target matrix
  5042. */
  5043. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5044. /**
  5045. * 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"
  5046. * This function works in right handed mode
  5047. * @param eye defines the final position of the entity
  5048. * @param target defines where the entity should look at
  5049. * @param up defines the up vector for the entity
  5050. * @returns the new matrix
  5051. */
  5052. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5053. /**
  5054. * 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".
  5055. * This function works in right handed mode
  5056. * @param eye defines the final position of the entity
  5057. * @param target defines where the entity should look at
  5058. * @param up defines the up vector for the entity
  5059. * @param result defines the target matrix
  5060. */
  5061. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5062. /**
  5063. * Create a left-handed orthographic projection matrix
  5064. * @param width defines the viewport width
  5065. * @param height defines the viewport height
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a left-handed orthographic projection matrix
  5069. */
  5070. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Store a left-handed orthographic projection to a given matrix
  5073. * @param width defines the viewport width
  5074. * @param height defines the viewport height
  5075. * @param znear defines the near clip plane
  5076. * @param zfar defines the far clip plane
  5077. * @param result defines the target matrix
  5078. */
  5079. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5080. /**
  5081. * Create a left-handed orthographic projection matrix
  5082. * @param left defines the viewport left coordinate
  5083. * @param right defines the viewport right coordinate
  5084. * @param bottom defines the viewport bottom coordinate
  5085. * @param top defines the viewport top coordinate
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed orthographic projection matrix
  5089. */
  5090. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Stores a left-handed orthographic projection into a given matrix
  5093. * @param left defines the viewport left coordinate
  5094. * @param right defines the viewport right coordinate
  5095. * @param bottom defines the viewport bottom coordinate
  5096. * @param top defines the viewport top coordinate
  5097. * @param znear defines the near clip plane
  5098. * @param zfar defines the far clip plane
  5099. * @param result defines the target matrix
  5100. */
  5101. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5102. /**
  5103. * Creates a right-handed orthographic projection matrix
  5104. * @param left defines the viewport left coordinate
  5105. * @param right defines the viewport right coordinate
  5106. * @param bottom defines the viewport bottom coordinate
  5107. * @param top defines the viewport top coordinate
  5108. * @param znear defines the near clip plane
  5109. * @param zfar defines the far clip plane
  5110. * @returns a new matrix as a right-handed orthographic projection matrix
  5111. */
  5112. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5113. /**
  5114. * Stores a right-handed orthographic projection into a given matrix
  5115. * @param left defines the viewport left coordinate
  5116. * @param right defines the viewport right coordinate
  5117. * @param bottom defines the viewport bottom coordinate
  5118. * @param top defines the viewport top coordinate
  5119. * @param znear defines the near clip plane
  5120. * @param zfar defines the far clip plane
  5121. * @param result defines the target matrix
  5122. */
  5123. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5124. /**
  5125. * Creates a left-handed perspective projection matrix
  5126. * @param width defines the viewport width
  5127. * @param height defines the viewport height
  5128. * @param znear defines the near clip plane
  5129. * @param zfar defines the far clip plane
  5130. * @returns a new matrix as a left-handed perspective projection matrix
  5131. */
  5132. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5133. /**
  5134. * Creates a left-handed perspective projection matrix
  5135. * @param fov defines the horizontal field of view
  5136. * @param aspect defines the aspect ratio
  5137. * @param znear defines the near clip plane
  5138. * @param zfar defines the far clip plane
  5139. * @returns a new matrix as a left-handed perspective projection matrix
  5140. */
  5141. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5142. /**
  5143. * Stores a left-handed perspective projection into a given matrix
  5144. * @param fov defines the horizontal field of view
  5145. * @param aspect defines the aspect ratio
  5146. * @param znear defines the near clip plane
  5147. * @param zfar defines the far clip plane
  5148. * @param result defines the target matrix
  5149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5150. */
  5151. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5152. /**
  5153. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5154. * @param fov defines the horizontal field of view
  5155. * @param aspect defines the aspect ratio
  5156. * @param znear defines the near clip plane
  5157. * @param zfar not used as infinity is used as far clip
  5158. * @param result defines the target matrix
  5159. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5160. */
  5161. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5162. /**
  5163. * Creates a right-handed perspective projection matrix
  5164. * @param fov defines the horizontal field of view
  5165. * @param aspect defines the aspect ratio
  5166. * @param znear defines the near clip plane
  5167. * @param zfar defines the far clip plane
  5168. * @returns a new matrix as a right-handed perspective projection matrix
  5169. */
  5170. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5171. /**
  5172. * Stores a right-handed perspective projection into a given matrix
  5173. * @param fov defines the horizontal field of view
  5174. * @param aspect defines the aspect ratio
  5175. * @param znear defines the near clip plane
  5176. * @param zfar defines the far clip plane
  5177. * @param result defines the target matrix
  5178. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5179. */
  5180. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5181. /**
  5182. * Stores a right-handed perspective projection into a given matrix
  5183. * @param fov defines the horizontal field of view
  5184. * @param aspect defines the aspect ratio
  5185. * @param znear defines the near clip plane
  5186. * @param zfar not used as infinity is used as far clip
  5187. * @param result defines the target matrix
  5188. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5189. */
  5190. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5191. /**
  5192. * Stores a perspective projection for WebVR info a given matrix
  5193. * @param fov defines the field of view
  5194. * @param znear defines the near clip plane
  5195. * @param zfar defines the far clip plane
  5196. * @param result defines the target matrix
  5197. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5198. */
  5199. static PerspectiveFovWebVRToRef(fov: {
  5200. upDegrees: number;
  5201. downDegrees: number;
  5202. leftDegrees: number;
  5203. rightDegrees: number;
  5204. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5205. /**
  5206. * Computes a complete transformation matrix
  5207. * @param viewport defines the viewport to use
  5208. * @param world defines the world matrix
  5209. * @param view defines the view matrix
  5210. * @param projection defines the projection matrix
  5211. * @param zmin defines the near clip plane
  5212. * @param zmax defines the far clip plane
  5213. * @returns the transformation matrix
  5214. */
  5215. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5216. /**
  5217. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5218. * @param matrix defines the matrix to use
  5219. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5220. */
  5221. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5222. /**
  5223. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5224. * @param matrix defines the matrix to use
  5225. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5226. */
  5227. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5228. /**
  5229. * Compute the transpose of a given matrix
  5230. * @param matrix defines the matrix to transpose
  5231. * @returns the new matrix
  5232. */
  5233. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5234. /**
  5235. * Compute the transpose of a matrix and store it in a target matrix
  5236. * @param matrix defines the matrix to transpose
  5237. * @param result defines the target matrix
  5238. */
  5239. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5240. /**
  5241. * Computes a reflection matrix from a plane
  5242. * @param plane defines the reflection plane
  5243. * @returns a new matrix
  5244. */
  5245. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5246. /**
  5247. * Computes a reflection matrix from a plane
  5248. * @param plane defines the reflection plane
  5249. * @param result defines the target matrix
  5250. */
  5251. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5252. /**
  5253. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5254. * @param xaxis defines the value of the 1st axis
  5255. * @param yaxis defines the value of the 2nd axis
  5256. * @param zaxis defines the value of the 3rd axis
  5257. * @param result defines the target matrix
  5258. */
  5259. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5260. /**
  5261. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5262. * @param quat defines the quaternion to use
  5263. * @param result defines the target matrix
  5264. */
  5265. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5266. }
  5267. /**
  5268. * @hidden
  5269. */
  5270. export class TmpVectors {
  5271. static Vector2: Vector2[];
  5272. static Vector3: Vector3[];
  5273. static Vector4: Vector4[];
  5274. static Quaternion: Quaternion[];
  5275. static Matrix: Matrix[];
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5327. * @param a defines first point as the origin
  5328. * @param b defines point
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. private _alignTangentsWithPath;
  5466. private readonly _pointAtData;
  5467. /**
  5468. * new Path3D(path, normal, raw)
  5469. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5470. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5471. * @param path an array of Vector3, the curve axis of the Path3D
  5472. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5473. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5474. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5475. */
  5476. constructor(
  5477. /**
  5478. * an array of Vector3, the curve axis of the Path3D
  5479. */
  5480. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5481. /**
  5482. * Returns the Path3D array of successive Vector3 designing its curve.
  5483. * @returns the Path3D array of successive Vector3 designing its curve.
  5484. */
  5485. getCurve(): Vector3[];
  5486. /**
  5487. * Returns the Path3D array of successive Vector3 designing its curve.
  5488. * @returns the Path3D array of successive Vector3 designing its curve.
  5489. */
  5490. getPoints(): Vector3[];
  5491. /**
  5492. * @returns the computed length (float) of the path.
  5493. */
  5494. length(): number;
  5495. /**
  5496. * Returns an array populated with tangent vectors on each Path3D curve point.
  5497. * @returns an array populated with tangent vectors on each Path3D curve point.
  5498. */
  5499. getTangents(): Vector3[];
  5500. /**
  5501. * Returns an array populated with normal vectors on each Path3D curve point.
  5502. * @returns an array populated with normal vectors on each Path3D curve point.
  5503. */
  5504. getNormals(): Vector3[];
  5505. /**
  5506. * Returns an array populated with binormal vectors on each Path3D curve point.
  5507. * @returns an array populated with binormal vectors on each Path3D curve point.
  5508. */
  5509. getBinormals(): Vector3[];
  5510. /**
  5511. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5512. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5513. */
  5514. getDistances(): number[];
  5515. /**
  5516. * Returns an interpolated point along this path
  5517. * @param position the position of the point along this path, from 0.0 to 1.0
  5518. * @returns a new Vector3 as the point
  5519. */
  5520. getPointAt(position: number): Vector3;
  5521. /**
  5522. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5523. * @param position the position of the point along this path, from 0.0 to 1.0
  5524. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5525. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5526. */
  5527. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5528. /**
  5529. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5530. * @param position the position of the point along this path, from 0.0 to 1.0
  5531. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5532. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5533. */
  5534. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5535. /**
  5536. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5537. * @param position the position of the point along this path, from 0.0 to 1.0
  5538. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5539. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5540. */
  5541. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5542. /**
  5543. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5544. * @param position the position of the point along this path, from 0.0 to 1.0
  5545. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5546. */
  5547. getDistanceAt(position: number): number;
  5548. /**
  5549. * Returns the array index of the previous point of an interpolated point along this path
  5550. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5551. * @returns the array index
  5552. */
  5553. getPreviousPointIndexAt(position: number): number;
  5554. /**
  5555. * 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)
  5556. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5557. * @returns the sub position
  5558. */
  5559. getSubPositionAt(position: number): number;
  5560. /**
  5561. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5562. * @param target the vector of which to get the closest position to
  5563. * @returns the position of the closest virtual point on this path to the target vector
  5564. */
  5565. getClosestPositionTo(target: Vector3): number;
  5566. /**
  5567. * Returns a sub path (slice) of this path
  5568. * @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
  5569. * @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
  5570. * @returns a sub path (slice) of this path
  5571. */
  5572. slice(start?: number, end?: number): Path3D;
  5573. /**
  5574. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5575. * @param path path which all values are copied into the curves points
  5576. * @param firstNormal which should be projected onto the curve
  5577. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5578. * @returns the same object updated.
  5579. */
  5580. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5581. private _compute;
  5582. private _getFirstNonNullVector;
  5583. private _getLastNonNullVector;
  5584. private _normalVector;
  5585. /**
  5586. * Updates the point at data for an interpolated point along this curve
  5587. * @param position the position of the point along this curve, from 0.0 to 1.0
  5588. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5589. * @returns the (updated) point at data
  5590. */
  5591. private _updatePointAtData;
  5592. /**
  5593. * Updates the point at data from the specified parameters
  5594. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5595. * @param point the interpolated point
  5596. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5597. */
  5598. private _setPointAtData;
  5599. /**
  5600. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5601. */
  5602. private _updateInterpolationMatrix;
  5603. }
  5604. /**
  5605. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5606. * A Curve3 is designed from a series of successive Vector3.
  5607. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5608. */
  5609. export class Curve3 {
  5610. private _points;
  5611. private _length;
  5612. /**
  5613. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5614. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5615. * @param v1 (Vector3) the control point
  5616. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5617. * @param nbPoints (integer) the wanted number of points in the curve
  5618. * @returns the created Curve3
  5619. */
  5620. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5621. /**
  5622. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5623. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5624. * @param v1 (Vector3) the first control point
  5625. * @param v2 (Vector3) the second control point
  5626. * @param v3 (Vector3) the end point of the Cubic Bezier
  5627. * @param nbPoints (integer) the wanted number of points in the curve
  5628. * @returns the created Curve3
  5629. */
  5630. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5631. /**
  5632. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5633. * @param p1 (Vector3) the origin point of the Hermite Spline
  5634. * @param t1 (Vector3) the tangent vector at the origin point
  5635. * @param p2 (Vector3) the end point of the Hermite Spline
  5636. * @param t2 (Vector3) the tangent vector at the end point
  5637. * @param nbPoints (integer) the wanted number of points in the curve
  5638. * @returns the created Curve3
  5639. */
  5640. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5641. /**
  5642. * Returns a Curve3 object along a CatmullRom Spline curve :
  5643. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5644. * @param nbPoints (integer) the wanted number of points between each curve control points
  5645. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5646. * @returns the created Curve3
  5647. */
  5648. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5649. /**
  5650. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5651. * A Curve3 is designed from a series of successive Vector3.
  5652. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5653. * @param points points which make up the curve
  5654. */
  5655. constructor(points: Vector3[]);
  5656. /**
  5657. * @returns the Curve3 stored array of successive Vector3
  5658. */
  5659. getPoints(): Vector3[];
  5660. /**
  5661. * @returns the computed length (float) of the curve.
  5662. */
  5663. length(): number;
  5664. /**
  5665. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5666. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5667. * curveA and curveB keep unchanged.
  5668. * @param curve the curve to continue from this curve
  5669. * @returns the newly constructed curve
  5670. */
  5671. continue(curve: DeepImmutable<Curve3>): Curve3;
  5672. private _computeLength;
  5673. }
  5674. }
  5675. declare module "babylonjs/Animations/easing" {
  5676. /**
  5677. * This represents the main contract an easing function should follow.
  5678. * Easing functions are used throughout the animation system.
  5679. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5680. */
  5681. export interface IEasingFunction {
  5682. /**
  5683. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5684. * of the easing function.
  5685. * The link below provides some of the most common examples of easing functions.
  5686. * @see https://easings.net/
  5687. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5688. * @returns the corresponding value on the curve defined by the easing function
  5689. */
  5690. ease(gradient: number): number;
  5691. }
  5692. /**
  5693. * Base class used for every default easing function.
  5694. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class EasingFunction implements IEasingFunction {
  5697. /**
  5698. * Interpolation follows the mathematical formula associated with the easing function.
  5699. */
  5700. static readonly EASINGMODE_EASEIN: number;
  5701. /**
  5702. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5703. */
  5704. static readonly EASINGMODE_EASEOUT: number;
  5705. /**
  5706. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5707. */
  5708. static readonly EASINGMODE_EASEINOUT: number;
  5709. private _easingMode;
  5710. /**
  5711. * Sets the easing mode of the current function.
  5712. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5713. */
  5714. setEasingMode(easingMode: number): void;
  5715. /**
  5716. * Gets the current easing mode.
  5717. * @returns the easing mode
  5718. */
  5719. getEasingMode(): number;
  5720. /**
  5721. * @hidden
  5722. */
  5723. easeInCore(gradient: number): number;
  5724. /**
  5725. * Given an input gradient between 0 and 1, this returns the corresponding value
  5726. * of the easing function.
  5727. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5728. * @returns the corresponding value on the curve defined by the easing function
  5729. */
  5730. ease(gradient: number): number;
  5731. }
  5732. /**
  5733. * Easing function with a circle shape (see link below).
  5734. * @see https://easings.net/#easeInCirc
  5735. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5736. */
  5737. export class CircleEase extends EasingFunction implements IEasingFunction {
  5738. /** @hidden */
  5739. easeInCore(gradient: number): number;
  5740. }
  5741. /**
  5742. * Easing function with a ease back shape (see link below).
  5743. * @see https://easings.net/#easeInBack
  5744. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5745. */
  5746. export class BackEase extends EasingFunction implements IEasingFunction {
  5747. /** Defines the amplitude of the function */
  5748. amplitude: number;
  5749. /**
  5750. * Instantiates a back ease easing
  5751. * @see https://easings.net/#easeInBack
  5752. * @param amplitude Defines the amplitude of the function
  5753. */
  5754. constructor(
  5755. /** Defines the amplitude of the function */
  5756. amplitude?: number);
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a bouncing shape (see link below).
  5762. * @see https://easings.net/#easeInBounce
  5763. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class BounceEase extends EasingFunction implements IEasingFunction {
  5766. /** Defines the number of bounces */
  5767. bounces: number;
  5768. /** Defines the amplitude of the bounce */
  5769. bounciness: number;
  5770. /**
  5771. * Instantiates a bounce easing
  5772. * @see https://easings.net/#easeInBounce
  5773. * @param bounces Defines the number of bounces
  5774. * @param bounciness Defines the amplitude of the bounce
  5775. */
  5776. constructor(
  5777. /** Defines the number of bounces */
  5778. bounces?: number,
  5779. /** Defines the amplitude of the bounce */
  5780. bounciness?: number);
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 3 shape (see link below).
  5786. * @see https://easings.net/#easeInCubic
  5787. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class CubicEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with an elastic shape (see link below).
  5795. * @see https://easings.net/#easeInElastic
  5796. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5799. /** Defines the number of oscillations*/
  5800. oscillations: number;
  5801. /** Defines the amplitude of the oscillations*/
  5802. springiness: number;
  5803. /**
  5804. * Instantiates an elastic easing function
  5805. * @see https://easings.net/#easeInElastic
  5806. * @param oscillations Defines the number of oscillations
  5807. * @param springiness Defines the amplitude of the oscillations
  5808. */
  5809. constructor(
  5810. /** Defines the number of oscillations*/
  5811. oscillations?: number,
  5812. /** Defines the amplitude of the oscillations*/
  5813. springiness?: number);
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with an exponential shape (see link below).
  5819. * @see https://easings.net/#easeInExpo
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5823. /** Defines the exponent of the function */
  5824. exponent: number;
  5825. /**
  5826. * Instantiates an exponential easing function
  5827. * @see https://easings.net/#easeInExpo
  5828. * @param exponent Defines the exponent of the function
  5829. */
  5830. constructor(
  5831. /** Defines the exponent of the function */
  5832. exponent?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. /**
  5837. * Easing function with a power shape (see link below).
  5838. * @see https://easings.net/#easeInQuad
  5839. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5840. */
  5841. export class PowerEase extends EasingFunction implements IEasingFunction {
  5842. /** Defines the power of the function */
  5843. power: number;
  5844. /**
  5845. * Instantiates an power base easing function
  5846. * @see https://easings.net/#easeInQuad
  5847. * @param power Defines the power of the function
  5848. */
  5849. constructor(
  5850. /** Defines the power of the function */
  5851. power?: number);
  5852. /** @hidden */
  5853. easeInCore(gradient: number): number;
  5854. }
  5855. /**
  5856. * Easing function with a power of 2 shape (see link below).
  5857. * @see https://easings.net/#easeInQuad
  5858. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5859. */
  5860. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5861. /** @hidden */
  5862. easeInCore(gradient: number): number;
  5863. }
  5864. /**
  5865. * Easing function with a power of 4 shape (see link below).
  5866. * @see https://easings.net/#easeInQuart
  5867. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5868. */
  5869. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5870. /** @hidden */
  5871. easeInCore(gradient: number): number;
  5872. }
  5873. /**
  5874. * Easing function with a power of 5 shape (see link below).
  5875. * @see https://easings.net/#easeInQuint
  5876. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5877. */
  5878. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5879. /** @hidden */
  5880. easeInCore(gradient: number): number;
  5881. }
  5882. /**
  5883. * Easing function with a sin shape (see link below).
  5884. * @see https://easings.net/#easeInSine
  5885. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5886. */
  5887. export class SineEase extends EasingFunction implements IEasingFunction {
  5888. /** @hidden */
  5889. easeInCore(gradient: number): number;
  5890. }
  5891. /**
  5892. * Easing function with a bezier shape (see link below).
  5893. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5894. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5895. */
  5896. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5897. /** Defines the x component of the start tangent in the bezier curve */
  5898. x1: number;
  5899. /** Defines the y component of the start tangent in the bezier curve */
  5900. y1: number;
  5901. /** Defines the x component of the end tangent in the bezier curve */
  5902. x2: number;
  5903. /** Defines the y component of the end tangent in the bezier curve */
  5904. y2: number;
  5905. /**
  5906. * Instantiates a bezier function
  5907. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5908. * @param x1 Defines the x component of the start tangent in the bezier curve
  5909. * @param y1 Defines the y component of the start tangent in the bezier curve
  5910. * @param x2 Defines the x component of the end tangent in the bezier curve
  5911. * @param y2 Defines the y component of the end tangent in the bezier curve
  5912. */
  5913. constructor(
  5914. /** Defines the x component of the start tangent in the bezier curve */
  5915. x1?: number,
  5916. /** Defines the y component of the start tangent in the bezier curve */
  5917. y1?: number,
  5918. /** Defines the x component of the end tangent in the bezier curve */
  5919. x2?: number,
  5920. /** Defines the y component of the end tangent in the bezier curve */
  5921. y2?: number);
  5922. /** @hidden */
  5923. easeInCore(gradient: number): number;
  5924. }
  5925. }
  5926. declare module "babylonjs/Maths/math.color" {
  5927. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5928. /**
  5929. * Class used to hold a RBG color
  5930. */
  5931. export class Color3 {
  5932. /**
  5933. * Defines the red component (between 0 and 1, default is 0)
  5934. */
  5935. r: number;
  5936. /**
  5937. * Defines the green component (between 0 and 1, default is 0)
  5938. */
  5939. g: number;
  5940. /**
  5941. * Defines the blue component (between 0 and 1, default is 0)
  5942. */
  5943. b: number;
  5944. /**
  5945. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5946. * @param r defines the red component (between 0 and 1, default is 0)
  5947. * @param g defines the green component (between 0 and 1, default is 0)
  5948. * @param b defines the blue component (between 0 and 1, default is 0)
  5949. */
  5950. constructor(
  5951. /**
  5952. * Defines the red component (between 0 and 1, default is 0)
  5953. */
  5954. r?: number,
  5955. /**
  5956. * Defines the green component (between 0 and 1, default is 0)
  5957. */
  5958. g?: number,
  5959. /**
  5960. * Defines the blue component (between 0 and 1, default is 0)
  5961. */
  5962. b?: number);
  5963. /**
  5964. * Creates a string with the Color3 current values
  5965. * @returns the string representation of the Color3 object
  5966. */
  5967. toString(): string;
  5968. /**
  5969. * Returns the string "Color3"
  5970. * @returns "Color3"
  5971. */
  5972. getClassName(): string;
  5973. /**
  5974. * Compute the Color3 hash code
  5975. * @returns an unique number that can be used to hash Color3 objects
  5976. */
  5977. getHashCode(): number;
  5978. /**
  5979. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5980. * @param array defines the array where to store the r,g,b components
  5981. * @param index defines an optional index in the target array to define where to start storing values
  5982. * @returns the current Color3 object
  5983. */
  5984. toArray(array: FloatArray, index?: number): Color3;
  5985. /**
  5986. * Update the current color with values stored in an array from the starting index of the given array
  5987. * @param array defines the source array
  5988. * @param offset defines an offset in the source array
  5989. * @returns the current Color3 object
  5990. */
  5991. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5992. /**
  5993. * Returns a new Color4 object from the current Color3 and the given alpha
  5994. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5995. * @returns a new Color4 object
  5996. */
  5997. toColor4(alpha?: number): Color4;
  5998. /**
  5999. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6000. * @returns the new array
  6001. */
  6002. asArray(): number[];
  6003. /**
  6004. * Returns the luminance value
  6005. * @returns a float value
  6006. */
  6007. toLuminance(): number;
  6008. /**
  6009. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6010. * @param otherColor defines the second operand
  6011. * @returns the new Color3 object
  6012. */
  6013. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6014. /**
  6015. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6016. * @param otherColor defines the second operand
  6017. * @param result defines the Color3 object where to store the result
  6018. * @returns the current Color3
  6019. */
  6020. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6021. /**
  6022. * Determines equality between Color3 objects
  6023. * @param otherColor defines the second operand
  6024. * @returns true if the rgb values are equal to the given ones
  6025. */
  6026. equals(otherColor: DeepImmutable<Color3>): boolean;
  6027. /**
  6028. * Determines equality between the current Color3 object and a set of r,b,g values
  6029. * @param r defines the red component to check
  6030. * @param g defines the green component to check
  6031. * @param b defines the blue component to check
  6032. * @returns true if the rgb values are equal to the given ones
  6033. */
  6034. equalsFloats(r: number, g: number, b: number): boolean;
  6035. /**
  6036. * Multiplies in place each rgb value by scale
  6037. * @param scale defines the scaling factor
  6038. * @returns the updated Color3
  6039. */
  6040. scale(scale: number): Color3;
  6041. /**
  6042. * Multiplies the rgb values by scale and stores the result into "result"
  6043. * @param scale defines the scaling factor
  6044. * @param result defines the Color3 object where to store the result
  6045. * @returns the unmodified current Color3
  6046. */
  6047. scaleToRef(scale: number, result: Color3): Color3;
  6048. /**
  6049. * Scale the current Color3 values by a factor and add the result to a given Color3
  6050. * @param scale defines the scale factor
  6051. * @param result defines color to store the result into
  6052. * @returns the unmodified current Color3
  6053. */
  6054. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6055. /**
  6056. * Clamps the rgb values by the min and max values and stores the result into "result"
  6057. * @param min defines minimum clamping value (default is 0)
  6058. * @param max defines maximum clamping value (default is 1)
  6059. * @param result defines color to store the result into
  6060. * @returns the original Color3
  6061. */
  6062. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6063. /**
  6064. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6065. * @param otherColor defines the second operand
  6066. * @returns the new Color3
  6067. */
  6068. add(otherColor: DeepImmutable<Color3>): Color3;
  6069. /**
  6070. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6071. * @param otherColor defines the second operand
  6072. * @param result defines Color3 object to store the result into
  6073. * @returns the unmodified current Color3
  6074. */
  6075. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6076. /**
  6077. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6078. * @param otherColor defines the second operand
  6079. * @returns the new Color3
  6080. */
  6081. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6082. /**
  6083. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6084. * @param otherColor defines the second operand
  6085. * @param result defines Color3 object to store the result into
  6086. * @returns the unmodified current Color3
  6087. */
  6088. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6089. /**
  6090. * Copy the current object
  6091. * @returns a new Color3 copied the current one
  6092. */
  6093. clone(): Color3;
  6094. /**
  6095. * Copies the rgb values from the source in the current Color3
  6096. * @param source defines the source Color3 object
  6097. * @returns the updated Color3 object
  6098. */
  6099. copyFrom(source: DeepImmutable<Color3>): Color3;
  6100. /**
  6101. * Updates the Color3 rgb values from the given floats
  6102. * @param r defines the red component to read from
  6103. * @param g defines the green component to read from
  6104. * @param b defines the blue component to read from
  6105. * @returns the current Color3 object
  6106. */
  6107. copyFromFloats(r: number, g: number, b: number): Color3;
  6108. /**
  6109. * Updates the Color3 rgb values from the given floats
  6110. * @param r defines the red component to read from
  6111. * @param g defines the green component to read from
  6112. * @param b defines the blue component to read from
  6113. * @returns the current Color3 object
  6114. */
  6115. set(r: number, g: number, b: number): Color3;
  6116. /**
  6117. * Compute the Color3 hexadecimal code as a string
  6118. * @returns a string containing the hexadecimal representation of the Color3 object
  6119. */
  6120. toHexString(): string;
  6121. /**
  6122. * Computes a new Color3 converted from the current one to linear space
  6123. * @returns a new Color3 object
  6124. */
  6125. toLinearSpace(): Color3;
  6126. /**
  6127. * Converts current color in rgb space to HSV values
  6128. * @returns a new color3 representing the HSV values
  6129. */
  6130. toHSV(): Color3;
  6131. /**
  6132. * Converts current color in rgb space to HSV values
  6133. * @param result defines the Color3 where to store the HSV values
  6134. */
  6135. toHSVToRef(result: Color3): void;
  6136. /**
  6137. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6138. * @param convertedColor defines the Color3 object where to store the linear space version
  6139. * @returns the unmodified Color3
  6140. */
  6141. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6142. /**
  6143. * Computes a new Color3 converted from the current one to gamma space
  6144. * @returns a new Color3 object
  6145. */
  6146. toGammaSpace(): Color3;
  6147. /**
  6148. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6149. * @param convertedColor defines the Color3 object where to store the gamma space version
  6150. * @returns the unmodified Color3
  6151. */
  6152. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6153. private static _BlackReadOnly;
  6154. /**
  6155. * Convert Hue, saturation and value to a Color3 (RGB)
  6156. * @param hue defines the hue
  6157. * @param saturation defines the saturation
  6158. * @param value defines the value
  6159. * @param result defines the Color3 where to store the RGB values
  6160. */
  6161. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6162. /**
  6163. * Creates a new Color3 from the string containing valid hexadecimal values
  6164. * @param hex defines a string containing valid hexadecimal values
  6165. * @returns a new Color3 object
  6166. */
  6167. static FromHexString(hex: string): Color3;
  6168. /**
  6169. * Creates a new Color3 from the starting index of the given array
  6170. * @param array defines the source array
  6171. * @param offset defines an offset in the source array
  6172. * @returns a new Color3 object
  6173. */
  6174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6175. /**
  6176. * Creates a new Color3 from the starting index element of the given array
  6177. * @param array defines the source array to read from
  6178. * @param offset defines the offset in the source array
  6179. * @param result defines the target Color3 object
  6180. */
  6181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6182. /**
  6183. * Creates a new Color3 from integer values (< 256)
  6184. * @param r defines the red component to read from (value between 0 and 255)
  6185. * @param g defines the green component to read from (value between 0 and 255)
  6186. * @param b defines the blue component to read from (value between 0 and 255)
  6187. * @returns a new Color3 object
  6188. */
  6189. static FromInts(r: number, g: number, b: number): Color3;
  6190. /**
  6191. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6192. * @param start defines the start Color3 value
  6193. * @param end defines the end Color3 value
  6194. * @param amount defines the gradient value between start and end
  6195. * @returns a new Color3 object
  6196. */
  6197. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6198. /**
  6199. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6200. * @param left defines the start value
  6201. * @param right defines the end value
  6202. * @param amount defines the gradient factor
  6203. * @param result defines the Color3 object where to store the result
  6204. */
  6205. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6206. /**
  6207. * Returns a Color3 value containing a red color
  6208. * @returns a new Color3 object
  6209. */
  6210. static Red(): Color3;
  6211. /**
  6212. * Returns a Color3 value containing a green color
  6213. * @returns a new Color3 object
  6214. */
  6215. static Green(): Color3;
  6216. /**
  6217. * Returns a Color3 value containing a blue color
  6218. * @returns a new Color3 object
  6219. */
  6220. static Blue(): Color3;
  6221. /**
  6222. * Returns a Color3 value containing a black color
  6223. * @returns a new Color3 object
  6224. */
  6225. static Black(): Color3;
  6226. /**
  6227. * Gets a Color3 value containing a black color that must not be updated
  6228. */
  6229. static get BlackReadOnly(): DeepImmutable<Color3>;
  6230. /**
  6231. * Returns a Color3 value containing a white color
  6232. * @returns a new Color3 object
  6233. */
  6234. static White(): Color3;
  6235. /**
  6236. * Returns a Color3 value containing a purple color
  6237. * @returns a new Color3 object
  6238. */
  6239. static Purple(): Color3;
  6240. /**
  6241. * Returns a Color3 value containing a magenta color
  6242. * @returns a new Color3 object
  6243. */
  6244. static Magenta(): Color3;
  6245. /**
  6246. * Returns a Color3 value containing a yellow color
  6247. * @returns a new Color3 object
  6248. */
  6249. static Yellow(): Color3;
  6250. /**
  6251. * Returns a Color3 value containing a gray color
  6252. * @returns a new Color3 object
  6253. */
  6254. static Gray(): Color3;
  6255. /**
  6256. * Returns a Color3 value containing a teal color
  6257. * @returns a new Color3 object
  6258. */
  6259. static Teal(): Color3;
  6260. /**
  6261. * Returns a Color3 value containing a random color
  6262. * @returns a new Color3 object
  6263. */
  6264. static Random(): Color3;
  6265. }
  6266. /**
  6267. * Class used to hold a RBGA color
  6268. */
  6269. export class Color4 {
  6270. /**
  6271. * Defines the red component (between 0 and 1, default is 0)
  6272. */
  6273. r: number;
  6274. /**
  6275. * Defines the green component (between 0 and 1, default is 0)
  6276. */
  6277. g: number;
  6278. /**
  6279. * Defines the blue component (between 0 and 1, default is 0)
  6280. */
  6281. b: number;
  6282. /**
  6283. * Defines the alpha component (between 0 and 1, default is 1)
  6284. */
  6285. a: number;
  6286. /**
  6287. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6288. * @param r defines the red component (between 0 and 1, default is 0)
  6289. * @param g defines the green component (between 0 and 1, default is 0)
  6290. * @param b defines the blue component (between 0 and 1, default is 0)
  6291. * @param a defines the alpha component (between 0 and 1, default is 1)
  6292. */
  6293. constructor(
  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. * Adds in place the given Color4 values to the current Color4 object
  6312. * @param right defines the second operand
  6313. * @returns the current updated Color4 object
  6314. */
  6315. addInPlace(right: DeepImmutable<Color4>): Color4;
  6316. /**
  6317. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6318. * @returns the new array
  6319. */
  6320. asArray(): number[];
  6321. /**
  6322. * Stores from the starting index in the given array the Color4 successive values
  6323. * @param array defines the array where to store the r,g,b components
  6324. * @param index defines an optional index in the target array to define where to start storing values
  6325. * @returns the current Color4 object
  6326. */
  6327. toArray(array: number[], index?: number): Color4;
  6328. /**
  6329. * Update the current color with values stored in an array from the starting index of the given array
  6330. * @param array defines the source array
  6331. * @param offset defines an offset in the source array
  6332. * @returns the current Color4 object
  6333. */
  6334. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6335. /**
  6336. * Determines equality between Color4 objects
  6337. * @param otherColor defines the second operand
  6338. * @returns true if the rgba values are equal to the given ones
  6339. */
  6340. equals(otherColor: DeepImmutable<Color4>): boolean;
  6341. /**
  6342. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6343. * @param right defines the second operand
  6344. * @returns a new Color4 object
  6345. */
  6346. add(right: DeepImmutable<Color4>): Color4;
  6347. /**
  6348. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6349. * @param right defines the second operand
  6350. * @returns a new Color4 object
  6351. */
  6352. subtract(right: DeepImmutable<Color4>): Color4;
  6353. /**
  6354. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6355. * @param right defines the second operand
  6356. * @param result defines the Color4 object where to store the result
  6357. * @returns the current Color4 object
  6358. */
  6359. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6360. /**
  6361. * Creates a new Color4 with the current Color4 values multiplied by scale
  6362. * @param scale defines the scaling factor to apply
  6363. * @returns a new Color4 object
  6364. */
  6365. scale(scale: number): Color4;
  6366. /**
  6367. * Multiplies the current Color4 values by scale and stores the result in "result"
  6368. * @param scale defines the scaling factor to apply
  6369. * @param result defines the Color4 object where to store the result
  6370. * @returns the current unmodified Color4
  6371. */
  6372. scaleToRef(scale: number, result: Color4): Color4;
  6373. /**
  6374. * Scale the current Color4 values by a factor and add the result to a given Color4
  6375. * @param scale defines the scale factor
  6376. * @param result defines the Color4 object where to store the result
  6377. * @returns the unmodified current Color4
  6378. */
  6379. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6380. /**
  6381. * Clamps the rgb values by the min and max values and stores the result into "result"
  6382. * @param min defines minimum clamping value (default is 0)
  6383. * @param max defines maximum clamping value (default is 1)
  6384. * @param result defines color to store the result into.
  6385. * @returns the cuurent Color4
  6386. */
  6387. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6388. /**
  6389. * Multipy an Color4 value by another and return a new Color4 object
  6390. * @param color defines the Color4 value to multiply by
  6391. * @returns a new Color4 object
  6392. */
  6393. multiply(color: Color4): Color4;
  6394. /**
  6395. * Multipy a Color4 value by another and push the result in a reference value
  6396. * @param color defines the Color4 value to multiply by
  6397. * @param result defines the Color4 to fill the result in
  6398. * @returns the result Color4
  6399. */
  6400. multiplyToRef(color: Color4, result: Color4): Color4;
  6401. /**
  6402. * Creates a string with the Color4 current values
  6403. * @returns the string representation of the Color4 object
  6404. */
  6405. toString(): string;
  6406. /**
  6407. * Returns the string "Color4"
  6408. * @returns "Color4"
  6409. */
  6410. getClassName(): string;
  6411. /**
  6412. * Compute the Color4 hash code
  6413. * @returns an unique number that can be used to hash Color4 objects
  6414. */
  6415. getHashCode(): number;
  6416. /**
  6417. * Creates a new Color4 copied from the current one
  6418. * @returns a new Color4 object
  6419. */
  6420. clone(): Color4;
  6421. /**
  6422. * Copies the given Color4 values into the current one
  6423. * @param source defines the source Color4 object
  6424. * @returns the current updated Color4 object
  6425. */
  6426. copyFrom(source: Color4): Color4;
  6427. /**
  6428. * Copies the given float values into the current one
  6429. * @param r defines the red component to read from
  6430. * @param g defines the green component to read from
  6431. * @param b defines the blue component to read from
  6432. * @param a defines the alpha component to read from
  6433. * @returns the current updated Color4 object
  6434. */
  6435. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6436. /**
  6437. * Copies the given float values into the current one
  6438. * @param r defines the red component to read from
  6439. * @param g defines the green component to read from
  6440. * @param b defines the blue component to read from
  6441. * @param a defines the alpha component to read from
  6442. * @returns the current updated Color4 object
  6443. */
  6444. set(r: number, g: number, b: number, a: number): Color4;
  6445. /**
  6446. * Compute the Color4 hexadecimal code as a string
  6447. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6448. * @returns a string containing the hexadecimal representation of the Color4 object
  6449. */
  6450. toHexString(returnAsColor3?: boolean): string;
  6451. /**
  6452. * Computes a new Color4 converted from the current one to linear space
  6453. * @returns a new Color4 object
  6454. */
  6455. toLinearSpace(): Color4;
  6456. /**
  6457. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6458. * @param convertedColor defines the Color4 object where to store the linear space version
  6459. * @returns the unmodified Color4
  6460. */
  6461. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6462. /**
  6463. * Computes a new Color4 converted from the current one to gamma space
  6464. * @returns a new Color4 object
  6465. */
  6466. toGammaSpace(): Color4;
  6467. /**
  6468. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6469. * @param convertedColor defines the Color4 object where to store the gamma space version
  6470. * @returns the unmodified Color4
  6471. */
  6472. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6473. /**
  6474. * Creates a new Color4 from the string containing valid hexadecimal values
  6475. * @param hex defines a string containing valid hexadecimal values
  6476. * @returns a new Color4 object
  6477. */
  6478. static FromHexString(hex: string): Color4;
  6479. /**
  6480. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6481. * @param left defines the start value
  6482. * @param right defines the end value
  6483. * @param amount defines the gradient factor
  6484. * @returns a new Color4 object
  6485. */
  6486. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6487. /**
  6488. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6489. * @param left defines the start value
  6490. * @param right defines the end value
  6491. * @param amount defines the gradient factor
  6492. * @param result defines the Color4 object where to store data
  6493. */
  6494. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6495. /**
  6496. * Creates a new Color4 from a Color3 and an alpha value
  6497. * @param color3 defines the source Color3 to read from
  6498. * @param alpha defines the alpha component (1.0 by default)
  6499. * @returns a new Color4 object
  6500. */
  6501. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6502. /**
  6503. * Creates a new Color4 from the starting index element of the given array
  6504. * @param array defines the source array to read from
  6505. * @param offset defines the offset in the source array
  6506. * @returns a new Color4 object
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6509. /**
  6510. * Creates a new Color4 from the starting index element of the given array
  6511. * @param array defines the source array to read from
  6512. * @param offset defines the offset in the source array
  6513. * @param result defines the target Color4 object
  6514. */
  6515. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6516. /**
  6517. * Creates a new Color3 from integer values (< 256)
  6518. * @param r defines the red component to read from (value between 0 and 255)
  6519. * @param g defines the green component to read from (value between 0 and 255)
  6520. * @param b defines the blue component to read from (value between 0 and 255)
  6521. * @param a defines the alpha component to read from (value between 0 and 255)
  6522. * @returns a new Color3 object
  6523. */
  6524. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6525. /**
  6526. * Check the content of a given array and convert it to an array containing RGBA data
  6527. * If the original array was already containing count * 4 values then it is returned directly
  6528. * @param colors defines the array to check
  6529. * @param count defines the number of RGBA data to expect
  6530. * @returns an array containing count * 4 values (RGBA)
  6531. */
  6532. static CheckColors4(colors: number[], count: number): number[];
  6533. }
  6534. /**
  6535. * @hidden
  6536. */
  6537. export class TmpColors {
  6538. static Color3: Color3[];
  6539. static Color4: Color4[];
  6540. }
  6541. }
  6542. declare module "babylonjs/Animations/animationKey" {
  6543. /**
  6544. * Defines an interface which represents an animation key frame
  6545. */
  6546. export interface IAnimationKey {
  6547. /**
  6548. * Frame of the key frame
  6549. */
  6550. frame: number;
  6551. /**
  6552. * Value at the specifies key frame
  6553. */
  6554. value: any;
  6555. /**
  6556. * The input tangent for the cubic hermite spline
  6557. */
  6558. inTangent?: any;
  6559. /**
  6560. * The output tangent for the cubic hermite spline
  6561. */
  6562. outTangent?: any;
  6563. /**
  6564. * The animation interpolation type
  6565. */
  6566. interpolation?: AnimationKeyInterpolation;
  6567. }
  6568. /**
  6569. * Enum for the animation key frame interpolation type
  6570. */
  6571. export enum AnimationKeyInterpolation {
  6572. /**
  6573. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6574. */
  6575. STEP = 1
  6576. }
  6577. }
  6578. declare module "babylonjs/Animations/animationRange" {
  6579. /**
  6580. * Represents the range of an animation
  6581. */
  6582. export class AnimationRange {
  6583. /**The name of the animation range**/
  6584. name: string;
  6585. /**The starting frame of the animation */
  6586. from: number;
  6587. /**The ending frame of the animation*/
  6588. to: number;
  6589. /**
  6590. * Initializes the range of an animation
  6591. * @param name The name of the animation range
  6592. * @param from The starting frame of the animation
  6593. * @param to The ending frame of the animation
  6594. */
  6595. constructor(
  6596. /**The name of the animation range**/
  6597. name: string,
  6598. /**The starting frame of the animation */
  6599. from: number,
  6600. /**The ending frame of the animation*/
  6601. to: number);
  6602. /**
  6603. * Makes a copy of the animation range
  6604. * @returns A copy of the animation range
  6605. */
  6606. clone(): AnimationRange;
  6607. }
  6608. }
  6609. declare module "babylonjs/Animations/animationEvent" {
  6610. /**
  6611. * Composed of a frame, and an action function
  6612. */
  6613. export class AnimationEvent {
  6614. /** The frame for which the event is triggered **/
  6615. frame: number;
  6616. /** The event to perform when triggered **/
  6617. action: (currentFrame: number) => void;
  6618. /** Specifies if the event should be triggered only once**/
  6619. onlyOnce?: boolean | undefined;
  6620. /**
  6621. * Specifies if the animation event is done
  6622. */
  6623. isDone: boolean;
  6624. /**
  6625. * Initializes the animation event
  6626. * @param frame The frame for which the event is triggered
  6627. * @param action The event to perform when triggered
  6628. * @param onlyOnce Specifies if the event should be triggered only once
  6629. */
  6630. constructor(
  6631. /** The frame for which the event is triggered **/
  6632. frame: number,
  6633. /** The event to perform when triggered **/
  6634. action: (currentFrame: number) => void,
  6635. /** Specifies if the event should be triggered only once**/
  6636. onlyOnce?: boolean | undefined);
  6637. /** @hidden */
  6638. _clone(): AnimationEvent;
  6639. }
  6640. }
  6641. declare module "babylonjs/Behaviors/behavior" {
  6642. import { Nullable } from "babylonjs/types";
  6643. /**
  6644. * Interface used to define a behavior
  6645. */
  6646. export interface Behavior<T> {
  6647. /** gets or sets behavior's name */
  6648. name: string;
  6649. /**
  6650. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6651. */
  6652. init(): void;
  6653. /**
  6654. * Called when the behavior is attached to a target
  6655. * @param target defines the target where the behavior is attached to
  6656. */
  6657. attach(target: T): void;
  6658. /**
  6659. * Called when the behavior is detached from its target
  6660. */
  6661. detach(): void;
  6662. }
  6663. /**
  6664. * Interface implemented by classes supporting behaviors
  6665. */
  6666. export interface IBehaviorAware<T> {
  6667. /**
  6668. * Attach a behavior
  6669. * @param behavior defines the behavior to attach
  6670. * @returns the current host
  6671. */
  6672. addBehavior(behavior: Behavior<T>): T;
  6673. /**
  6674. * Remove a behavior from the current object
  6675. * @param behavior defines the behavior to detach
  6676. * @returns the current host
  6677. */
  6678. removeBehavior(behavior: Behavior<T>): T;
  6679. /**
  6680. * Gets a behavior using its name to search
  6681. * @param name defines the name to search
  6682. * @returns the behavior or null if not found
  6683. */
  6684. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6685. }
  6686. }
  6687. declare module "babylonjs/Meshes/buffer" {
  6688. import { Nullable, DataArray } from "babylonjs/types";
  6689. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6690. /**
  6691. * Class used to store data that will be store in GPU memory
  6692. */
  6693. export class Buffer {
  6694. private _engine;
  6695. private _buffer;
  6696. /** @hidden */
  6697. _data: Nullable<DataArray>;
  6698. private _updatable;
  6699. private _instanced;
  6700. private _divisor;
  6701. private _isAlreadyOwned;
  6702. /**
  6703. * Gets the byte stride.
  6704. */
  6705. readonly byteStride: number;
  6706. /**
  6707. * Constructor
  6708. * @param engine the engine
  6709. * @param data the data to use for this buffer
  6710. * @param updatable whether the data is updatable
  6711. * @param stride the stride (optional)
  6712. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6713. * @param instanced whether the buffer is instanced (optional)
  6714. * @param useBytes set to true if the stride in in bytes (optional)
  6715. * @param divisor sets an optional divisor for instances (1 by default)
  6716. */
  6717. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6718. /**
  6719. * Create a new VertexBuffer based on the current buffer
  6720. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6721. * @param offset defines offset in the buffer (0 by default)
  6722. * @param size defines the size in floats of attributes (position is 3 for instance)
  6723. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6724. * @param instanced defines if the vertex buffer contains indexed data
  6725. * @param useBytes defines if the offset and stride are in bytes *
  6726. * @param divisor sets an optional divisor for instances (1 by default)
  6727. * @returns the new vertex buffer
  6728. */
  6729. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6730. /**
  6731. * Gets a boolean indicating if the Buffer is updatable?
  6732. * @returns true if the buffer is updatable
  6733. */
  6734. isUpdatable(): boolean;
  6735. /**
  6736. * Gets current buffer's data
  6737. * @returns a DataArray or null
  6738. */
  6739. getData(): Nullable<DataArray>;
  6740. /**
  6741. * Gets underlying native buffer
  6742. * @returns underlying native buffer
  6743. */
  6744. getBuffer(): Nullable<DataBuffer>;
  6745. /**
  6746. * Gets the stride in float32 units (i.e. byte stride / 4).
  6747. * May not be an integer if the byte stride is not divisible by 4.
  6748. * @returns the stride in float32 units
  6749. * @deprecated Please use byteStride instead.
  6750. */
  6751. getStrideSize(): number;
  6752. /**
  6753. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6754. * @param data defines the data to store
  6755. */
  6756. create(data?: Nullable<DataArray>): void;
  6757. /** @hidden */
  6758. _rebuild(): void;
  6759. /**
  6760. * Update current buffer data
  6761. * @param data defines the data to store
  6762. */
  6763. update(data: DataArray): void;
  6764. /**
  6765. * Updates the data directly.
  6766. * @param data the new data
  6767. * @param offset the new offset
  6768. * @param vertexCount the vertex count (optional)
  6769. * @param useBytes set to true if the offset is in bytes
  6770. */
  6771. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6772. /** @hidden */
  6773. _increaseReferences(): void;
  6774. /**
  6775. * Release all resources
  6776. */
  6777. dispose(): void;
  6778. }
  6779. /**
  6780. * Specialized buffer used to store vertex data
  6781. */
  6782. export class VertexBuffer {
  6783. /** @hidden */
  6784. _buffer: Buffer;
  6785. private _kind;
  6786. private _size;
  6787. private _ownsBuffer;
  6788. private _instanced;
  6789. private _instanceDivisor;
  6790. /**
  6791. * The byte type.
  6792. */
  6793. static readonly BYTE: number;
  6794. /**
  6795. * The unsigned byte type.
  6796. */
  6797. static readonly UNSIGNED_BYTE: number;
  6798. /**
  6799. * The short type.
  6800. */
  6801. static readonly SHORT: number;
  6802. /**
  6803. * The unsigned short type.
  6804. */
  6805. static readonly UNSIGNED_SHORT: number;
  6806. /**
  6807. * The integer type.
  6808. */
  6809. static readonly INT: number;
  6810. /**
  6811. * The unsigned integer type.
  6812. */
  6813. static readonly UNSIGNED_INT: number;
  6814. /**
  6815. * The float type.
  6816. */
  6817. static readonly FLOAT: number;
  6818. /**
  6819. * Gets or sets the instance divisor when in instanced mode
  6820. */
  6821. get instanceDivisor(): number;
  6822. set instanceDivisor(value: number);
  6823. /**
  6824. * Gets the byte stride.
  6825. */
  6826. readonly byteStride: number;
  6827. /**
  6828. * Gets the byte offset.
  6829. */
  6830. readonly byteOffset: number;
  6831. /**
  6832. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6833. */
  6834. readonly normalized: boolean;
  6835. /**
  6836. * Gets the data type of each component in the array.
  6837. */
  6838. readonly type: number;
  6839. /**
  6840. * Constructor
  6841. * @param engine the engine
  6842. * @param data the data to use for this vertex buffer
  6843. * @param kind the vertex buffer kind
  6844. * @param updatable whether the data is updatable
  6845. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6846. * @param stride the stride (optional)
  6847. * @param instanced whether the buffer is instanced (optional)
  6848. * @param offset the offset of the data (optional)
  6849. * @param size the number of components (optional)
  6850. * @param type the type of the component (optional)
  6851. * @param normalized whether the data contains normalized data (optional)
  6852. * @param useBytes set to true if stride and offset are in bytes (optional)
  6853. * @param divisor defines the instance divisor to use (1 by default)
  6854. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6855. */
  6856. 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);
  6857. /** @hidden */
  6858. _rebuild(): void;
  6859. /**
  6860. * Returns the kind of the VertexBuffer (string)
  6861. * @returns a string
  6862. */
  6863. getKind(): string;
  6864. /**
  6865. * Gets a boolean indicating if the VertexBuffer is updatable?
  6866. * @returns true if the buffer is updatable
  6867. */
  6868. isUpdatable(): boolean;
  6869. /**
  6870. * Gets current buffer's data
  6871. * @returns a DataArray or null
  6872. */
  6873. getData(): Nullable<DataArray>;
  6874. /**
  6875. * Gets underlying native buffer
  6876. * @returns underlying native buffer
  6877. */
  6878. getBuffer(): Nullable<DataBuffer>;
  6879. /**
  6880. * Gets the stride in float32 units (i.e. byte stride / 4).
  6881. * May not be an integer if the byte stride is not divisible by 4.
  6882. * @returns the stride in float32 units
  6883. * @deprecated Please use byteStride instead.
  6884. */
  6885. getStrideSize(): number;
  6886. /**
  6887. * Returns the offset as a multiple of the type byte length.
  6888. * @returns the offset in bytes
  6889. * @deprecated Please use byteOffset instead.
  6890. */
  6891. getOffset(): number;
  6892. /**
  6893. * Returns the number of components per vertex attribute (integer)
  6894. * @returns the size in float
  6895. */
  6896. getSize(): number;
  6897. /**
  6898. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6899. * @returns true if this buffer is instanced
  6900. */
  6901. getIsInstanced(): boolean;
  6902. /**
  6903. * Returns the instancing divisor, zero for non-instanced (integer).
  6904. * @returns a number
  6905. */
  6906. getInstanceDivisor(): number;
  6907. /**
  6908. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6909. * @param data defines the data to store
  6910. */
  6911. create(data?: DataArray): void;
  6912. /**
  6913. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6914. * This function will create a new buffer if the current one is not updatable
  6915. * @param data defines the data to store
  6916. */
  6917. update(data: DataArray): void;
  6918. /**
  6919. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6920. * Returns the directly updated WebGLBuffer.
  6921. * @param data the new data
  6922. * @param offset the new offset
  6923. * @param useBytes set to true if the offset is in bytes
  6924. */
  6925. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6926. /**
  6927. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6928. */
  6929. dispose(): void;
  6930. /**
  6931. * Enumerates each value of this vertex buffer as numbers.
  6932. * @param count the number of values to enumerate
  6933. * @param callback the callback function called for each value
  6934. */
  6935. forEach(count: number, callback: (value: number, index: number) => void): void;
  6936. /**
  6937. * Positions
  6938. */
  6939. static readonly PositionKind: string;
  6940. /**
  6941. * Normals
  6942. */
  6943. static readonly NormalKind: string;
  6944. /**
  6945. * Tangents
  6946. */
  6947. static readonly TangentKind: string;
  6948. /**
  6949. * Texture coordinates
  6950. */
  6951. static readonly UVKind: string;
  6952. /**
  6953. * Texture coordinates 2
  6954. */
  6955. static readonly UV2Kind: string;
  6956. /**
  6957. * Texture coordinates 3
  6958. */
  6959. static readonly UV3Kind: string;
  6960. /**
  6961. * Texture coordinates 4
  6962. */
  6963. static readonly UV4Kind: string;
  6964. /**
  6965. * Texture coordinates 5
  6966. */
  6967. static readonly UV5Kind: string;
  6968. /**
  6969. * Texture coordinates 6
  6970. */
  6971. static readonly UV6Kind: string;
  6972. /**
  6973. * Colors
  6974. */
  6975. static readonly ColorKind: string;
  6976. /**
  6977. * Matrix indices (for bones)
  6978. */
  6979. static readonly MatricesIndicesKind: string;
  6980. /**
  6981. * Matrix weights (for bones)
  6982. */
  6983. static readonly MatricesWeightsKind: string;
  6984. /**
  6985. * Additional matrix indices (for bones)
  6986. */
  6987. static readonly MatricesIndicesExtraKind: string;
  6988. /**
  6989. * Additional matrix weights (for bones)
  6990. */
  6991. static readonly MatricesWeightsExtraKind: string;
  6992. /**
  6993. * Deduces the stride given a kind.
  6994. * @param kind The kind string to deduce
  6995. * @returns The deduced stride
  6996. */
  6997. static DeduceStride(kind: string): number;
  6998. /**
  6999. * Gets the byte length of the given type.
  7000. * @param type the type
  7001. * @returns the number of bytes
  7002. */
  7003. static GetTypeByteLength(type: number): number;
  7004. /**
  7005. * Enumerates each value of the given parameters as numbers.
  7006. * @param data the data to enumerate
  7007. * @param byteOffset the byte offset of the data
  7008. * @param byteStride the byte stride of the data
  7009. * @param componentCount the number of components per element
  7010. * @param componentType the type of the component
  7011. * @param count the number of values to enumerate
  7012. * @param normalized whether the data is normalized
  7013. * @param callback the callback function called for each value
  7014. */
  7015. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7016. private static _GetFloatValue;
  7017. }
  7018. }
  7019. declare module "babylonjs/Collisions/intersectionInfo" {
  7020. import { Nullable } from "babylonjs/types";
  7021. /**
  7022. * @hidden
  7023. */
  7024. export class IntersectionInfo {
  7025. bu: Nullable<number>;
  7026. bv: Nullable<number>;
  7027. distance: number;
  7028. faceId: number;
  7029. subMeshId: number;
  7030. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7031. }
  7032. }
  7033. declare module "babylonjs/Culling/boundingSphere" {
  7034. import { DeepImmutable } from "babylonjs/types";
  7035. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7036. import { Plane } from "babylonjs/Maths/math.plane";
  7037. /**
  7038. * Class used to store bounding sphere information
  7039. */
  7040. export class BoundingSphere {
  7041. /**
  7042. * Gets the center of the bounding sphere in local space
  7043. */
  7044. readonly center: Vector3;
  7045. /**
  7046. * Radius of the bounding sphere in local space
  7047. */
  7048. radius: number;
  7049. /**
  7050. * Gets the center of the bounding sphere in world space
  7051. */
  7052. readonly centerWorld: Vector3;
  7053. /**
  7054. * Radius of the bounding sphere in world space
  7055. */
  7056. radiusWorld: number;
  7057. /**
  7058. * Gets the minimum vector in local space
  7059. */
  7060. readonly minimum: Vector3;
  7061. /**
  7062. * Gets the maximum vector in local space
  7063. */
  7064. readonly maximum: Vector3;
  7065. private _worldMatrix;
  7066. private static readonly TmpVector3;
  7067. /**
  7068. * Creates a new bounding sphere
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding sphere by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingSphere;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding sphere is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding sphere center is in between the frustum planes.
  7102. * Used for optimistic fast inclusion.
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @returns true if the sphere center is in between the frustum planes
  7105. */
  7106. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a point is inside the bounding sphere
  7109. * @param point defines the point to test
  7110. * @returns true if the point is inside the bounding sphere
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if two sphere intersct
  7115. * @param sphere0 sphere 0
  7116. * @param sphere1 sphere 1
  7117. * @returns true if the speres intersect
  7118. */
  7119. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7120. }
  7121. }
  7122. declare module "babylonjs/Culling/boundingBox" {
  7123. import { DeepImmutable } from "babylonjs/types";
  7124. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7125. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7126. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7127. import { Plane } from "babylonjs/Maths/math.plane";
  7128. /**
  7129. * Class used to store bounding box information
  7130. */
  7131. export class BoundingBox implements ICullable {
  7132. /**
  7133. * Gets the 8 vectors representing the bounding box in local space
  7134. */
  7135. readonly vectors: Vector3[];
  7136. /**
  7137. * Gets the center of the bounding box in local space
  7138. */
  7139. readonly center: Vector3;
  7140. /**
  7141. * Gets the center of the bounding box in world space
  7142. */
  7143. readonly centerWorld: Vector3;
  7144. /**
  7145. * Gets the extend size in local space
  7146. */
  7147. readonly extendSize: Vector3;
  7148. /**
  7149. * Gets the extend size in world space
  7150. */
  7151. readonly extendSizeWorld: Vector3;
  7152. /**
  7153. * Gets the OBB (object bounding box) directions
  7154. */
  7155. readonly directions: Vector3[];
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in world space
  7158. */
  7159. readonly vectorsWorld: Vector3[];
  7160. /**
  7161. * Gets the minimum vector in world space
  7162. */
  7163. readonly minimumWorld: Vector3;
  7164. /**
  7165. * Gets the maximum vector in world space
  7166. */
  7167. readonly maximumWorld: Vector3;
  7168. /**
  7169. * Gets the minimum vector in local space
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * Gets the maximum vector in local space
  7174. */
  7175. readonly maximum: Vector3;
  7176. private _worldMatrix;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * @hidden
  7180. */
  7181. _tag: number;
  7182. /**
  7183. * Creates a new bounding box
  7184. * @param min defines the minimum vector (in local space)
  7185. * @param max defines the maximum vector (in local space)
  7186. * @param worldMatrix defines the new world matrix
  7187. */
  7188. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7189. /**
  7190. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7191. * @param min defines the new minimum vector (in local space)
  7192. * @param max defines the new maximum vector (in local space)
  7193. * @param worldMatrix defines the new world matrix
  7194. */
  7195. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7196. /**
  7197. * Scale the current bounding box by applying a scale factor
  7198. * @param factor defines the scale factor to apply
  7199. * @returns the current bounding box
  7200. */
  7201. scale(factor: number): BoundingBox;
  7202. /**
  7203. * Gets the world matrix of the bounding box
  7204. * @returns a matrix
  7205. */
  7206. getWorldMatrix(): DeepImmutable<Matrix>;
  7207. /** @hidden */
  7208. _update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Tests if the bounding box is intersecting the frustum planes
  7211. * @param frustumPlanes defines the frustum planes to test
  7212. * @returns true if there is an intersection
  7213. */
  7214. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7215. /**
  7216. * Tests if the bounding box is entirely inside the frustum planes
  7217. * @param frustumPlanes defines the frustum planes to test
  7218. * @returns true if there is an inclusion
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /**
  7222. * Tests if a point is inside the bounding box
  7223. * @param point defines the point to test
  7224. * @returns true if the point is inside the bounding box
  7225. */
  7226. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7227. /**
  7228. * Tests if the bounding box intersects with a bounding sphere
  7229. * @param sphere defines the sphere to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7233. /**
  7234. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7235. * @param min defines the min vector to use
  7236. * @param max defines the max vector to use
  7237. * @returns true if there is an intersection
  7238. */
  7239. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7240. /**
  7241. * Tests if two bounding boxes are intersections
  7242. * @param box0 defines the first box to test
  7243. * @param box1 defines the second box to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7247. /**
  7248. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7249. * @param minPoint defines the minimum vector of the bounding box
  7250. * @param maxPoint defines the maximum vector of the bounding box
  7251. * @param sphereCenter defines the sphere center
  7252. * @param sphereRadius defines the sphere radius
  7253. * @returns true if there is an intersection
  7254. */
  7255. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7256. /**
  7257. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7258. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7259. * @param frustumPlanes defines the frustum planes to test
  7260. * @return true if there is an inclusion
  7261. */
  7262. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7263. /**
  7264. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7265. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7266. * @param frustumPlanes defines the frustum planes to test
  7267. * @return true if there is an intersection
  7268. */
  7269. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Collisions/collider" {
  7273. import { Nullable, IndicesArray } from "babylonjs/types";
  7274. import { Vector3 } from "babylonjs/Maths/math.vector";
  7275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7276. import { Plane } from "babylonjs/Maths/math.plane";
  7277. /** @hidden */
  7278. export class Collider {
  7279. /** Define if a collision was found */
  7280. collisionFound: boolean;
  7281. /**
  7282. * Define last intersection point in local space
  7283. */
  7284. intersectionPoint: Vector3;
  7285. /**
  7286. * Define last collided mesh
  7287. */
  7288. collidedMesh: Nullable<AbstractMesh>;
  7289. private _collisionPoint;
  7290. private _planeIntersectionPoint;
  7291. private _tempVector;
  7292. private _tempVector2;
  7293. private _tempVector3;
  7294. private _tempVector4;
  7295. private _edge;
  7296. private _baseToVertex;
  7297. private _destinationPoint;
  7298. private _slidePlaneNormal;
  7299. private _displacementVector;
  7300. /** @hidden */
  7301. _radius: Vector3;
  7302. /** @hidden */
  7303. _retry: number;
  7304. private _velocity;
  7305. private _basePoint;
  7306. private _epsilon;
  7307. /** @hidden */
  7308. _velocityWorldLength: number;
  7309. /** @hidden */
  7310. _basePointWorld: Vector3;
  7311. private _velocityWorld;
  7312. private _normalizedVelocity;
  7313. /** @hidden */
  7314. _initialVelocity: Vector3;
  7315. /** @hidden */
  7316. _initialPosition: Vector3;
  7317. private _nearestDistance;
  7318. private _collisionMask;
  7319. get collisionMask(): number;
  7320. set collisionMask(mask: number);
  7321. /**
  7322. * Gets the plane normal used to compute the sliding response (in local space)
  7323. */
  7324. get slidePlaneNormal(): Vector3;
  7325. /** @hidden */
  7326. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7327. /** @hidden */
  7328. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7329. /** @hidden */
  7330. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7331. /** @hidden */
  7332. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7333. /** @hidden */
  7334. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7335. /** @hidden */
  7336. _getResponse(pos: Vector3, vel: Vector3): void;
  7337. }
  7338. }
  7339. declare module "babylonjs/Culling/boundingInfo" {
  7340. import { DeepImmutable } from "babylonjs/types";
  7341. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7342. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7343. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7344. import { Plane } from "babylonjs/Maths/math.plane";
  7345. import { Collider } from "babylonjs/Collisions/collider";
  7346. /**
  7347. * Interface for cullable objects
  7348. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7349. */
  7350. export interface ICullable {
  7351. /**
  7352. * Checks if the object or part of the object is in the frustum
  7353. * @param frustumPlanes Camera near/planes
  7354. * @returns true if the object is in frustum otherwise false
  7355. */
  7356. isInFrustum(frustumPlanes: Plane[]): boolean;
  7357. /**
  7358. * Checks if a cullable object (mesh...) is in the camera frustum
  7359. * Unlike isInFrustum this cheks the full bounding box
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7364. }
  7365. /**
  7366. * Info for a bounding data of a mesh
  7367. */
  7368. export class BoundingInfo implements ICullable {
  7369. /**
  7370. * Bounding box for the mesh
  7371. */
  7372. readonly boundingBox: BoundingBox;
  7373. /**
  7374. * Bounding sphere for the mesh
  7375. */
  7376. readonly boundingSphere: BoundingSphere;
  7377. private _isLocked;
  7378. private static readonly TmpVector3;
  7379. /**
  7380. * Constructs bounding info
  7381. * @param minimum min vector of the bounding box/sphere
  7382. * @param maximum max vector of the bounding box/sphere
  7383. * @param worldMatrix defines the new world matrix
  7384. */
  7385. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7386. /**
  7387. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7388. * @param min defines the new minimum vector (in local space)
  7389. * @param max defines the new maximum vector (in local space)
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7393. /**
  7394. * min vector of the bounding box/sphere
  7395. */
  7396. get minimum(): Vector3;
  7397. /**
  7398. * max vector of the bounding box/sphere
  7399. */
  7400. get maximum(): Vector3;
  7401. /**
  7402. * If the info is locked and won't be updated to avoid perf overhead
  7403. */
  7404. get isLocked(): boolean;
  7405. set isLocked(value: boolean);
  7406. /**
  7407. * Updates the bounding sphere and box
  7408. * @param world world matrix to be used to update
  7409. */
  7410. update(world: DeepImmutable<Matrix>): void;
  7411. /**
  7412. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7413. * @param center New center of the bounding info
  7414. * @param extend New extend of the bounding info
  7415. * @returns the current bounding info
  7416. */
  7417. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7418. /**
  7419. * Scale the current bounding info by applying a scale factor
  7420. * @param factor defines the scale factor to apply
  7421. * @returns the current bounding info
  7422. */
  7423. scale(factor: number): BoundingInfo;
  7424. /**
  7425. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7426. * @param frustumPlanes defines the frustum to test
  7427. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7428. * @returns true if the bounding info is in the frustum planes
  7429. */
  7430. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7431. /**
  7432. * Gets the world distance between the min and max points of the bounding box
  7433. */
  7434. get diagonalLength(): number;
  7435. /**
  7436. * Checks if a cullable object (mesh...) is in the camera frustum
  7437. * Unlike isInFrustum this cheks the full bounding box
  7438. * @param frustumPlanes Camera near/planes
  7439. * @returns true if the object is in frustum otherwise false
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /** @hidden */
  7443. _checkCollision(collider: Collider): boolean;
  7444. /**
  7445. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7447. * @param point the point to check intersection with
  7448. * @returns if the point intersects
  7449. */
  7450. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7451. /**
  7452. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7453. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7454. * @param boundingInfo the bounding info to check intersection with
  7455. * @param precise if the intersection should be done using OBB
  7456. * @returns if the bounding info intersects
  7457. */
  7458. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7459. }
  7460. }
  7461. declare module "babylonjs/Maths/math.functions" {
  7462. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7463. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7464. /**
  7465. * Extracts minimum and maximum values from a list of indexed positions
  7466. * @param positions defines the positions to use
  7467. * @param indices defines the indices to the positions
  7468. * @param indexStart defines the start index
  7469. * @param indexCount defines the end index
  7470. * @param bias defines bias value to add to the result
  7471. * @return minimum and maximum values
  7472. */
  7473. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7474. minimum: Vector3;
  7475. maximum: Vector3;
  7476. };
  7477. /**
  7478. * Extracts minimum and maximum values from a list of positions
  7479. * @param positions defines the positions to use
  7480. * @param start defines the start index in the positions array
  7481. * @param count defines the number of positions to handle
  7482. * @param bias defines bias value to add to the result
  7483. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7484. * @return minimum and maximum values
  7485. */
  7486. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7487. minimum: Vector3;
  7488. maximum: Vector3;
  7489. };
  7490. }
  7491. declare module "babylonjs/Misc/guid" {
  7492. /**
  7493. * Class used to manipulate GUIDs
  7494. */
  7495. export class GUID {
  7496. /**
  7497. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7498. * Be aware Math.random() could cause collisions, but:
  7499. * "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"
  7500. * @returns a pseudo random id
  7501. */
  7502. static RandomId(): string;
  7503. }
  7504. }
  7505. declare module "babylonjs/Materials/Textures/baseTexture" {
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Scene } from "babylonjs/scene";
  7509. import { Matrix } from "babylonjs/Maths/math.vector";
  7510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7512. import "babylonjs/Misc/fileTools";
  7513. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7514. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7515. /**
  7516. * Base class of all the textures in babylon.
  7517. * It groups all the common properties the materials, post process, lights... might need
  7518. * in order to make a correct use of the texture.
  7519. */
  7520. export class BaseTexture extends ThinTexture implements IAnimatable {
  7521. /**
  7522. * Default anisotropic filtering level for the application.
  7523. * It is set to 4 as a good tradeoff between perf and quality.
  7524. */
  7525. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7526. /**
  7527. * Gets or sets the unique id of the texture
  7528. */
  7529. uniqueId: number;
  7530. /**
  7531. * Define the name of the texture.
  7532. */
  7533. name: string;
  7534. /**
  7535. * Gets or sets an object used to store user defined information.
  7536. */
  7537. metadata: any;
  7538. /**
  7539. * For internal use only. Please do not use.
  7540. */
  7541. reservedDataStore: any;
  7542. private _hasAlpha;
  7543. /**
  7544. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7545. */
  7546. set hasAlpha(value: boolean);
  7547. get hasAlpha(): boolean;
  7548. /**
  7549. * Defines if the alpha value should be determined via the rgb values.
  7550. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7551. */
  7552. getAlphaFromRGB: boolean;
  7553. /**
  7554. * Intensity or strength of the texture.
  7555. * It is commonly used by materials to fine tune the intensity of the texture
  7556. */
  7557. level: number;
  7558. /**
  7559. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7560. * This is part of the texture as textures usually maps to one uv set.
  7561. */
  7562. coordinatesIndex: number;
  7563. protected _coordinatesMode: number;
  7564. /**
  7565. * How a texture is mapped.
  7566. *
  7567. * | Value | Type | Description |
  7568. * | ----- | ----------------------------------- | ----------- |
  7569. * | 0 | EXPLICIT_MODE | |
  7570. * | 1 | SPHERICAL_MODE | |
  7571. * | 2 | PLANAR_MODE | |
  7572. * | 3 | CUBIC_MODE | |
  7573. * | 4 | PROJECTION_MODE | |
  7574. * | 5 | SKYBOX_MODE | |
  7575. * | 6 | INVCUBIC_MODE | |
  7576. * | 7 | EQUIRECTANGULAR_MODE | |
  7577. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7578. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7579. */
  7580. set coordinatesMode(value: number);
  7581. get coordinatesMode(): number;
  7582. /**
  7583. * | Value | Type | Description |
  7584. * | ----- | ------------------ | ----------- |
  7585. * | 0 | CLAMP_ADDRESSMODE | |
  7586. * | 1 | WRAP_ADDRESSMODE | |
  7587. * | 2 | MIRROR_ADDRESSMODE | |
  7588. */
  7589. get wrapU(): number;
  7590. set wrapU(value: number);
  7591. /**
  7592. * | Value | Type | Description |
  7593. * | ----- | ------------------ | ----------- |
  7594. * | 0 | CLAMP_ADDRESSMODE | |
  7595. * | 1 | WRAP_ADDRESSMODE | |
  7596. * | 2 | MIRROR_ADDRESSMODE | |
  7597. */
  7598. get wrapV(): number;
  7599. set wrapV(value: number);
  7600. /**
  7601. * | Value | Type | Description |
  7602. * | ----- | ------------------ | ----------- |
  7603. * | 0 | CLAMP_ADDRESSMODE | |
  7604. * | 1 | WRAP_ADDRESSMODE | |
  7605. * | 2 | MIRROR_ADDRESSMODE | |
  7606. */
  7607. wrapR: number;
  7608. /**
  7609. * With compliant hardware and browser (supporting anisotropic filtering)
  7610. * this defines the level of anisotropic filtering in the texture.
  7611. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7612. */
  7613. anisotropicFilteringLevel: number;
  7614. private _isCube;
  7615. /**
  7616. * Define if the texture is a cube texture or if false a 2d texture.
  7617. */
  7618. get isCube(): boolean;
  7619. set isCube(value: boolean);
  7620. /**
  7621. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7622. */
  7623. get is3D(): boolean;
  7624. set is3D(value: boolean);
  7625. /**
  7626. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7627. */
  7628. get is2DArray(): boolean;
  7629. set is2DArray(value: boolean);
  7630. private _gammaSpace;
  7631. /**
  7632. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7633. * HDR texture are usually stored in linear space.
  7634. * This only impacts the PBR and Background materials
  7635. */
  7636. get gammaSpace(): boolean;
  7637. set gammaSpace(gamma: boolean);
  7638. /**
  7639. * Gets or sets whether or not the texture contains RGBD data.
  7640. */
  7641. get isRGBD(): boolean;
  7642. set isRGBD(value: boolean);
  7643. /**
  7644. * Is Z inverted in the texture (useful in a cube texture).
  7645. */
  7646. invertZ: boolean;
  7647. /**
  7648. * Are mip maps generated for this texture or not.
  7649. */
  7650. get noMipmap(): boolean;
  7651. /**
  7652. * @hidden
  7653. */
  7654. lodLevelInAlpha: boolean;
  7655. /**
  7656. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7657. */
  7658. get lodGenerationOffset(): number;
  7659. set lodGenerationOffset(value: number);
  7660. /**
  7661. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7662. */
  7663. get lodGenerationScale(): number;
  7664. set lodGenerationScale(value: number);
  7665. /**
  7666. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7667. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7668. * average roughness values.
  7669. */
  7670. get linearSpecularLOD(): boolean;
  7671. set linearSpecularLOD(value: boolean);
  7672. /**
  7673. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7674. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7675. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7676. */
  7677. get irradianceTexture(): Nullable<BaseTexture>;
  7678. set irradianceTexture(value: Nullable<BaseTexture>);
  7679. /**
  7680. * Define if the texture is a render target.
  7681. */
  7682. isRenderTarget: boolean;
  7683. /**
  7684. * Define the unique id of the texture in the scene.
  7685. */
  7686. get uid(): string;
  7687. /** @hidden */
  7688. _prefiltered: boolean;
  7689. /**
  7690. * Return a string representation of the texture.
  7691. * @returns the texture as a string
  7692. */
  7693. toString(): string;
  7694. /**
  7695. * Get the class name of the texture.
  7696. * @returns "BaseTexture"
  7697. */
  7698. getClassName(): string;
  7699. /**
  7700. * Define the list of animation attached to the texture.
  7701. */
  7702. animations: import("babylonjs/Animations/animation").Animation[];
  7703. /**
  7704. * An event triggered when the texture is disposed.
  7705. */
  7706. onDisposeObservable: Observable<BaseTexture>;
  7707. private _onDisposeObserver;
  7708. /**
  7709. * Callback triggered when the texture has been disposed.
  7710. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7711. */
  7712. set onDispose(callback: () => void);
  7713. protected _scene: Nullable<Scene>;
  7714. /** @hidden */
  7715. _texture: Nullable<InternalTexture>;
  7716. private _uid;
  7717. /**
  7718. * Define if the texture is preventinga material to render or not.
  7719. * If not and the texture is not ready, the engine will use a default black texture instead.
  7720. */
  7721. get isBlocking(): boolean;
  7722. /**
  7723. * Instantiates a new BaseTexture.
  7724. * Base class of all the textures in babylon.
  7725. * It groups all the common properties the materials, post process, lights... might need
  7726. * in order to make a correct use of the texture.
  7727. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7728. */
  7729. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7730. /**
  7731. * Get the scene the texture belongs to.
  7732. * @returns the scene or null if undefined
  7733. */
  7734. getScene(): Nullable<Scene>;
  7735. /** @hidden */
  7736. protected _getEngine(): Nullable<ThinEngine>;
  7737. /**
  7738. * Checks if the texture has the same transform matrix than another texture
  7739. * @param texture texture to check against
  7740. * @returns true if the transforms are the same, else false
  7741. */
  7742. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7743. /**
  7744. * Get the texture transform matrix used to offset tile the texture for istance.
  7745. * @returns the transformation matrix
  7746. */
  7747. getTextureMatrix(): Matrix;
  7748. /**
  7749. * Get the texture reflection matrix used to rotate/transform the reflection.
  7750. * @returns the reflection matrix
  7751. */
  7752. getReflectionTextureMatrix(): Matrix;
  7753. /**
  7754. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7755. * @returns true if ready or not blocking
  7756. */
  7757. isReadyOrNotBlocking(): boolean;
  7758. /**
  7759. * Scales the texture if is `canRescale()`
  7760. * @param ratio the resize factor we want to use to rescale
  7761. */
  7762. scale(ratio: number): void;
  7763. /**
  7764. * Get if the texture can rescale.
  7765. */
  7766. get canRescale(): boolean;
  7767. /** @hidden */
  7768. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7769. /** @hidden */
  7770. _rebuild(): void;
  7771. /**
  7772. * Clones the texture.
  7773. * @returns the cloned texture
  7774. */
  7775. clone(): Nullable<BaseTexture>;
  7776. /**
  7777. * Get the texture underlying type (INT, FLOAT...)
  7778. */
  7779. get textureType(): number;
  7780. /**
  7781. * Get the texture underlying format (RGB, RGBA...)
  7782. */
  7783. get textureFormat(): number;
  7784. /**
  7785. * Indicates that textures need to be re-calculated for all materials
  7786. */
  7787. protected _markAllSubMeshesAsTexturesDirty(): void;
  7788. /**
  7789. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7790. * This will returns an RGBA array buffer containing either in values (0-255) or
  7791. * float values (0-1) depending of the underlying buffer type.
  7792. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7793. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7794. * @param buffer defines a user defined buffer to fill with data (can be null)
  7795. * @returns The Array buffer containing the pixels data.
  7796. */
  7797. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7798. /** @hidden */
  7799. get _lodTextureHigh(): Nullable<BaseTexture>;
  7800. /** @hidden */
  7801. get _lodTextureMid(): Nullable<BaseTexture>;
  7802. /** @hidden */
  7803. get _lodTextureLow(): Nullable<BaseTexture>;
  7804. /**
  7805. * Dispose the texture and release its associated resources.
  7806. */
  7807. dispose(): void;
  7808. /**
  7809. * Serialize the texture into a JSON representation that can be parsed later on.
  7810. * @returns the JSON representation of the texture
  7811. */
  7812. serialize(): any;
  7813. /**
  7814. * Helper function to be called back once a list of texture contains only ready textures.
  7815. * @param textures Define the list of textures to wait for
  7816. * @param callback Define the callback triggered once the entire list will be ready
  7817. */
  7818. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7819. private static _isScene;
  7820. }
  7821. }
  7822. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7823. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7824. /** @hidden */
  7825. export class WebGLDataBuffer extends DataBuffer {
  7826. private _buffer;
  7827. constructor(resource: WebGLBuffer);
  7828. get underlyingResource(): any;
  7829. }
  7830. }
  7831. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7832. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7833. import { Nullable } from "babylonjs/types";
  7834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7835. /** @hidden */
  7836. export class WebGLPipelineContext implements IPipelineContext {
  7837. engine: ThinEngine;
  7838. program: Nullable<WebGLProgram>;
  7839. context?: WebGLRenderingContext;
  7840. vertexShader?: WebGLShader;
  7841. fragmentShader?: WebGLShader;
  7842. isParallelCompiled: boolean;
  7843. onCompiled?: () => void;
  7844. transformFeedback?: WebGLTransformFeedback | null;
  7845. vertexCompilationError: Nullable<string>;
  7846. fragmentCompilationError: Nullable<string>;
  7847. programLinkError: Nullable<string>;
  7848. programValidationError: Nullable<string>;
  7849. get isAsync(): boolean;
  7850. get isReady(): boolean;
  7851. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7852. _getVertexShaderCode(): string | null;
  7853. _getFragmentShaderCode(): string | null;
  7854. }
  7855. }
  7856. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7857. import { FloatArray, Nullable } from "babylonjs/types";
  7858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7859. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7860. module "babylonjs/Engines/thinEngine" {
  7861. interface ThinEngine {
  7862. /**
  7863. * Create an uniform buffer
  7864. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7865. * @param elements defines the content of the uniform buffer
  7866. * @returns the webGL uniform buffer
  7867. */
  7868. createUniformBuffer(elements: FloatArray): DataBuffer;
  7869. /**
  7870. * Create a dynamic uniform buffer
  7871. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7872. * @param elements defines the content of the uniform buffer
  7873. * @returns the webGL uniform buffer
  7874. */
  7875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7876. /**
  7877. * Update an existing uniform buffer
  7878. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7879. * @param uniformBuffer defines the target uniform buffer
  7880. * @param elements defines the content to update
  7881. * @param offset defines the offset in the uniform buffer where update should start
  7882. * @param count defines the size of the data to update
  7883. */
  7884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7885. /**
  7886. * Bind an uniform buffer to the current webGL context
  7887. * @param buffer defines the buffer to bind
  7888. */
  7889. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7890. /**
  7891. * Bind a buffer to the current webGL context at a given location
  7892. * @param buffer defines the buffer to bind
  7893. * @param location defines the index where to bind the buffer
  7894. */
  7895. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7896. /**
  7897. * Bind a specific block at a given index in a specific shader program
  7898. * @param pipelineContext defines the pipeline context to use
  7899. * @param blockName defines the block name
  7900. * @param index defines the index where to bind the block
  7901. */
  7902. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7903. }
  7904. }
  7905. }
  7906. declare module "babylonjs/Materials/uniformBuffer" {
  7907. import { Nullable, FloatArray } from "babylonjs/types";
  7908. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7909. import { Engine } from "babylonjs/Engines/engine";
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7913. import { Color3 } from "babylonjs/Maths/math.color";
  7914. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7915. /**
  7916. * Uniform buffer objects.
  7917. *
  7918. * Handles blocks of uniform on the GPU.
  7919. *
  7920. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7921. *
  7922. * For more information, please refer to :
  7923. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7924. */
  7925. export class UniformBuffer {
  7926. private _engine;
  7927. private _buffer;
  7928. private _data;
  7929. private _bufferData;
  7930. private _dynamic?;
  7931. private _uniformLocations;
  7932. private _uniformSizes;
  7933. private _uniformLocationPointer;
  7934. private _needSync;
  7935. private _noUBO;
  7936. private _currentEffect;
  7937. /** @hidden */
  7938. _alreadyBound: boolean;
  7939. private static _MAX_UNIFORM_SIZE;
  7940. private static _tempBuffer;
  7941. /**
  7942. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7943. * This is dynamic to allow compat with webgl 1 and 2.
  7944. * You will need to pass the name of the uniform as well as the value.
  7945. */
  7946. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7947. /**
  7948. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7949. * This is dynamic to allow compat with webgl 1 and 2.
  7950. * You will need to pass the name of the uniform as well as the value.
  7951. */
  7952. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7953. /**
  7954. * Lambda to Update a single float in a uniform buffer.
  7955. * This is dynamic to allow compat with webgl 1 and 2.
  7956. * You will need to pass the name of the uniform as well as the value.
  7957. */
  7958. updateFloat: (name: string, x: number) => void;
  7959. /**
  7960. * Lambda to Update a vec2 of float in a uniform buffer.
  7961. * This is dynamic to allow compat with webgl 1 and 2.
  7962. * You will need to pass the name of the uniform as well as the value.
  7963. */
  7964. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7965. /**
  7966. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7971. /**
  7972. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7977. /**
  7978. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7983. /**
  7984. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7989. /**
  7990. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7995. /**
  7996. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8001. /**
  8002. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8007. /**
  8008. * Instantiates a new Uniform buffer objects.
  8009. *
  8010. * Handles blocks of uniform on the GPU.
  8011. *
  8012. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8013. *
  8014. * For more information, please refer to :
  8015. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8016. * @param engine Define the engine the buffer is associated with
  8017. * @param data Define the data contained in the buffer
  8018. * @param dynamic Define if the buffer is updatable
  8019. */
  8020. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8021. /**
  8022. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8023. * or just falling back on setUniformXXX calls.
  8024. */
  8025. get useUbo(): boolean;
  8026. /**
  8027. * Indicates if the WebGL underlying uniform buffer is in sync
  8028. * with the javascript cache data.
  8029. */
  8030. get isSync(): boolean;
  8031. /**
  8032. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8033. * Also, a dynamic UniformBuffer will disable cache verification and always
  8034. * update the underlying WebGL uniform buffer to the GPU.
  8035. * @returns if Dynamic, otherwise false
  8036. */
  8037. isDynamic(): boolean;
  8038. /**
  8039. * The data cache on JS side.
  8040. * @returns the underlying data as a float array
  8041. */
  8042. getData(): Float32Array;
  8043. /**
  8044. * The underlying WebGL Uniform buffer.
  8045. * @returns the webgl buffer
  8046. */
  8047. getBuffer(): Nullable<DataBuffer>;
  8048. /**
  8049. * std140 layout specifies how to align data within an UBO structure.
  8050. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8051. * for specs.
  8052. */
  8053. private _fillAlignment;
  8054. /**
  8055. * Adds an uniform in the buffer.
  8056. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8057. * for the layout to be correct !
  8058. * @param name Name of the uniform, as used in the uniform block in the shader.
  8059. * @param size Data size, or data directly.
  8060. */
  8061. addUniform(name: string, size: number | number[]): void;
  8062. /**
  8063. * Adds a Matrix 4x4 to the uniform buffer.
  8064. * @param name Name of the uniform, as used in the uniform block in the shader.
  8065. * @param mat A 4x4 matrix.
  8066. */
  8067. addMatrix(name: string, mat: Matrix): void;
  8068. /**
  8069. * Adds a vec2 to the uniform buffer.
  8070. * @param name Name of the uniform, as used in the uniform block in the shader.
  8071. * @param x Define the x component value of the vec2
  8072. * @param y Define the y component value of the vec2
  8073. */
  8074. addFloat2(name: string, x: number, y: number): void;
  8075. /**
  8076. * Adds a vec3 to the uniform buffer.
  8077. * @param name Name of the uniform, as used in the uniform block in the shader.
  8078. * @param x Define the x component value of the vec3
  8079. * @param y Define the y component value of the vec3
  8080. * @param z Define the z component value of the vec3
  8081. */
  8082. addFloat3(name: string, x: number, y: number, z: number): void;
  8083. /**
  8084. * Adds a vec3 to the uniform buffer.
  8085. * @param name Name of the uniform, as used in the uniform block in the shader.
  8086. * @param color Define the vec3 from a Color
  8087. */
  8088. addColor3(name: string, color: Color3): void;
  8089. /**
  8090. * Adds a vec4 to the uniform buffer.
  8091. * @param name Name of the uniform, as used in the uniform block in the shader.
  8092. * @param color Define the rgb components from a Color
  8093. * @param alpha Define the a component of the vec4
  8094. */
  8095. addColor4(name: string, color: Color3, alpha: number): void;
  8096. /**
  8097. * Adds a vec3 to the uniform buffer.
  8098. * @param name Name of the uniform, as used in the uniform block in the shader.
  8099. * @param vector Define the vec3 components from a Vector
  8100. */
  8101. addVector3(name: string, vector: Vector3): void;
  8102. /**
  8103. * Adds a Matrix 3x3 to the uniform buffer.
  8104. * @param name Name of the uniform, as used in the uniform block in the shader.
  8105. */
  8106. addMatrix3x3(name: string): void;
  8107. /**
  8108. * Adds a Matrix 2x2 to the uniform buffer.
  8109. * @param name Name of the uniform, as used in the uniform block in the shader.
  8110. */
  8111. addMatrix2x2(name: string): void;
  8112. /**
  8113. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8114. */
  8115. create(): void;
  8116. /** @hidden */
  8117. _rebuild(): void;
  8118. /**
  8119. * Updates the WebGL Uniform Buffer on the GPU.
  8120. * If the `dynamic` flag is set to true, no cache comparison is done.
  8121. * Otherwise, the buffer will be updated only if the cache differs.
  8122. */
  8123. update(): void;
  8124. /**
  8125. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8126. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8127. * @param data Define the flattened data
  8128. * @param size Define the size of the data.
  8129. */
  8130. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8131. private _valueCache;
  8132. private _cacheMatrix;
  8133. private _updateMatrix3x3ForUniform;
  8134. private _updateMatrix3x3ForEffect;
  8135. private _updateMatrix2x2ForEffect;
  8136. private _updateMatrix2x2ForUniform;
  8137. private _updateFloatForEffect;
  8138. private _updateFloatForUniform;
  8139. private _updateFloat2ForEffect;
  8140. private _updateFloat2ForUniform;
  8141. private _updateFloat3ForEffect;
  8142. private _updateFloat3ForUniform;
  8143. private _updateFloat4ForEffect;
  8144. private _updateFloat4ForUniform;
  8145. private _updateMatrixForEffect;
  8146. private _updateMatrixForUniform;
  8147. private _updateVector3ForEffect;
  8148. private _updateVector3ForUniform;
  8149. private _updateVector4ForEffect;
  8150. private _updateVector4ForUniform;
  8151. private _updateColor3ForEffect;
  8152. private _updateColor3ForUniform;
  8153. private _updateColor4ForEffect;
  8154. private _updateColor4ForUniform;
  8155. /**
  8156. * Sets a sampler uniform on the effect.
  8157. * @param name Define the name of the sampler.
  8158. * @param texture Define the texture to set in the sampler
  8159. */
  8160. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8161. /**
  8162. * Directly updates the value of the uniform in the cache AND on the GPU.
  8163. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8164. * @param data Define the flattened data
  8165. */
  8166. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8167. /**
  8168. * Binds this uniform buffer to an effect.
  8169. * @param effect Define the effect to bind the buffer to
  8170. * @param name Name of the uniform block in the shader.
  8171. */
  8172. bindToEffect(effect: Effect, name: string): void;
  8173. /**
  8174. * Disposes the uniform buffer.
  8175. */
  8176. dispose(): void;
  8177. }
  8178. }
  8179. declare module "babylonjs/Materials/materialDefines" {
  8180. /**
  8181. * Manages the defines for the Material
  8182. */
  8183. export class MaterialDefines {
  8184. /** @hidden */
  8185. protected _keys: string[];
  8186. private _isDirty;
  8187. /** @hidden */
  8188. _renderId: number;
  8189. /** @hidden */
  8190. _areLightsDirty: boolean;
  8191. /** @hidden */
  8192. _areLightsDisposed: boolean;
  8193. /** @hidden */
  8194. _areAttributesDirty: boolean;
  8195. /** @hidden */
  8196. _areTexturesDirty: boolean;
  8197. /** @hidden */
  8198. _areFresnelDirty: boolean;
  8199. /** @hidden */
  8200. _areMiscDirty: boolean;
  8201. /** @hidden */
  8202. _arePrePassDirty: boolean;
  8203. /** @hidden */
  8204. _areImageProcessingDirty: boolean;
  8205. /** @hidden */
  8206. _normals: boolean;
  8207. /** @hidden */
  8208. _uvs: boolean;
  8209. /** @hidden */
  8210. _needNormals: boolean;
  8211. /** @hidden */
  8212. _needUVs: boolean;
  8213. [id: string]: any;
  8214. /**
  8215. * Specifies if the material needs to be re-calculated
  8216. */
  8217. get isDirty(): boolean;
  8218. /**
  8219. * Marks the material to indicate that it has been re-calculated
  8220. */
  8221. markAsProcessed(): void;
  8222. /**
  8223. * Marks the material to indicate that it needs to be re-calculated
  8224. */
  8225. markAsUnprocessed(): void;
  8226. /**
  8227. * Marks the material to indicate all of its defines need to be re-calculated
  8228. */
  8229. markAllAsDirty(): void;
  8230. /**
  8231. * Marks the material to indicate that image processing needs to be re-calculated
  8232. */
  8233. markAsImageProcessingDirty(): void;
  8234. /**
  8235. * Marks the material to indicate the lights need to be re-calculated
  8236. * @param disposed Defines whether the light is dirty due to dispose or not
  8237. */
  8238. markAsLightDirty(disposed?: boolean): void;
  8239. /**
  8240. * Marks the attribute state as changed
  8241. */
  8242. markAsAttributesDirty(): void;
  8243. /**
  8244. * Marks the texture state as changed
  8245. */
  8246. markAsTexturesDirty(): void;
  8247. /**
  8248. * Marks the fresnel state as changed
  8249. */
  8250. markAsFresnelDirty(): void;
  8251. /**
  8252. * Marks the misc state as changed
  8253. */
  8254. markAsMiscDirty(): void;
  8255. /**
  8256. * Marks the prepass state as changed
  8257. */
  8258. markAsPrePassDirty(): void;
  8259. /**
  8260. * Rebuilds the material defines
  8261. */
  8262. rebuild(): void;
  8263. /**
  8264. * Specifies if two material defines are equal
  8265. * @param other - A material define instance to compare to
  8266. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8267. */
  8268. isEqual(other: MaterialDefines): boolean;
  8269. /**
  8270. * Clones this instance's defines to another instance
  8271. * @param other - material defines to clone values to
  8272. */
  8273. cloneTo(other: MaterialDefines): void;
  8274. /**
  8275. * Resets the material define values
  8276. */
  8277. reset(): void;
  8278. /**
  8279. * Converts the material define values to a string
  8280. * @returns - String of material define information
  8281. */
  8282. toString(): string;
  8283. }
  8284. }
  8285. declare module "babylonjs/Misc/iInspectable" {
  8286. /**
  8287. * Enum that determines the text-wrapping mode to use.
  8288. */
  8289. export enum InspectableType {
  8290. /**
  8291. * Checkbox for booleans
  8292. */
  8293. Checkbox = 0,
  8294. /**
  8295. * Sliders for numbers
  8296. */
  8297. Slider = 1,
  8298. /**
  8299. * Vector3
  8300. */
  8301. Vector3 = 2,
  8302. /**
  8303. * Quaternions
  8304. */
  8305. Quaternion = 3,
  8306. /**
  8307. * Color3
  8308. */
  8309. Color3 = 4,
  8310. /**
  8311. * String
  8312. */
  8313. String = 5
  8314. }
  8315. /**
  8316. * Interface used to define custom inspectable properties.
  8317. * This interface is used by the inspector to display custom property grids
  8318. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8319. */
  8320. export interface IInspectable {
  8321. /**
  8322. * Gets the label to display
  8323. */
  8324. label: string;
  8325. /**
  8326. * Gets the name of the property to edit
  8327. */
  8328. propertyName: string;
  8329. /**
  8330. * Gets the type of the editor to use
  8331. */
  8332. type: InspectableType;
  8333. /**
  8334. * Gets the minimum value of the property when using in "slider" mode
  8335. */
  8336. min?: number;
  8337. /**
  8338. * Gets the maximum value of the property when using in "slider" mode
  8339. */
  8340. max?: number;
  8341. /**
  8342. * Gets the setp to use when using in "slider" mode
  8343. */
  8344. step?: number;
  8345. }
  8346. }
  8347. declare module "babylonjs/Lights/light" {
  8348. import { Nullable } from "babylonjs/types";
  8349. import { Scene } from "babylonjs/scene";
  8350. import { Vector3 } from "babylonjs/Maths/math.vector";
  8351. import { Color3 } from "babylonjs/Maths/math.color";
  8352. import { Node } from "babylonjs/node";
  8353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8354. import { Effect } from "babylonjs/Materials/effect";
  8355. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8356. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8357. /**
  8358. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8359. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8360. * 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.
  8361. */
  8362. export abstract class Light extends Node {
  8363. /**
  8364. * Falloff Default: light is falling off following the material specification:
  8365. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8366. */
  8367. static readonly FALLOFF_DEFAULT: number;
  8368. /**
  8369. * Falloff Physical: light is falling off following the inverse squared distance law.
  8370. */
  8371. static readonly FALLOFF_PHYSICAL: number;
  8372. /**
  8373. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8374. * to enhance interoperability with other engines.
  8375. */
  8376. static readonly FALLOFF_GLTF: number;
  8377. /**
  8378. * Falloff Standard: light is falling off like in the standard material
  8379. * to enhance interoperability with other materials.
  8380. */
  8381. static readonly FALLOFF_STANDARD: number;
  8382. /**
  8383. * If every light affecting the material is in this lightmapMode,
  8384. * material.lightmapTexture adds or multiplies
  8385. * (depends on material.useLightmapAsShadowmap)
  8386. * after every other light calculations.
  8387. */
  8388. static readonly LIGHTMAP_DEFAULT: number;
  8389. /**
  8390. * material.lightmapTexture as only diffuse lighting from this light
  8391. * adds only specular lighting from this light
  8392. * adds dynamic shadows
  8393. */
  8394. static readonly LIGHTMAP_SPECULAR: number;
  8395. /**
  8396. * material.lightmapTexture as only lighting
  8397. * no light calculation from this light
  8398. * only adds dynamic shadows from this light
  8399. */
  8400. static readonly LIGHTMAP_SHADOWSONLY: number;
  8401. /**
  8402. * Each light type uses the default quantity according to its type:
  8403. * point/spot lights use luminous intensity
  8404. * directional lights use illuminance
  8405. */
  8406. static readonly INTENSITYMODE_AUTOMATIC: number;
  8407. /**
  8408. * lumen (lm)
  8409. */
  8410. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8411. /**
  8412. * candela (lm/sr)
  8413. */
  8414. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8415. /**
  8416. * lux (lm/m^2)
  8417. */
  8418. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8419. /**
  8420. * nit (cd/m^2)
  8421. */
  8422. static readonly INTENSITYMODE_LUMINANCE: number;
  8423. /**
  8424. * Light type const id of the point light.
  8425. */
  8426. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8427. /**
  8428. * Light type const id of the directional light.
  8429. */
  8430. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8431. /**
  8432. * Light type const id of the spot light.
  8433. */
  8434. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8435. /**
  8436. * Light type const id of the hemispheric light.
  8437. */
  8438. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8439. /**
  8440. * Diffuse gives the basic color to an object.
  8441. */
  8442. diffuse: Color3;
  8443. /**
  8444. * Specular produces a highlight color on an object.
  8445. * Note: This is note affecting PBR materials.
  8446. */
  8447. specular: Color3;
  8448. /**
  8449. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8450. * falling off base on range or angle.
  8451. * This can be set to any values in Light.FALLOFF_x.
  8452. *
  8453. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8454. * other types of materials.
  8455. */
  8456. falloffType: number;
  8457. /**
  8458. * Strength of the light.
  8459. * Note: By default it is define in the framework own unit.
  8460. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8461. */
  8462. intensity: number;
  8463. private _range;
  8464. protected _inverseSquaredRange: number;
  8465. /**
  8466. * Defines how far from the source the light is impacting in scene units.
  8467. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8468. */
  8469. get range(): number;
  8470. /**
  8471. * Defines how far from the source the light is impacting in scene units.
  8472. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8473. */
  8474. set range(value: number);
  8475. /**
  8476. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8477. * of light.
  8478. */
  8479. private _photometricScale;
  8480. private _intensityMode;
  8481. /**
  8482. * Gets the photometric scale used to interpret the intensity.
  8483. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8484. */
  8485. get intensityMode(): number;
  8486. /**
  8487. * Sets the photometric scale used to interpret the intensity.
  8488. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8489. */
  8490. set intensityMode(value: number);
  8491. private _radius;
  8492. /**
  8493. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8494. */
  8495. get radius(): number;
  8496. /**
  8497. * sets the light radius used by PBR Materials to simulate soft area lights.
  8498. */
  8499. set radius(value: number);
  8500. private _renderPriority;
  8501. /**
  8502. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8503. * exceeding the number allowed of the materials.
  8504. */
  8505. renderPriority: number;
  8506. private _shadowEnabled;
  8507. /**
  8508. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8509. * the current shadow generator.
  8510. */
  8511. get shadowEnabled(): boolean;
  8512. /**
  8513. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8514. * the current shadow generator.
  8515. */
  8516. set shadowEnabled(value: boolean);
  8517. private _includedOnlyMeshes;
  8518. /**
  8519. * Gets the only meshes impacted by this light.
  8520. */
  8521. get includedOnlyMeshes(): AbstractMesh[];
  8522. /**
  8523. * Sets the only meshes impacted by this light.
  8524. */
  8525. set includedOnlyMeshes(value: AbstractMesh[]);
  8526. private _excludedMeshes;
  8527. /**
  8528. * Gets the meshes not impacted by this light.
  8529. */
  8530. get excludedMeshes(): AbstractMesh[];
  8531. /**
  8532. * Sets the meshes not impacted by this light.
  8533. */
  8534. set excludedMeshes(value: AbstractMesh[]);
  8535. private _excludeWithLayerMask;
  8536. /**
  8537. * Gets the layer id use to find what meshes are not impacted by the light.
  8538. * Inactive if 0
  8539. */
  8540. get excludeWithLayerMask(): number;
  8541. /**
  8542. * Sets the layer id use to find what meshes are not impacted by the light.
  8543. * Inactive if 0
  8544. */
  8545. set excludeWithLayerMask(value: number);
  8546. private _includeOnlyWithLayerMask;
  8547. /**
  8548. * Gets the layer id use to find what meshes are impacted by the light.
  8549. * Inactive if 0
  8550. */
  8551. get includeOnlyWithLayerMask(): number;
  8552. /**
  8553. * Sets the layer id use to find what meshes are impacted by the light.
  8554. * Inactive if 0
  8555. */
  8556. set includeOnlyWithLayerMask(value: number);
  8557. private _lightmapMode;
  8558. /**
  8559. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8560. */
  8561. get lightmapMode(): number;
  8562. /**
  8563. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8564. */
  8565. set lightmapMode(value: number);
  8566. /**
  8567. * Shadow generator associted to the light.
  8568. * @hidden Internal use only.
  8569. */
  8570. _shadowGenerator: Nullable<IShadowGenerator>;
  8571. /**
  8572. * @hidden Internal use only.
  8573. */
  8574. _excludedMeshesIds: string[];
  8575. /**
  8576. * @hidden Internal use only.
  8577. */
  8578. _includedOnlyMeshesIds: string[];
  8579. /**
  8580. * The current light unifom buffer.
  8581. * @hidden Internal use only.
  8582. */
  8583. _uniformBuffer: UniformBuffer;
  8584. /** @hidden */
  8585. _renderId: number;
  8586. /**
  8587. * Creates a Light object in the scene.
  8588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8589. * @param name The firendly name of the light
  8590. * @param scene The scene the light belongs too
  8591. */
  8592. constructor(name: string, scene: Scene);
  8593. protected abstract _buildUniformLayout(): void;
  8594. /**
  8595. * Sets the passed Effect "effect" with the Light information.
  8596. * @param effect The effect to update
  8597. * @param lightIndex The index of the light in the effect to update
  8598. * @returns The light
  8599. */
  8600. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8601. /**
  8602. * Sets the passed Effect "effect" with the Light textures.
  8603. * @param effect The effect to update
  8604. * @param lightIndex The index of the light in the effect to update
  8605. * @returns The light
  8606. */
  8607. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8608. /**
  8609. * Binds the lights information from the scene to the effect for the given mesh.
  8610. * @param lightIndex Light index
  8611. * @param scene The scene where the light belongs to
  8612. * @param effect The effect we are binding the data to
  8613. * @param useSpecular Defines if specular is supported
  8614. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8615. */
  8616. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8617. /**
  8618. * Sets the passed Effect "effect" with the Light information.
  8619. * @param effect The effect to update
  8620. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8621. * @returns The light
  8622. */
  8623. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8624. /**
  8625. * Returns the string "Light".
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /** @hidden */
  8630. readonly _isLight: boolean;
  8631. /**
  8632. * Converts the light information to a readable string for debug purpose.
  8633. * @param fullDetails Supports for multiple levels of logging within scene loading
  8634. * @returns the human readable light info
  8635. */
  8636. toString(fullDetails?: boolean): string;
  8637. /** @hidden */
  8638. protected _syncParentEnabledState(): void;
  8639. /**
  8640. * Set the enabled state of this node.
  8641. * @param value - the new enabled state
  8642. */
  8643. setEnabled(value: boolean): void;
  8644. /**
  8645. * Returns the Light associated shadow generator if any.
  8646. * @return the associated shadow generator.
  8647. */
  8648. getShadowGenerator(): Nullable<IShadowGenerator>;
  8649. /**
  8650. * Returns a Vector3, the absolute light position in the World.
  8651. * @returns the world space position of the light
  8652. */
  8653. getAbsolutePosition(): Vector3;
  8654. /**
  8655. * Specifies if the light will affect the passed mesh.
  8656. * @param mesh The mesh to test against the light
  8657. * @return true the mesh is affected otherwise, false.
  8658. */
  8659. canAffectMesh(mesh: AbstractMesh): boolean;
  8660. /**
  8661. * Sort function to order lights for rendering.
  8662. * @param a First Light object to compare to second.
  8663. * @param b Second Light object to compare first.
  8664. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8665. */
  8666. static CompareLightsPriority(a: Light, b: Light): number;
  8667. /**
  8668. * Releases resources associated with this node.
  8669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8671. */
  8672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8673. /**
  8674. * Returns the light type ID (integer).
  8675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8676. */
  8677. getTypeID(): number;
  8678. /**
  8679. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8680. * @returns the scaled intensity in intensity mode unit
  8681. */
  8682. getScaledIntensity(): number;
  8683. /**
  8684. * Returns a new Light object, named "name", from the current one.
  8685. * @param name The name of the cloned light
  8686. * @param newParent The parent of this light, if it has one
  8687. * @returns the new created light
  8688. */
  8689. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8690. /**
  8691. * Serializes the current light into a Serialization object.
  8692. * @returns the serialized object.
  8693. */
  8694. serialize(): any;
  8695. /**
  8696. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8697. * This new light is named "name" and added to the passed scene.
  8698. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8699. * @param name The friendly name of the light
  8700. * @param scene The scene the new light will belong to
  8701. * @returns the constructor function
  8702. */
  8703. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8704. /**
  8705. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8706. * @param parsedLight The JSON representation of the light
  8707. * @param scene The scene to create the parsed light in
  8708. * @returns the created light after parsing
  8709. */
  8710. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8711. private _hookArrayForExcluded;
  8712. private _hookArrayForIncludedOnly;
  8713. private _resyncMeshes;
  8714. /**
  8715. * Forces the meshes to update their light related information in their rendering used effects
  8716. * @hidden Internal Use Only
  8717. */
  8718. _markMeshesAsLightDirty(): void;
  8719. /**
  8720. * Recomputes the cached photometric scale if needed.
  8721. */
  8722. private _computePhotometricScale;
  8723. /**
  8724. * Returns the Photometric Scale according to the light type and intensity mode.
  8725. */
  8726. private _getPhotometricScale;
  8727. /**
  8728. * Reorder the light in the scene according to their defined priority.
  8729. * @hidden Internal Use Only
  8730. */
  8731. _reorderLightsInScene(): void;
  8732. /**
  8733. * Prepares the list of defines specific to the light type.
  8734. * @param defines the list of defines
  8735. * @param lightIndex defines the index of the light for the effect
  8736. */
  8737. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8738. }
  8739. }
  8740. declare module "babylonjs/Maths/math.axis" {
  8741. import { Vector3 } from "babylonjs/Maths/math.vector";
  8742. /** Defines supported spaces */
  8743. export enum Space {
  8744. /** Local (object) space */
  8745. LOCAL = 0,
  8746. /** World space */
  8747. WORLD = 1,
  8748. /** Bone space */
  8749. BONE = 2
  8750. }
  8751. /** Defines the 3 main axes */
  8752. export class Axis {
  8753. /** X axis */
  8754. static X: Vector3;
  8755. /** Y axis */
  8756. static Y: Vector3;
  8757. /** Z axis */
  8758. static Z: Vector3;
  8759. }
  8760. /**
  8761. * Defines cartesian components.
  8762. */
  8763. export enum Coordinate {
  8764. /** X axis */
  8765. X = 0,
  8766. /** Y axis */
  8767. Y = 1,
  8768. /** Z axis */
  8769. Z = 2
  8770. }
  8771. }
  8772. declare module "babylonjs/Lights/shadowLight" {
  8773. import { Camera } from "babylonjs/Cameras/camera";
  8774. import { Scene } from "babylonjs/scene";
  8775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8777. import { Light } from "babylonjs/Lights/light";
  8778. /**
  8779. * Interface describing all the common properties and methods a shadow light needs to implement.
  8780. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8781. * as well as binding the different shadow properties to the effects.
  8782. */
  8783. export interface IShadowLight extends Light {
  8784. /**
  8785. * The light id in the scene (used in scene.findLighById for instance)
  8786. */
  8787. id: string;
  8788. /**
  8789. * The position the shdow will be casted from.
  8790. */
  8791. position: Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8794. */
  8795. direction: Vector3;
  8796. /**
  8797. * The transformed position. Position of the light in world space taking parenting in account.
  8798. */
  8799. transformedPosition: Vector3;
  8800. /**
  8801. * The transformed direction. Direction of the light in world space taking parenting in account.
  8802. */
  8803. transformedDirection: Vector3;
  8804. /**
  8805. * The friendly name of the light in the scene.
  8806. */
  8807. name: string;
  8808. /**
  8809. * Defines the shadow projection clipping minimum z value.
  8810. */
  8811. shadowMinZ: number;
  8812. /**
  8813. * Defines the shadow projection clipping maximum z value.
  8814. */
  8815. shadowMaxZ: number;
  8816. /**
  8817. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8818. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8819. */
  8820. computeTransformedInformation(): boolean;
  8821. /**
  8822. * Gets the scene the light belongs to.
  8823. * @returns The scene
  8824. */
  8825. getScene(): Scene;
  8826. /**
  8827. * Callback defining a custom Projection Matrix Builder.
  8828. * This can be used to override the default projection matrix computation.
  8829. */
  8830. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8831. /**
  8832. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8833. * @param matrix The materix to updated with the projection information
  8834. * @param viewMatrix The transform matrix of the light
  8835. * @param renderList The list of mesh to render in the map
  8836. * @returns The current light
  8837. */
  8838. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8839. /**
  8840. * Gets the current depth scale used in ESM.
  8841. * @returns The scale
  8842. */
  8843. getDepthScale(): number;
  8844. /**
  8845. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8846. * @returns true if a cube texture needs to be use
  8847. */
  8848. needCube(): boolean;
  8849. /**
  8850. * Detects if the projection matrix requires to be recomputed this frame.
  8851. * @returns true if it requires to be recomputed otherwise, false.
  8852. */
  8853. needProjectionMatrixCompute(): boolean;
  8854. /**
  8855. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8856. */
  8857. forceProjectionMatrixCompute(): void;
  8858. /**
  8859. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8860. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8861. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8862. */
  8863. getShadowDirection(faceIndex?: number): Vector3;
  8864. /**
  8865. * Gets the minZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the min for
  8867. * @returns the depth min z
  8868. */
  8869. getDepthMinZ(activeCamera: Camera): number;
  8870. /**
  8871. * Gets the maxZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the max for
  8873. * @returns the depth max z
  8874. */
  8875. getDepthMaxZ(activeCamera: Camera): number;
  8876. }
  8877. /**
  8878. * Base implementation IShadowLight
  8879. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8880. */
  8881. export abstract class ShadowLight extends Light implements IShadowLight {
  8882. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8883. protected _position: Vector3;
  8884. protected _setPosition(value: Vector3): void;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. get position(): Vector3;
  8890. /**
  8891. * Sets the position the shadow will be casted from. Also use as the light position for both
  8892. * point and spot lights.
  8893. */
  8894. set position(value: Vector3);
  8895. protected _direction: Vector3;
  8896. protected _setDirection(value: Vector3): void;
  8897. /**
  8898. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8899. * Also use as the light direction on spot and directional lights.
  8900. */
  8901. get direction(): Vector3;
  8902. /**
  8903. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8904. * Also use as the light direction on spot and directional lights.
  8905. */
  8906. set direction(value: Vector3);
  8907. protected _shadowMinZ: number;
  8908. /**
  8909. * Gets the shadow projection clipping minimum z value.
  8910. */
  8911. get shadowMinZ(): number;
  8912. /**
  8913. * Sets the shadow projection clipping minimum z value.
  8914. */
  8915. set shadowMinZ(value: number);
  8916. protected _shadowMaxZ: number;
  8917. /**
  8918. * Sets the shadow projection clipping maximum z value.
  8919. */
  8920. get shadowMaxZ(): number;
  8921. /**
  8922. * Gets the shadow projection clipping maximum z value.
  8923. */
  8924. set shadowMaxZ(value: number);
  8925. /**
  8926. * Callback defining a custom Projection Matrix Builder.
  8927. * This can be used to override the default projection matrix computation.
  8928. */
  8929. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8930. /**
  8931. * The transformed position. Position of the light in world space taking parenting in account.
  8932. */
  8933. transformedPosition: Vector3;
  8934. /**
  8935. * The transformed direction. Direction of the light in world space taking parenting in account.
  8936. */
  8937. transformedDirection: Vector3;
  8938. private _needProjectionMatrixCompute;
  8939. /**
  8940. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8941. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8942. */
  8943. computeTransformedInformation(): boolean;
  8944. /**
  8945. * Return the depth scale used for the shadow map.
  8946. * @returns the depth scale.
  8947. */
  8948. getDepthScale(): number;
  8949. /**
  8950. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8951. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8952. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8953. */
  8954. getShadowDirection(faceIndex?: number): Vector3;
  8955. /**
  8956. * Returns the ShadowLight absolute position in the World.
  8957. * @returns the position vector in world space
  8958. */
  8959. getAbsolutePosition(): Vector3;
  8960. /**
  8961. * Sets the ShadowLight direction toward the passed target.
  8962. * @param target The point to target in local space
  8963. * @returns the updated ShadowLight direction
  8964. */
  8965. setDirectionToTarget(target: Vector3): Vector3;
  8966. /**
  8967. * Returns the light rotation in euler definition.
  8968. * @returns the x y z rotation in local space.
  8969. */
  8970. getRotation(): Vector3;
  8971. /**
  8972. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8973. * @returns true if a cube texture needs to be use
  8974. */
  8975. needCube(): boolean;
  8976. /**
  8977. * Detects if the projection matrix requires to be recomputed this frame.
  8978. * @returns true if it requires to be recomputed otherwise, false.
  8979. */
  8980. needProjectionMatrixCompute(): boolean;
  8981. /**
  8982. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8983. */
  8984. forceProjectionMatrixCompute(): void;
  8985. /** @hidden */
  8986. _initCache(): void;
  8987. /** @hidden */
  8988. _isSynchronized(): boolean;
  8989. /**
  8990. * Computes the world matrix of the node
  8991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8992. * @returns the world matrix
  8993. */
  8994. computeWorldMatrix(force?: boolean): Matrix;
  8995. /**
  8996. * Gets the minZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the min for
  8998. * @returns the depth min z
  8999. */
  9000. getDepthMinZ(activeCamera: Camera): number;
  9001. /**
  9002. * Gets the maxZ used for shadow according to both the scene and the light.
  9003. * @param activeCamera The camera we are returning the max for
  9004. * @returns the depth max z
  9005. */
  9006. getDepthMaxZ(activeCamera: Camera): number;
  9007. /**
  9008. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9009. * @param matrix The materix to updated with the projection information
  9010. * @param viewMatrix The transform matrix of the light
  9011. * @param renderList The list of mesh to render in the map
  9012. * @returns The current light
  9013. */
  9014. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9015. }
  9016. }
  9017. declare module "babylonjs/Materials/prePassConfiguration" {
  9018. import { Matrix } from "babylonjs/Maths/math.vector";
  9019. import { Mesh } from "babylonjs/Meshes/mesh";
  9020. import { Scene } from "babylonjs/scene";
  9021. import { Effect } from "babylonjs/Materials/effect";
  9022. /**
  9023. * Configuration needed for prepass-capable materials
  9024. */
  9025. export class PrePassConfiguration {
  9026. /**
  9027. * Previous world matrices of meshes carrying this material
  9028. * Used for computing velocity
  9029. */
  9030. previousWorldMatrices: {
  9031. [index: number]: Matrix;
  9032. };
  9033. /**
  9034. * Previous view project matrix
  9035. * Used for computing velocity
  9036. */
  9037. previousViewProjection: Matrix;
  9038. /**
  9039. * Previous bones of meshes carrying this material
  9040. * Used for computing velocity
  9041. */
  9042. previousBones: {
  9043. [index: number]: Float32Array;
  9044. };
  9045. /**
  9046. * Add the required uniforms to the current list.
  9047. * @param uniforms defines the current uniform list.
  9048. */
  9049. static AddUniforms(uniforms: string[]): void;
  9050. /**
  9051. * Add the required samplers to the current list.
  9052. * @param samplers defines the current sampler list.
  9053. */
  9054. static AddSamplers(samplers: string[]): void;
  9055. /**
  9056. * Binds the material data.
  9057. * @param effect defines the effect to update
  9058. * @param scene defines the scene the material belongs to.
  9059. * @param mesh The mesh
  9060. * @param world World matrix of this mesh
  9061. * @param isFrozen Is the material frozen
  9062. */
  9063. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9064. }
  9065. }
  9066. declare module "babylonjs/Cameras/targetCamera" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Camera } from "babylonjs/Cameras/camera";
  9069. import { Scene } from "babylonjs/scene";
  9070. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9071. /**
  9072. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9073. * This is the base of the follow, arc rotate cameras and Free camera
  9074. * @see https://doc.babylonjs.com/features/cameras
  9075. */
  9076. export class TargetCamera extends Camera {
  9077. private static _RigCamTransformMatrix;
  9078. private static _TargetTransformMatrix;
  9079. private static _TargetFocalPoint;
  9080. private _tmpUpVector;
  9081. private _tmpTargetVector;
  9082. /**
  9083. * Define the current direction the camera is moving to
  9084. */
  9085. cameraDirection: Vector3;
  9086. /**
  9087. * Define the current rotation the camera is rotating to
  9088. */
  9089. cameraRotation: Vector2;
  9090. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9091. ignoreParentScaling: boolean;
  9092. /**
  9093. * When set, the up vector of the camera will be updated by the rotation of the camera
  9094. */
  9095. updateUpVectorFromRotation: boolean;
  9096. private _tmpQuaternion;
  9097. /**
  9098. * Define the current rotation of the camera
  9099. */
  9100. rotation: Vector3;
  9101. /**
  9102. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9103. */
  9104. rotationQuaternion: Quaternion;
  9105. /**
  9106. * Define the current speed of the camera
  9107. */
  9108. speed: number;
  9109. /**
  9110. * Add constraint to the camera to prevent it to move freely in all directions and
  9111. * around all axis.
  9112. */
  9113. noRotationConstraint: boolean;
  9114. /**
  9115. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9116. * panning
  9117. */
  9118. invertRotation: boolean;
  9119. /**
  9120. * Speed multiplier for inverse camera panning
  9121. */
  9122. inverseRotationSpeed: number;
  9123. /**
  9124. * Define the current target of the camera as an object or a position.
  9125. */
  9126. lockedTarget: any;
  9127. /** @hidden */
  9128. _currentTarget: Vector3;
  9129. /** @hidden */
  9130. _initialFocalDistance: number;
  9131. /** @hidden */
  9132. _viewMatrix: Matrix;
  9133. /** @hidden */
  9134. _camMatrix: Matrix;
  9135. /** @hidden */
  9136. _cameraTransformMatrix: Matrix;
  9137. /** @hidden */
  9138. _cameraRotationMatrix: Matrix;
  9139. /** @hidden */
  9140. _referencePoint: Vector3;
  9141. /** @hidden */
  9142. _transformedReferencePoint: Vector3;
  9143. /** @hidden */
  9144. _reset: () => void;
  9145. private _defaultUp;
  9146. /**
  9147. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9148. * This is the base of the follow, arc rotate cameras and Free camera
  9149. * @see https://doc.babylonjs.com/features/cameras
  9150. * @param name Defines the name of the camera in the scene
  9151. * @param position Defines the start position of the camera in the scene
  9152. * @param scene Defines the scene the camera belongs to
  9153. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9154. */
  9155. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9156. /**
  9157. * Gets the position in front of the camera at a given distance.
  9158. * @param distance The distance from the camera we want the position to be
  9159. * @returns the position
  9160. */
  9161. getFrontPosition(distance: number): Vector3;
  9162. /** @hidden */
  9163. _getLockedTargetPosition(): Nullable<Vector3>;
  9164. private _storedPosition;
  9165. private _storedRotation;
  9166. private _storedRotationQuaternion;
  9167. /**
  9168. * Store current camera state of the camera (fov, position, rotation, etc..)
  9169. * @returns the camera
  9170. */
  9171. storeState(): Camera;
  9172. /**
  9173. * Restored camera state. You must call storeState() first
  9174. * @returns whether it was successful or not
  9175. * @hidden
  9176. */
  9177. _restoreStateValues(): boolean;
  9178. /** @hidden */
  9179. _initCache(): void;
  9180. /** @hidden */
  9181. _updateCache(ignoreParentClass?: boolean): void;
  9182. /** @hidden */
  9183. _isSynchronizedViewMatrix(): boolean;
  9184. /** @hidden */
  9185. _computeLocalCameraSpeed(): number;
  9186. /**
  9187. * Defines the target the camera should look at.
  9188. * @param target Defines the new target as a Vector or a mesh
  9189. */
  9190. setTarget(target: Vector3): void;
  9191. /**
  9192. * Defines the target point of the camera.
  9193. * The camera looks towards it form the radius distance.
  9194. */
  9195. get target(): Vector3;
  9196. set target(value: Vector3);
  9197. /**
  9198. * Return the current target position of the camera. This value is expressed in local space.
  9199. * @returns the target position
  9200. */
  9201. getTarget(): Vector3;
  9202. /** @hidden */
  9203. _decideIfNeedsToMove(): boolean;
  9204. /** @hidden */
  9205. _updatePosition(): void;
  9206. /** @hidden */
  9207. _checkInputs(): void;
  9208. protected _updateCameraRotationMatrix(): void;
  9209. /**
  9210. * 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)
  9211. * @returns the current camera
  9212. */
  9213. private _rotateUpVectorWithCameraRotationMatrix;
  9214. private _cachedRotationZ;
  9215. private _cachedQuaternionRotationZ;
  9216. /** @hidden */
  9217. _getViewMatrix(): Matrix;
  9218. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9219. /**
  9220. * @hidden
  9221. */
  9222. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9223. /**
  9224. * @hidden
  9225. */
  9226. _updateRigCameras(): void;
  9227. private _getRigCamPositionAndTarget;
  9228. /**
  9229. * Gets the current object class name.
  9230. * @return the class name
  9231. */
  9232. getClassName(): string;
  9233. }
  9234. }
  9235. declare module "babylonjs/Cameras/cameraInputsManager" {
  9236. import { Nullable } from "babylonjs/types";
  9237. import { Camera } from "babylonjs/Cameras/camera";
  9238. /**
  9239. * @ignore
  9240. * This is a list of all the different input types that are available in the application.
  9241. * Fo instance: ArcRotateCameraGamepadInput...
  9242. */
  9243. export var CameraInputTypes: {};
  9244. /**
  9245. * This is the contract to implement in order to create a new input class.
  9246. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9247. */
  9248. export interface ICameraInput<TCamera extends Camera> {
  9249. /**
  9250. * Defines the camera the input is attached to.
  9251. */
  9252. camera: Nullable<TCamera>;
  9253. /**
  9254. * Gets the class name of the current intput.
  9255. * @returns the class name
  9256. */
  9257. getClassName(): string;
  9258. /**
  9259. * Get the friendly name associated with the input class.
  9260. * @returns the input friendly name
  9261. */
  9262. getSimpleName(): string;
  9263. /**
  9264. * Attach the input controls to a specific dom element to get the input from.
  9265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9266. */
  9267. attachControl(noPreventDefault?: boolean): void;
  9268. /**
  9269. * Detach the current controls from the specified dom element.
  9270. */
  9271. detachControl(): void;
  9272. /**
  9273. * Update the current camera state depending on the inputs that have been used this frame.
  9274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9275. */
  9276. checkInputs?: () => void;
  9277. }
  9278. /**
  9279. * Represents a map of input types to input instance or input index to input instance.
  9280. */
  9281. export interface CameraInputsMap<TCamera extends Camera> {
  9282. /**
  9283. * Accessor to the input by input type.
  9284. */
  9285. [name: string]: ICameraInput<TCamera>;
  9286. /**
  9287. * Accessor to the input by input index.
  9288. */
  9289. [idx: number]: ICameraInput<TCamera>;
  9290. }
  9291. /**
  9292. * This represents the input manager used within a camera.
  9293. * It helps dealing with all the different kind of input attached to a camera.
  9294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9295. */
  9296. export class CameraInputsManager<TCamera extends Camera> {
  9297. /**
  9298. * Defines the list of inputs attahed to the camera.
  9299. */
  9300. attached: CameraInputsMap<TCamera>;
  9301. /**
  9302. * Defines the dom element the camera is collecting inputs from.
  9303. * This is null if the controls have not been attached.
  9304. */
  9305. attachedToElement: boolean;
  9306. /**
  9307. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9308. */
  9309. noPreventDefault: boolean;
  9310. /**
  9311. * Defined the camera the input manager belongs to.
  9312. */
  9313. camera: TCamera;
  9314. /**
  9315. * Update the current camera state depending on the inputs that have been used this frame.
  9316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9317. */
  9318. checkInputs: () => void;
  9319. /**
  9320. * Instantiate a new Camera Input Manager.
  9321. * @param camera Defines the camera the input manager blongs to
  9322. */
  9323. constructor(camera: TCamera);
  9324. /**
  9325. * Add an input method to a camera
  9326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9327. * @param input camera input method
  9328. */
  9329. add(input: ICameraInput<TCamera>): void;
  9330. /**
  9331. * Remove a specific input method from a camera
  9332. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9333. * @param inputToRemove camera input method
  9334. */
  9335. remove(inputToRemove: ICameraInput<TCamera>): void;
  9336. /**
  9337. * Remove a specific input type from a camera
  9338. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9339. * @param inputType the type of the input to remove
  9340. */
  9341. removeByType(inputType: string): void;
  9342. private _addCheckInputs;
  9343. /**
  9344. * Attach the input controls to the currently attached dom element to listen the events from.
  9345. * @param input Defines the input to attach
  9346. */
  9347. attachInput(input: ICameraInput<TCamera>): void;
  9348. /**
  9349. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9350. * @param element Defines the dom element to collect the events from
  9351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9352. */
  9353. attachElement(noPreventDefault?: boolean): void;
  9354. /**
  9355. * Detach the current manager inputs controls from a specific dom element.
  9356. * @param element Defines the dom element to collect the events from
  9357. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9358. */
  9359. detachElement(disconnect?: boolean): void;
  9360. /**
  9361. * Rebuild the dynamic inputCheck function from the current list of
  9362. * defined inputs in the manager.
  9363. */
  9364. rebuildInputCheck(): void;
  9365. /**
  9366. * Remove all attached input methods from a camera
  9367. */
  9368. clear(): void;
  9369. /**
  9370. * Serialize the current input manager attached to a camera.
  9371. * This ensures than once parsed,
  9372. * the input associated to the camera will be identical to the current ones
  9373. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9374. */
  9375. serialize(serializedCamera: any): void;
  9376. /**
  9377. * Parses an input manager serialized JSON to restore the previous list of inputs
  9378. * and states associated to a camera.
  9379. * @param parsedCamera Defines the JSON to parse
  9380. */
  9381. parse(parsedCamera: any): void;
  9382. }
  9383. }
  9384. declare module "babylonjs/Events/keyboardEvents" {
  9385. /**
  9386. * Gather the list of keyboard event types as constants.
  9387. */
  9388. export class KeyboardEventTypes {
  9389. /**
  9390. * The keydown event is fired when a key becomes active (pressed).
  9391. */
  9392. static readonly KEYDOWN: number;
  9393. /**
  9394. * The keyup event is fired when a key has been released.
  9395. */
  9396. static readonly KEYUP: number;
  9397. }
  9398. /**
  9399. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9400. */
  9401. export class KeyboardInfo {
  9402. /**
  9403. * Defines the type of event (KeyboardEventTypes)
  9404. */
  9405. type: number;
  9406. /**
  9407. * Defines the related dom event
  9408. */
  9409. event: KeyboardEvent;
  9410. /**
  9411. * Instantiates a new keyboard info.
  9412. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9413. * @param type Defines the type of event (KeyboardEventTypes)
  9414. * @param event Defines the related dom event
  9415. */
  9416. constructor(
  9417. /**
  9418. * Defines the type of event (KeyboardEventTypes)
  9419. */
  9420. type: number,
  9421. /**
  9422. * Defines the related dom event
  9423. */
  9424. event: KeyboardEvent);
  9425. }
  9426. /**
  9427. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9428. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9429. */
  9430. export class KeyboardInfoPre extends KeyboardInfo {
  9431. /**
  9432. * Defines the type of event (KeyboardEventTypes)
  9433. */
  9434. type: number;
  9435. /**
  9436. * Defines the related dom event
  9437. */
  9438. event: KeyboardEvent;
  9439. /**
  9440. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9441. */
  9442. skipOnPointerObservable: boolean;
  9443. /**
  9444. * Instantiates a new keyboard pre info.
  9445. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9446. * @param type Defines the type of event (KeyboardEventTypes)
  9447. * @param event Defines the related dom event
  9448. */
  9449. constructor(
  9450. /**
  9451. * Defines the type of event (KeyboardEventTypes)
  9452. */
  9453. type: number,
  9454. /**
  9455. * Defines the related dom event
  9456. */
  9457. event: KeyboardEvent);
  9458. }
  9459. }
  9460. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9462. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9463. /**
  9464. * Manage the keyboard inputs to control the movement of a free camera.
  9465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9466. */
  9467. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9468. /**
  9469. * Defines the camera the input is attached to.
  9470. */
  9471. camera: FreeCamera;
  9472. /**
  9473. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9474. */
  9475. keysUp: number[];
  9476. /**
  9477. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9478. */
  9479. keysUpward: number[];
  9480. /**
  9481. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9482. */
  9483. keysDown: number[];
  9484. /**
  9485. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9486. */
  9487. keysDownward: number[];
  9488. /**
  9489. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9490. */
  9491. keysLeft: number[];
  9492. /**
  9493. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9494. */
  9495. keysRight: number[];
  9496. private _keys;
  9497. private _onCanvasBlurObserver;
  9498. private _onKeyboardObserver;
  9499. private _engine;
  9500. private _scene;
  9501. /**
  9502. * Attach the input controls to a specific dom element to get the input from.
  9503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9504. */
  9505. attachControl(noPreventDefault?: boolean): void;
  9506. /**
  9507. * Detach the current controls from the specified dom element.
  9508. */
  9509. detachControl(): void;
  9510. /**
  9511. * Update the current camera state depending on the inputs that have been used this frame.
  9512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9513. */
  9514. checkInputs(): void;
  9515. /**
  9516. * Gets the class name of the current intput.
  9517. * @returns the class name
  9518. */
  9519. getClassName(): string;
  9520. /** @hidden */
  9521. _onLostFocus(): void;
  9522. /**
  9523. * Get the friendly name associated with the input class.
  9524. * @returns the input friendly name
  9525. */
  9526. getSimpleName(): string;
  9527. }
  9528. }
  9529. declare module "babylonjs/Actions/action" {
  9530. import { Observable } from "babylonjs/Misc/observable";
  9531. import { Condition } from "babylonjs/Actions/condition";
  9532. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9533. import { Nullable } from "babylonjs/types";
  9534. import { Scene } from "babylonjs/scene";
  9535. import { ActionManager } from "babylonjs/Actions/actionManager";
  9536. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9537. import { Node } from "babylonjs/node";
  9538. /**
  9539. * Interface used to define Action
  9540. */
  9541. export interface IAction {
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /** Options of the trigger */
  9547. triggerOptions: any;
  9548. /**
  9549. * Gets the trigger parameters
  9550. * @returns the trigger parameters
  9551. */
  9552. getTriggerParameter(): any;
  9553. /**
  9554. * Internal only - executes current action event
  9555. * @hidden
  9556. */
  9557. _executeCurrent(evt?: ActionEvent): void;
  9558. /**
  9559. * Serialize placeholder for child classes
  9560. * @param parent of child
  9561. * @returns the serialized object
  9562. */
  9563. serialize(parent: any): any;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _prepare(): void;
  9569. /**
  9570. * Internal only - manager for action
  9571. * @hidden
  9572. */
  9573. _actionManager: Nullable<AbstractActionManager>;
  9574. /**
  9575. * Adds action to chain of actions, may be a DoNothingAction
  9576. * @param action defines the next action to execute
  9577. * @returns The action passed in
  9578. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9579. */
  9580. then(action: IAction): IAction;
  9581. }
  9582. /**
  9583. * The action to be carried out following a trigger
  9584. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9585. */
  9586. export class Action implements IAction {
  9587. /** the trigger, with or without parameters, for the action */
  9588. triggerOptions: any;
  9589. /**
  9590. * Trigger for the action
  9591. */
  9592. trigger: number;
  9593. /**
  9594. * Internal only - manager for action
  9595. * @hidden
  9596. */
  9597. _actionManager: ActionManager;
  9598. private _nextActiveAction;
  9599. private _child;
  9600. private _condition?;
  9601. private _triggerParameter;
  9602. /**
  9603. * An event triggered prior to action being executed.
  9604. */
  9605. onBeforeExecuteObservable: Observable<Action>;
  9606. /**
  9607. * Creates a new Action
  9608. * @param triggerOptions the trigger, with or without parameters, for the action
  9609. * @param condition an optional determinant of action
  9610. */
  9611. constructor(
  9612. /** the trigger, with or without parameters, for the action */
  9613. triggerOptions: any, condition?: Condition);
  9614. /**
  9615. * Internal only
  9616. * @hidden
  9617. */
  9618. _prepare(): void;
  9619. /**
  9620. * Gets the trigger parameters
  9621. * @returns the trigger parameters
  9622. */
  9623. getTriggerParameter(): any;
  9624. /**
  9625. * Internal only - executes current action event
  9626. * @hidden
  9627. */
  9628. _executeCurrent(evt?: ActionEvent): void;
  9629. /**
  9630. * Execute placeholder for child classes
  9631. * @param evt optional action event
  9632. */
  9633. execute(evt?: ActionEvent): void;
  9634. /**
  9635. * Skips to next active action
  9636. */
  9637. skipToNextActiveAction(): void;
  9638. /**
  9639. * Adds action to chain of actions, may be a DoNothingAction
  9640. * @param action defines the next action to execute
  9641. * @returns The action passed in
  9642. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9643. */
  9644. then(action: Action): Action;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _getProperty(propertyPath: string): string;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _getEffectiveTarget(target: any, propertyPath: string): any;
  9655. /**
  9656. * Serialize placeholder for child classes
  9657. * @param parent of child
  9658. * @returns the serialized object
  9659. */
  9660. serialize(parent: any): any;
  9661. /**
  9662. * Internal only called by serialize
  9663. * @hidden
  9664. */
  9665. protected _serialize(serializedAction: any, parent?: any): any;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. static _SerializeValueAsString: (value: any) => string;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. static _GetTargetProperty: (target: Scene | Node) => {
  9676. name: string;
  9677. targetType: string;
  9678. value: string;
  9679. };
  9680. }
  9681. }
  9682. declare module "babylonjs/Actions/condition" {
  9683. import { ActionManager } from "babylonjs/Actions/actionManager";
  9684. /**
  9685. * A Condition applied to an Action
  9686. */
  9687. export class Condition {
  9688. /**
  9689. * Internal only - manager for action
  9690. * @hidden
  9691. */
  9692. _actionManager: ActionManager;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. _evaluationId: number;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. _currentResult: boolean;
  9703. /**
  9704. * Creates a new Condition
  9705. * @param actionManager the manager of the action the condition is applied to
  9706. */
  9707. constructor(actionManager: ActionManager);
  9708. /**
  9709. * Check if the current condition is valid
  9710. * @returns a boolean
  9711. */
  9712. isValid(): boolean;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. _getProperty(propertyPath: string): string;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. _getEffectiveTarget(target: any, propertyPath: string): any;
  9723. /**
  9724. * Serialize placeholder for child classes
  9725. * @returns the serialized object
  9726. */
  9727. serialize(): any;
  9728. /**
  9729. * Internal only
  9730. * @hidden
  9731. */
  9732. protected _serialize(serializedCondition: any): any;
  9733. }
  9734. /**
  9735. * Defines specific conditional operators as extensions of Condition
  9736. */
  9737. export class ValueCondition extends Condition {
  9738. /** path to specify the property of the target the conditional operator uses */
  9739. propertyPath: string;
  9740. /** the value compared by the conditional operator against the current value of the property */
  9741. value: any;
  9742. /** the conditional operator, default ValueCondition.IsEqual */
  9743. operator: number;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. private static _IsEqual;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. private static _IsDifferent;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. private static _IsGreater;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. private static _IsLesser;
  9764. /**
  9765. * returns the number for IsEqual
  9766. */
  9767. static get IsEqual(): number;
  9768. /**
  9769. * Returns the number for IsDifferent
  9770. */
  9771. static get IsDifferent(): number;
  9772. /**
  9773. * Returns the number for IsGreater
  9774. */
  9775. static get IsGreater(): number;
  9776. /**
  9777. * Returns the number for IsLesser
  9778. */
  9779. static get IsLesser(): number;
  9780. /**
  9781. * Internal only The action manager for the condition
  9782. * @hidden
  9783. */
  9784. _actionManager: ActionManager;
  9785. /**
  9786. * Internal only
  9787. * @hidden
  9788. */
  9789. private _target;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _effectiveTarget;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private _property;
  9800. /**
  9801. * Creates a new ValueCondition
  9802. * @param actionManager manager for the action the condition applies to
  9803. * @param target for the action
  9804. * @param propertyPath path to specify the property of the target the conditional operator uses
  9805. * @param value the value compared by the conditional operator against the current value of the property
  9806. * @param operator the conditional operator, default ValueCondition.IsEqual
  9807. */
  9808. constructor(actionManager: ActionManager, target: any,
  9809. /** path to specify the property of the target the conditional operator uses */
  9810. propertyPath: string,
  9811. /** the value compared by the conditional operator against the current value of the property */
  9812. value: any,
  9813. /** the conditional operator, default ValueCondition.IsEqual */
  9814. operator?: number);
  9815. /**
  9816. * Compares the given value with the property value for the specified conditional operator
  9817. * @returns the result of the comparison
  9818. */
  9819. isValid(): boolean;
  9820. /**
  9821. * Serialize the ValueCondition into a JSON compatible object
  9822. * @returns serialization object
  9823. */
  9824. serialize(): any;
  9825. /**
  9826. * Gets the name of the conditional operator for the ValueCondition
  9827. * @param operator the conditional operator
  9828. * @returns the name
  9829. */
  9830. static GetOperatorName(operator: number): string;
  9831. }
  9832. /**
  9833. * Defines a predicate condition as an extension of Condition
  9834. */
  9835. export class PredicateCondition extends Condition {
  9836. /** defines the predicate function used to validate the condition */
  9837. predicate: () => boolean;
  9838. /**
  9839. * Internal only - manager for action
  9840. * @hidden
  9841. */
  9842. _actionManager: ActionManager;
  9843. /**
  9844. * Creates a new PredicateCondition
  9845. * @param actionManager manager for the action the condition applies to
  9846. * @param predicate defines the predicate function used to validate the condition
  9847. */
  9848. constructor(actionManager: ActionManager,
  9849. /** defines the predicate function used to validate the condition */
  9850. predicate: () => boolean);
  9851. /**
  9852. * @returns the validity of the predicate condition
  9853. */
  9854. isValid(): boolean;
  9855. }
  9856. /**
  9857. * Defines a state condition as an extension of Condition
  9858. */
  9859. export class StateCondition extends Condition {
  9860. /** Value to compare with target state */
  9861. value: string;
  9862. /**
  9863. * Internal only - manager for action
  9864. * @hidden
  9865. */
  9866. _actionManager: ActionManager;
  9867. /**
  9868. * Internal only
  9869. * @hidden
  9870. */
  9871. private _target;
  9872. /**
  9873. * Creates a new StateCondition
  9874. * @param actionManager manager for the action the condition applies to
  9875. * @param target of the condition
  9876. * @param value to compare with target state
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** Value to compare with target state */
  9880. value: string);
  9881. /**
  9882. * Gets a boolean indicating if the current condition is met
  9883. * @returns the validity of the state
  9884. */
  9885. isValid(): boolean;
  9886. /**
  9887. * Serialize the StateCondition into a JSON compatible object
  9888. * @returns serialization object
  9889. */
  9890. serialize(): any;
  9891. }
  9892. }
  9893. declare module "babylonjs/Actions/directActions" {
  9894. import { Action } from "babylonjs/Actions/action";
  9895. import { Condition } from "babylonjs/Actions/condition";
  9896. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9897. /**
  9898. * This defines an action responsible to toggle a boolean once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class SwitchBooleanAction extends Action {
  9902. /**
  9903. * The path to the boolean property in the target object
  9904. */
  9905. propertyPath: string;
  9906. private _target;
  9907. private _effectiveTarget;
  9908. private _property;
  9909. /**
  9910. * Instantiate the action
  9911. * @param triggerOptions defines the trigger options
  9912. * @param target defines the object containing the boolean
  9913. * @param propertyPath defines the path to the boolean property in the target object
  9914. * @param condition defines the trigger related conditions
  9915. */
  9916. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9917. /** @hidden */
  9918. _prepare(): void;
  9919. /**
  9920. * Execute the action toggle the boolean value.
  9921. */
  9922. execute(): void;
  9923. /**
  9924. * Serializes the actions and its related information.
  9925. * @param parent defines the object to serialize in
  9926. * @returns the serialized object
  9927. */
  9928. serialize(parent: any): any;
  9929. }
  9930. /**
  9931. * This defines an action responsible to set a the state field of the target
  9932. * to a desired value once triggered.
  9933. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9934. */
  9935. export class SetStateAction extends Action {
  9936. /**
  9937. * The value to store in the state field.
  9938. */
  9939. value: string;
  9940. private _target;
  9941. /**
  9942. * Instantiate the action
  9943. * @param triggerOptions defines the trigger options
  9944. * @param target defines the object containing the state property
  9945. * @param value defines the value to store in the state field
  9946. * @param condition defines the trigger related conditions
  9947. */
  9948. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9949. /**
  9950. * Execute the action and store the value on the target state property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. /**
  9961. * This defines an action responsible to set a property of the target
  9962. * to a desired value once triggered.
  9963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9964. */
  9965. export class SetValueAction extends Action {
  9966. /**
  9967. * The path of the property to set in the target.
  9968. */
  9969. propertyPath: string;
  9970. /**
  9971. * The value to set in the property
  9972. */
  9973. value: any;
  9974. private _target;
  9975. private _effectiveTarget;
  9976. private _property;
  9977. /**
  9978. * Instantiate the action
  9979. * @param triggerOptions defines the trigger options
  9980. * @param target defines the object containing the property
  9981. * @param propertyPath defines the path of the property to set in the target
  9982. * @param value defines the value to set in the property
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and set the targetted property to the desired value.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible to increment the target value
  10001. * to a desired value once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class IncrementValueAction extends Action {
  10005. /**
  10006. * The path of the property to increment in the target.
  10007. */
  10008. propertyPath: string;
  10009. /**
  10010. * The value we should increment the property by.
  10011. */
  10012. value: any;
  10013. private _target;
  10014. private _effectiveTarget;
  10015. private _property;
  10016. /**
  10017. * Instantiate the action
  10018. * @param triggerOptions defines the trigger options
  10019. * @param target defines the object containing the property
  10020. * @param propertyPath defines the path of the property to increment in the target
  10021. * @param value defines the value value we should increment the property by
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10025. /** @hidden */
  10026. _prepare(): void;
  10027. /**
  10028. * Execute the action and increment the target of the value amount.
  10029. */
  10030. execute(): void;
  10031. /**
  10032. * Serializes the actions and its related information.
  10033. * @param parent defines the object to serialize in
  10034. * @returns the serialized object
  10035. */
  10036. serialize(parent: any): any;
  10037. }
  10038. /**
  10039. * This defines an action responsible to start an animation once triggered.
  10040. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10041. */
  10042. export class PlayAnimationAction extends Action {
  10043. /**
  10044. * Where the animation should start (animation frame)
  10045. */
  10046. from: number;
  10047. /**
  10048. * Where the animation should stop (animation frame)
  10049. */
  10050. to: number;
  10051. /**
  10052. * Define if the animation should loop or stop after the first play.
  10053. */
  10054. loop?: boolean;
  10055. private _target;
  10056. /**
  10057. * Instantiate the action
  10058. * @param triggerOptions defines the trigger options
  10059. * @param target defines the target animation or animation name
  10060. * @param from defines from where the animation should start (animation frame)
  10061. * @param end defines where the animation should stop (animation frame)
  10062. * @param loop defines if the animation should loop or stop after the first play
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10066. /** @hidden */
  10067. _prepare(): void;
  10068. /**
  10069. * Execute the action and play the animation.
  10070. */
  10071. execute(): void;
  10072. /**
  10073. * Serializes the actions and its related information.
  10074. * @param parent defines the object to serialize in
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. }
  10079. /**
  10080. * This defines an action responsible to stop an animation once triggered.
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10082. */
  10083. export class StopAnimationAction extends Action {
  10084. private _target;
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param target defines the target animation or animation name
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, target: any, condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and stop the animation.
  10096. */
  10097. execute(): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible that does nothing once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class DoNothingAction extends Action {
  10110. /**
  10111. * Instantiate the action
  10112. * @param triggerOptions defines the trigger options
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions?: any, condition?: Condition);
  10116. /**
  10117. * Execute the action and do nothing.
  10118. */
  10119. execute(): void;
  10120. /**
  10121. * Serializes the actions and its related information.
  10122. * @param parent defines the object to serialize in
  10123. * @returns the serialized object
  10124. */
  10125. serialize(parent: any): any;
  10126. }
  10127. /**
  10128. * This defines an action responsible to trigger several actions once triggered.
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10130. */
  10131. export class CombineAction extends Action {
  10132. /**
  10133. * The list of aggregated animations to run.
  10134. */
  10135. children: Action[];
  10136. /**
  10137. * Instantiate the action
  10138. * @param triggerOptions defines the trigger options
  10139. * @param children defines the list of aggregated animations to run
  10140. * @param condition defines the trigger related conditions
  10141. */
  10142. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10143. /** @hidden */
  10144. _prepare(): void;
  10145. /**
  10146. * Execute the action and executes all the aggregated actions.
  10147. */
  10148. execute(evt: ActionEvent): void;
  10149. /**
  10150. * Serializes the actions and its related information.
  10151. * @param parent defines the object to serialize in
  10152. * @returns the serialized object
  10153. */
  10154. serialize(parent: any): any;
  10155. }
  10156. /**
  10157. * This defines an action responsible to run code (external event) once triggered.
  10158. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10159. */
  10160. export class ExecuteCodeAction extends Action {
  10161. /**
  10162. * The callback function to run.
  10163. */
  10164. func: (evt: ActionEvent) => void;
  10165. /**
  10166. * Instantiate the action
  10167. * @param triggerOptions defines the trigger options
  10168. * @param func defines the callback function to run
  10169. * @param condition defines the trigger related conditions
  10170. */
  10171. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10172. /**
  10173. * Execute the action and run the attached code.
  10174. */
  10175. execute(evt: ActionEvent): void;
  10176. }
  10177. /**
  10178. * This defines an action responsible to set the parent property of the target once triggered.
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10180. */
  10181. export class SetParentAction extends Action {
  10182. private _parent;
  10183. private _target;
  10184. /**
  10185. * Instantiate the action
  10186. * @param triggerOptions defines the trigger options
  10187. * @param target defines the target containing the parent property
  10188. * @param parent defines from where the animation should start (animation frame)
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10192. /** @hidden */
  10193. _prepare(): void;
  10194. /**
  10195. * Execute the action and set the parent property.
  10196. */
  10197. execute(): void;
  10198. /**
  10199. * Serializes the actions and its related information.
  10200. * @param parent defines the object to serialize in
  10201. * @returns the serialized object
  10202. */
  10203. serialize(parent: any): any;
  10204. }
  10205. }
  10206. declare module "babylonjs/Actions/actionManager" {
  10207. import { Nullable } from "babylonjs/types";
  10208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10209. import { Scene } from "babylonjs/scene";
  10210. import { IAction } from "babylonjs/Actions/action";
  10211. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10212. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10213. /**
  10214. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10215. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10217. */
  10218. export class ActionManager extends AbstractActionManager {
  10219. /**
  10220. * Nothing
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly NothingTrigger: number;
  10224. /**
  10225. * On pick
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10227. */
  10228. static readonly OnPickTrigger: number;
  10229. /**
  10230. * On left pick
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10232. */
  10233. static readonly OnLeftPickTrigger: number;
  10234. /**
  10235. * On right pick
  10236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10237. */
  10238. static readonly OnRightPickTrigger: number;
  10239. /**
  10240. * On center pick
  10241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10242. */
  10243. static readonly OnCenterPickTrigger: number;
  10244. /**
  10245. * On pick down
  10246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10247. */
  10248. static readonly OnPickDownTrigger: number;
  10249. /**
  10250. * On double pick
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10252. */
  10253. static readonly OnDoublePickTrigger: number;
  10254. /**
  10255. * On pick up
  10256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10257. */
  10258. static readonly OnPickUpTrigger: number;
  10259. /**
  10260. * On pick out.
  10261. * This trigger will only be raised if you also declared a OnPickDown
  10262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10263. */
  10264. static readonly OnPickOutTrigger: number;
  10265. /**
  10266. * On long press
  10267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10268. */
  10269. static readonly OnLongPressTrigger: number;
  10270. /**
  10271. * On pointer over
  10272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10273. */
  10274. static readonly OnPointerOverTrigger: number;
  10275. /**
  10276. * On pointer out
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10278. */
  10279. static readonly OnPointerOutTrigger: number;
  10280. /**
  10281. * On every frame
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly OnEveryFrameTrigger: number;
  10285. /**
  10286. * On intersection enter
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnIntersectionEnterTrigger: number;
  10290. /**
  10291. * On intersection exit
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnIntersectionExitTrigger: number;
  10295. /**
  10296. * On key down
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnKeyDownTrigger: number;
  10300. /**
  10301. * On key up
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnKeyUpTrigger: number;
  10305. private _scene;
  10306. /**
  10307. * Creates a new action manager
  10308. * @param scene defines the hosting scene
  10309. */
  10310. constructor(scene: Scene);
  10311. /**
  10312. * Releases all associated resources
  10313. */
  10314. dispose(): void;
  10315. /**
  10316. * Gets hosting scene
  10317. * @returns the hosting scene
  10318. */
  10319. getScene(): Scene;
  10320. /**
  10321. * Does this action manager handles actions of any of the given triggers
  10322. * @param triggers defines the triggers to be tested
  10323. * @return a boolean indicating whether one (or more) of the triggers is handled
  10324. */
  10325. hasSpecificTriggers(triggers: number[]): boolean;
  10326. /**
  10327. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10328. * speed.
  10329. * @param triggerA defines the trigger to be tested
  10330. * @param triggerB defines the trigger to be tested
  10331. * @return a boolean indicating whether one (or more) of the triggers is handled
  10332. */
  10333. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10334. /**
  10335. * Does this action manager handles actions of a given trigger
  10336. * @param trigger defines the trigger to be tested
  10337. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10338. * @return whether the trigger is handled
  10339. */
  10340. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10341. /**
  10342. * Does this action manager has pointer triggers
  10343. */
  10344. get hasPointerTriggers(): boolean;
  10345. /**
  10346. * Does this action manager has pick triggers
  10347. */
  10348. get hasPickTriggers(): boolean;
  10349. /**
  10350. * Registers an action to this action manager
  10351. * @param action defines the action to be registered
  10352. * @return the action amended (prepared) after registration
  10353. */
  10354. registerAction(action: IAction): Nullable<IAction>;
  10355. /**
  10356. * Unregisters an action to this action manager
  10357. * @param action defines the action to be unregistered
  10358. * @return a boolean indicating whether the action has been unregistered
  10359. */
  10360. unregisterAction(action: IAction): Boolean;
  10361. /**
  10362. * Process a specific trigger
  10363. * @param trigger defines the trigger to process
  10364. * @param evt defines the event details to be processed
  10365. */
  10366. processTrigger(trigger: number, evt?: IActionEvent): void;
  10367. /** @hidden */
  10368. _getEffectiveTarget(target: any, propertyPath: string): any;
  10369. /** @hidden */
  10370. _getProperty(propertyPath: string): string;
  10371. /**
  10372. * Serialize this manager to a JSON object
  10373. * @param name defines the property name to store this manager
  10374. * @returns a JSON representation of this manager
  10375. */
  10376. serialize(name: string): any;
  10377. /**
  10378. * Creates a new ActionManager from a JSON data
  10379. * @param parsedActions defines the JSON data to read from
  10380. * @param object defines the hosting mesh
  10381. * @param scene defines the hosting scene
  10382. */
  10383. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10384. /**
  10385. * Get a trigger name by index
  10386. * @param trigger defines the trigger index
  10387. * @returns a trigger name
  10388. */
  10389. static GetTriggerName(trigger: number): string;
  10390. }
  10391. }
  10392. declare module "babylonjs/Culling/ray" {
  10393. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10394. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10397. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10398. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10399. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10400. import { Plane } from "babylonjs/Maths/math.plane";
  10401. /**
  10402. * Class representing a ray with position and direction
  10403. */
  10404. export class Ray {
  10405. /** origin point */
  10406. origin: Vector3;
  10407. /** direction */
  10408. direction: Vector3;
  10409. /** length of the ray */
  10410. length: number;
  10411. private static readonly _TmpVector3;
  10412. private _tmpRay;
  10413. /**
  10414. * Creates a new ray
  10415. * @param origin origin point
  10416. * @param direction direction
  10417. * @param length length of the ray
  10418. */
  10419. constructor(
  10420. /** origin point */
  10421. origin: Vector3,
  10422. /** direction */
  10423. direction: Vector3,
  10424. /** length of the ray */
  10425. length?: number);
  10426. /**
  10427. * Checks if the ray intersects a box
  10428. * This does not account for the ray lenght by design to improve perfs.
  10429. * @param minimum bound of the box
  10430. * @param maximum bound of the box
  10431. * @param intersectionTreshold extra extend to be added to the box in all direction
  10432. * @returns if the box was hit
  10433. */
  10434. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10435. /**
  10436. * Checks if the ray intersects a box
  10437. * This does not account for the ray lenght by design to improve perfs.
  10438. * @param box the bounding box to check
  10439. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10440. * @returns if the box was hit
  10441. */
  10442. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10443. /**
  10444. * If the ray hits a sphere
  10445. * @param sphere the bounding sphere to check
  10446. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10447. * @returns true if it hits the sphere
  10448. */
  10449. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10450. /**
  10451. * If the ray hits a triange
  10452. * @param vertex0 triangle vertex
  10453. * @param vertex1 triangle vertex
  10454. * @param vertex2 triangle vertex
  10455. * @returns intersection information if hit
  10456. */
  10457. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10458. /**
  10459. * Checks if ray intersects a plane
  10460. * @param plane the plane to check
  10461. * @returns the distance away it was hit
  10462. */
  10463. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10464. /**
  10465. * Calculate the intercept of a ray on a given axis
  10466. * @param axis to check 'x' | 'y' | 'z'
  10467. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10468. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10469. */
  10470. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10471. /**
  10472. * Checks if ray intersects a mesh
  10473. * @param mesh the mesh to check
  10474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10475. * @returns picking info of the intersecton
  10476. */
  10477. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10478. /**
  10479. * Checks if ray intersects a mesh
  10480. * @param meshes the meshes to check
  10481. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10482. * @param results array to store result in
  10483. * @returns Array of picking infos
  10484. */
  10485. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10486. private _comparePickingInfo;
  10487. private static smallnum;
  10488. private static rayl;
  10489. /**
  10490. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10491. * @param sega the first point of the segment to test the intersection against
  10492. * @param segb the second point of the segment to test the intersection against
  10493. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10494. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10495. */
  10496. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10497. /**
  10498. * Update the ray from viewport position
  10499. * @param x position
  10500. * @param y y position
  10501. * @param viewportWidth viewport width
  10502. * @param viewportHeight viewport height
  10503. * @param world world matrix
  10504. * @param view view matrix
  10505. * @param projection projection matrix
  10506. * @returns this ray updated
  10507. */
  10508. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10509. /**
  10510. * Creates a ray with origin and direction of 0,0,0
  10511. * @returns the new ray
  10512. */
  10513. static Zero(): Ray;
  10514. /**
  10515. * Creates a new ray from screen space and viewport
  10516. * @param x position
  10517. * @param y y position
  10518. * @param viewportWidth viewport width
  10519. * @param viewportHeight viewport height
  10520. * @param world world matrix
  10521. * @param view view matrix
  10522. * @param projection projection matrix
  10523. * @returns new ray
  10524. */
  10525. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10526. /**
  10527. * 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
  10528. * transformed to the given world matrix.
  10529. * @param origin The origin point
  10530. * @param end The end point
  10531. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10532. * @returns the new ray
  10533. */
  10534. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10535. /**
  10536. * Transforms a ray by a matrix
  10537. * @param ray ray to transform
  10538. * @param matrix matrix to apply
  10539. * @returns the resulting new ray
  10540. */
  10541. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10542. /**
  10543. * Transforms a ray by a matrix
  10544. * @param ray ray to transform
  10545. * @param matrix matrix to apply
  10546. * @param result ray to store result in
  10547. */
  10548. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10549. /**
  10550. * Unproject a ray from screen space to object space
  10551. * @param sourceX defines the screen space x coordinate to use
  10552. * @param sourceY defines the screen space y coordinate to use
  10553. * @param viewportWidth defines the current width of the viewport
  10554. * @param viewportHeight defines the current height of the viewport
  10555. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10556. * @param view defines the view matrix to use
  10557. * @param projection defines the projection matrix to use
  10558. */
  10559. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10560. }
  10561. /**
  10562. * Type used to define predicate used to select faces when a mesh intersection is detected
  10563. */
  10564. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10565. module "babylonjs/scene" {
  10566. interface Scene {
  10567. /** @hidden */
  10568. _tempPickingRay: Nullable<Ray>;
  10569. /** @hidden */
  10570. _cachedRayForTransform: Ray;
  10571. /** @hidden */
  10572. _pickWithRayInverseMatrix: Matrix;
  10573. /** @hidden */
  10574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10575. /** @hidden */
  10576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10577. /** @hidden */
  10578. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10579. }
  10580. }
  10581. }
  10582. declare module "babylonjs/sceneComponent" {
  10583. import { Scene } from "babylonjs/scene";
  10584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10586. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10587. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10588. import { Nullable } from "babylonjs/types";
  10589. import { Camera } from "babylonjs/Cameras/camera";
  10590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10591. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10592. import { AbstractScene } from "babylonjs/abstractScene";
  10593. import { Mesh } from "babylonjs/Meshes/mesh";
  10594. import { Effect } from "babylonjs/Materials/effect";
  10595. /**
  10596. * Groups all the scene component constants in one place to ease maintenance.
  10597. * @hidden
  10598. */
  10599. export class SceneComponentConstants {
  10600. static readonly NAME_EFFECTLAYER: string;
  10601. static readonly NAME_LAYER: string;
  10602. static readonly NAME_LENSFLARESYSTEM: string;
  10603. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10604. static readonly NAME_PARTICLESYSTEM: string;
  10605. static readonly NAME_GAMEPAD: string;
  10606. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10607. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10608. static readonly NAME_PREPASSRENDERER: string;
  10609. static readonly NAME_DEPTHRENDERER: string;
  10610. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10611. static readonly NAME_SPRITE: string;
  10612. static readonly NAME_SUBSURFACE: string;
  10613. static readonly NAME_OUTLINERENDERER: string;
  10614. static readonly NAME_PROCEDURALTEXTURE: string;
  10615. static readonly NAME_SHADOWGENERATOR: string;
  10616. static readonly NAME_OCTREE: string;
  10617. static readonly NAME_PHYSICSENGINE: string;
  10618. static readonly NAME_AUDIO: string;
  10619. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10620. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10622. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10623. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10624. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10625. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10626. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10627. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10628. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10630. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10631. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10632. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10633. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10634. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10635. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10636. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10637. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10638. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10639. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10640. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10641. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10643. static readonly STEP_AFTERRENDER_AUDIO: number;
  10644. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10645. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10646. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10648. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10649. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10650. static readonly STEP_POINTERMOVE_SPRITE: number;
  10651. static readonly STEP_POINTERDOWN_SPRITE: number;
  10652. static readonly STEP_POINTERUP_SPRITE: number;
  10653. }
  10654. /**
  10655. * This represents a scene component.
  10656. *
  10657. * This is used to decouple the dependency the scene is having on the different workloads like
  10658. * layers, post processes...
  10659. */
  10660. export interface ISceneComponent {
  10661. /**
  10662. * The name of the component. Each component must have a unique name.
  10663. */
  10664. name: string;
  10665. /**
  10666. * The scene the component belongs to.
  10667. */
  10668. scene: Scene;
  10669. /**
  10670. * Register the component to one instance of a scene.
  10671. */
  10672. register(): void;
  10673. /**
  10674. * Rebuilds the elements related to this component in case of
  10675. * context lost for instance.
  10676. */
  10677. rebuild(): void;
  10678. /**
  10679. * Disposes the component and the associated ressources.
  10680. */
  10681. dispose(): void;
  10682. }
  10683. /**
  10684. * This represents a SERIALIZABLE scene component.
  10685. *
  10686. * This extends Scene Component to add Serialization methods on top.
  10687. */
  10688. export interface ISceneSerializableComponent extends ISceneComponent {
  10689. /**
  10690. * Adds all the elements from the container to the scene
  10691. * @param container the container holding the elements
  10692. */
  10693. addFromContainer(container: AbstractScene): void;
  10694. /**
  10695. * Removes all the elements in the container from the scene
  10696. * @param container contains the elements to remove
  10697. * @param dispose if the removed element should be disposed (default: false)
  10698. */
  10699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10700. /**
  10701. * Serializes the component data to the specified json object
  10702. * @param serializationObject The object to serialize to
  10703. */
  10704. serialize(serializationObject: any): void;
  10705. }
  10706. /**
  10707. * Strong typing of a Mesh related stage step action
  10708. */
  10709. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10710. /**
  10711. * Strong typing of a Evaluate Sub Mesh related stage step action
  10712. */
  10713. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10714. /**
  10715. * Strong typing of a pre active Mesh related stage step action
  10716. */
  10717. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10718. /**
  10719. * Strong typing of a Camera related stage step action
  10720. */
  10721. export type CameraStageAction = (camera: Camera) => void;
  10722. /**
  10723. * Strong typing of a Camera Frame buffer related stage step action
  10724. */
  10725. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10726. /**
  10727. * Strong typing of a Render Target related stage step action
  10728. */
  10729. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10730. /**
  10731. * Strong typing of a RenderingGroup related stage step action
  10732. */
  10733. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10734. /**
  10735. * Strong typing of a Mesh Render related stage step action
  10736. */
  10737. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10738. /**
  10739. * Strong typing of a simple stage step action
  10740. */
  10741. export type SimpleStageAction = () => void;
  10742. /**
  10743. * Strong typing of a render target action.
  10744. */
  10745. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10746. /**
  10747. * Strong typing of a pointer move action.
  10748. */
  10749. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10750. /**
  10751. * Strong typing of a pointer up/down action.
  10752. */
  10753. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10754. /**
  10755. * Representation of a stage in the scene (Basically a list of ordered steps)
  10756. * @hidden
  10757. */
  10758. export class Stage<T extends Function> extends Array<{
  10759. index: number;
  10760. component: ISceneComponent;
  10761. action: T;
  10762. }> {
  10763. /**
  10764. * Hide ctor from the rest of the world.
  10765. * @param items The items to add.
  10766. */
  10767. private constructor();
  10768. /**
  10769. * Creates a new Stage.
  10770. * @returns A new instance of a Stage
  10771. */
  10772. static Create<T extends Function>(): Stage<T>;
  10773. /**
  10774. * Registers a step in an ordered way in the targeted stage.
  10775. * @param index Defines the position to register the step in
  10776. * @param component Defines the component attached to the step
  10777. * @param action Defines the action to launch during the step
  10778. */
  10779. registerStep(index: number, component: ISceneComponent, action: T): void;
  10780. /**
  10781. * Clears all the steps from the stage.
  10782. */
  10783. clear(): void;
  10784. }
  10785. }
  10786. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10787. import { Nullable } from "babylonjs/types";
  10788. import { Observable } from "babylonjs/Misc/observable";
  10789. import { Scene } from "babylonjs/scene";
  10790. import { Sprite } from "babylonjs/Sprites/sprite";
  10791. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10792. import { Ray } from "babylonjs/Culling/ray";
  10793. import { Camera } from "babylonjs/Cameras/camera";
  10794. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10795. import { ISceneComponent } from "babylonjs/sceneComponent";
  10796. module "babylonjs/scene" {
  10797. interface Scene {
  10798. /** @hidden */
  10799. _pointerOverSprite: Nullable<Sprite>;
  10800. /** @hidden */
  10801. _pickedDownSprite: Nullable<Sprite>;
  10802. /** @hidden */
  10803. _tempSpritePickingRay: Nullable<Ray>;
  10804. /**
  10805. * All of the sprite managers added to this scene
  10806. * @see https://doc.babylonjs.com/babylon101/sprites
  10807. */
  10808. spriteManagers: Array<ISpriteManager>;
  10809. /**
  10810. * An event triggered when sprites rendering is about to start
  10811. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10812. */
  10813. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10814. /**
  10815. * An event triggered when sprites rendering is done
  10816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10817. */
  10818. onAfterSpritesRenderingObservable: Observable<Scene>;
  10819. /** @hidden */
  10820. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10821. /** Launch a ray to try to pick a sprite in the scene
  10822. * @param x position on screen
  10823. * @param y position on screen
  10824. * @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
  10825. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10826. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10827. * @returns a PickingInfo
  10828. */
  10829. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10830. /** Use the given ray to pick a sprite in the scene
  10831. * @param ray The ray (in world space) to use to pick meshes
  10832. * @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
  10833. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10834. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10835. * @returns a PickingInfo
  10836. */
  10837. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10838. /** @hidden */
  10839. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10840. /** Launch a ray to try to pick sprites in the scene
  10841. * @param x position on screen
  10842. * @param y position on screen
  10843. * @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
  10844. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /** Use the given ray to pick sprites in the scene
  10849. * @param ray The ray (in world space) to use to pick meshes
  10850. * @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
  10851. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10852. * @returns a PickingInfo array
  10853. */
  10854. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10855. /**
  10856. * Force the sprite under the pointer
  10857. * @param sprite defines the sprite to use
  10858. */
  10859. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10860. /**
  10861. * Gets the sprite under the pointer
  10862. * @returns a Sprite or null if no sprite is under the pointer
  10863. */
  10864. getPointerOverSprite(): Nullable<Sprite>;
  10865. }
  10866. }
  10867. /**
  10868. * Defines the sprite scene component responsible to manage sprites
  10869. * in a given scene.
  10870. */
  10871. export class SpriteSceneComponent implements ISceneComponent {
  10872. /**
  10873. * The component name helpfull to identify the component in the list of scene components.
  10874. */
  10875. readonly name: string;
  10876. /**
  10877. * The scene the component belongs to.
  10878. */
  10879. scene: Scene;
  10880. /** @hidden */
  10881. private _spritePredicate;
  10882. /**
  10883. * Creates a new instance of the component for the given scene
  10884. * @param scene Defines the scene to register the component in
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Registers the component in a given scene
  10889. */
  10890. register(): void;
  10891. /**
  10892. * Rebuilds the elements related to this component in case of
  10893. * context lost for instance.
  10894. */
  10895. rebuild(): void;
  10896. /**
  10897. * Disposes the component and the associated ressources.
  10898. */
  10899. dispose(): void;
  10900. private _pickSpriteButKeepRay;
  10901. private _pointerMove;
  10902. private _pointerDown;
  10903. private _pointerUp;
  10904. }
  10905. }
  10906. declare module "babylonjs/Misc/timingTools" {
  10907. /**
  10908. * Class used to provide helper for timing
  10909. */
  10910. export class TimingTools {
  10911. /**
  10912. * Polyfill for setImmediate
  10913. * @param action defines the action to execute after the current execution block
  10914. */
  10915. static SetImmediate(action: () => void): void;
  10916. }
  10917. }
  10918. declare module "babylonjs/Misc/instantiationTools" {
  10919. /**
  10920. * Class used to enable instatition of objects by class name
  10921. */
  10922. export class InstantiationTools {
  10923. /**
  10924. * Use this object to register external classes like custom textures or material
  10925. * to allow the laoders to instantiate them
  10926. */
  10927. static RegisteredExternalClasses: {
  10928. [key: string]: Object;
  10929. };
  10930. /**
  10931. * Tries to instantiate a new object from a given class name
  10932. * @param className defines the class name to instantiate
  10933. * @returns the new object or null if the system was not able to do the instantiation
  10934. */
  10935. static Instantiate(className: string): any;
  10936. }
  10937. }
  10938. declare module "babylonjs/Misc/copyTools" {
  10939. import { Nullable } from "babylonjs/types";
  10940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10941. /**
  10942. * Class used to host copy specific utilities
  10943. */
  10944. export class CopyTools {
  10945. /**
  10946. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10947. * @param texture defines the texture to read pixels from
  10948. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10949. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10950. * @returns The base64 encoded string or null
  10951. */
  10952. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10953. }
  10954. }
  10955. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10956. /**
  10957. * Define options used to create a depth texture
  10958. */
  10959. export class DepthTextureCreationOptions {
  10960. /** Specifies whether or not a stencil should be allocated in the texture */
  10961. generateStencil?: boolean;
  10962. /** Specifies whether or not bilinear filtering is enable on the texture */
  10963. bilinearFiltering?: boolean;
  10964. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10965. comparisonFunction?: number;
  10966. /** Specifies if the created texture is a cube texture */
  10967. isCube?: boolean;
  10968. }
  10969. }
  10970. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10972. import { Nullable } from "babylonjs/types";
  10973. import { Scene } from "babylonjs/scene";
  10974. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10975. module "babylonjs/Engines/thinEngine" {
  10976. interface ThinEngine {
  10977. /**
  10978. * Creates a depth stencil cube texture.
  10979. * This is only available in WebGL 2.
  10980. * @param size The size of face edge in the cube texture.
  10981. * @param options The options defining the cube texture.
  10982. * @returns The cube texture
  10983. */
  10984. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10985. /**
  10986. * Creates a cube texture
  10987. * @param rootUrl defines the url where the files to load is located
  10988. * @param scene defines the current scene
  10989. * @param files defines the list of files to load (1 per face)
  10990. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10991. * @param onLoad defines an optional callback raised when the texture is loaded
  10992. * @param onError defines an optional callback raised if there is an issue to load the texture
  10993. * @param format defines the format of the data
  10994. * @param forcedExtension defines the extension to use to pick the right loader
  10995. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10996. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10997. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10998. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10999. * @param loaderOptions options to be passed to the loader
  11000. * @returns the cube texture as an InternalTexture
  11001. */
  11002. 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;
  11003. /**
  11004. * Creates a cube texture
  11005. * @param rootUrl defines the url where the files to load is located
  11006. * @param scene defines the current scene
  11007. * @param files defines the list of files to load (1 per face)
  11008. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11009. * @param onLoad defines an optional callback raised when the texture is loaded
  11010. * @param onError defines an optional callback raised if there is an issue to load the texture
  11011. * @param format defines the format of the data
  11012. * @param forcedExtension defines the extension to use to pick the right loader
  11013. * @returns the cube texture as an InternalTexture
  11014. */
  11015. 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;
  11016. /**
  11017. * Creates a cube texture
  11018. * @param rootUrl defines the url where the files to load is located
  11019. * @param scene defines the current scene
  11020. * @param files defines the list of files to load (1 per face)
  11021. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11022. * @param onLoad defines an optional callback raised when the texture is loaded
  11023. * @param onError defines an optional callback raised if there is an issue to load the texture
  11024. * @param format defines the format of the data
  11025. * @param forcedExtension defines the extension to use to pick the right loader
  11026. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11027. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11028. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11029. * @returns the cube texture as an InternalTexture
  11030. */
  11031. 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;
  11032. /** @hidden */
  11033. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11034. /** @hidden */
  11035. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11036. /** @hidden */
  11037. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11038. /** @hidden */
  11039. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11040. /**
  11041. * @hidden
  11042. */
  11043. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11044. }
  11045. }
  11046. }
  11047. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11048. import { Nullable } from "babylonjs/types";
  11049. import { Scene } from "babylonjs/scene";
  11050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11051. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11053. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11054. import { Observable } from "babylonjs/Misc/observable";
  11055. /**
  11056. * Class for creating a cube texture
  11057. */
  11058. export class CubeTexture extends BaseTexture {
  11059. private _delayedOnLoad;
  11060. /**
  11061. * Observable triggered once the texture has been loaded.
  11062. */
  11063. onLoadObservable: Observable<CubeTexture>;
  11064. /**
  11065. * The url of the texture
  11066. */
  11067. url: string;
  11068. /**
  11069. * Gets or sets the center of the bounding box associated with the cube texture.
  11070. * It must define where the camera used to render the texture was set
  11071. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11072. */
  11073. boundingBoxPosition: Vector3;
  11074. private _boundingBoxSize;
  11075. /**
  11076. * Gets or sets the size of the bounding box associated with the cube texture
  11077. * When defined, the cubemap will switch to local mode
  11078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11079. * @example https://www.babylonjs-playground.com/#RNASML
  11080. */
  11081. set boundingBoxSize(value: Vector3);
  11082. /**
  11083. * Returns the bounding box size
  11084. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11085. */
  11086. get boundingBoxSize(): Vector3;
  11087. protected _rotationY: number;
  11088. /**
  11089. * Sets texture matrix rotation angle around Y axis in radians.
  11090. */
  11091. set rotationY(value: number);
  11092. /**
  11093. * Gets texture matrix rotation angle around Y axis radians.
  11094. */
  11095. get rotationY(): number;
  11096. /**
  11097. * Are mip maps generated for this texture or not.
  11098. */
  11099. get noMipmap(): boolean;
  11100. private _noMipmap;
  11101. private _files;
  11102. protected _forcedExtension: Nullable<string>;
  11103. private _extensions;
  11104. private _textureMatrix;
  11105. private _format;
  11106. private _createPolynomials;
  11107. private _loaderOptions;
  11108. /**
  11109. * Creates a cube texture from an array of image urls
  11110. * @param files defines an array of image urls
  11111. * @param scene defines the hosting scene
  11112. * @param noMipmap specifies if mip maps are not used
  11113. * @returns a cube texture
  11114. */
  11115. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11116. /**
  11117. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11118. * @param url defines the url of the prefiltered texture
  11119. * @param scene defines the scene the texture is attached to
  11120. * @param forcedExtension defines the extension of the file if different from the url
  11121. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11122. * @return the prefiltered texture
  11123. */
  11124. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11125. /**
  11126. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11127. * as prefiltered data.
  11128. * @param rootUrl defines the url of the texture or the root name of the six images
  11129. * @param null defines the scene or engine the texture is attached to
  11130. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11131. * @param noMipmap defines if mipmaps should be created or not
  11132. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11133. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11134. * @param onError defines a callback triggered in case of error during load
  11135. * @param format defines the internal format to use for the texture once loaded
  11136. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11137. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11138. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11141. * @param loaderOptions options to be passed to the loader
  11142. * @return the cube texture
  11143. */
  11144. 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);
  11145. /**
  11146. * Get the current class name of the texture useful for serialization or dynamic coding.
  11147. * @returns "CubeTexture"
  11148. */
  11149. getClassName(): string;
  11150. /**
  11151. * Update the url (and optional buffer) of this texture if url was null during construction.
  11152. * @param url the url of the texture
  11153. * @param forcedExtension defines the extension to use
  11154. * @param onLoad callback called when the texture is loaded (defaults to null)
  11155. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11156. */
  11157. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11158. /**
  11159. * Delays loading of the cube texture
  11160. * @param forcedExtension defines the extension to use
  11161. */
  11162. delayLoad(forcedExtension?: string): void;
  11163. /**
  11164. * Returns the reflection texture matrix
  11165. * @returns the reflection texture matrix
  11166. */
  11167. getReflectionTextureMatrix(): Matrix;
  11168. /**
  11169. * Sets the reflection texture matrix
  11170. * @param value Reflection texture matrix
  11171. */
  11172. setReflectionTextureMatrix(value: Matrix): void;
  11173. /**
  11174. * Parses text to create a cube texture
  11175. * @param parsedTexture define the serialized text to read from
  11176. * @param scene defines the hosting scene
  11177. * @param rootUrl defines the root url of the cube texture
  11178. * @returns a cube texture
  11179. */
  11180. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11181. /**
  11182. * Makes a clone, or deep copy, of the cube texture
  11183. * @returns a new cube texture
  11184. */
  11185. clone(): CubeTexture;
  11186. }
  11187. }
  11188. declare module "babylonjs/Materials/colorCurves" {
  11189. import { Effect } from "babylonjs/Materials/effect";
  11190. /**
  11191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11193. * 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;
  11194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11195. */
  11196. export class ColorCurves {
  11197. private _dirty;
  11198. private _tempColor;
  11199. private _globalCurve;
  11200. private _highlightsCurve;
  11201. private _midtonesCurve;
  11202. private _shadowsCurve;
  11203. private _positiveCurve;
  11204. private _negativeCurve;
  11205. private _globalHue;
  11206. private _globalDensity;
  11207. private _globalSaturation;
  11208. private _globalExposure;
  11209. /**
  11210. * Gets the global Hue value.
  11211. * 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).
  11212. */
  11213. get globalHue(): number;
  11214. /**
  11215. * Sets the global Hue value.
  11216. * 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).
  11217. */
  11218. set globalHue(value: number);
  11219. /**
  11220. * Gets the global Density value.
  11221. * 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.
  11222. * Values less than zero provide a filter of opposite hue.
  11223. */
  11224. get globalDensity(): number;
  11225. /**
  11226. * Sets the global Density value.
  11227. * 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.
  11228. * Values less than zero provide a filter of opposite hue.
  11229. */
  11230. set globalDensity(value: number);
  11231. /**
  11232. * Gets the global Saturation value.
  11233. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11234. */
  11235. get globalSaturation(): number;
  11236. /**
  11237. * Sets the global Saturation value.
  11238. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11239. */
  11240. set globalSaturation(value: number);
  11241. /**
  11242. * Gets the global Exposure value.
  11243. * 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.
  11244. */
  11245. get globalExposure(): number;
  11246. /**
  11247. * Sets the global Exposure value.
  11248. * 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.
  11249. */
  11250. set globalExposure(value: number);
  11251. private _highlightsHue;
  11252. private _highlightsDensity;
  11253. private _highlightsSaturation;
  11254. private _highlightsExposure;
  11255. /**
  11256. * Gets the highlights Hue value.
  11257. * 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).
  11258. */
  11259. get highlightsHue(): number;
  11260. /**
  11261. * Sets the highlights Hue value.
  11262. * 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).
  11263. */
  11264. set highlightsHue(value: number);
  11265. /**
  11266. * Gets the highlights Density value.
  11267. * 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.
  11268. * Values less than zero provide a filter of opposite hue.
  11269. */
  11270. get highlightsDensity(): number;
  11271. /**
  11272. * Sets the highlights Density value.
  11273. * 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.
  11274. * Values less than zero provide a filter of opposite hue.
  11275. */
  11276. set highlightsDensity(value: number);
  11277. /**
  11278. * Gets the highlights Saturation value.
  11279. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11280. */
  11281. get highlightsSaturation(): number;
  11282. /**
  11283. * Sets the highlights Saturation value.
  11284. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11285. */
  11286. set highlightsSaturation(value: number);
  11287. /**
  11288. * Gets the highlights Exposure value.
  11289. * 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.
  11290. */
  11291. get highlightsExposure(): number;
  11292. /**
  11293. * Sets the highlights Exposure value.
  11294. * 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.
  11295. */
  11296. set highlightsExposure(value: number);
  11297. private _midtonesHue;
  11298. private _midtonesDensity;
  11299. private _midtonesSaturation;
  11300. private _midtonesExposure;
  11301. /**
  11302. * Gets the midtones Hue value.
  11303. * 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).
  11304. */
  11305. get midtonesHue(): number;
  11306. /**
  11307. * Sets the midtones Hue value.
  11308. * 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).
  11309. */
  11310. set midtonesHue(value: number);
  11311. /**
  11312. * Gets the midtones Density value.
  11313. * 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.
  11314. * Values less than zero provide a filter of opposite hue.
  11315. */
  11316. get midtonesDensity(): number;
  11317. /**
  11318. * Sets the midtones Density value.
  11319. * 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.
  11320. * Values less than zero provide a filter of opposite hue.
  11321. */
  11322. set midtonesDensity(value: number);
  11323. /**
  11324. * Gets the midtones Saturation value.
  11325. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11326. */
  11327. get midtonesSaturation(): number;
  11328. /**
  11329. * Sets the midtones Saturation value.
  11330. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11331. */
  11332. set midtonesSaturation(value: number);
  11333. /**
  11334. * Gets the midtones Exposure value.
  11335. * 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.
  11336. */
  11337. get midtonesExposure(): number;
  11338. /**
  11339. * Sets the midtones Exposure value.
  11340. * 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.
  11341. */
  11342. set midtonesExposure(value: number);
  11343. private _shadowsHue;
  11344. private _shadowsDensity;
  11345. private _shadowsSaturation;
  11346. private _shadowsExposure;
  11347. /**
  11348. * Gets the shadows Hue value.
  11349. * 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).
  11350. */
  11351. get shadowsHue(): number;
  11352. /**
  11353. * Sets the shadows Hue value.
  11354. * 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).
  11355. */
  11356. set shadowsHue(value: number);
  11357. /**
  11358. * Gets the shadows Density value.
  11359. * 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.
  11360. * Values less than zero provide a filter of opposite hue.
  11361. */
  11362. get shadowsDensity(): number;
  11363. /**
  11364. * Sets the shadows Density value.
  11365. * 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.
  11366. * Values less than zero provide a filter of opposite hue.
  11367. */
  11368. set shadowsDensity(value: number);
  11369. /**
  11370. * Gets the shadows Saturation value.
  11371. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11372. */
  11373. get shadowsSaturation(): number;
  11374. /**
  11375. * Sets the shadows Saturation value.
  11376. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11377. */
  11378. set shadowsSaturation(value: number);
  11379. /**
  11380. * Gets the shadows Exposure value.
  11381. * 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.
  11382. */
  11383. get shadowsExposure(): number;
  11384. /**
  11385. * Sets the shadows Exposure value.
  11386. * 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.
  11387. */
  11388. set shadowsExposure(value: number);
  11389. /**
  11390. * Returns the class name
  11391. * @returns The class name
  11392. */
  11393. getClassName(): string;
  11394. /**
  11395. * Binds the color curves to the shader.
  11396. * @param colorCurves The color curve to bind
  11397. * @param effect The effect to bind to
  11398. * @param positiveUniform The positive uniform shader parameter
  11399. * @param neutralUniform The neutral uniform shader parameter
  11400. * @param negativeUniform The negative uniform shader parameter
  11401. */
  11402. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11403. /**
  11404. * Prepare the list of uniforms associated with the ColorCurves effects.
  11405. * @param uniformsList The list of uniforms used in the effect
  11406. */
  11407. static PrepareUniforms(uniformsList: string[]): void;
  11408. /**
  11409. * Returns color grading data based on a hue, density, saturation and exposure value.
  11410. * @param filterHue The hue of the color filter.
  11411. * @param filterDensity The density of the color filter.
  11412. * @param saturation The saturation.
  11413. * @param exposure The exposure.
  11414. * @param result The result data container.
  11415. */
  11416. private getColorGradingDataToRef;
  11417. /**
  11418. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11419. * @param value The input slider value in range [-100,100].
  11420. * @returns Adjusted value.
  11421. */
  11422. private static applyColorGradingSliderNonlinear;
  11423. /**
  11424. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11425. * @param hue The hue (H) input.
  11426. * @param saturation The saturation (S) input.
  11427. * @param brightness The brightness (B) input.
  11428. * @result An RGBA color represented as Vector4.
  11429. */
  11430. private static fromHSBToRef;
  11431. /**
  11432. * Returns a value clamped between min and max
  11433. * @param value The value to clamp
  11434. * @param min The minimum of value
  11435. * @param max The maximum of value
  11436. * @returns The clamped value.
  11437. */
  11438. private static clamp;
  11439. /**
  11440. * Clones the current color curve instance.
  11441. * @return The cloned curves
  11442. */
  11443. clone(): ColorCurves;
  11444. /**
  11445. * Serializes the current color curve instance to a json representation.
  11446. * @return a JSON representation
  11447. */
  11448. serialize(): any;
  11449. /**
  11450. * Parses the color curve from a json representation.
  11451. * @param source the JSON source to parse
  11452. * @return The parsed curves
  11453. */
  11454. static Parse(source: any): ColorCurves;
  11455. }
  11456. }
  11457. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11458. import { Observable } from "babylonjs/Misc/observable";
  11459. import { Nullable } from "babylonjs/types";
  11460. import { Color4 } from "babylonjs/Maths/math.color";
  11461. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11462. import { Effect } from "babylonjs/Materials/effect";
  11463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11464. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11465. /**
  11466. * Interface to follow in your material defines to integrate easily the
  11467. * Image proccessing functions.
  11468. * @hidden
  11469. */
  11470. export interface IImageProcessingConfigurationDefines {
  11471. IMAGEPROCESSING: boolean;
  11472. VIGNETTE: boolean;
  11473. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11474. VIGNETTEBLENDMODEOPAQUE: boolean;
  11475. TONEMAPPING: boolean;
  11476. TONEMAPPING_ACES: boolean;
  11477. CONTRAST: boolean;
  11478. EXPOSURE: boolean;
  11479. COLORCURVES: boolean;
  11480. COLORGRADING: boolean;
  11481. COLORGRADING3D: boolean;
  11482. SAMPLER3DGREENDEPTH: boolean;
  11483. SAMPLER3DBGRMAP: boolean;
  11484. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11485. }
  11486. /**
  11487. * @hidden
  11488. */
  11489. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11490. IMAGEPROCESSING: boolean;
  11491. VIGNETTE: boolean;
  11492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11493. VIGNETTEBLENDMODEOPAQUE: boolean;
  11494. TONEMAPPING: boolean;
  11495. TONEMAPPING_ACES: boolean;
  11496. CONTRAST: boolean;
  11497. COLORCURVES: boolean;
  11498. COLORGRADING: boolean;
  11499. COLORGRADING3D: boolean;
  11500. SAMPLER3DGREENDEPTH: boolean;
  11501. SAMPLER3DBGRMAP: boolean;
  11502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11503. EXPOSURE: boolean;
  11504. constructor();
  11505. }
  11506. /**
  11507. * This groups together the common properties used for image processing either in direct forward pass
  11508. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11509. * or not.
  11510. */
  11511. export class ImageProcessingConfiguration {
  11512. /**
  11513. * Default tone mapping applied in BabylonJS.
  11514. */
  11515. static readonly TONEMAPPING_STANDARD: number;
  11516. /**
  11517. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11518. * to other engines rendering to increase portability.
  11519. */
  11520. static readonly TONEMAPPING_ACES: number;
  11521. /**
  11522. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11523. */
  11524. colorCurves: Nullable<ColorCurves>;
  11525. private _colorCurvesEnabled;
  11526. /**
  11527. * Gets wether the color curves effect is enabled.
  11528. */
  11529. get colorCurvesEnabled(): boolean;
  11530. /**
  11531. * Sets wether the color curves effect is enabled.
  11532. */
  11533. set colorCurvesEnabled(value: boolean);
  11534. private _colorGradingTexture;
  11535. /**
  11536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11537. */
  11538. get colorGradingTexture(): Nullable<BaseTexture>;
  11539. /**
  11540. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11541. */
  11542. set colorGradingTexture(value: Nullable<BaseTexture>);
  11543. private _colorGradingEnabled;
  11544. /**
  11545. * Gets wether the color grading effect is enabled.
  11546. */
  11547. get colorGradingEnabled(): boolean;
  11548. /**
  11549. * Sets wether the color grading effect is enabled.
  11550. */
  11551. set colorGradingEnabled(value: boolean);
  11552. private _colorGradingWithGreenDepth;
  11553. /**
  11554. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11555. */
  11556. get colorGradingWithGreenDepth(): boolean;
  11557. /**
  11558. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11559. */
  11560. set colorGradingWithGreenDepth(value: boolean);
  11561. private _colorGradingBGR;
  11562. /**
  11563. * Gets wether the color grading texture contains BGR values.
  11564. */
  11565. get colorGradingBGR(): boolean;
  11566. /**
  11567. * Sets wether the color grading texture contains BGR values.
  11568. */
  11569. set colorGradingBGR(value: boolean);
  11570. /** @hidden */
  11571. _exposure: number;
  11572. /**
  11573. * Gets the Exposure used in the effect.
  11574. */
  11575. get exposure(): number;
  11576. /**
  11577. * Sets the Exposure used in the effect.
  11578. */
  11579. set exposure(value: number);
  11580. private _toneMappingEnabled;
  11581. /**
  11582. * Gets wether the tone mapping effect is enabled.
  11583. */
  11584. get toneMappingEnabled(): boolean;
  11585. /**
  11586. * Sets wether the tone mapping effect is enabled.
  11587. */
  11588. set toneMappingEnabled(value: boolean);
  11589. private _toneMappingType;
  11590. /**
  11591. * Gets the type of tone mapping effect.
  11592. */
  11593. get toneMappingType(): number;
  11594. /**
  11595. * Sets the type of tone mapping effect used in BabylonJS.
  11596. */
  11597. set toneMappingType(value: number);
  11598. protected _contrast: number;
  11599. /**
  11600. * Gets the contrast used in the effect.
  11601. */
  11602. get contrast(): number;
  11603. /**
  11604. * Sets the contrast used in the effect.
  11605. */
  11606. set contrast(value: number);
  11607. /**
  11608. * Vignette stretch size.
  11609. */
  11610. vignetteStretch: number;
  11611. /**
  11612. * Vignette centre X Offset.
  11613. */
  11614. vignetteCentreX: number;
  11615. /**
  11616. * Vignette centre Y Offset.
  11617. */
  11618. vignetteCentreY: number;
  11619. /**
  11620. * Vignette weight or intensity of the vignette effect.
  11621. */
  11622. vignetteWeight: number;
  11623. /**
  11624. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11625. * if vignetteEnabled is set to true.
  11626. */
  11627. vignetteColor: Color4;
  11628. /**
  11629. * Camera field of view used by the Vignette effect.
  11630. */
  11631. vignetteCameraFov: number;
  11632. private _vignetteBlendMode;
  11633. /**
  11634. * Gets the vignette blend mode allowing different kind of effect.
  11635. */
  11636. get vignetteBlendMode(): number;
  11637. /**
  11638. * Sets the vignette blend mode allowing different kind of effect.
  11639. */
  11640. set vignetteBlendMode(value: number);
  11641. private _vignetteEnabled;
  11642. /**
  11643. * Gets wether the vignette effect is enabled.
  11644. */
  11645. get vignetteEnabled(): boolean;
  11646. /**
  11647. * Sets wether the vignette effect is enabled.
  11648. */
  11649. set vignetteEnabled(value: boolean);
  11650. private _applyByPostProcess;
  11651. /**
  11652. * Gets wether the image processing is applied through a post process or not.
  11653. */
  11654. get applyByPostProcess(): boolean;
  11655. /**
  11656. * Sets wether the image processing is applied through a post process or not.
  11657. */
  11658. set applyByPostProcess(value: boolean);
  11659. private _isEnabled;
  11660. /**
  11661. * Gets wether the image processing is enabled or not.
  11662. */
  11663. get isEnabled(): boolean;
  11664. /**
  11665. * Sets wether the image processing is enabled or not.
  11666. */
  11667. set isEnabled(value: boolean);
  11668. /**
  11669. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11670. */
  11671. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11672. /**
  11673. * Method called each time the image processing information changes requires to recompile the effect.
  11674. */
  11675. protected _updateParameters(): void;
  11676. /**
  11677. * Gets the current class name.
  11678. * @return "ImageProcessingConfiguration"
  11679. */
  11680. getClassName(): string;
  11681. /**
  11682. * Prepare the list of uniforms associated with the Image Processing effects.
  11683. * @param uniforms The list of uniforms used in the effect
  11684. * @param defines the list of defines currently in use
  11685. */
  11686. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11687. /**
  11688. * Prepare the list of samplers associated with the Image Processing effects.
  11689. * @param samplersList The list of uniforms used in the effect
  11690. * @param defines the list of defines currently in use
  11691. */
  11692. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11693. /**
  11694. * Prepare the list of defines associated to the shader.
  11695. * @param defines the list of defines to complete
  11696. * @param forPostProcess Define if we are currently in post process mode or not
  11697. */
  11698. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11699. /**
  11700. * Returns true if all the image processing information are ready.
  11701. * @returns True if ready, otherwise, false
  11702. */
  11703. isReady(): boolean;
  11704. /**
  11705. * Binds the image processing to the shader.
  11706. * @param effect The effect to bind to
  11707. * @param overrideAspectRatio Override the aspect ratio of the effect
  11708. */
  11709. bind(effect: Effect, overrideAspectRatio?: number): void;
  11710. /**
  11711. * Clones the current image processing instance.
  11712. * @return The cloned image processing
  11713. */
  11714. clone(): ImageProcessingConfiguration;
  11715. /**
  11716. * Serializes the current image processing instance to a json representation.
  11717. * @return a JSON representation
  11718. */
  11719. serialize(): any;
  11720. /**
  11721. * Parses the image processing from a json representation.
  11722. * @param source the JSON source to parse
  11723. * @return The parsed image processing
  11724. */
  11725. static Parse(source: any): ImageProcessingConfiguration;
  11726. private static _VIGNETTEMODE_MULTIPLY;
  11727. private static _VIGNETTEMODE_OPAQUE;
  11728. /**
  11729. * Used to apply the vignette as a mix with the pixel color.
  11730. */
  11731. static get VIGNETTEMODE_MULTIPLY(): number;
  11732. /**
  11733. * Used to apply the vignette as a replacement of the pixel color.
  11734. */
  11735. static get VIGNETTEMODE_OPAQUE(): number;
  11736. }
  11737. }
  11738. declare module "babylonjs/Shaders/postprocess.vertex" {
  11739. /** @hidden */
  11740. export var postprocessVertexShader: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11747. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11748. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11749. /**
  11750. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11751. */
  11752. export type RenderTargetTextureSize = number | {
  11753. width: number;
  11754. height: number;
  11755. layers?: number;
  11756. };
  11757. module "babylonjs/Engines/thinEngine" {
  11758. interface ThinEngine {
  11759. /**
  11760. * Creates a new render target texture
  11761. * @param size defines the size of the texture
  11762. * @param options defines the options used to create the texture
  11763. * @returns a new render target texture stored in an InternalTexture
  11764. */
  11765. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11766. /**
  11767. * Creates a depth stencil texture.
  11768. * This is only available in WebGL 2 or with the depth texture extension available.
  11769. * @param size The size of face edge in the texture.
  11770. * @param options The options defining the texture.
  11771. * @returns The texture
  11772. */
  11773. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11774. /** @hidden */
  11775. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11776. }
  11777. }
  11778. }
  11779. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11780. /**
  11781. * Defines the kind of connection point for node based material
  11782. */
  11783. export enum NodeMaterialBlockConnectionPointTypes {
  11784. /** Float */
  11785. Float = 1,
  11786. /** Int */
  11787. Int = 2,
  11788. /** Vector2 */
  11789. Vector2 = 4,
  11790. /** Vector3 */
  11791. Vector3 = 8,
  11792. /** Vector4 */
  11793. Vector4 = 16,
  11794. /** Color3 */
  11795. Color3 = 32,
  11796. /** Color4 */
  11797. Color4 = 64,
  11798. /** Matrix */
  11799. Matrix = 128,
  11800. /** Custom object */
  11801. Object = 256,
  11802. /** Detect type based on connection */
  11803. AutoDetect = 1024,
  11804. /** Output type that will be defined by input type */
  11805. BasedOnInput = 2048
  11806. }
  11807. }
  11808. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11809. /**
  11810. * Enum used to define the target of a block
  11811. */
  11812. export enum NodeMaterialBlockTargets {
  11813. /** Vertex shader */
  11814. Vertex = 1,
  11815. /** Fragment shader */
  11816. Fragment = 2,
  11817. /** Neutral */
  11818. Neutral = 4,
  11819. /** Vertex and Fragment */
  11820. VertexAndFragment = 3
  11821. }
  11822. }
  11823. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11824. /**
  11825. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11826. */
  11827. export enum NodeMaterialBlockConnectionPointMode {
  11828. /** Value is an uniform */
  11829. Uniform = 0,
  11830. /** Value is a mesh attribute */
  11831. Attribute = 1,
  11832. /** Value is a varying between vertex and fragment shaders */
  11833. Varying = 2,
  11834. /** Mode is undefined */
  11835. Undefined = 3
  11836. }
  11837. }
  11838. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11839. /**
  11840. * Enum used to define system values e.g. values automatically provided by the system
  11841. */
  11842. export enum NodeMaterialSystemValues {
  11843. /** World */
  11844. World = 1,
  11845. /** View */
  11846. View = 2,
  11847. /** Projection */
  11848. Projection = 3,
  11849. /** ViewProjection */
  11850. ViewProjection = 4,
  11851. /** WorldView */
  11852. WorldView = 5,
  11853. /** WorldViewProjection */
  11854. WorldViewProjection = 6,
  11855. /** CameraPosition */
  11856. CameraPosition = 7,
  11857. /** Fog Color */
  11858. FogColor = 8,
  11859. /** Delta time */
  11860. DeltaTime = 9
  11861. }
  11862. }
  11863. declare module "babylonjs/Maths/math.frustum" {
  11864. import { Matrix } from "babylonjs/Maths/math.vector";
  11865. import { DeepImmutable } from "babylonjs/types";
  11866. import { Plane } from "babylonjs/Maths/math.plane";
  11867. /**
  11868. * Represents a camera frustum
  11869. */
  11870. export class Frustum {
  11871. /**
  11872. * Gets the planes representing the frustum
  11873. * @param transform matrix to be applied to the returned planes
  11874. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11875. */
  11876. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11877. /**
  11878. * Gets the near frustum plane transformed by the transform matrix
  11879. * @param transform transformation matrix to be applied to the resulting frustum plane
  11880. * @param frustumPlane the resuling frustum plane
  11881. */
  11882. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11883. /**
  11884. * Gets the far frustum plane transformed by the transform matrix
  11885. * @param transform transformation matrix to be applied to the resulting frustum plane
  11886. * @param frustumPlane the resuling frustum plane
  11887. */
  11888. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11889. /**
  11890. * Gets the left frustum plane transformed by the transform matrix
  11891. * @param transform transformation matrix to be applied to the resulting frustum plane
  11892. * @param frustumPlane the resuling frustum plane
  11893. */
  11894. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11895. /**
  11896. * Gets the right frustum plane transformed by the transform matrix
  11897. * @param transform transformation matrix to be applied to the resulting frustum plane
  11898. * @param frustumPlane the resuling frustum plane
  11899. */
  11900. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11901. /**
  11902. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11907. /**
  11908. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11913. /**
  11914. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11915. * @param transform transformation matrix to be applied to the resulting frustum planes
  11916. * @param frustumPlanes the resuling frustum planes
  11917. */
  11918. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11919. }
  11920. }
  11921. declare module "babylonjs/Maths/math.vertexFormat" {
  11922. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11923. /**
  11924. * Contains position and normal vectors for a vertex
  11925. */
  11926. export class PositionNormalVertex {
  11927. /** the position of the vertex (defaut: 0,0,0) */
  11928. position: Vector3;
  11929. /** the normal of the vertex (defaut: 0,1,0) */
  11930. normal: Vector3;
  11931. /**
  11932. * Creates a PositionNormalVertex
  11933. * @param position the position of the vertex (defaut: 0,0,0)
  11934. * @param normal the normal of the vertex (defaut: 0,1,0)
  11935. */
  11936. constructor(
  11937. /** the position of the vertex (defaut: 0,0,0) */
  11938. position?: Vector3,
  11939. /** the normal of the vertex (defaut: 0,1,0) */
  11940. normal?: Vector3);
  11941. /**
  11942. * Clones the PositionNormalVertex
  11943. * @returns the cloned PositionNormalVertex
  11944. */
  11945. clone(): PositionNormalVertex;
  11946. }
  11947. /**
  11948. * Contains position, normal and uv vectors for a vertex
  11949. */
  11950. export class PositionNormalTextureVertex {
  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. /** the uv of the vertex (default: 0,0) */
  11956. uv: Vector2;
  11957. /**
  11958. * Creates a PositionNormalTextureVertex
  11959. * @param position the position of the vertex (defaut: 0,0,0)
  11960. * @param normal the normal of the vertex (defaut: 0,1,0)
  11961. * @param uv the uv of the vertex (default: 0,0)
  11962. */
  11963. constructor(
  11964. /** the position of the vertex (defaut: 0,0,0) */
  11965. position?: Vector3,
  11966. /** the normal of the vertex (defaut: 0,1,0) */
  11967. normal?: Vector3,
  11968. /** the uv of the vertex (default: 0,0) */
  11969. uv?: Vector2);
  11970. /**
  11971. * Clones the PositionNormalTextureVertex
  11972. * @returns the cloned PositionNormalTextureVertex
  11973. */
  11974. clone(): PositionNormalTextureVertex;
  11975. }
  11976. }
  11977. declare module "babylonjs/Maths/math" {
  11978. export * from "babylonjs/Maths/math.axis";
  11979. export * from "babylonjs/Maths/math.color";
  11980. export * from "babylonjs/Maths/math.constants";
  11981. export * from "babylonjs/Maths/math.frustum";
  11982. export * from "babylonjs/Maths/math.path";
  11983. export * from "babylonjs/Maths/math.plane";
  11984. export * from "babylonjs/Maths/math.size";
  11985. export * from "babylonjs/Maths/math.vector";
  11986. export * from "babylonjs/Maths/math.vertexFormat";
  11987. export * from "babylonjs/Maths/math.viewport";
  11988. }
  11989. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  11990. /**
  11991. * Enum defining the type of animations supported by InputBlock
  11992. */
  11993. export enum AnimatedInputBlockTypes {
  11994. /** No animation */
  11995. None = 0,
  11996. /** Time based animation. Will only work for floats */
  11997. Time = 1
  11998. }
  11999. }
  12000. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12002. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12003. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12004. import { Nullable } from "babylonjs/types";
  12005. import { Effect } from "babylonjs/Materials/effect";
  12006. import { Matrix } from "babylonjs/Maths/math.vector";
  12007. import { Scene } from "babylonjs/scene";
  12008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12010. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12011. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12012. import { Observable } from "babylonjs/Misc/observable";
  12013. /**
  12014. * Block used to expose an input value
  12015. */
  12016. export class InputBlock extends NodeMaterialBlock {
  12017. private _mode;
  12018. private _associatedVariableName;
  12019. private _storedValue;
  12020. private _valueCallback;
  12021. private _type;
  12022. private _animationType;
  12023. /** Gets or set a value used to limit the range of float values */
  12024. min: number;
  12025. /** Gets or set a value used to limit the range of float values */
  12026. max: number;
  12027. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12028. isBoolean: boolean;
  12029. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12030. matrixMode: number;
  12031. /** @hidden */
  12032. _systemValue: Nullable<NodeMaterialSystemValues>;
  12033. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12034. isConstant: boolean;
  12035. /** Gets or sets the group to use to display this block in the Inspector */
  12036. groupInInspector: string;
  12037. /** Gets an observable raised when the value is changed */
  12038. onValueChangedObservable: Observable<InputBlock>;
  12039. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12040. convertToGammaSpace: boolean;
  12041. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12042. convertToLinearSpace: boolean;
  12043. /**
  12044. * Gets or sets the connection point type (default is float)
  12045. */
  12046. get type(): NodeMaterialBlockConnectionPointTypes;
  12047. /**
  12048. * Creates a new InputBlock
  12049. * @param name defines the block name
  12050. * @param target defines the target of that block (Vertex by default)
  12051. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12052. */
  12053. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12054. /**
  12055. * Validates if a name is a reserve word.
  12056. * @param newName the new name to be given to the node.
  12057. * @returns false if the name is a reserve word, else true.
  12058. */
  12059. validateBlockName(newName: string): boolean;
  12060. /**
  12061. * Gets the output component
  12062. */
  12063. get output(): NodeMaterialConnectionPoint;
  12064. /**
  12065. * Set the source of this connection point to a vertex attribute
  12066. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12067. * @returns the current connection point
  12068. */
  12069. setAsAttribute(attributeName?: string): InputBlock;
  12070. /**
  12071. * Set the source of this connection point to a system value
  12072. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12073. * @returns the current connection point
  12074. */
  12075. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12076. /**
  12077. * Gets or sets the value of that point.
  12078. * Please note that this value will be ignored if valueCallback is defined
  12079. */
  12080. get value(): any;
  12081. set value(value: any);
  12082. /**
  12083. * Gets or sets a callback used to get the value of that point.
  12084. * Please note that setting this value will force the connection point to ignore the value property
  12085. */
  12086. get valueCallback(): () => any;
  12087. set valueCallback(value: () => any);
  12088. /**
  12089. * Gets or sets the associated variable name in the shader
  12090. */
  12091. get associatedVariableName(): string;
  12092. set associatedVariableName(value: string);
  12093. /** Gets or sets the type of animation applied to the input */
  12094. get animationType(): AnimatedInputBlockTypes;
  12095. set animationType(value: AnimatedInputBlockTypes);
  12096. /**
  12097. * Gets a boolean indicating that this connection point not defined yet
  12098. */
  12099. get isUndefined(): boolean;
  12100. /**
  12101. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12102. * In this case the connection point name must be the name of the uniform to use.
  12103. * Can only be set on inputs
  12104. */
  12105. get isUniform(): boolean;
  12106. set isUniform(value: boolean);
  12107. /**
  12108. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12109. * In this case the connection point name must be the name of the attribute to use
  12110. * Can only be set on inputs
  12111. */
  12112. get isAttribute(): boolean;
  12113. set isAttribute(value: boolean);
  12114. /**
  12115. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12116. * Can only be set on exit points
  12117. */
  12118. get isVarying(): boolean;
  12119. set isVarying(value: boolean);
  12120. /**
  12121. * Gets a boolean indicating that the current connection point is a system value
  12122. */
  12123. get isSystemValue(): boolean;
  12124. /**
  12125. * Gets or sets the current well known value or null if not defined as a system value
  12126. */
  12127. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12128. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12129. /**
  12130. * Gets the current class name
  12131. * @returns the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Animate the input if animationType !== None
  12136. * @param scene defines the rendering scene
  12137. */
  12138. animate(scene: Scene): void;
  12139. private _emitDefine;
  12140. initialize(state: NodeMaterialBuildState): void;
  12141. /**
  12142. * Set the input block to its default value (based on its type)
  12143. */
  12144. setDefaultValue(): void;
  12145. private _emitConstant;
  12146. /** @hidden */
  12147. get _noContextSwitch(): boolean;
  12148. private _emit;
  12149. /** @hidden */
  12150. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12151. /** @hidden */
  12152. _transmit(effect: Effect, scene: Scene): void;
  12153. protected _buildBlock(state: NodeMaterialBuildState): void;
  12154. protected _dumpPropertiesCode(): string;
  12155. dispose(): void;
  12156. serialize(): any;
  12157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12158. }
  12159. }
  12160. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12161. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12162. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12163. import { Nullable } from "babylonjs/types";
  12164. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12165. import { Observable } from "babylonjs/Misc/observable";
  12166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12167. /**
  12168. * Enum used to define the compatibility state between two connection points
  12169. */
  12170. export enum NodeMaterialConnectionPointCompatibilityStates {
  12171. /** Points are compatibles */
  12172. Compatible = 0,
  12173. /** Points are incompatible because of their types */
  12174. TypeIncompatible = 1,
  12175. /** Points are incompatible because of their targets (vertex vs fragment) */
  12176. TargetIncompatible = 2
  12177. }
  12178. /**
  12179. * Defines the direction of a connection point
  12180. */
  12181. export enum NodeMaterialConnectionPointDirection {
  12182. /** Input */
  12183. Input = 0,
  12184. /** Output */
  12185. Output = 1
  12186. }
  12187. /**
  12188. * Defines a connection point for a block
  12189. */
  12190. export class NodeMaterialConnectionPoint {
  12191. /**
  12192. * Checks if two types are equivalent
  12193. * @param type1 type 1 to check
  12194. * @param type2 type 2 to check
  12195. * @returns true if both types are equivalent, else false
  12196. */
  12197. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12198. /** @hidden */
  12199. _ownerBlock: NodeMaterialBlock;
  12200. /** @hidden */
  12201. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12202. private _endpoints;
  12203. private _associatedVariableName;
  12204. private _direction;
  12205. /** @hidden */
  12206. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12207. /** @hidden */
  12208. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12209. /** @hidden */
  12210. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12211. private _type;
  12212. /** @hidden */
  12213. _enforceAssociatedVariableName: boolean;
  12214. /** Gets the direction of the point */
  12215. get direction(): NodeMaterialConnectionPointDirection;
  12216. /** Indicates that this connection point needs dual validation before being connected to another point */
  12217. needDualDirectionValidation: boolean;
  12218. /**
  12219. * Gets or sets the additional types supported by this connection point
  12220. */
  12221. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12222. /**
  12223. * Gets or sets the additional types excluded by this connection point
  12224. */
  12225. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12226. /**
  12227. * Observable triggered when this point is connected
  12228. */
  12229. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12230. /**
  12231. * Gets or sets the associated variable name in the shader
  12232. */
  12233. get associatedVariableName(): string;
  12234. set associatedVariableName(value: string);
  12235. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12236. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12237. /**
  12238. * Gets or sets the connection point type (default is float)
  12239. */
  12240. get type(): NodeMaterialBlockConnectionPointTypes;
  12241. set type(value: NodeMaterialBlockConnectionPointTypes);
  12242. /**
  12243. * Gets or sets the connection point name
  12244. */
  12245. name: string;
  12246. /**
  12247. * Gets or sets the connection point name
  12248. */
  12249. displayName: string;
  12250. /**
  12251. * Gets or sets a boolean indicating that this connection point can be omitted
  12252. */
  12253. isOptional: boolean;
  12254. /**
  12255. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12256. */
  12257. isExposedOnFrame: boolean;
  12258. /**
  12259. * Gets or sets number indicating the position that the port is exposed to on a frame
  12260. */
  12261. exposedPortPosition: number;
  12262. /**
  12263. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12264. */
  12265. define: string;
  12266. /** @hidden */
  12267. _prioritizeVertex: boolean;
  12268. private _target;
  12269. /** Gets or sets the target of that connection point */
  12270. get target(): NodeMaterialBlockTargets;
  12271. set target(value: NodeMaterialBlockTargets);
  12272. /**
  12273. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12274. */
  12275. get isConnected(): boolean;
  12276. /**
  12277. * Gets a boolean indicating that the current point is connected to an input block
  12278. */
  12279. get isConnectedToInputBlock(): boolean;
  12280. /**
  12281. * Gets a the connected input block (if any)
  12282. */
  12283. get connectInputBlock(): Nullable<InputBlock>;
  12284. /** Get the other side of the connection (if any) */
  12285. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12286. /** Get the block that owns this connection point */
  12287. get ownerBlock(): NodeMaterialBlock;
  12288. /** Get the block connected on the other side of this connection (if any) */
  12289. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12290. /** Get the block connected on the endpoints of this connection (if any) */
  12291. get connectedBlocks(): Array<NodeMaterialBlock>;
  12292. /** Gets the list of connected endpoints */
  12293. get endpoints(): NodeMaterialConnectionPoint[];
  12294. /** Gets a boolean indicating if that output point is connected to at least one input */
  12295. get hasEndpoints(): boolean;
  12296. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12297. get isConnectedInVertexShader(): boolean;
  12298. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12299. get isConnectedInFragmentShader(): boolean;
  12300. /**
  12301. * Creates a block suitable to be used as an input for this input point.
  12302. * If null is returned, a block based on the point type will be created.
  12303. * @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
  12304. */
  12305. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12306. /**
  12307. * Creates a new connection point
  12308. * @param name defines the connection point name
  12309. * @param ownerBlock defines the block hosting this connection point
  12310. * @param direction defines the direction of the connection point
  12311. */
  12312. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12313. /**
  12314. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12315. * @returns the class name
  12316. */
  12317. getClassName(): string;
  12318. /**
  12319. * Gets a boolean indicating if the current point can be connected to another point
  12320. * @param connectionPoint defines the other connection point
  12321. * @returns a boolean
  12322. */
  12323. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12324. /**
  12325. * Gets a number indicating if the current point can be connected to another point
  12326. * @param connectionPoint defines the other connection point
  12327. * @returns a number defining the compatibility state
  12328. */
  12329. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12330. /**
  12331. * Connect this point to another connection point
  12332. * @param connectionPoint defines the other connection point
  12333. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12334. * @returns the current connection point
  12335. */
  12336. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12337. /**
  12338. * Disconnect this point from one of his endpoint
  12339. * @param endpoint defines the other connection point
  12340. * @returns the current connection point
  12341. */
  12342. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12343. /**
  12344. * Serializes this point in a JSON representation
  12345. * @param isInput defines if the connection point is an input (default is true)
  12346. * @returns the serialized point object
  12347. */
  12348. serialize(isInput?: boolean): any;
  12349. /**
  12350. * Release resources
  12351. */
  12352. dispose(): void;
  12353. }
  12354. }
  12355. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12356. /**
  12357. * Enum used to define the material modes
  12358. */
  12359. export enum NodeMaterialModes {
  12360. /** Regular material */
  12361. Material = 0,
  12362. /** For post process */
  12363. PostProcess = 1,
  12364. /** For particle system */
  12365. Particle = 2,
  12366. /** For procedural texture */
  12367. ProceduralTexture = 3
  12368. }
  12369. }
  12370. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12371. /** @hidden */
  12372. export var helperFunctions: {
  12373. name: string;
  12374. shader: string;
  12375. };
  12376. }
  12377. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12380. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12383. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12384. import { Effect } from "babylonjs/Materials/effect";
  12385. import { Mesh } from "babylonjs/Meshes/mesh";
  12386. import { Nullable } from "babylonjs/types";
  12387. import { Texture } from "babylonjs/Materials/Textures/texture";
  12388. import { Scene } from "babylonjs/scene";
  12389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12390. /**
  12391. * Block used to read a texture from a sampler
  12392. */
  12393. export class TextureBlock extends NodeMaterialBlock {
  12394. private _defineName;
  12395. private _linearDefineName;
  12396. private _gammaDefineName;
  12397. private _tempTextureRead;
  12398. private _samplerName;
  12399. private _transformedUVName;
  12400. private _textureTransformName;
  12401. private _textureInfoName;
  12402. private _mainUVName;
  12403. private _mainUVDefineName;
  12404. private _fragmentOnly;
  12405. /**
  12406. * Gets or sets the texture associated with the node
  12407. */
  12408. texture: Nullable<Texture>;
  12409. /**
  12410. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12411. */
  12412. convertToGammaSpace: boolean;
  12413. /**
  12414. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12415. */
  12416. convertToLinearSpace: boolean;
  12417. /**
  12418. * Create a new TextureBlock
  12419. * @param name defines the block name
  12420. */
  12421. constructor(name: string, fragmentOnly?: boolean);
  12422. /**
  12423. * Gets the current class name
  12424. * @returns the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Gets the uv input component
  12429. */
  12430. get uv(): NodeMaterialConnectionPoint;
  12431. /**
  12432. * Gets the rgba output component
  12433. */
  12434. get rgba(): NodeMaterialConnectionPoint;
  12435. /**
  12436. * Gets the rgb output component
  12437. */
  12438. get rgb(): NodeMaterialConnectionPoint;
  12439. /**
  12440. * Gets the r output component
  12441. */
  12442. get r(): NodeMaterialConnectionPoint;
  12443. /**
  12444. * Gets the g output component
  12445. */
  12446. get g(): NodeMaterialConnectionPoint;
  12447. /**
  12448. * Gets the b output component
  12449. */
  12450. get b(): NodeMaterialConnectionPoint;
  12451. /**
  12452. * Gets the a output component
  12453. */
  12454. get a(): NodeMaterialConnectionPoint;
  12455. get target(): NodeMaterialBlockTargets;
  12456. autoConfigure(material: NodeMaterial): void;
  12457. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12459. isReady(): boolean;
  12460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12461. private get _isMixed();
  12462. private _injectVertexCode;
  12463. private _writeTextureRead;
  12464. private _writeOutput;
  12465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12466. protected _dumpPropertiesCode(): string;
  12467. serialize(): any;
  12468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12472. /** @hidden */
  12473. export var reflectionFunction: {
  12474. name: string;
  12475. shader: string;
  12476. };
  12477. }
  12478. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12485. import { Effect } from "babylonjs/Materials/effect";
  12486. import { Mesh } from "babylonjs/Meshes/mesh";
  12487. import { Nullable } from "babylonjs/types";
  12488. import { Scene } from "babylonjs/scene";
  12489. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12490. /**
  12491. * Base block used to read a reflection texture from a sampler
  12492. */
  12493. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12494. /** @hidden */
  12495. _define3DName: string;
  12496. /** @hidden */
  12497. _defineCubicName: string;
  12498. /** @hidden */
  12499. _defineExplicitName: string;
  12500. /** @hidden */
  12501. _defineProjectionName: string;
  12502. /** @hidden */
  12503. _defineLocalCubicName: string;
  12504. /** @hidden */
  12505. _defineSphericalName: string;
  12506. /** @hidden */
  12507. _definePlanarName: string;
  12508. /** @hidden */
  12509. _defineEquirectangularName: string;
  12510. /** @hidden */
  12511. _defineMirroredEquirectangularFixedName: string;
  12512. /** @hidden */
  12513. _defineEquirectangularFixedName: string;
  12514. /** @hidden */
  12515. _defineSkyboxName: string;
  12516. /** @hidden */
  12517. _defineOppositeZ: string;
  12518. /** @hidden */
  12519. _cubeSamplerName: string;
  12520. /** @hidden */
  12521. _2DSamplerName: string;
  12522. protected _positionUVWName: string;
  12523. protected _directionWName: string;
  12524. protected _reflectionVectorName: string;
  12525. /** @hidden */
  12526. _reflectionCoordsName: string;
  12527. /** @hidden */
  12528. _reflectionMatrixName: string;
  12529. protected _reflectionColorName: string;
  12530. /**
  12531. * Gets or sets the texture associated with the node
  12532. */
  12533. texture: Nullable<BaseTexture>;
  12534. /**
  12535. * Create a new ReflectionTextureBaseBlock
  12536. * @param name defines the block name
  12537. */
  12538. constructor(name: string);
  12539. /**
  12540. * Gets the current class name
  12541. * @returns the class name
  12542. */
  12543. getClassName(): string;
  12544. /**
  12545. * Gets the world position input component
  12546. */
  12547. abstract get position(): NodeMaterialConnectionPoint;
  12548. /**
  12549. * Gets the world position input component
  12550. */
  12551. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12552. /**
  12553. * Gets the world normal input component
  12554. */
  12555. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12556. /**
  12557. * Gets the world input component
  12558. */
  12559. abstract get world(): NodeMaterialConnectionPoint;
  12560. /**
  12561. * Gets the camera (or eye) position component
  12562. */
  12563. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12564. /**
  12565. * Gets the view input component
  12566. */
  12567. abstract get view(): NodeMaterialConnectionPoint;
  12568. protected _getTexture(): Nullable<BaseTexture>;
  12569. autoConfigure(material: NodeMaterial): void;
  12570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12571. isReady(): boolean;
  12572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12573. /**
  12574. * Gets the code to inject in the vertex shader
  12575. * @param state current state of the node material building
  12576. * @returns the shader code
  12577. */
  12578. handleVertexSide(state: NodeMaterialBuildState): string;
  12579. /**
  12580. * Handles the inits for the fragment code path
  12581. * @param state node material build state
  12582. */
  12583. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12584. /**
  12585. * Generates the reflection coords code for the fragment code path
  12586. * @param worldNormalVarName name of the world normal variable
  12587. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12588. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12589. * @returns the shader code
  12590. */
  12591. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12592. /**
  12593. * Generates the reflection color code for the fragment code path
  12594. * @param lodVarName name of the lod variable
  12595. * @param swizzleLookupTexture swizzle to use for the final color variable
  12596. * @returns the shader code
  12597. */
  12598. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12599. /**
  12600. * Generates the code corresponding to the connected output points
  12601. * @param state node material build state
  12602. * @param varName name of the variable to output
  12603. * @returns the shader code
  12604. */
  12605. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12606. protected _buildBlock(state: NodeMaterialBuildState): this;
  12607. protected _dumpPropertiesCode(): string;
  12608. serialize(): any;
  12609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12610. }
  12611. }
  12612. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12614. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12615. import { Nullable } from "babylonjs/types";
  12616. /**
  12617. * Defines a connection point to be used for points with a custom object type
  12618. */
  12619. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12620. private _blockType;
  12621. private _blockName;
  12622. private _nameForCheking?;
  12623. /**
  12624. * Creates a new connection point
  12625. * @param name defines the connection point name
  12626. * @param ownerBlock defines the block hosting this connection point
  12627. * @param direction defines the direction of the connection point
  12628. */
  12629. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12630. /**
  12631. * Gets a number indicating if the current point can be connected to another point
  12632. * @param connectionPoint defines the other connection point
  12633. * @returns a number defining the compatibility state
  12634. */
  12635. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12636. /**
  12637. * Creates a block suitable to be used as an input for this input point.
  12638. * If null is returned, a block based on the point type will be created.
  12639. * @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
  12640. */
  12641. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12642. }
  12643. }
  12644. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12645. /**
  12646. * Enum defining the type of properties that can be edited in the property pages in the NME
  12647. */
  12648. export enum PropertyTypeForEdition {
  12649. /** property is a boolean */
  12650. Boolean = 0,
  12651. /** property is a float */
  12652. Float = 1,
  12653. /** property is a Vector2 */
  12654. Vector2 = 2,
  12655. /** property is a list of values */
  12656. List = 3
  12657. }
  12658. /**
  12659. * Interface that defines an option in a variable of type list
  12660. */
  12661. export interface IEditablePropertyListOption {
  12662. /** label of the option */
  12663. "label": string;
  12664. /** value of the option */
  12665. "value": number;
  12666. }
  12667. /**
  12668. * Interface that defines the options available for an editable property
  12669. */
  12670. export interface IEditablePropertyOption {
  12671. /** min value */
  12672. "min"?: number;
  12673. /** max value */
  12674. "max"?: number;
  12675. /** notifiers: indicates which actions to take when the property is changed */
  12676. "notifiers"?: {
  12677. /** the material should be rebuilt */
  12678. "rebuild"?: boolean;
  12679. /** the preview should be updated */
  12680. "update"?: boolean;
  12681. };
  12682. /** list of the options for a variable of type list */
  12683. "options"?: IEditablePropertyListOption[];
  12684. }
  12685. /**
  12686. * Interface that describes an editable property
  12687. */
  12688. export interface IPropertyDescriptionForEdition {
  12689. /** name of the property */
  12690. "propertyName": string;
  12691. /** display name of the property */
  12692. "displayName": string;
  12693. /** type of the property */
  12694. "type": PropertyTypeForEdition;
  12695. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12696. "groupName": string;
  12697. /** options for the property */
  12698. "options": IEditablePropertyOption;
  12699. }
  12700. /**
  12701. * Decorator that flags a property in a node material block as being editable
  12702. */
  12703. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12704. }
  12705. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12708. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12710. import { Nullable } from "babylonjs/types";
  12711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12712. import { Mesh } from "babylonjs/Meshes/mesh";
  12713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12714. import { Effect } from "babylonjs/Materials/effect";
  12715. import { Scene } from "babylonjs/scene";
  12716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12717. /**
  12718. * Block used to implement the refraction part of the sub surface module of the PBR material
  12719. */
  12720. export class RefractionBlock extends NodeMaterialBlock {
  12721. /** @hidden */
  12722. _define3DName: string;
  12723. /** @hidden */
  12724. _refractionMatrixName: string;
  12725. /** @hidden */
  12726. _defineLODRefractionAlpha: string;
  12727. /** @hidden */
  12728. _defineLinearSpecularRefraction: string;
  12729. /** @hidden */
  12730. _defineOppositeZ: string;
  12731. /** @hidden */
  12732. _cubeSamplerName: string;
  12733. /** @hidden */
  12734. _2DSamplerName: string;
  12735. /** @hidden */
  12736. _vRefractionMicrosurfaceInfosName: string;
  12737. /** @hidden */
  12738. _vRefractionInfosName: string;
  12739. /** @hidden */
  12740. _vRefractionFilteringInfoName: string;
  12741. private _scene;
  12742. /**
  12743. * The properties below are set by the main PBR block prior to calling methods of this class.
  12744. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12745. * It's less burden on the user side in the editor part.
  12746. */
  12747. /** @hidden */
  12748. viewConnectionPoint: NodeMaterialConnectionPoint;
  12749. /** @hidden */
  12750. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12751. /**
  12752. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12753. * Materials half opaque for instance using refraction could benefit from this control.
  12754. */
  12755. linkRefractionWithTransparency: boolean;
  12756. /**
  12757. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12758. */
  12759. invertRefractionY: boolean;
  12760. /**
  12761. * Gets or sets the texture associated with the node
  12762. */
  12763. texture: Nullable<BaseTexture>;
  12764. /**
  12765. * Create a new RefractionBlock
  12766. * @param name defines the block name
  12767. */
  12768. constructor(name: string);
  12769. /**
  12770. * Gets the current class name
  12771. * @returns the class name
  12772. */
  12773. getClassName(): string;
  12774. /**
  12775. * Gets the intensity input component
  12776. */
  12777. get intensity(): NodeMaterialConnectionPoint;
  12778. /**
  12779. * Gets the tint at distance input component
  12780. */
  12781. get tintAtDistance(): NodeMaterialConnectionPoint;
  12782. /**
  12783. * Gets the view input component
  12784. */
  12785. get view(): NodeMaterialConnectionPoint;
  12786. /**
  12787. * Gets the refraction object output component
  12788. */
  12789. get refraction(): NodeMaterialConnectionPoint;
  12790. /**
  12791. * Returns true if the block has a texture
  12792. */
  12793. get hasTexture(): boolean;
  12794. protected _getTexture(): Nullable<BaseTexture>;
  12795. autoConfigure(material: NodeMaterial): void;
  12796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12797. isReady(): boolean;
  12798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12799. /**
  12800. * Gets the main code of the block (fragment side)
  12801. * @param state current state of the node material building
  12802. * @returns the shader code
  12803. */
  12804. getCode(state: NodeMaterialBuildState): string;
  12805. protected _buildBlock(state: NodeMaterialBuildState): this;
  12806. protected _dumpPropertiesCode(): string;
  12807. serialize(): any;
  12808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12809. }
  12810. }
  12811. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12814. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12817. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12819. import { Nullable } from "babylonjs/types";
  12820. import { Scene } from "babylonjs/scene";
  12821. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12822. /**
  12823. * Base block used as input for post process
  12824. */
  12825. export class CurrentScreenBlock extends NodeMaterialBlock {
  12826. private _samplerName;
  12827. private _linearDefineName;
  12828. private _gammaDefineName;
  12829. private _mainUVName;
  12830. private _tempTextureRead;
  12831. /**
  12832. * Gets or sets the texture associated with the node
  12833. */
  12834. texture: Nullable<BaseTexture>;
  12835. /**
  12836. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12837. */
  12838. convertToGammaSpace: boolean;
  12839. /**
  12840. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12841. */
  12842. convertToLinearSpace: boolean;
  12843. /**
  12844. * Create a new CurrentScreenBlock
  12845. * @param name defines the block name
  12846. */
  12847. constructor(name: string);
  12848. /**
  12849. * Gets the current class name
  12850. * @returns the class name
  12851. */
  12852. getClassName(): string;
  12853. /**
  12854. * Gets the uv input component
  12855. */
  12856. get uv(): NodeMaterialConnectionPoint;
  12857. /**
  12858. * Gets the rgba output component
  12859. */
  12860. get rgba(): NodeMaterialConnectionPoint;
  12861. /**
  12862. * Gets the rgb output component
  12863. */
  12864. get rgb(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the r output component
  12867. */
  12868. get r(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Gets the g output component
  12871. */
  12872. get g(): NodeMaterialConnectionPoint;
  12873. /**
  12874. * Gets the b output component
  12875. */
  12876. get b(): NodeMaterialConnectionPoint;
  12877. /**
  12878. * Gets the a output component
  12879. */
  12880. get a(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Initialize the block and prepare the context for build
  12883. * @param state defines the state that will be used for the build
  12884. */
  12885. initialize(state: NodeMaterialBuildState): void;
  12886. get target(): NodeMaterialBlockTargets;
  12887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12888. isReady(): boolean;
  12889. private _injectVertexCode;
  12890. private _writeTextureRead;
  12891. private _writeOutput;
  12892. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12893. serialize(): any;
  12894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12895. }
  12896. }
  12897. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12902. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12904. import { Nullable } from "babylonjs/types";
  12905. import { Scene } from "babylonjs/scene";
  12906. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12907. /**
  12908. * Base block used for the particle texture
  12909. */
  12910. export class ParticleTextureBlock extends NodeMaterialBlock {
  12911. private _samplerName;
  12912. private _linearDefineName;
  12913. private _gammaDefineName;
  12914. private _tempTextureRead;
  12915. /**
  12916. * Gets or sets the texture associated with the node
  12917. */
  12918. texture: Nullable<BaseTexture>;
  12919. /**
  12920. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12921. */
  12922. convertToGammaSpace: boolean;
  12923. /**
  12924. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12925. */
  12926. convertToLinearSpace: boolean;
  12927. /**
  12928. * Create a new ParticleTextureBlock
  12929. * @param name defines the block name
  12930. */
  12931. constructor(name: string);
  12932. /**
  12933. * Gets the current class name
  12934. * @returns the class name
  12935. */
  12936. getClassName(): string;
  12937. /**
  12938. * Gets the uv input component
  12939. */
  12940. get uv(): NodeMaterialConnectionPoint;
  12941. /**
  12942. * Gets the rgba output component
  12943. */
  12944. get rgba(): NodeMaterialConnectionPoint;
  12945. /**
  12946. * Gets the rgb output component
  12947. */
  12948. get rgb(): NodeMaterialConnectionPoint;
  12949. /**
  12950. * Gets the r output component
  12951. */
  12952. get r(): NodeMaterialConnectionPoint;
  12953. /**
  12954. * Gets the g output component
  12955. */
  12956. get g(): NodeMaterialConnectionPoint;
  12957. /**
  12958. * Gets the b output component
  12959. */
  12960. get b(): NodeMaterialConnectionPoint;
  12961. /**
  12962. * Gets the a output component
  12963. */
  12964. get a(): NodeMaterialConnectionPoint;
  12965. /**
  12966. * Initialize the block and prepare the context for build
  12967. * @param state defines the state that will be used for the build
  12968. */
  12969. initialize(state: NodeMaterialBuildState): void;
  12970. autoConfigure(material: NodeMaterial): void;
  12971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12972. isReady(): boolean;
  12973. private _writeOutput;
  12974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12975. serialize(): any;
  12976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12977. }
  12978. }
  12979. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  12980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12982. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12983. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  12984. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  12985. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  12986. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  12987. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  12988. import { Scene } from "babylonjs/scene";
  12989. /**
  12990. * Class used to store shared data between 2 NodeMaterialBuildState
  12991. */
  12992. export class NodeMaterialBuildStateSharedData {
  12993. /**
  12994. * Gets the list of emitted varyings
  12995. */
  12996. temps: string[];
  12997. /**
  12998. * Gets the list of emitted varyings
  12999. */
  13000. varyings: string[];
  13001. /**
  13002. * Gets the varying declaration string
  13003. */
  13004. varyingDeclaration: string;
  13005. /**
  13006. * Input blocks
  13007. */
  13008. inputBlocks: InputBlock[];
  13009. /**
  13010. * Input blocks
  13011. */
  13012. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13013. /**
  13014. * Bindable blocks (Blocks that need to set data to the effect)
  13015. */
  13016. bindableBlocks: NodeMaterialBlock[];
  13017. /**
  13018. * List of blocks that can provide a compilation fallback
  13019. */
  13020. blocksWithFallbacks: NodeMaterialBlock[];
  13021. /**
  13022. * List of blocks that can provide a define update
  13023. */
  13024. blocksWithDefines: NodeMaterialBlock[];
  13025. /**
  13026. * List of blocks that can provide a repeatable content
  13027. */
  13028. repeatableContentBlocks: NodeMaterialBlock[];
  13029. /**
  13030. * List of blocks that can provide a dynamic list of uniforms
  13031. */
  13032. dynamicUniformBlocks: NodeMaterialBlock[];
  13033. /**
  13034. * List of blocks that can block the isReady function for the material
  13035. */
  13036. blockingBlocks: NodeMaterialBlock[];
  13037. /**
  13038. * Gets the list of animated inputs
  13039. */
  13040. animatedInputs: InputBlock[];
  13041. /**
  13042. * Build Id used to avoid multiple recompilations
  13043. */
  13044. buildId: number;
  13045. /** List of emitted variables */
  13046. variableNames: {
  13047. [key: string]: number;
  13048. };
  13049. /** List of emitted defines */
  13050. defineNames: {
  13051. [key: string]: number;
  13052. };
  13053. /** Should emit comments? */
  13054. emitComments: boolean;
  13055. /** Emit build activity */
  13056. verbose: boolean;
  13057. /** Gets or sets the hosting scene */
  13058. scene: Scene;
  13059. /**
  13060. * Gets the compilation hints emitted at compilation time
  13061. */
  13062. hints: {
  13063. needWorldViewMatrix: boolean;
  13064. needWorldViewProjectionMatrix: boolean;
  13065. needAlphaBlending: boolean;
  13066. needAlphaTesting: boolean;
  13067. };
  13068. /**
  13069. * List of compilation checks
  13070. */
  13071. checks: {
  13072. emitVertex: boolean;
  13073. emitFragment: boolean;
  13074. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13075. };
  13076. /**
  13077. * Is vertex program allowed to be empty?
  13078. */
  13079. allowEmptyVertexProgram: boolean;
  13080. /** Creates a new shared data */
  13081. constructor();
  13082. /**
  13083. * Emits console errors and exceptions if there is a failing check
  13084. */
  13085. emitErrors(): void;
  13086. }
  13087. }
  13088. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13089. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13090. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13091. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13092. /**
  13093. * Class used to store node based material build state
  13094. */
  13095. export class NodeMaterialBuildState {
  13096. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13097. supportUniformBuffers: boolean;
  13098. /**
  13099. * Gets the list of emitted attributes
  13100. */
  13101. attributes: string[];
  13102. /**
  13103. * Gets the list of emitted uniforms
  13104. */
  13105. uniforms: string[];
  13106. /**
  13107. * Gets the list of emitted constants
  13108. */
  13109. constants: string[];
  13110. /**
  13111. * Gets the list of emitted samplers
  13112. */
  13113. samplers: string[];
  13114. /**
  13115. * Gets the list of emitted functions
  13116. */
  13117. functions: {
  13118. [key: string]: string;
  13119. };
  13120. /**
  13121. * Gets the list of emitted extensions
  13122. */
  13123. extensions: {
  13124. [key: string]: string;
  13125. };
  13126. /**
  13127. * Gets the target of the compilation state
  13128. */
  13129. target: NodeMaterialBlockTargets;
  13130. /**
  13131. * Gets the list of emitted counters
  13132. */
  13133. counters: {
  13134. [key: string]: number;
  13135. };
  13136. /**
  13137. * Shared data between multiple NodeMaterialBuildState instances
  13138. */
  13139. sharedData: NodeMaterialBuildStateSharedData;
  13140. /** @hidden */
  13141. _vertexState: NodeMaterialBuildState;
  13142. /** @hidden */
  13143. _attributeDeclaration: string;
  13144. /** @hidden */
  13145. _uniformDeclaration: string;
  13146. /** @hidden */
  13147. _constantDeclaration: string;
  13148. /** @hidden */
  13149. _samplerDeclaration: string;
  13150. /** @hidden */
  13151. _varyingTransfer: string;
  13152. /** @hidden */
  13153. _injectAtEnd: string;
  13154. private _repeatableContentAnchorIndex;
  13155. /** @hidden */
  13156. _builtCompilationString: string;
  13157. /**
  13158. * Gets the emitted compilation strings
  13159. */
  13160. compilationString: string;
  13161. /**
  13162. * Finalize the compilation strings
  13163. * @param state defines the current compilation state
  13164. */
  13165. finalize(state: NodeMaterialBuildState): void;
  13166. /** @hidden */
  13167. get _repeatableContentAnchor(): string;
  13168. /** @hidden */
  13169. _getFreeVariableName(prefix: string): string;
  13170. /** @hidden */
  13171. _getFreeDefineName(prefix: string): string;
  13172. /** @hidden */
  13173. _excludeVariableName(name: string): void;
  13174. /** @hidden */
  13175. _emit2DSampler(name: string): void;
  13176. /** @hidden */
  13177. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13178. /** @hidden */
  13179. _emitExtension(name: string, extension: string, define?: string): void;
  13180. /** @hidden */
  13181. _emitFunction(name: string, code: string, comments: string): void;
  13182. /** @hidden */
  13183. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13184. replaceStrings?: {
  13185. search: RegExp;
  13186. replace: string;
  13187. }[];
  13188. repeatKey?: string;
  13189. }): string;
  13190. /** @hidden */
  13191. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13192. repeatKey?: string;
  13193. removeAttributes?: boolean;
  13194. removeUniforms?: boolean;
  13195. removeVaryings?: boolean;
  13196. removeIfDef?: boolean;
  13197. replaceStrings?: {
  13198. search: RegExp;
  13199. replace: string;
  13200. }[];
  13201. }, storeKey?: string): void;
  13202. /** @hidden */
  13203. _registerTempVariable(name: string): boolean;
  13204. /** @hidden */
  13205. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13206. /** @hidden */
  13207. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13208. /** @hidden */
  13209. _emitFloat(value: number): string;
  13210. }
  13211. }
  13212. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13213. /**
  13214. * Helper class used to generate session unique ID
  13215. */
  13216. export class UniqueIdGenerator {
  13217. private static _UniqueIdCounter;
  13218. /**
  13219. * Gets an unique (relatively to the current scene) Id
  13220. */
  13221. static get UniqueId(): number;
  13222. }
  13223. }
  13224. declare module "babylonjs/Materials/effectFallbacks" {
  13225. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13226. import { Effect } from "babylonjs/Materials/effect";
  13227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13228. /**
  13229. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13230. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13231. */
  13232. export class EffectFallbacks implements IEffectFallbacks {
  13233. private _defines;
  13234. private _currentRank;
  13235. private _maxRank;
  13236. private _mesh;
  13237. /**
  13238. * Removes the fallback from the bound mesh.
  13239. */
  13240. unBindMesh(): void;
  13241. /**
  13242. * Adds a fallback on the specified property.
  13243. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13244. * @param define The name of the define in the shader
  13245. */
  13246. addFallback(rank: number, define: string): void;
  13247. /**
  13248. * Sets the mesh to use CPU skinning when needing to fallback.
  13249. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13250. * @param mesh The mesh to use the fallbacks.
  13251. */
  13252. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13253. /**
  13254. * Checks to see if more fallbacks are still availible.
  13255. */
  13256. get hasMoreFallbacks(): boolean;
  13257. /**
  13258. * Removes the defines that should be removed when falling back.
  13259. * @param currentDefines defines the current define statements for the shader.
  13260. * @param effect defines the current effect we try to compile
  13261. * @returns The resulting defines with defines of the current rank removed.
  13262. */
  13263. reduce(currentDefines: string, effect: Effect): string;
  13264. }
  13265. }
  13266. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13267. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13269. import { Nullable } from "babylonjs/types";
  13270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13271. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13272. import { Effect } from "babylonjs/Materials/effect";
  13273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13274. import { Mesh } from "babylonjs/Meshes/mesh";
  13275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13276. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13277. import { Scene } from "babylonjs/scene";
  13278. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13279. /**
  13280. * Defines a block that can be used inside a node based material
  13281. */
  13282. export class NodeMaterialBlock {
  13283. private _buildId;
  13284. private _buildTarget;
  13285. private _target;
  13286. private _isFinalMerger;
  13287. private _isInput;
  13288. private _name;
  13289. protected _isUnique: boolean;
  13290. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13291. inputsAreExclusive: boolean;
  13292. /** @hidden */
  13293. _codeVariableName: string;
  13294. /** @hidden */
  13295. _inputs: NodeMaterialConnectionPoint[];
  13296. /** @hidden */
  13297. _outputs: NodeMaterialConnectionPoint[];
  13298. /** @hidden */
  13299. _preparationId: number;
  13300. /**
  13301. * Gets the name of the block
  13302. */
  13303. get name(): string;
  13304. /**
  13305. * Sets the name of the block. Will check if the name is valid.
  13306. */
  13307. set name(newName: string);
  13308. /**
  13309. * Gets or sets the unique id of the node
  13310. */
  13311. uniqueId: number;
  13312. /**
  13313. * Gets or sets the comments associated with this block
  13314. */
  13315. comments: string;
  13316. /**
  13317. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13318. */
  13319. get isUnique(): boolean;
  13320. /**
  13321. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13322. */
  13323. get isFinalMerger(): boolean;
  13324. /**
  13325. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13326. */
  13327. get isInput(): boolean;
  13328. /**
  13329. * Gets or sets the build Id
  13330. */
  13331. get buildId(): number;
  13332. set buildId(value: number);
  13333. /**
  13334. * Gets or sets the target of the block
  13335. */
  13336. get target(): NodeMaterialBlockTargets;
  13337. set target(value: NodeMaterialBlockTargets);
  13338. /**
  13339. * Gets the list of input points
  13340. */
  13341. get inputs(): NodeMaterialConnectionPoint[];
  13342. /** Gets the list of output points */
  13343. get outputs(): NodeMaterialConnectionPoint[];
  13344. /**
  13345. * Find an input by its name
  13346. * @param name defines the name of the input to look for
  13347. * @returns the input or null if not found
  13348. */
  13349. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13350. /**
  13351. * Find an output by its name
  13352. * @param name defines the name of the outputto look for
  13353. * @returns the output or null if not found
  13354. */
  13355. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13356. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13357. visibleInInspector: boolean;
  13358. /**
  13359. * Creates a new NodeMaterialBlock
  13360. * @param name defines the block name
  13361. * @param target defines the target of that block (Vertex by default)
  13362. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13363. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13364. */
  13365. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13366. /**
  13367. * Initialize the block and prepare the context for build
  13368. * @param state defines the state that will be used for the build
  13369. */
  13370. initialize(state: NodeMaterialBuildState): void;
  13371. /**
  13372. * Bind data to effect. Will only be called for blocks with isBindable === true
  13373. * @param effect defines the effect to bind data to
  13374. * @param nodeMaterial defines the hosting NodeMaterial
  13375. * @param mesh defines the mesh that will be rendered
  13376. * @param subMesh defines the submesh that will be rendered
  13377. */
  13378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13379. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13380. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13381. protected _writeFloat(value: number): string;
  13382. /**
  13383. * Gets the current class name e.g. "NodeMaterialBlock"
  13384. * @returns the class name
  13385. */
  13386. getClassName(): string;
  13387. /**
  13388. * Register a new input. Must be called inside a block constructor
  13389. * @param name defines the connection point name
  13390. * @param type defines the connection point type
  13391. * @param isOptional defines a boolean indicating that this input can be omitted
  13392. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13393. * @param point an already created connection point. If not provided, create a new one
  13394. * @returns the current block
  13395. */
  13396. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13397. /**
  13398. * Register a new output. Must be called inside a block constructor
  13399. * @param name defines the connection point name
  13400. * @param type defines the connection point type
  13401. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13402. * @param point an already created connection point. If not provided, create a new one
  13403. * @returns the current block
  13404. */
  13405. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13406. /**
  13407. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13408. * @param forOutput defines an optional connection point to check compatibility with
  13409. * @returns the first available input or null
  13410. */
  13411. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13412. /**
  13413. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13414. * @param forBlock defines an optional block to check compatibility with
  13415. * @returns the first available input or null
  13416. */
  13417. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13418. /**
  13419. * Gets the sibling of the given output
  13420. * @param current defines the current output
  13421. * @returns the next output in the list or null
  13422. */
  13423. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13424. /**
  13425. * Connect current block with another block
  13426. * @param other defines the block to connect with
  13427. * @param options define the various options to help pick the right connections
  13428. * @returns the current block
  13429. */
  13430. connectTo(other: NodeMaterialBlock, options?: {
  13431. input?: string;
  13432. output?: string;
  13433. outputSwizzle?: string;
  13434. }): this | undefined;
  13435. protected _buildBlock(state: NodeMaterialBuildState): void;
  13436. /**
  13437. * Add uniforms, samplers and uniform buffers at compilation time
  13438. * @param state defines the state to update
  13439. * @param nodeMaterial defines the node material requesting the update
  13440. * @param defines defines the material defines to update
  13441. * @param uniformBuffers defines the list of uniform buffer names
  13442. */
  13443. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13444. /**
  13445. * Add potential fallbacks if shader compilation fails
  13446. * @param mesh defines the mesh to be rendered
  13447. * @param fallbacks defines the current prioritized list of fallbacks
  13448. */
  13449. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13450. /**
  13451. * Initialize defines for shader compilation
  13452. * @param mesh defines the mesh to be rendered
  13453. * @param nodeMaterial defines the node material requesting the update
  13454. * @param defines defines the material defines to update
  13455. * @param useInstances specifies that instances should be used
  13456. */
  13457. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13458. /**
  13459. * Update defines for shader compilation
  13460. * @param mesh defines the mesh to be rendered
  13461. * @param nodeMaterial defines the node material requesting the update
  13462. * @param defines defines the material defines to update
  13463. * @param useInstances specifies that instances should be used
  13464. * @param subMesh defines which submesh to render
  13465. */
  13466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13467. /**
  13468. * Lets the block try to connect some inputs automatically
  13469. * @param material defines the hosting NodeMaterial
  13470. */
  13471. autoConfigure(material: NodeMaterial): void;
  13472. /**
  13473. * Function called when a block is declared as repeatable content generator
  13474. * @param vertexShaderState defines the current compilation state for the vertex shader
  13475. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13476. * @param mesh defines the mesh to be rendered
  13477. * @param defines defines the material defines to update
  13478. */
  13479. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13480. /**
  13481. * Checks if the block is ready
  13482. * @param mesh defines the mesh to be rendered
  13483. * @param nodeMaterial defines the node material requesting the update
  13484. * @param defines defines the material defines to update
  13485. * @param useInstances specifies that instances should be used
  13486. * @returns true if the block is ready
  13487. */
  13488. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13489. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13490. private _processBuild;
  13491. /**
  13492. * Validates the new name for the block node.
  13493. * @param newName the new name to be given to the node.
  13494. * @returns false if the name is a reserve word, else true.
  13495. */
  13496. validateBlockName(newName: string): boolean;
  13497. /**
  13498. * Compile the current node and generate the shader code
  13499. * @param state defines the current compilation state (uniforms, samplers, current string)
  13500. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13501. * @returns true if already built
  13502. */
  13503. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13504. protected _inputRename(name: string): string;
  13505. protected _outputRename(name: string): string;
  13506. protected _dumpPropertiesCode(): string;
  13507. /** @hidden */
  13508. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13509. /** @hidden */
  13510. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13511. /**
  13512. * Clone the current block to a new identical block
  13513. * @param scene defines the hosting scene
  13514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13515. * @returns a copy of the current block
  13516. */
  13517. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13518. /**
  13519. * Serializes this block in a JSON representation
  13520. * @returns the serialized block object
  13521. */
  13522. serialize(): any;
  13523. /** @hidden */
  13524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13525. private _deserializePortDisplayNamesAndExposedOnFrame;
  13526. /**
  13527. * Release resources
  13528. */
  13529. dispose(): void;
  13530. }
  13531. }
  13532. declare module "babylonjs/Materials/pushMaterial" {
  13533. import { Nullable } from "babylonjs/types";
  13534. import { Scene } from "babylonjs/scene";
  13535. import { Matrix } from "babylonjs/Maths/math.vector";
  13536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13537. import { Mesh } from "babylonjs/Meshes/mesh";
  13538. import { Material } from "babylonjs/Materials/material";
  13539. import { Effect } from "babylonjs/Materials/effect";
  13540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13541. /**
  13542. * Base class of materials working in push mode in babylon JS
  13543. * @hidden
  13544. */
  13545. export class PushMaterial extends Material {
  13546. protected _activeEffect: Effect;
  13547. protected _normalMatrix: Matrix;
  13548. constructor(name: string, scene: Scene);
  13549. getEffect(): Effect;
  13550. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13551. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13552. /**
  13553. * Binds the given world matrix to the active effect
  13554. *
  13555. * @param world the matrix to bind
  13556. */
  13557. bindOnlyWorldMatrix(world: Matrix): void;
  13558. /**
  13559. * Binds the given normal matrix to the active effect
  13560. *
  13561. * @param normalMatrix the matrix to bind
  13562. */
  13563. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13564. bind(world: Matrix, mesh?: Mesh): void;
  13565. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13566. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13567. }
  13568. }
  13569. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13571. /**
  13572. * Root class for all node material optimizers
  13573. */
  13574. export class NodeMaterialOptimizer {
  13575. /**
  13576. * Function used to optimize a NodeMaterial graph
  13577. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13578. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13579. */
  13580. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13587. import { Scene } from "babylonjs/scene";
  13588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13591. /**
  13592. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13593. */
  13594. export class TransformBlock extends NodeMaterialBlock {
  13595. /**
  13596. * Defines the value to use to complement W value to transform it to a Vector4
  13597. */
  13598. complementW: number;
  13599. /**
  13600. * Defines the value to use to complement z value to transform it to a Vector4
  13601. */
  13602. complementZ: number;
  13603. /**
  13604. * Creates a new TransformBlock
  13605. * @param name defines the block name
  13606. */
  13607. constructor(name: string);
  13608. /**
  13609. * Gets the current class name
  13610. * @returns the class name
  13611. */
  13612. getClassName(): string;
  13613. /**
  13614. * Gets the vector input
  13615. */
  13616. get vector(): NodeMaterialConnectionPoint;
  13617. /**
  13618. * Gets the output component
  13619. */
  13620. get output(): NodeMaterialConnectionPoint;
  13621. /**
  13622. * Gets the xyz output component
  13623. */
  13624. get xyz(): NodeMaterialConnectionPoint;
  13625. /**
  13626. * Gets the matrix transform input
  13627. */
  13628. get transform(): NodeMaterialConnectionPoint;
  13629. protected _buildBlock(state: NodeMaterialBuildState): this;
  13630. /**
  13631. * Update defines for shader compilation
  13632. * @param mesh defines the mesh to be rendered
  13633. * @param nodeMaterial defines the node material requesting the update
  13634. * @param defines defines the material defines to update
  13635. * @param useInstances specifies that instances should be used
  13636. * @param subMesh defines which submesh to render
  13637. */
  13638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13639. serialize(): any;
  13640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13641. protected _dumpPropertiesCode(): string;
  13642. }
  13643. }
  13644. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13648. /**
  13649. * Block used to output the vertex position
  13650. */
  13651. export class VertexOutputBlock extends NodeMaterialBlock {
  13652. /**
  13653. * Creates a new VertexOutputBlock
  13654. * @param name defines the block name
  13655. */
  13656. constructor(name: string);
  13657. /**
  13658. * Gets the current class name
  13659. * @returns the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Gets the vector input component
  13664. */
  13665. get vector(): NodeMaterialConnectionPoint;
  13666. protected _buildBlock(state: NodeMaterialBuildState): this;
  13667. }
  13668. }
  13669. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13673. /**
  13674. * Block used to output the final color
  13675. */
  13676. export class FragmentOutputBlock extends NodeMaterialBlock {
  13677. /**
  13678. * Create a new FragmentOutputBlock
  13679. * @param name defines the block name
  13680. */
  13681. constructor(name: string);
  13682. /**
  13683. * Gets the current class name
  13684. * @returns the class name
  13685. */
  13686. getClassName(): string;
  13687. /**
  13688. * Gets the rgba input component
  13689. */
  13690. get rgba(): NodeMaterialConnectionPoint;
  13691. /**
  13692. * Gets the rgb input component
  13693. */
  13694. get rgb(): NodeMaterialConnectionPoint;
  13695. /**
  13696. * Gets the a input component
  13697. */
  13698. get a(): NodeMaterialConnectionPoint;
  13699. protected _buildBlock(state: NodeMaterialBuildState): this;
  13700. }
  13701. }
  13702. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13706. /**
  13707. * Block used for the particle ramp gradient section
  13708. */
  13709. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13710. /**
  13711. * Create a new ParticleRampGradientBlock
  13712. * @param name defines the block name
  13713. */
  13714. constructor(name: string);
  13715. /**
  13716. * Gets the current class name
  13717. * @returns the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Gets the color input component
  13722. */
  13723. get color(): NodeMaterialConnectionPoint;
  13724. /**
  13725. * Gets the rampColor output component
  13726. */
  13727. get rampColor(): NodeMaterialConnectionPoint;
  13728. /**
  13729. * Initialize the block and prepare the context for build
  13730. * @param state defines the state that will be used for the build
  13731. */
  13732. initialize(state: NodeMaterialBuildState): void;
  13733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13734. }
  13735. }
  13736. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13740. /**
  13741. * Block used for the particle blend multiply section
  13742. */
  13743. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13744. /**
  13745. * Create a new ParticleBlendMultiplyBlock
  13746. * @param name defines the block name
  13747. */
  13748. constructor(name: string);
  13749. /**
  13750. * Gets the current class name
  13751. * @returns the class name
  13752. */
  13753. getClassName(): string;
  13754. /**
  13755. * Gets the color input component
  13756. */
  13757. get color(): NodeMaterialConnectionPoint;
  13758. /**
  13759. * Gets the alphaTexture input component
  13760. */
  13761. get alphaTexture(): NodeMaterialConnectionPoint;
  13762. /**
  13763. * Gets the alphaColor input component
  13764. */
  13765. get alphaColor(): NodeMaterialConnectionPoint;
  13766. /**
  13767. * Gets the blendColor output component
  13768. */
  13769. get blendColor(): NodeMaterialConnectionPoint;
  13770. /**
  13771. * Initialize the block and prepare the context for build
  13772. * @param state defines the state that will be used for the build
  13773. */
  13774. initialize(state: NodeMaterialBuildState): void;
  13775. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13776. }
  13777. }
  13778. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13782. /**
  13783. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13784. */
  13785. export class VectorMergerBlock extends NodeMaterialBlock {
  13786. /**
  13787. * Create a new VectorMergerBlock
  13788. * @param name defines the block name
  13789. */
  13790. constructor(name: string);
  13791. /**
  13792. * Gets the current class name
  13793. * @returns the class name
  13794. */
  13795. getClassName(): string;
  13796. /**
  13797. * Gets the xyz component (input)
  13798. */
  13799. get xyzIn(): NodeMaterialConnectionPoint;
  13800. /**
  13801. * Gets the xy component (input)
  13802. */
  13803. get xyIn(): NodeMaterialConnectionPoint;
  13804. /**
  13805. * Gets the x component (input)
  13806. */
  13807. get x(): NodeMaterialConnectionPoint;
  13808. /**
  13809. * Gets the y component (input)
  13810. */
  13811. get y(): NodeMaterialConnectionPoint;
  13812. /**
  13813. * Gets the z component (input)
  13814. */
  13815. get z(): NodeMaterialConnectionPoint;
  13816. /**
  13817. * Gets the w component (input)
  13818. */
  13819. get w(): NodeMaterialConnectionPoint;
  13820. /**
  13821. * Gets the xyzw component (output)
  13822. */
  13823. get xyzw(): NodeMaterialConnectionPoint;
  13824. /**
  13825. * Gets the xyz component (output)
  13826. */
  13827. get xyzOut(): NodeMaterialConnectionPoint;
  13828. /**
  13829. * Gets the xy component (output)
  13830. */
  13831. get xyOut(): NodeMaterialConnectionPoint;
  13832. /**
  13833. * Gets the xy component (output)
  13834. * @deprecated Please use xyOut instead.
  13835. */
  13836. get xy(): NodeMaterialConnectionPoint;
  13837. /**
  13838. * Gets the xyz component (output)
  13839. * @deprecated Please use xyzOut instead.
  13840. */
  13841. get xyz(): NodeMaterialConnectionPoint;
  13842. protected _buildBlock(state: NodeMaterialBuildState): this;
  13843. }
  13844. }
  13845. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13849. import { Vector2 } from "babylonjs/Maths/math.vector";
  13850. import { Scene } from "babylonjs/scene";
  13851. /**
  13852. * Block used to remap a float from a range to a new one
  13853. */
  13854. export class RemapBlock extends NodeMaterialBlock {
  13855. /**
  13856. * Gets or sets the source range
  13857. */
  13858. sourceRange: Vector2;
  13859. /**
  13860. * Gets or sets the target range
  13861. */
  13862. targetRange: Vector2;
  13863. /**
  13864. * Creates a new RemapBlock
  13865. * @param name defines the block name
  13866. */
  13867. constructor(name: string);
  13868. /**
  13869. * Gets the current class name
  13870. * @returns the class name
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Gets the input component
  13875. */
  13876. get input(): NodeMaterialConnectionPoint;
  13877. /**
  13878. * Gets the source min input component
  13879. */
  13880. get sourceMin(): NodeMaterialConnectionPoint;
  13881. /**
  13882. * Gets the source max input component
  13883. */
  13884. get sourceMax(): NodeMaterialConnectionPoint;
  13885. /**
  13886. * Gets the target min input component
  13887. */
  13888. get targetMin(): NodeMaterialConnectionPoint;
  13889. /**
  13890. * Gets the target max input component
  13891. */
  13892. get targetMax(): NodeMaterialConnectionPoint;
  13893. /**
  13894. * Gets the output component
  13895. */
  13896. get output(): NodeMaterialConnectionPoint;
  13897. protected _buildBlock(state: NodeMaterialBuildState): this;
  13898. protected _dumpPropertiesCode(): string;
  13899. serialize(): any;
  13900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13907. /**
  13908. * Block used to multiply 2 values
  13909. */
  13910. export class MultiplyBlock extends NodeMaterialBlock {
  13911. /**
  13912. * Creates a new MultiplyBlock
  13913. * @param name defines the block name
  13914. */
  13915. constructor(name: string);
  13916. /**
  13917. * Gets the current class name
  13918. * @returns the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Gets the left operand input component
  13923. */
  13924. get left(): NodeMaterialConnectionPoint;
  13925. /**
  13926. * Gets the right operand input component
  13927. */
  13928. get right(): NodeMaterialConnectionPoint;
  13929. /**
  13930. * Gets the output component
  13931. */
  13932. get output(): NodeMaterialConnectionPoint;
  13933. protected _buildBlock(state: NodeMaterialBuildState): this;
  13934. }
  13935. }
  13936. declare module "babylonjs/Misc/gradients" {
  13937. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13938. /** Interface used by value gradients (color, factor, ...) */
  13939. export interface IValueGradient {
  13940. /**
  13941. * Gets or sets the gradient value (between 0 and 1)
  13942. */
  13943. gradient: number;
  13944. }
  13945. /** Class used to store color4 gradient */
  13946. export class ColorGradient implements IValueGradient {
  13947. /**
  13948. * Gets or sets the gradient value (between 0 and 1)
  13949. */
  13950. gradient: number;
  13951. /**
  13952. * Gets or sets first associated color
  13953. */
  13954. color1: Color4;
  13955. /**
  13956. * Gets or sets second associated color
  13957. */
  13958. color2?: Color4 | undefined;
  13959. /**
  13960. * Creates a new color4 gradient
  13961. * @param gradient gets or sets the gradient value (between 0 and 1)
  13962. * @param color1 gets or sets first associated color
  13963. * @param color2 gets or sets first second color
  13964. */
  13965. constructor(
  13966. /**
  13967. * Gets or sets the gradient value (between 0 and 1)
  13968. */
  13969. gradient: number,
  13970. /**
  13971. * Gets or sets first associated color
  13972. */
  13973. color1: Color4,
  13974. /**
  13975. * Gets or sets second associated color
  13976. */
  13977. color2?: Color4 | undefined);
  13978. /**
  13979. * Will get a color picked randomly between color1 and color2.
  13980. * If color2 is undefined then color1 will be used
  13981. * @param result defines the target Color4 to store the result in
  13982. */
  13983. getColorToRef(result: Color4): void;
  13984. }
  13985. /** Class used to store color 3 gradient */
  13986. export class Color3Gradient implements IValueGradient {
  13987. /**
  13988. * Gets or sets the gradient value (between 0 and 1)
  13989. */
  13990. gradient: number;
  13991. /**
  13992. * Gets or sets the associated color
  13993. */
  13994. color: Color3;
  13995. /**
  13996. * Creates a new color3 gradient
  13997. * @param gradient gets or sets the gradient value (between 0 and 1)
  13998. * @param color gets or sets associated color
  13999. */
  14000. constructor(
  14001. /**
  14002. * Gets or sets the gradient value (between 0 and 1)
  14003. */
  14004. gradient: number,
  14005. /**
  14006. * Gets or sets the associated color
  14007. */
  14008. color: Color3);
  14009. }
  14010. /** Class used to store factor gradient */
  14011. export class FactorGradient implements IValueGradient {
  14012. /**
  14013. * Gets or sets the gradient value (between 0 and 1)
  14014. */
  14015. gradient: number;
  14016. /**
  14017. * Gets or sets first associated factor
  14018. */
  14019. factor1: number;
  14020. /**
  14021. * Gets or sets second associated factor
  14022. */
  14023. factor2?: number | undefined;
  14024. /**
  14025. * Creates a new factor gradient
  14026. * @param gradient gets or sets the gradient value (between 0 and 1)
  14027. * @param factor1 gets or sets first associated factor
  14028. * @param factor2 gets or sets second associated factor
  14029. */
  14030. constructor(
  14031. /**
  14032. * Gets or sets the gradient value (between 0 and 1)
  14033. */
  14034. gradient: number,
  14035. /**
  14036. * Gets or sets first associated factor
  14037. */
  14038. factor1: number,
  14039. /**
  14040. * Gets or sets second associated factor
  14041. */
  14042. factor2?: number | undefined);
  14043. /**
  14044. * Will get a number picked randomly between factor1 and factor2.
  14045. * If factor2 is undefined then factor1 will be used
  14046. * @returns the picked number
  14047. */
  14048. getFactor(): number;
  14049. }
  14050. /**
  14051. * Helper used to simplify some generic gradient tasks
  14052. */
  14053. export class GradientHelper {
  14054. /**
  14055. * Gets the current gradient from an array of IValueGradient
  14056. * @param ratio defines the current ratio to get
  14057. * @param gradients defines the array of IValueGradient
  14058. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14059. */
  14060. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14061. }
  14062. }
  14063. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14064. import { Nullable } from "babylonjs/types";
  14065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14066. import { Scene } from "babylonjs/scene";
  14067. module "babylonjs/Engines/thinEngine" {
  14068. interface ThinEngine {
  14069. /**
  14070. * Creates a raw texture
  14071. * @param data defines the data to store in the texture
  14072. * @param width defines the width of the texture
  14073. * @param height defines the height of the texture
  14074. * @param format defines the format of the data
  14075. * @param generateMipMaps defines if the engine should generate the mip levels
  14076. * @param invertY defines if data must be stored with Y axis inverted
  14077. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14078. * @param compression defines the compression used (null by default)
  14079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14080. * @returns the raw texture inside an InternalTexture
  14081. */
  14082. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14083. /**
  14084. * Update a raw texture
  14085. * @param texture defines the texture to update
  14086. * @param data defines the data to store in the texture
  14087. * @param format defines the format of the data
  14088. * @param invertY defines if data must be stored with Y axis inverted
  14089. */
  14090. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14091. /**
  14092. * Update a raw texture
  14093. * @param texture defines the texture to update
  14094. * @param data defines the data to store in the texture
  14095. * @param format defines the format of the data
  14096. * @param invertY defines if data must be stored with Y axis inverted
  14097. * @param compression defines the compression used (null by default)
  14098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14099. */
  14100. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14101. /**
  14102. * Creates a new raw cube texture
  14103. * @param data defines the array of data to use to create each face
  14104. * @param size defines the size of the textures
  14105. * @param format defines the format of the data
  14106. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14107. * @param generateMipMaps defines if the engine should generate the mip levels
  14108. * @param invertY defines if data must be stored with Y axis inverted
  14109. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14110. * @param compression defines the compression used (null by default)
  14111. * @returns the cube texture as an InternalTexture
  14112. */
  14113. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14114. /**
  14115. * Update a raw cube texture
  14116. * @param texture defines the texture to udpdate
  14117. * @param data defines the data to store
  14118. * @param format defines the data format
  14119. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14120. * @param invertY defines if data must be stored with Y axis inverted
  14121. */
  14122. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14123. /**
  14124. * Update a raw cube texture
  14125. * @param texture defines the texture to udpdate
  14126. * @param data defines the data to store
  14127. * @param format defines the data format
  14128. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14129. * @param invertY defines if data must be stored with Y axis inverted
  14130. * @param compression defines the compression used (null by default)
  14131. */
  14132. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14133. /**
  14134. * Update a raw cube texture
  14135. * @param texture defines the texture to udpdate
  14136. * @param data defines the data to store
  14137. * @param format defines the data format
  14138. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14139. * @param invertY defines if data must be stored with Y axis inverted
  14140. * @param compression defines the compression used (null by default)
  14141. * @param level defines which level of the texture to update
  14142. */
  14143. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14144. /**
  14145. * Creates a new raw cube texture from a specified url
  14146. * @param url defines the url where the data is located
  14147. * @param scene defines the current scene
  14148. * @param size defines the size of the textures
  14149. * @param format defines the format of the data
  14150. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14151. * @param noMipmap defines if the engine should avoid generating the mip levels
  14152. * @param callback defines a callback used to extract texture data from loaded data
  14153. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14154. * @param onLoad defines a callback called when texture is loaded
  14155. * @param onError defines a callback called if there is an error
  14156. * @returns the cube texture as an InternalTexture
  14157. */
  14158. 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;
  14159. /**
  14160. * Creates a new raw cube texture from a specified url
  14161. * @param url defines the url where the data is located
  14162. * @param scene defines the current scene
  14163. * @param size defines the size of the textures
  14164. * @param format defines the format of the data
  14165. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14166. * @param noMipmap defines if the engine should avoid generating the mip levels
  14167. * @param callback defines a callback used to extract texture data from loaded data
  14168. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14169. * @param onLoad defines a callback called when texture is loaded
  14170. * @param onError defines a callback called if there is an error
  14171. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14172. * @param invertY defines if data must be stored with Y axis inverted
  14173. * @returns the cube texture as an InternalTexture
  14174. */
  14175. 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;
  14176. /**
  14177. * Creates a new raw 3D texture
  14178. * @param data defines the data used to create the texture
  14179. * @param width defines the width of the texture
  14180. * @param height defines the height of the texture
  14181. * @param depth defines the depth of the texture
  14182. * @param format defines the format of the texture
  14183. * @param generateMipMaps defines if the engine must generate mip levels
  14184. * @param invertY defines if data must be stored with Y axis inverted
  14185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14186. * @param compression defines the compressed used (can be null)
  14187. * @param textureType defines the compressed used (can be null)
  14188. * @returns a new raw 3D texture (stored in an InternalTexture)
  14189. */
  14190. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14191. /**
  14192. * Update a raw 3D texture
  14193. * @param texture defines the texture to update
  14194. * @param data defines the data to store
  14195. * @param format defines the data format
  14196. * @param invertY defines if data must be stored with Y axis inverted
  14197. */
  14198. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14199. /**
  14200. * Update a raw 3D texture
  14201. * @param texture defines the texture to update
  14202. * @param data defines the data to store
  14203. * @param format defines the data format
  14204. * @param invertY defines if data must be stored with Y axis inverted
  14205. * @param compression defines the used compression (can be null)
  14206. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14207. */
  14208. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14209. /**
  14210. * Creates a new raw 2D array texture
  14211. * @param data defines the data used to create the texture
  14212. * @param width defines the width of the texture
  14213. * @param height defines the height of the texture
  14214. * @param depth defines the number of layers of the texture
  14215. * @param format defines the format of the texture
  14216. * @param generateMipMaps defines if the engine must generate mip levels
  14217. * @param invertY defines if data must be stored with Y axis inverted
  14218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14219. * @param compression defines the compressed used (can be null)
  14220. * @param textureType defines the compressed used (can be null)
  14221. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14222. */
  14223. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14224. /**
  14225. * Update a raw 2D array texture
  14226. * @param texture defines the texture to update
  14227. * @param data defines the data to store
  14228. * @param format defines the data format
  14229. * @param invertY defines if data must be stored with Y axis inverted
  14230. */
  14231. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14232. /**
  14233. * Update a raw 2D array texture
  14234. * @param texture defines the texture to update
  14235. * @param data defines the data to store
  14236. * @param format defines the data format
  14237. * @param invertY defines if data must be stored with Y axis inverted
  14238. * @param compression defines the used compression (can be null)
  14239. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14240. */
  14241. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14242. }
  14243. }
  14244. }
  14245. declare module "babylonjs/Materials/Textures/rawTexture" {
  14246. import { Texture } from "babylonjs/Materials/Textures/texture";
  14247. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14248. import { Nullable } from "babylonjs/types";
  14249. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14250. import { Scene } from "babylonjs/scene";
  14251. /**
  14252. * Raw texture can help creating a texture directly from an array of data.
  14253. * This can be super useful if you either get the data from an uncompressed source or
  14254. * if you wish to create your texture pixel by pixel.
  14255. */
  14256. export class RawTexture extends Texture {
  14257. /**
  14258. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14259. */
  14260. format: number;
  14261. /**
  14262. * Instantiates a new RawTexture.
  14263. * Raw texture can help creating a texture directly from an array of data.
  14264. * This can be super useful if you either get the data from an uncompressed source or
  14265. * if you wish to create your texture pixel by pixel.
  14266. * @param data define the array of data to use to create the texture
  14267. * @param width define the width of the texture
  14268. * @param height define the height of the texture
  14269. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14270. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14271. * @param generateMipMaps define whether mip maps should be generated or not
  14272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14275. */
  14276. constructor(data: ArrayBufferView, width: number, height: number,
  14277. /**
  14278. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14279. */
  14280. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14281. /**
  14282. * Updates the texture underlying data.
  14283. * @param data Define the new data of the texture
  14284. */
  14285. update(data: ArrayBufferView): void;
  14286. /**
  14287. * Creates a luminance texture from some data.
  14288. * @param data Define the texture data
  14289. * @param width Define the width of the texture
  14290. * @param height Define the height of the texture
  14291. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14295. * @returns the luminance texture
  14296. */
  14297. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14298. /**
  14299. * Creates a luminance alpha texture from some data.
  14300. * @param data Define the texture data
  14301. * @param width Define the width of the texture
  14302. * @param height Define the height of the texture
  14303. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14307. * @returns the luminance alpha texture
  14308. */
  14309. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14310. /**
  14311. * Creates an alpha 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 alpha texture
  14320. */
  14321. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14322. /**
  14323. * Creates a RGB 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14332. * @returns the RGB alpha texture
  14333. */
  14334. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14335. /**
  14336. * Creates a RGBA texture from some data.
  14337. * @param data Define the texture data
  14338. * @param width Define the width of the texture
  14339. * @param height Define the height of the texture
  14340. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14341. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14345. * @returns the RGBA texture
  14346. */
  14347. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14348. /**
  14349. * Creates a R texture from some data.
  14350. * @param data Define the texture data
  14351. * @param width Define the width of the texture
  14352. * @param height Define the height of the texture
  14353. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14354. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14355. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14356. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14357. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14358. * @returns the R texture
  14359. */
  14360. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14361. }
  14362. }
  14363. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14365. import { IndicesArray, DataArray } from "babylonjs/types";
  14366. module "babylonjs/Engines/thinEngine" {
  14367. interface ThinEngine {
  14368. /**
  14369. * Update a dynamic index buffer
  14370. * @param indexBuffer defines the target index buffer
  14371. * @param indices defines the data to update
  14372. * @param offset defines the offset in the target index buffer where update should start
  14373. */
  14374. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14375. /**
  14376. * Updates a dynamic vertex buffer.
  14377. * @param vertexBuffer the vertex buffer to update
  14378. * @param data the data used to update the vertex buffer
  14379. * @param byteOffset the byte offset of the data
  14380. * @param byteLength the byte length of the data
  14381. */
  14382. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14383. }
  14384. }
  14385. }
  14386. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14387. import { Scene } from "babylonjs/scene";
  14388. import { ISceneComponent } from "babylonjs/sceneComponent";
  14389. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14390. module "babylonjs/abstractScene" {
  14391. interface AbstractScene {
  14392. /**
  14393. * The list of procedural textures added to the scene
  14394. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14395. */
  14396. proceduralTextures: Array<ProceduralTexture>;
  14397. }
  14398. }
  14399. /**
  14400. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14401. * in a given scene.
  14402. */
  14403. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14404. /**
  14405. * The component name helpfull to identify the component in the list of scene components.
  14406. */
  14407. readonly name: string;
  14408. /**
  14409. * The scene the component belongs to.
  14410. */
  14411. scene: Scene;
  14412. /**
  14413. * Creates a new instance of the component for the given scene
  14414. * @param scene Defines the scene to register the component in
  14415. */
  14416. constructor(scene: Scene);
  14417. /**
  14418. * Registers the component in a given scene
  14419. */
  14420. register(): void;
  14421. /**
  14422. * Rebuilds the elements related to this component in case of
  14423. * context lost for instance.
  14424. */
  14425. rebuild(): void;
  14426. /**
  14427. * Disposes the component and the associated ressources.
  14428. */
  14429. dispose(): void;
  14430. private _beforeClear;
  14431. }
  14432. }
  14433. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14435. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14436. module "babylonjs/Engines/thinEngine" {
  14437. interface ThinEngine {
  14438. /**
  14439. * Creates a new render target cube texture
  14440. * @param size defines the size of the texture
  14441. * @param options defines the options used to create the texture
  14442. * @returns a new render target cube texture stored in an InternalTexture
  14443. */
  14444. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14445. }
  14446. }
  14447. }
  14448. declare module "babylonjs/Shaders/procedural.vertex" {
  14449. /** @hidden */
  14450. export var proceduralVertexShader: {
  14451. name: string;
  14452. shader: string;
  14453. };
  14454. }
  14455. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14456. import { Observable } from "babylonjs/Misc/observable";
  14457. import { Nullable } from "babylonjs/types";
  14458. import { Scene } from "babylonjs/scene";
  14459. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14460. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14461. import { Effect } from "babylonjs/Materials/effect";
  14462. import { Texture } from "babylonjs/Materials/Textures/texture";
  14463. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14464. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14465. import "babylonjs/Shaders/procedural.vertex";
  14466. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14467. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14468. /**
  14469. * 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.
  14470. * This is the base class of any Procedural texture and contains most of the shareable code.
  14471. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14472. */
  14473. export class ProceduralTexture extends Texture {
  14474. /**
  14475. * Define if the texture is enabled or not (disabled texture will not render)
  14476. */
  14477. isEnabled: boolean;
  14478. /**
  14479. * Define if the texture must be cleared before rendering (default is true)
  14480. */
  14481. autoClear: boolean;
  14482. /**
  14483. * Callback called when the texture is generated
  14484. */
  14485. onGenerated: () => void;
  14486. /**
  14487. * Event raised when the texture is generated
  14488. */
  14489. onGeneratedObservable: Observable<ProceduralTexture>;
  14490. /**
  14491. * Event raised before the texture is generated
  14492. */
  14493. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14494. /**
  14495. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14496. */
  14497. nodeMaterialSource: Nullable<NodeMaterial>;
  14498. /** @hidden */
  14499. _generateMipMaps: boolean;
  14500. /** @hidden **/
  14501. _effect: Effect;
  14502. /** @hidden */
  14503. _textures: {
  14504. [key: string]: Texture;
  14505. };
  14506. /** @hidden */
  14507. protected _fallbackTexture: Nullable<Texture>;
  14508. private _size;
  14509. private _currentRefreshId;
  14510. private _frameId;
  14511. private _refreshRate;
  14512. private _vertexBuffers;
  14513. private _indexBuffer;
  14514. private _uniforms;
  14515. private _samplers;
  14516. private _fragment;
  14517. private _floats;
  14518. private _ints;
  14519. private _floatsArrays;
  14520. private _colors3;
  14521. private _colors4;
  14522. private _vectors2;
  14523. private _vectors3;
  14524. private _matrices;
  14525. private _fallbackTextureUsed;
  14526. private _fullEngine;
  14527. private _cachedDefines;
  14528. private _contentUpdateId;
  14529. private _contentData;
  14530. /**
  14531. * Instantiates a new procedural texture.
  14532. * 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.
  14533. * This is the base class of any Procedural texture and contains most of the shareable code.
  14534. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14535. * @param name Define the name of the texture
  14536. * @param size Define the size of the texture to create
  14537. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14538. * @param scene Define the scene the texture belongs to
  14539. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14540. * @param generateMipMaps Define if the texture should creates mip maps or not
  14541. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14542. * @param textureType The FBO internal texture type
  14543. */
  14544. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14545. /**
  14546. * The effect that is created when initializing the post process.
  14547. * @returns The created effect corresponding the the postprocess.
  14548. */
  14549. getEffect(): Effect;
  14550. /**
  14551. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14552. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14553. */
  14554. getContent(): Nullable<ArrayBufferView>;
  14555. private _createIndexBuffer;
  14556. /** @hidden */
  14557. _rebuild(): void;
  14558. /**
  14559. * Resets the texture in order to recreate its associated resources.
  14560. * This can be called in case of context loss
  14561. */
  14562. reset(): void;
  14563. protected _getDefines(): string;
  14564. /**
  14565. * Is the texture ready to be used ? (rendered at least once)
  14566. * @returns true if ready, otherwise, false.
  14567. */
  14568. isReady(): boolean;
  14569. /**
  14570. * Resets the refresh counter of the texture and start bak from scratch.
  14571. * Could be useful to regenerate the texture if it is setup to render only once.
  14572. */
  14573. resetRefreshCounter(): void;
  14574. /**
  14575. * Set the fragment shader to use in order to render the texture.
  14576. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14577. */
  14578. setFragment(fragment: any): void;
  14579. /**
  14580. * Define the refresh rate of the texture or the rendering frequency.
  14581. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14582. */
  14583. get refreshRate(): number;
  14584. set refreshRate(value: number);
  14585. /** @hidden */
  14586. _shouldRender(): boolean;
  14587. /**
  14588. * Get the size the texture is rendering at.
  14589. * @returns the size (on cube texture it is always squared)
  14590. */
  14591. getRenderSize(): RenderTargetTextureSize;
  14592. /**
  14593. * Resize the texture to new value.
  14594. * @param size Define the new size the texture should have
  14595. * @param generateMipMaps Define whether the new texture should create mip maps
  14596. */
  14597. resize(size: number, generateMipMaps: boolean): void;
  14598. private _checkUniform;
  14599. /**
  14600. * Set a texture in the shader program used to render.
  14601. * @param name Define the name of the uniform samplers as defined in the shader
  14602. * @param texture Define the texture to bind to this sampler
  14603. * @return the texture itself allowing "fluent" like uniform updates
  14604. */
  14605. setTexture(name: string, texture: Texture): ProceduralTexture;
  14606. /**
  14607. * Set a float in the shader.
  14608. * @param name Define the name of the uniform as defined in the shader
  14609. * @param value Define the value to give to the uniform
  14610. * @return the texture itself allowing "fluent" like uniform updates
  14611. */
  14612. setFloat(name: string, value: number): ProceduralTexture;
  14613. /**
  14614. * Set a int in the shader.
  14615. * @param name Define the name of the uniform as defined in the shader
  14616. * @param value Define the value to give to the uniform
  14617. * @return the texture itself allowing "fluent" like uniform updates
  14618. */
  14619. setInt(name: string, value: number): ProceduralTexture;
  14620. /**
  14621. * Set an array of floats in the shader.
  14622. * @param name Define the name of the uniform as defined in the shader
  14623. * @param value Define the value to give to the uniform
  14624. * @return the texture itself allowing "fluent" like uniform updates
  14625. */
  14626. setFloats(name: string, value: number[]): ProceduralTexture;
  14627. /**
  14628. * Set a vec3 in the shader from a Color3.
  14629. * @param name Define the name of the uniform as defined in the shader
  14630. * @param value Define the value to give to the uniform
  14631. * @return the texture itself allowing "fluent" like uniform updates
  14632. */
  14633. setColor3(name: string, value: Color3): ProceduralTexture;
  14634. /**
  14635. * Set a vec4 in the shader from a Color4.
  14636. * @param name Define the name of the uniform as defined in the shader
  14637. * @param value Define the value to give to the uniform
  14638. * @return the texture itself allowing "fluent" like uniform updates
  14639. */
  14640. setColor4(name: string, value: Color4): ProceduralTexture;
  14641. /**
  14642. * Set a vec2 in the shader from a Vector2.
  14643. * @param name Define the name of the uniform as defined in the shader
  14644. * @param value Define the value to give to the uniform
  14645. * @return the texture itself allowing "fluent" like uniform updates
  14646. */
  14647. setVector2(name: string, value: Vector2): ProceduralTexture;
  14648. /**
  14649. * Set a vec3 in the shader from a Vector3.
  14650. * @param name Define the name of the uniform as defined in the shader
  14651. * @param value Define the value to give to the uniform
  14652. * @return the texture itself allowing "fluent" like uniform updates
  14653. */
  14654. setVector3(name: string, value: Vector3): ProceduralTexture;
  14655. /**
  14656. * Set a mat4 in the shader from a MAtrix.
  14657. * @param name Define the name of the uniform as defined in the shader
  14658. * @param value Define the value to give to the uniform
  14659. * @return the texture itself allowing "fluent" like uniform updates
  14660. */
  14661. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14662. /**
  14663. * Render the texture to its associated render target.
  14664. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14665. */
  14666. render(useCameraPostProcess?: boolean): void;
  14667. /**
  14668. * Clone the texture.
  14669. * @returns the cloned texture
  14670. */
  14671. clone(): ProceduralTexture;
  14672. /**
  14673. * Dispose the texture and release its asoociated resources.
  14674. */
  14675. dispose(): void;
  14676. }
  14677. }
  14678. declare module "babylonjs/Particles/baseParticleSystem" {
  14679. import { Nullable } from "babylonjs/types";
  14680. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14682. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14683. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14684. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14686. import { Color4 } from "babylonjs/Maths/math.color";
  14687. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14688. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14689. import { Animation } from "babylonjs/Animations/animation";
  14690. import { Scene } from "babylonjs/scene";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. /**
  14694. * This represents the base class for particle system in Babylon.
  14695. * 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.
  14696. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14697. * @example https://doc.babylonjs.com/babylon101/particles
  14698. */
  14699. export class BaseParticleSystem {
  14700. /**
  14701. * Source color is added to the destination color without alpha affecting the result
  14702. */
  14703. static BLENDMODE_ONEONE: number;
  14704. /**
  14705. * Blend current color and particle color using particle’s alpha
  14706. */
  14707. static BLENDMODE_STANDARD: number;
  14708. /**
  14709. * Add current color and particle color multiplied by particle’s alpha
  14710. */
  14711. static BLENDMODE_ADD: number;
  14712. /**
  14713. * Multiply current color with particle color
  14714. */
  14715. static BLENDMODE_MULTIPLY: number;
  14716. /**
  14717. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14718. */
  14719. static BLENDMODE_MULTIPLYADD: number;
  14720. /**
  14721. * List of animations used by the particle system.
  14722. */
  14723. animations: Animation[];
  14724. /**
  14725. * Gets or sets the unique id of the particle system
  14726. */
  14727. uniqueId: number;
  14728. /**
  14729. * The id of the Particle system.
  14730. */
  14731. id: string;
  14732. /**
  14733. * The friendly name of the Particle system.
  14734. */
  14735. name: string;
  14736. /**
  14737. * Snippet ID if the particle system was created from the snippet server
  14738. */
  14739. snippetId: string;
  14740. /**
  14741. * The rendering group used by the Particle system to chose when to render.
  14742. */
  14743. renderingGroupId: number;
  14744. /**
  14745. * The emitter represents the Mesh or position we are attaching the particle system to.
  14746. */
  14747. emitter: Nullable<AbstractMesh | Vector3>;
  14748. /**
  14749. * The maximum number of particles to emit per frame
  14750. */
  14751. emitRate: number;
  14752. /**
  14753. * If you want to launch only a few particles at once, that can be done, as well.
  14754. */
  14755. manualEmitCount: number;
  14756. /**
  14757. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14758. */
  14759. updateSpeed: number;
  14760. /**
  14761. * The amount of time the particle system is running (depends of the overall update speed).
  14762. */
  14763. targetStopDuration: number;
  14764. /**
  14765. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14766. */
  14767. disposeOnStop: boolean;
  14768. /**
  14769. * Minimum power of emitting particles.
  14770. */
  14771. minEmitPower: number;
  14772. /**
  14773. * Maximum power of emitting particles.
  14774. */
  14775. maxEmitPower: number;
  14776. /**
  14777. * Minimum life time of emitting particles.
  14778. */
  14779. minLifeTime: number;
  14780. /**
  14781. * Maximum life time of emitting particles.
  14782. */
  14783. maxLifeTime: number;
  14784. /**
  14785. * Minimum Size of emitting particles.
  14786. */
  14787. minSize: number;
  14788. /**
  14789. * Maximum Size of emitting particles.
  14790. */
  14791. maxSize: number;
  14792. /**
  14793. * Minimum scale of emitting particles on X axis.
  14794. */
  14795. minScaleX: number;
  14796. /**
  14797. * Maximum scale of emitting particles on X axis.
  14798. */
  14799. maxScaleX: number;
  14800. /**
  14801. * Minimum scale of emitting particles on Y axis.
  14802. */
  14803. minScaleY: number;
  14804. /**
  14805. * Maximum scale of emitting particles on Y axis.
  14806. */
  14807. maxScaleY: number;
  14808. /**
  14809. * Gets or sets the minimal initial rotation in radians.
  14810. */
  14811. minInitialRotation: number;
  14812. /**
  14813. * Gets or sets the maximal initial rotation in radians.
  14814. */
  14815. maxInitialRotation: number;
  14816. /**
  14817. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14818. */
  14819. minAngularSpeed: number;
  14820. /**
  14821. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14822. */
  14823. maxAngularSpeed: number;
  14824. /**
  14825. * The texture used to render each particle. (this can be a spritesheet)
  14826. */
  14827. particleTexture: Nullable<BaseTexture>;
  14828. /**
  14829. * The layer mask we are rendering the particles through.
  14830. */
  14831. layerMask: number;
  14832. /**
  14833. * This can help using your own shader to render the particle system.
  14834. * The according effect will be created
  14835. */
  14836. customShader: any;
  14837. /**
  14838. * By default particle system starts as soon as they are created. This prevents the
  14839. * automatic start to happen and let you decide when to start emitting particles.
  14840. */
  14841. preventAutoStart: boolean;
  14842. private _noiseTexture;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. get noiseTexture(): Nullable<ProceduralTexture>;
  14847. set noiseTexture(value: Nullable<ProceduralTexture>);
  14848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14849. noiseStrength: Vector3;
  14850. /**
  14851. * Callback triggered when the particle animation is ending.
  14852. */
  14853. onAnimationEnd: Nullable<() => void>;
  14854. /**
  14855. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14856. */
  14857. blendMode: number;
  14858. /**
  14859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14860. * to override the particles.
  14861. */
  14862. forceDepthWrite: boolean;
  14863. /** 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 */
  14864. preWarmCycles: number;
  14865. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14866. preWarmStepOffset: number;
  14867. /**
  14868. * 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)
  14869. */
  14870. spriteCellChangeSpeed: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14873. */
  14874. startSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14877. */
  14878. endSpriteCellID: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14881. */
  14882. spriteCellWidth: number;
  14883. /**
  14884. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14885. */
  14886. spriteCellHeight: number;
  14887. /**
  14888. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14889. */
  14890. spriteRandomStartCell: boolean;
  14891. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14892. translationPivot: Vector2;
  14893. /** @hidden */
  14894. protected _isAnimationSheetEnabled: boolean;
  14895. /**
  14896. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14897. */
  14898. beginAnimationOnStart: boolean;
  14899. /**
  14900. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationFrom: number;
  14903. /**
  14904. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationTo: number;
  14907. /**
  14908. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14909. */
  14910. beginAnimationLoop: boolean;
  14911. /**
  14912. * Gets or sets a world offset applied to all particles
  14913. */
  14914. worldOffset: Vector3;
  14915. /**
  14916. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14917. */
  14918. get isAnimationSheetEnabled(): boolean;
  14919. set isAnimationSheetEnabled(value: boolean);
  14920. /**
  14921. * Get hosting scene
  14922. * @returns the scene
  14923. */
  14924. getScene(): Nullable<Scene>;
  14925. /**
  14926. * You can use gravity if you want to give an orientation to your particles.
  14927. */
  14928. gravity: Vector3;
  14929. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14930. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14931. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14932. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14933. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14934. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14935. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14936. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14937. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14938. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14939. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14940. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14941. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14942. /**
  14943. * Defines the delay in milliseconds before starting the system (0 by default)
  14944. */
  14945. startDelay: number;
  14946. /**
  14947. * Gets the current list of drag gradients.
  14948. * You must use addDragGradient and removeDragGradient to udpate this list
  14949. * @returns the list of drag gradients
  14950. */
  14951. getDragGradients(): Nullable<Array<FactorGradient>>;
  14952. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14953. limitVelocityDamping: number;
  14954. /**
  14955. * Gets the current list of limit velocity gradients.
  14956. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14957. * @returns the list of limit velocity gradients
  14958. */
  14959. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14960. /**
  14961. * Gets the current list of color gradients.
  14962. * You must use addColorGradient and removeColorGradient to udpate this list
  14963. * @returns the list of color gradients
  14964. */
  14965. getColorGradients(): Nullable<Array<ColorGradient>>;
  14966. /**
  14967. * Gets the current list of size gradients.
  14968. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14969. * @returns the list of size gradients
  14970. */
  14971. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14972. /**
  14973. * Gets the current list of color remap gradients.
  14974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14975. * @returns the list of color remap gradients
  14976. */
  14977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Gets the current list of alpha remap gradients.
  14980. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14981. * @returns the list of alpha remap gradients
  14982. */
  14983. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14984. /**
  14985. * Gets the current list of life time gradients.
  14986. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14987. * @returns the list of life time gradients
  14988. */
  14989. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14990. /**
  14991. * Gets the current list of angular speed gradients.
  14992. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14993. * @returns the list of angular speed gradients
  14994. */
  14995. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Gets the current list of velocity gradients.
  14998. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14999. * @returns the list of velocity gradients
  15000. */
  15001. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15002. /**
  15003. * Gets the current list of start size gradients.
  15004. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15005. * @returns the list of start size gradients
  15006. */
  15007. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15008. /**
  15009. * Gets the current list of emit rate gradients.
  15010. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15011. * @returns the list of emit rate gradients
  15012. */
  15013. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. get direction1(): Vector3;
  15019. set direction1(value: Vector3);
  15020. /**
  15021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15023. */
  15024. get direction2(): Vector3;
  15025. set direction2(value: Vector3);
  15026. /**
  15027. * 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.
  15028. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15029. */
  15030. get minEmitBox(): Vector3;
  15031. set minEmitBox(value: Vector3);
  15032. /**
  15033. * 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.
  15034. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15035. */
  15036. get maxEmitBox(): Vector3;
  15037. set maxEmitBox(value: Vector3);
  15038. /**
  15039. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15040. */
  15041. color1: Color4;
  15042. /**
  15043. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15044. */
  15045. color2: Color4;
  15046. /**
  15047. * Color the particle will have at the end of its lifetime
  15048. */
  15049. colorDead: Color4;
  15050. /**
  15051. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15052. */
  15053. textureMask: Color4;
  15054. /**
  15055. * The particle emitter type defines the emitter used by the particle system.
  15056. * It can be for example box, sphere, or cone...
  15057. */
  15058. particleEmitterType: IParticleEmitterType;
  15059. /** @hidden */
  15060. _isSubEmitter: boolean;
  15061. /**
  15062. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15063. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15064. */
  15065. billboardMode: number;
  15066. protected _isBillboardBased: boolean;
  15067. /**
  15068. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15069. */
  15070. get isBillboardBased(): boolean;
  15071. set isBillboardBased(value: boolean);
  15072. /**
  15073. * The scene the particle system belongs to.
  15074. */
  15075. protected _scene: Nullable<Scene>;
  15076. /**
  15077. * The engine the particle system belongs to.
  15078. */
  15079. protected _engine: ThinEngine;
  15080. /**
  15081. * Local cache of defines for image processing.
  15082. */
  15083. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15084. /**
  15085. * Default configuration related to image processing available in the standard Material.
  15086. */
  15087. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15088. /**
  15089. * Gets the image processing configuration used either in this material.
  15090. */
  15091. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15092. /**
  15093. * Sets the Default image processing configuration used either in the this material.
  15094. *
  15095. * If sets to null, the scene one is in use.
  15096. */
  15097. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15098. /**
  15099. * Attaches a new image processing configuration to the Standard Material.
  15100. * @param configuration
  15101. */
  15102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15103. /** @hidden */
  15104. protected _reset(): void;
  15105. /** @hidden */
  15106. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15107. /**
  15108. * Instantiates a particle system.
  15109. * 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.
  15110. * @param name The name of the particle system
  15111. */
  15112. constructor(name: string);
  15113. /**
  15114. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15117. * @returns the emitter
  15118. */
  15119. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15120. /**
  15121. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15122. * @param radius The radius of the hemisphere to emit from
  15123. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15124. * @returns the emitter
  15125. */
  15126. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15127. /**
  15128. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15129. * @param radius The radius of the sphere to emit from
  15130. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15131. * @returns the emitter
  15132. */
  15133. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15134. /**
  15135. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15136. * @param radius The radius of the sphere to emit from
  15137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15139. * @returns the emitter
  15140. */
  15141. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15142. /**
  15143. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15144. * @param radius The radius of the emission cylinder
  15145. * @param height The height of the emission cylinder
  15146. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15147. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15148. * @returns the emitter
  15149. */
  15150. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15151. /**
  15152. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15153. * @param radius The radius of the cylinder to emit from
  15154. * @param height The height of the emission cylinder
  15155. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15156. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15157. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15158. * @returns the emitter
  15159. */
  15160. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15161. /**
  15162. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15163. * @param radius The radius of the cone to emit from
  15164. * @param angle The base angle of the cone
  15165. * @returns the emitter
  15166. */
  15167. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15168. /**
  15169. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15170. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15171. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15172. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15173. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15174. * @returns the emitter
  15175. */
  15176. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15177. }
  15178. }
  15179. declare module "babylonjs/Particles/subEmitter" {
  15180. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15181. import { Scene } from "babylonjs/scene";
  15182. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15183. /**
  15184. * Type of sub emitter
  15185. */
  15186. export enum SubEmitterType {
  15187. /**
  15188. * Attached to the particle over it's lifetime
  15189. */
  15190. ATTACHED = 0,
  15191. /**
  15192. * Created when the particle dies
  15193. */
  15194. END = 1
  15195. }
  15196. /**
  15197. * Sub emitter class used to emit particles from an existing particle
  15198. */
  15199. export class SubEmitter {
  15200. /**
  15201. * the particle system to be used by the sub emitter
  15202. */
  15203. particleSystem: ParticleSystem;
  15204. /**
  15205. * Type of the submitter (Default: END)
  15206. */
  15207. type: SubEmitterType;
  15208. /**
  15209. * 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)
  15210. * Note: This only is supported when using an emitter of type Mesh
  15211. */
  15212. inheritDirection: boolean;
  15213. /**
  15214. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15215. */
  15216. inheritedVelocityAmount: number;
  15217. /**
  15218. * Creates a sub emitter
  15219. * @param particleSystem the particle system to be used by the sub emitter
  15220. */
  15221. constructor(
  15222. /**
  15223. * the particle system to be used by the sub emitter
  15224. */
  15225. particleSystem: ParticleSystem);
  15226. /**
  15227. * Clones the sub emitter
  15228. * @returns the cloned sub emitter
  15229. */
  15230. clone(): SubEmitter;
  15231. /**
  15232. * Serialize current object to a JSON object
  15233. * @returns the serialized object
  15234. */
  15235. serialize(): any;
  15236. /** @hidden */
  15237. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15238. /**
  15239. * Creates a new SubEmitter from a serialized JSON version
  15240. * @param serializationObject defines the JSON object to read from
  15241. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15242. * @param rootUrl defines the rootUrl for data loading
  15243. * @returns a new SubEmitter
  15244. */
  15245. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15246. /** Release associated resources */
  15247. dispose(): void;
  15248. }
  15249. }
  15250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15251. /** @hidden */
  15252. export var clipPlaneFragmentDeclaration: {
  15253. name: string;
  15254. shader: string;
  15255. };
  15256. }
  15257. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15258. /** @hidden */
  15259. export var imageProcessingDeclaration: {
  15260. name: string;
  15261. shader: string;
  15262. };
  15263. }
  15264. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15265. /** @hidden */
  15266. export var imageProcessingFunctions: {
  15267. name: string;
  15268. shader: string;
  15269. };
  15270. }
  15271. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15272. /** @hidden */
  15273. export var clipPlaneFragment: {
  15274. name: string;
  15275. shader: string;
  15276. };
  15277. }
  15278. declare module "babylonjs/Shaders/particles.fragment" {
  15279. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15280. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15282. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15283. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15284. /** @hidden */
  15285. export var particlesPixelShader: {
  15286. name: string;
  15287. shader: string;
  15288. };
  15289. }
  15290. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15291. /** @hidden */
  15292. export var clipPlaneVertexDeclaration: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15298. /** @hidden */
  15299. export var clipPlaneVertex: {
  15300. name: string;
  15301. shader: string;
  15302. };
  15303. }
  15304. declare module "babylonjs/Shaders/particles.vertex" {
  15305. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15306. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15307. /** @hidden */
  15308. export var particlesVertexShader: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15314. import { Nullable } from "babylonjs/types";
  15315. import { Plane } from "babylonjs/Maths/math";
  15316. /**
  15317. * Interface used to define entities containing multiple clip planes
  15318. */
  15319. export interface IClipPlanesHolder {
  15320. /**
  15321. * Gets or sets the active clipplane 1
  15322. */
  15323. clipPlane: Nullable<Plane>;
  15324. /**
  15325. * Gets or sets the active clipplane 2
  15326. */
  15327. clipPlane2: Nullable<Plane>;
  15328. /**
  15329. * Gets or sets the active clipplane 3
  15330. */
  15331. clipPlane3: Nullable<Plane>;
  15332. /**
  15333. * Gets or sets the active clipplane 4
  15334. */
  15335. clipPlane4: Nullable<Plane>;
  15336. /**
  15337. * Gets or sets the active clipplane 5
  15338. */
  15339. clipPlane5: Nullable<Plane>;
  15340. /**
  15341. * Gets or sets the active clipplane 6
  15342. */
  15343. clipPlane6: Nullable<Plane>;
  15344. }
  15345. }
  15346. declare module "babylonjs/Materials/thinMaterialHelper" {
  15347. import { Effect } from "babylonjs/Materials/effect";
  15348. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15349. /**
  15350. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15351. *
  15352. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15353. *
  15354. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15355. */
  15356. export class ThinMaterialHelper {
  15357. /**
  15358. * Binds the clip plane information from the holder to the effect.
  15359. * @param effect The effect we are binding the data to
  15360. * @param holder The entity containing the clip plane information
  15361. */
  15362. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15363. }
  15364. }
  15365. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15366. module "babylonjs/Engines/thinEngine" {
  15367. interface ThinEngine {
  15368. /**
  15369. * Sets alpha constants used by some alpha blending modes
  15370. * @param r defines the red component
  15371. * @param g defines the green component
  15372. * @param b defines the blue component
  15373. * @param a defines the alpha component
  15374. */
  15375. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15376. /**
  15377. * Sets the current alpha mode
  15378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15381. */
  15382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15383. /**
  15384. * Gets the current alpha mode
  15385. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15386. * @returns the current alpha mode
  15387. */
  15388. getAlphaMode(): number;
  15389. /**
  15390. * Sets the current alpha equation
  15391. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15392. */
  15393. setAlphaEquation(equation: number): void;
  15394. /**
  15395. * Gets the current alpha equation.
  15396. * @returns the current alpha equation
  15397. */
  15398. getAlphaEquation(): number;
  15399. }
  15400. }
  15401. }
  15402. declare module "babylonjs/Particles/particleSystem" {
  15403. import { Nullable } from "babylonjs/types";
  15404. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15405. import { Observable } from "babylonjs/Misc/observable";
  15406. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15407. import { Effect } from "babylonjs/Materials/effect";
  15408. import { IDisposable } from "babylonjs/scene";
  15409. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15410. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15411. import { Particle } from "babylonjs/Particles/particle";
  15412. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15414. import "babylonjs/Shaders/particles.fragment";
  15415. import "babylonjs/Shaders/particles.vertex";
  15416. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15417. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15418. import "babylonjs/Engines/Extensions/engine.alpha";
  15419. import { Scene } from "babylonjs/scene";
  15420. /**
  15421. * This represents a particle system in Babylon.
  15422. * 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.
  15423. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15424. * @example https://doc.babylonjs.com/babylon101/particles
  15425. */
  15426. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15427. /**
  15428. * Billboard mode will only apply to Y axis
  15429. */
  15430. static readonly BILLBOARDMODE_Y: number;
  15431. /**
  15432. * Billboard mode will apply to all axes
  15433. */
  15434. static readonly BILLBOARDMODE_ALL: number;
  15435. /**
  15436. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15437. */
  15438. static readonly BILLBOARDMODE_STRETCHED: number;
  15439. /**
  15440. * This function can be defined to provide custom update for active particles.
  15441. * This function will be called instead of regular update (age, position, color, etc.).
  15442. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15443. */
  15444. updateFunction: (particles: Particle[]) => void;
  15445. private _emitterWorldMatrix;
  15446. /**
  15447. * This function can be defined to specify initial direction for every new particle.
  15448. * It by default use the emitterType defined function
  15449. */
  15450. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15451. /**
  15452. * This function can be defined to specify initial position for every new particle.
  15453. * It by default use the emitterType defined function
  15454. */
  15455. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15456. /**
  15457. * @hidden
  15458. */
  15459. _inheritedVelocityOffset: Vector3;
  15460. /**
  15461. * An event triggered when the system is disposed
  15462. */
  15463. onDisposeObservable: Observable<IParticleSystem>;
  15464. /**
  15465. * An event triggered when the system is stopped
  15466. */
  15467. onStoppedObservable: Observable<IParticleSystem>;
  15468. private _onDisposeObserver;
  15469. /**
  15470. * Sets a callback that will be triggered when the system is disposed
  15471. */
  15472. set onDispose(callback: () => void);
  15473. private _particles;
  15474. private _epsilon;
  15475. private _capacity;
  15476. private _stockParticles;
  15477. private _newPartsExcess;
  15478. private _vertexData;
  15479. private _vertexBuffer;
  15480. private _vertexBuffers;
  15481. private _spriteBuffer;
  15482. private _indexBuffer;
  15483. private _effect;
  15484. private _customEffect;
  15485. private _cachedDefines;
  15486. private _scaledColorStep;
  15487. private _colorDiff;
  15488. private _scaledDirection;
  15489. private _scaledGravity;
  15490. private _currentRenderId;
  15491. private _alive;
  15492. private _useInstancing;
  15493. private _vertexArrayObject;
  15494. private _started;
  15495. private _stopped;
  15496. private _actualFrame;
  15497. private _scaledUpdateSpeed;
  15498. private _vertexBufferSize;
  15499. /** @hidden */
  15500. _currentEmitRateGradient: Nullable<FactorGradient>;
  15501. /** @hidden */
  15502. _currentEmitRate1: number;
  15503. /** @hidden */
  15504. _currentEmitRate2: number;
  15505. /** @hidden */
  15506. _currentStartSizeGradient: Nullable<FactorGradient>;
  15507. /** @hidden */
  15508. _currentStartSize1: number;
  15509. /** @hidden */
  15510. _currentStartSize2: number;
  15511. private readonly _rawTextureWidth;
  15512. private _rampGradientsTexture;
  15513. private _useRampGradients;
  15514. /** Gets or sets a matrix to use to compute projection */
  15515. defaultProjectionMatrix: Matrix;
  15516. /** Gets or sets a matrix to use to compute view */
  15517. defaultViewMatrix: Matrix;
  15518. /** Gets or sets a boolean indicating that ramp gradients must be used
  15519. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15520. */
  15521. get useRampGradients(): boolean;
  15522. set useRampGradients(value: boolean);
  15523. /**
  15524. * 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.
  15525. * 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: [])
  15526. */
  15527. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15528. private _subEmitters;
  15529. /**
  15530. * @hidden
  15531. * If the particle systems emitter should be disposed when the particle system is disposed
  15532. */
  15533. _disposeEmitterOnDispose: boolean;
  15534. /**
  15535. * The current active Sub-systems, this property is used by the root particle system only.
  15536. */
  15537. activeSubSystems: Array<ParticleSystem>;
  15538. /**
  15539. * Specifies if the particles are updated in emitter local space or world space
  15540. */
  15541. isLocal: boolean;
  15542. private _rootParticleSystem;
  15543. /**
  15544. * Gets the current list of active particles
  15545. */
  15546. get particles(): Particle[];
  15547. /**
  15548. * Gets the number of particles active at the same time.
  15549. * @returns The number of active particles.
  15550. */
  15551. getActiveCount(): number;
  15552. /**
  15553. * Returns the string "ParticleSystem"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Gets a boolean indicating that the system is stopping
  15559. * @returns true if the system is currently stopping
  15560. */
  15561. isStopping(): boolean;
  15562. /**
  15563. * Gets the custom effect used to render the particles
  15564. * @param blendMode Blend mode for which the effect should be retrieved
  15565. * @returns The effect
  15566. */
  15567. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15568. /**
  15569. * Sets the custom effect used to render the particles
  15570. * @param effect The effect to set
  15571. * @param blendMode Blend mode for which the effect should be set
  15572. */
  15573. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15574. /** @hidden */
  15575. private _onBeforeDrawParticlesObservable;
  15576. /**
  15577. * Observable that will be called just before the particles are drawn
  15578. */
  15579. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15580. /**
  15581. * Gets the name of the particle vertex shader
  15582. */
  15583. get vertexShaderName(): string;
  15584. /**
  15585. * Instantiates a particle system.
  15586. * 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.
  15587. * @param name The name of the particle system
  15588. * @param capacity The max number of particles alive at the same time
  15589. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15590. * @param customEffect a custom effect used to change the way particles are rendered by default
  15591. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15592. * @param epsilon Offset used to render the particles
  15593. */
  15594. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15595. private _addFactorGradient;
  15596. private _removeFactorGradient;
  15597. /**
  15598. * Adds a new life time gradient
  15599. * @param gradient defines the gradient to use (between 0 and 1)
  15600. * @param factor defines the life time factor to affect to the specified gradient
  15601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15602. * @returns the current particle system
  15603. */
  15604. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15605. /**
  15606. * Remove a specific life time gradient
  15607. * @param gradient defines the gradient to remove
  15608. * @returns the current particle system
  15609. */
  15610. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15611. /**
  15612. * Adds a new size gradient
  15613. * @param gradient defines the gradient to use (between 0 and 1)
  15614. * @param factor defines the size factor to affect to the specified gradient
  15615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15616. * @returns the current particle system
  15617. */
  15618. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15619. /**
  15620. * Remove a specific size gradient
  15621. * @param gradient defines the gradient to remove
  15622. * @returns the current particle system
  15623. */
  15624. removeSizeGradient(gradient: number): IParticleSystem;
  15625. /**
  15626. * Adds a new color remap gradient
  15627. * @param gradient defines the gradient to use (between 0 and 1)
  15628. * @param min defines the color remap minimal range
  15629. * @param max defines the color remap maximal range
  15630. * @returns the current particle system
  15631. */
  15632. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15633. /**
  15634. * Remove a specific color remap gradient
  15635. * @param gradient defines the gradient to remove
  15636. * @returns the current particle system
  15637. */
  15638. removeColorRemapGradient(gradient: number): IParticleSystem;
  15639. /**
  15640. * Adds a new alpha remap gradient
  15641. * @param gradient defines the gradient to use (between 0 and 1)
  15642. * @param min defines the alpha remap minimal range
  15643. * @param max defines the alpha remap maximal range
  15644. * @returns the current particle system
  15645. */
  15646. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15647. /**
  15648. * Remove a specific alpha remap gradient
  15649. * @param gradient defines the gradient to remove
  15650. * @returns the current particle system
  15651. */
  15652. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15653. /**
  15654. * Adds a new angular speed gradient
  15655. * @param gradient defines the gradient to use (between 0 and 1)
  15656. * @param factor defines the angular speed to affect to the specified gradient
  15657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15658. * @returns the current particle system
  15659. */
  15660. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15661. /**
  15662. * Remove a specific angular speed gradient
  15663. * @param gradient defines the gradient to remove
  15664. * @returns the current particle system
  15665. */
  15666. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15667. /**
  15668. * Adds a new velocity gradient
  15669. * @param gradient defines the gradient to use (between 0 and 1)
  15670. * @param factor defines the velocity to affect to the specified gradient
  15671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15672. * @returns the current particle system
  15673. */
  15674. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15675. /**
  15676. * Remove a specific velocity gradient
  15677. * @param gradient defines the gradient to remove
  15678. * @returns the current particle system
  15679. */
  15680. removeVelocityGradient(gradient: number): IParticleSystem;
  15681. /**
  15682. * Adds a new limit velocity gradient
  15683. * @param gradient defines the gradient to use (between 0 and 1)
  15684. * @param factor defines the limit velocity value to affect to the specified gradient
  15685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15686. * @returns the current particle system
  15687. */
  15688. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15689. /**
  15690. * Remove a specific limit velocity gradient
  15691. * @param gradient defines the gradient to remove
  15692. * @returns the current particle system
  15693. */
  15694. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15695. /**
  15696. * Adds a new drag gradient
  15697. * @param gradient defines the gradient to use (between 0 and 1)
  15698. * @param factor defines the drag value to affect to the specified gradient
  15699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15700. * @returns the current particle system
  15701. */
  15702. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15703. /**
  15704. * Remove a specific drag gradient
  15705. * @param gradient defines the gradient to remove
  15706. * @returns the current particle system
  15707. */
  15708. removeDragGradient(gradient: number): IParticleSystem;
  15709. /**
  15710. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15711. * @param gradient defines the gradient to use (between 0 and 1)
  15712. * @param factor defines the emit rate value to affect to the specified gradient
  15713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15714. * @returns the current particle system
  15715. */
  15716. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15717. /**
  15718. * Remove a specific emit rate gradient
  15719. * @param gradient defines the gradient to remove
  15720. * @returns the current particle system
  15721. */
  15722. removeEmitRateGradient(gradient: number): IParticleSystem;
  15723. /**
  15724. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15725. * @param gradient defines the gradient to use (between 0 and 1)
  15726. * @param factor defines the start size value to affect to the specified gradient
  15727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15728. * @returns the current particle system
  15729. */
  15730. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15731. /**
  15732. * Remove a specific start size gradient
  15733. * @param gradient defines the gradient to remove
  15734. * @returns the current particle system
  15735. */
  15736. removeStartSizeGradient(gradient: number): IParticleSystem;
  15737. private _createRampGradientTexture;
  15738. /**
  15739. * Gets the current list of ramp gradients.
  15740. * You must use addRampGradient and removeRampGradient to udpate this list
  15741. * @returns the list of ramp gradients
  15742. */
  15743. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15744. /** Force the system to rebuild all gradients that need to be resync */
  15745. forceRefreshGradients(): void;
  15746. private _syncRampGradientTexture;
  15747. /**
  15748. * Adds a new ramp gradient used to remap particle colors
  15749. * @param gradient defines the gradient to use (between 0 and 1)
  15750. * @param color defines the color to affect to the specified gradient
  15751. * @returns the current particle system
  15752. */
  15753. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15754. /**
  15755. * Remove a specific ramp gradient
  15756. * @param gradient defines the gradient to remove
  15757. * @returns the current particle system
  15758. */
  15759. removeRampGradient(gradient: number): ParticleSystem;
  15760. /**
  15761. * Adds a new color gradient
  15762. * @param gradient defines the gradient to use (between 0 and 1)
  15763. * @param color1 defines the color to affect to the specified gradient
  15764. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15765. * @returns this particle system
  15766. */
  15767. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15768. /**
  15769. * Remove a specific color gradient
  15770. * @param gradient defines the gradient to remove
  15771. * @returns this particle system
  15772. */
  15773. removeColorGradient(gradient: number): IParticleSystem;
  15774. private _fetchR;
  15775. protected _reset(): void;
  15776. private _resetEffect;
  15777. private _createVertexBuffers;
  15778. private _createIndexBuffer;
  15779. /**
  15780. * Gets the maximum number of particles active at the same time.
  15781. * @returns The max number of active particles.
  15782. */
  15783. getCapacity(): number;
  15784. /**
  15785. * Gets whether there are still active particles in the system.
  15786. * @returns True if it is alive, otherwise false.
  15787. */
  15788. isAlive(): boolean;
  15789. /**
  15790. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15791. * @returns True if it has been started, otherwise false.
  15792. */
  15793. isStarted(): boolean;
  15794. private _prepareSubEmitterInternalArray;
  15795. /**
  15796. * Starts the particle system and begins to emit
  15797. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15798. */
  15799. start(delay?: number): void;
  15800. /**
  15801. * Stops the particle system.
  15802. * @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.
  15803. */
  15804. stop(stopSubEmitters?: boolean): void;
  15805. /**
  15806. * Remove all active particles
  15807. */
  15808. reset(): void;
  15809. /**
  15810. * @hidden (for internal use only)
  15811. */
  15812. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15813. /**
  15814. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15815. * Its lifetime will start back at 0.
  15816. */
  15817. recycleParticle: (particle: Particle) => void;
  15818. private _stopSubEmitters;
  15819. private _createParticle;
  15820. private _removeFromRoot;
  15821. private _emitFromParticle;
  15822. private _update;
  15823. /** @hidden */
  15824. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15825. /** @hidden */
  15826. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15827. /**
  15828. * Fill the defines array according to the current settings of the particle system
  15829. * @param defines Array to be updated
  15830. * @param blendMode blend mode to take into account when updating the array
  15831. */
  15832. fillDefines(defines: Array<string>, blendMode: number): void;
  15833. /**
  15834. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15835. * @param uniforms Uniforms array to fill
  15836. * @param attributes Attributes array to fill
  15837. * @param samplers Samplers array to fill
  15838. */
  15839. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15840. /** @hidden */
  15841. private _getEffect;
  15842. /**
  15843. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15844. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15845. */
  15846. animate(preWarmOnly?: boolean): void;
  15847. private _appendParticleVertices;
  15848. /**
  15849. * Rebuilds the particle system.
  15850. */
  15851. rebuild(): void;
  15852. /**
  15853. * Is this system ready to be used/rendered
  15854. * @return true if the system is ready
  15855. */
  15856. isReady(): boolean;
  15857. private _render;
  15858. /**
  15859. * Renders the particle system in its current state.
  15860. * @returns the current number of particles
  15861. */
  15862. render(): number;
  15863. /**
  15864. * Disposes the particle system and free the associated resources
  15865. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15866. */
  15867. dispose(disposeTexture?: boolean): void;
  15868. /**
  15869. * Clones the particle system.
  15870. * @param name The name of the cloned object
  15871. * @param newEmitter The new emitter to use
  15872. * @returns the cloned particle system
  15873. */
  15874. clone(name: string, newEmitter: any): ParticleSystem;
  15875. /**
  15876. * Serializes the particle system to a JSON object
  15877. * @param serializeTexture defines if the texture must be serialized as well
  15878. * @returns the JSON object
  15879. */
  15880. serialize(serializeTexture?: boolean): any;
  15881. /** @hidden */
  15882. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15883. /** @hidden */
  15884. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15885. /**
  15886. * Parses a JSON object to create a particle system.
  15887. * @param parsedParticleSystem The JSON object to parse
  15888. * @param sceneOrEngine The scene or the engine to create the particle system in
  15889. * @param rootUrl The root url to use to load external dependencies like texture
  15890. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15891. * @returns the Parsed particle system
  15892. */
  15893. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15894. }
  15895. }
  15896. declare module "babylonjs/Particles/particle" {
  15897. import { Nullable } from "babylonjs/types";
  15898. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15899. import { Color4 } from "babylonjs/Maths/math.color";
  15900. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15901. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15902. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15903. /**
  15904. * A particle represents one of the element emitted by a particle system.
  15905. * This is mainly define by its coordinates, direction, velocity and age.
  15906. */
  15907. export class Particle {
  15908. /**
  15909. * The particle system the particle belongs to.
  15910. */
  15911. particleSystem: ParticleSystem;
  15912. private static _Count;
  15913. /**
  15914. * Unique ID of the particle
  15915. */
  15916. id: number;
  15917. /**
  15918. * The world position of the particle in the scene.
  15919. */
  15920. position: Vector3;
  15921. /**
  15922. * The world direction of the particle in the scene.
  15923. */
  15924. direction: Vector3;
  15925. /**
  15926. * The color of the particle.
  15927. */
  15928. color: Color4;
  15929. /**
  15930. * The color change of the particle per step.
  15931. */
  15932. colorStep: Color4;
  15933. /**
  15934. * Defines how long will the life of the particle be.
  15935. */
  15936. lifeTime: number;
  15937. /**
  15938. * The current age of the particle.
  15939. */
  15940. age: number;
  15941. /**
  15942. * The current size of the particle.
  15943. */
  15944. size: number;
  15945. /**
  15946. * The current scale of the particle.
  15947. */
  15948. scale: Vector2;
  15949. /**
  15950. * The current angle of the particle.
  15951. */
  15952. angle: number;
  15953. /**
  15954. * Defines how fast is the angle changing.
  15955. */
  15956. angularSpeed: number;
  15957. /**
  15958. * Defines the cell index used by the particle to be rendered from a sprite.
  15959. */
  15960. cellIndex: number;
  15961. /**
  15962. * The information required to support color remapping
  15963. */
  15964. remapData: Vector4;
  15965. /** @hidden */
  15966. _randomCellOffset?: number;
  15967. /** @hidden */
  15968. _initialDirection: Nullable<Vector3>;
  15969. /** @hidden */
  15970. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15971. /** @hidden */
  15972. _initialStartSpriteCellID: number;
  15973. /** @hidden */
  15974. _initialEndSpriteCellID: number;
  15975. /** @hidden */
  15976. _currentColorGradient: Nullable<ColorGradient>;
  15977. /** @hidden */
  15978. _currentColor1: Color4;
  15979. /** @hidden */
  15980. _currentColor2: Color4;
  15981. /** @hidden */
  15982. _currentSizeGradient: Nullable<FactorGradient>;
  15983. /** @hidden */
  15984. _currentSize1: number;
  15985. /** @hidden */
  15986. _currentSize2: number;
  15987. /** @hidden */
  15988. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15989. /** @hidden */
  15990. _currentAngularSpeed1: number;
  15991. /** @hidden */
  15992. _currentAngularSpeed2: number;
  15993. /** @hidden */
  15994. _currentVelocityGradient: Nullable<FactorGradient>;
  15995. /** @hidden */
  15996. _currentVelocity1: number;
  15997. /** @hidden */
  15998. _currentVelocity2: number;
  15999. /** @hidden */
  16000. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16001. /** @hidden */
  16002. _currentLimitVelocity1: number;
  16003. /** @hidden */
  16004. _currentLimitVelocity2: number;
  16005. /** @hidden */
  16006. _currentDragGradient: Nullable<FactorGradient>;
  16007. /** @hidden */
  16008. _currentDrag1: number;
  16009. /** @hidden */
  16010. _currentDrag2: number;
  16011. /** @hidden */
  16012. _randomNoiseCoordinates1: Vector3;
  16013. /** @hidden */
  16014. _randomNoiseCoordinates2: Vector3;
  16015. /** @hidden */
  16016. _localPosition?: Vector3;
  16017. /**
  16018. * Creates a new instance Particle
  16019. * @param particleSystem the particle system the particle belongs to
  16020. */
  16021. constructor(
  16022. /**
  16023. * The particle system the particle belongs to.
  16024. */
  16025. particleSystem: ParticleSystem);
  16026. private updateCellInfoFromSystem;
  16027. /**
  16028. * Defines how the sprite cell index is updated for the particle
  16029. */
  16030. updateCellIndex(): void;
  16031. /** @hidden */
  16032. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16033. /** @hidden */
  16034. _inheritParticleInfoToSubEmitters(): void;
  16035. /** @hidden */
  16036. _reset(): void;
  16037. /**
  16038. * Copy the properties of particle to another one.
  16039. * @param other the particle to copy the information to.
  16040. */
  16041. copyTo(other: Particle): void;
  16042. }
  16043. }
  16044. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16045. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16046. import { Effect } from "babylonjs/Materials/effect";
  16047. import { Particle } from "babylonjs/Particles/particle";
  16048. import { Nullable } from "babylonjs/types";
  16049. import { Scene } from "babylonjs/scene";
  16050. /**
  16051. * Particle emitter represents a volume emitting particles.
  16052. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16053. */
  16054. export interface IParticleEmitterType {
  16055. /**
  16056. * Called by the particle System when the direction is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param directionToUpdate is the direction vector to update with the result
  16059. * @param particle is the particle we are computed the direction for
  16060. * @param isLocal defines if the direction should be set in local space
  16061. */
  16062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16063. /**
  16064. * Called by the particle System when the position is computed for the created particle.
  16065. * @param worldMatrix is the world matrix of the particle system
  16066. * @param positionToUpdate is the position vector to update with the result
  16067. * @param particle is the particle we are computed the position for
  16068. * @param isLocal defines if the position should be set in local space
  16069. */
  16070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16071. /**
  16072. * Clones the current emitter and returns a copy of it
  16073. * @returns the new emitter
  16074. */
  16075. clone(): IParticleEmitterType;
  16076. /**
  16077. * Called by the GPUParticleSystem to setup the update shader
  16078. * @param effect defines the update shader
  16079. */
  16080. applyToShader(effect: Effect): void;
  16081. /**
  16082. * Returns a string to use to update the GPU particles update shader
  16083. * @returns the effect defines string
  16084. */
  16085. getEffectDefines(): string;
  16086. /**
  16087. * Returns a string representing the class name
  16088. * @returns a string containing the class name
  16089. */
  16090. getClassName(): string;
  16091. /**
  16092. * Serializes the particle system to a JSON object.
  16093. * @returns the JSON object
  16094. */
  16095. serialize(): any;
  16096. /**
  16097. * Parse properties from a JSON object
  16098. * @param serializationObject defines the JSON object
  16099. * @param scene defines the hosting scene
  16100. */
  16101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16102. }
  16103. }
  16104. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16106. import { Effect } from "babylonjs/Materials/effect";
  16107. import { Particle } from "babylonjs/Particles/particle";
  16108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16109. /**
  16110. * Particle emitter emitting particles from the inside of a box.
  16111. * It emits the particles randomly between 2 given directions.
  16112. */
  16113. export class BoxParticleEmitter implements IParticleEmitterType {
  16114. /**
  16115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16116. */
  16117. direction1: Vector3;
  16118. /**
  16119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16120. */
  16121. direction2: Vector3;
  16122. /**
  16123. * 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.
  16124. */
  16125. minEmitBox: Vector3;
  16126. /**
  16127. * 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.
  16128. */
  16129. maxEmitBox: Vector3;
  16130. /**
  16131. * Creates a new instance BoxParticleEmitter
  16132. */
  16133. constructor();
  16134. /**
  16135. * Called by the particle System when the direction is computed for the created particle.
  16136. * @param worldMatrix is the world matrix of the particle system
  16137. * @param directionToUpdate is the direction vector to update with the result
  16138. * @param particle is the particle we are computed the direction for
  16139. * @param isLocal defines if the direction should be set in local space
  16140. */
  16141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16142. /**
  16143. * Called by the particle System when the position is computed for the created particle.
  16144. * @param worldMatrix is the world matrix of the particle system
  16145. * @param positionToUpdate is the position vector to update with the result
  16146. * @param particle is the particle we are computed the position for
  16147. * @param isLocal defines if the position should be set in local space
  16148. */
  16149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16150. /**
  16151. * Clones the current emitter and returns a copy of it
  16152. * @returns the new emitter
  16153. */
  16154. clone(): BoxParticleEmitter;
  16155. /**
  16156. * Called by the GPUParticleSystem to setup the update shader
  16157. * @param effect defines the update shader
  16158. */
  16159. applyToShader(effect: Effect): void;
  16160. /**
  16161. * Returns a string to use to update the GPU particles update shader
  16162. * @returns a string containng the defines string
  16163. */
  16164. getEffectDefines(): string;
  16165. /**
  16166. * Returns the string "BoxParticleEmitter"
  16167. * @returns a string containing the class name
  16168. */
  16169. getClassName(): string;
  16170. /**
  16171. * Serializes the particle system to a JSON object.
  16172. * @returns the JSON object
  16173. */
  16174. serialize(): any;
  16175. /**
  16176. * Parse properties from a JSON object
  16177. * @param serializationObject defines the JSON object
  16178. */
  16179. parse(serializationObject: any): void;
  16180. }
  16181. }
  16182. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16184. import { Effect } from "babylonjs/Materials/effect";
  16185. import { Particle } from "babylonjs/Particles/particle";
  16186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16187. /**
  16188. * Particle emitter emitting particles from the inside of a cone.
  16189. * It emits the particles alongside the cone volume from the base to the particle.
  16190. * The emission direction might be randomized.
  16191. */
  16192. export class ConeParticleEmitter implements IParticleEmitterType {
  16193. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16194. directionRandomizer: number;
  16195. private _radius;
  16196. private _angle;
  16197. private _height;
  16198. /**
  16199. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16200. */
  16201. radiusRange: number;
  16202. /**
  16203. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16204. */
  16205. heightRange: number;
  16206. /**
  16207. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16208. */
  16209. emitFromSpawnPointOnly: boolean;
  16210. /**
  16211. * Gets or sets the radius of the emission cone
  16212. */
  16213. get radius(): number;
  16214. set radius(value: number);
  16215. /**
  16216. * Gets or sets the angle of the emission cone
  16217. */
  16218. get angle(): number;
  16219. set angle(value: number);
  16220. private _buildHeight;
  16221. /**
  16222. * Creates a new instance ConeParticleEmitter
  16223. * @param radius the radius of the emission cone (1 by default)
  16224. * @param angle the cone base angle (PI by default)
  16225. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16226. */
  16227. constructor(radius?: number, angle?: number,
  16228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16229. directionRandomizer?: number);
  16230. /**
  16231. * Called by the particle System when the direction is computed for the created particle.
  16232. * @param worldMatrix is the world matrix of the particle system
  16233. * @param directionToUpdate is the direction vector to update with the result
  16234. * @param particle is the particle we are computed the direction for
  16235. * @param isLocal defines if the direction should be set in local space
  16236. */
  16237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16238. /**
  16239. * Called by the particle System when the position is computed for the created particle.
  16240. * @param worldMatrix is the world matrix of the particle system
  16241. * @param positionToUpdate is the position vector to update with the result
  16242. * @param particle is the particle we are computed the position for
  16243. * @param isLocal defines if the position should be set in local space
  16244. */
  16245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16246. /**
  16247. * Clones the current emitter and returns a copy of it
  16248. * @returns the new emitter
  16249. */
  16250. clone(): ConeParticleEmitter;
  16251. /**
  16252. * Called by the GPUParticleSystem to setup the update shader
  16253. * @param effect defines the update shader
  16254. */
  16255. applyToShader(effect: Effect): void;
  16256. /**
  16257. * Returns a string to use to update the GPU particles update shader
  16258. * @returns a string containng the defines string
  16259. */
  16260. getEffectDefines(): string;
  16261. /**
  16262. * Returns the string "ConeParticleEmitter"
  16263. * @returns a string containing the class name
  16264. */
  16265. getClassName(): string;
  16266. /**
  16267. * Serializes the particle system to a JSON object.
  16268. * @returns the JSON object
  16269. */
  16270. serialize(): any;
  16271. /**
  16272. * Parse properties from a JSON object
  16273. * @param serializationObject defines the JSON object
  16274. */
  16275. parse(serializationObject: any): void;
  16276. }
  16277. }
  16278. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16279. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16280. import { Effect } from "babylonjs/Materials/effect";
  16281. import { Particle } from "babylonjs/Particles/particle";
  16282. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16283. /**
  16284. * Particle emitter emitting particles from the inside of a cylinder.
  16285. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16286. */
  16287. export class CylinderParticleEmitter implements IParticleEmitterType {
  16288. /**
  16289. * The radius of the emission cylinder.
  16290. */
  16291. radius: number;
  16292. /**
  16293. * The height of the emission cylinder.
  16294. */
  16295. height: number;
  16296. /**
  16297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16298. */
  16299. radiusRange: number;
  16300. /**
  16301. * How much to randomize the particle direction [0-1].
  16302. */
  16303. directionRandomizer: number;
  16304. /**
  16305. * Creates a new instance CylinderParticleEmitter
  16306. * @param radius the radius of the emission cylinder (1 by default)
  16307. * @param height the height of the emission cylinder (1 by default)
  16308. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16309. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16310. */
  16311. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  16330. * @param worldMatrix is the world matrix of the particle system
  16331. * @param directionToUpdate is the direction vector to update with the result
  16332. * @param particle is the particle we are computed the direction for
  16333. * @param isLocal defines if the direction should be set in local space
  16334. */
  16335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16336. /**
  16337. * Called by the particle System when the position is computed for the created particle.
  16338. * @param worldMatrix is the world matrix of the particle system
  16339. * @param positionToUpdate is the position vector to update with the result
  16340. * @param particle is the particle we are computed the position for
  16341. * @param isLocal defines if the position should be set in local space
  16342. */
  16343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16344. /**
  16345. * Clones the current emitter and returns a copy of it
  16346. * @returns the new emitter
  16347. */
  16348. clone(): CylinderParticleEmitter;
  16349. /**
  16350. * Called by the GPUParticleSystem to setup the update shader
  16351. * @param effect defines the update shader
  16352. */
  16353. applyToShader(effect: Effect): void;
  16354. /**
  16355. * Returns a string to use to update the GPU particles update shader
  16356. * @returns a string containng the defines string
  16357. */
  16358. getEffectDefines(): string;
  16359. /**
  16360. * Returns the string "CylinderParticleEmitter"
  16361. * @returns a string containing the class name
  16362. */
  16363. getClassName(): string;
  16364. /**
  16365. * Serializes the particle system to a JSON object.
  16366. * @returns the JSON object
  16367. */
  16368. serialize(): any;
  16369. /**
  16370. * Parse properties from a JSON object
  16371. * @param serializationObject defines the JSON object
  16372. */
  16373. parse(serializationObject: any): void;
  16374. }
  16375. /**
  16376. * Particle emitter emitting particles from the inside of a cylinder.
  16377. * It emits the particles randomly between two vectors.
  16378. */
  16379. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16380. /**
  16381. * The min limit of the emission direction.
  16382. */
  16383. direction1: Vector3;
  16384. /**
  16385. * The max limit of the emission direction.
  16386. */
  16387. direction2: Vector3;
  16388. /**
  16389. * Creates a new instance CylinderDirectedParticleEmitter
  16390. * @param radius the radius of the emission cylinder (1 by default)
  16391. * @param height the height of the emission cylinder (1 by default)
  16392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16393. * @param direction1 the min limit of the emission direction (up vector by default)
  16394. * @param direction2 the max limit of the emission direction (up vector by default)
  16395. */
  16396. constructor(radius?: number, height?: number, radiusRange?: number,
  16397. /**
  16398. * The min limit of the emission direction.
  16399. */
  16400. direction1?: Vector3,
  16401. /**
  16402. * The max limit of the emission direction.
  16403. */
  16404. direction2?: Vector3);
  16405. /**
  16406. * Called by the particle System when the direction is computed for the created particle.
  16407. * @param worldMatrix is the world matrix of the particle system
  16408. * @param directionToUpdate is the direction vector to update with the result
  16409. * @param particle is the particle we are computed the direction for
  16410. */
  16411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16412. /**
  16413. * Clones the current emitter and returns a copy of it
  16414. * @returns the new emitter
  16415. */
  16416. clone(): CylinderDirectedParticleEmitter;
  16417. /**
  16418. * Called by the GPUParticleSystem to setup the update shader
  16419. * @param effect defines the update shader
  16420. */
  16421. applyToShader(effect: Effect): void;
  16422. /**
  16423. * Returns a string to use to update the GPU particles update shader
  16424. * @returns a string containng the defines string
  16425. */
  16426. getEffectDefines(): string;
  16427. /**
  16428. * Returns the string "CylinderDirectedParticleEmitter"
  16429. * @returns a string containing the class name
  16430. */
  16431. getClassName(): string;
  16432. /**
  16433. * Serializes the particle system to a JSON object.
  16434. * @returns the JSON object
  16435. */
  16436. serialize(): any;
  16437. /**
  16438. * Parse properties from a JSON object
  16439. * @param serializationObject defines the JSON object
  16440. */
  16441. parse(serializationObject: any): void;
  16442. }
  16443. }
  16444. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16445. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16446. import { Effect } from "babylonjs/Materials/effect";
  16447. import { Particle } from "babylonjs/Particles/particle";
  16448. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16449. /**
  16450. * Particle emitter emitting particles from the inside of a hemisphere.
  16451. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16452. */
  16453. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16454. /**
  16455. * The radius of the emission hemisphere.
  16456. */
  16457. radius: number;
  16458. /**
  16459. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16460. */
  16461. radiusRange: number;
  16462. /**
  16463. * How much to randomize the particle direction [0-1].
  16464. */
  16465. directionRandomizer: number;
  16466. /**
  16467. * Creates a new instance HemisphericParticleEmitter
  16468. * @param radius the radius of the emission hemisphere (1 by default)
  16469. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16470. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16471. */
  16472. constructor(
  16473. /**
  16474. * The radius of the emission hemisphere.
  16475. */
  16476. radius?: number,
  16477. /**
  16478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16479. */
  16480. radiusRange?: number,
  16481. /**
  16482. * How much to randomize the particle direction [0-1].
  16483. */
  16484. directionRandomizer?: number);
  16485. /**
  16486. * Called by the particle System when the direction is computed for the created particle.
  16487. * @param worldMatrix is the world matrix of the particle system
  16488. * @param directionToUpdate is the direction vector to update with the result
  16489. * @param particle is the particle we are computed the direction for
  16490. * @param isLocal defines if the direction should be set in local space
  16491. */
  16492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16493. /**
  16494. * Called by the particle System when the position is computed for the created particle.
  16495. * @param worldMatrix is the world matrix of the particle system
  16496. * @param positionToUpdate is the position vector to update with the result
  16497. * @param particle is the particle we are computed the position for
  16498. * @param isLocal defines if the position should be set in local space
  16499. */
  16500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16501. /**
  16502. * Clones the current emitter and returns a copy of it
  16503. * @returns the new emitter
  16504. */
  16505. clone(): HemisphericParticleEmitter;
  16506. /**
  16507. * Called by the GPUParticleSystem to setup the update shader
  16508. * @param effect defines the update shader
  16509. */
  16510. applyToShader(effect: Effect): void;
  16511. /**
  16512. * Returns a string to use to update the GPU particles update shader
  16513. * @returns a string containng the defines string
  16514. */
  16515. getEffectDefines(): string;
  16516. /**
  16517. * Returns the string "HemisphericParticleEmitter"
  16518. * @returns a string containing the class name
  16519. */
  16520. getClassName(): string;
  16521. /**
  16522. * Serializes the particle system to a JSON object.
  16523. * @returns the JSON object
  16524. */
  16525. serialize(): any;
  16526. /**
  16527. * Parse properties from a JSON object
  16528. * @param serializationObject defines the JSON object
  16529. */
  16530. parse(serializationObject: any): void;
  16531. }
  16532. }
  16533. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16534. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16535. import { Effect } from "babylonjs/Materials/effect";
  16536. import { Particle } from "babylonjs/Particles/particle";
  16537. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16538. /**
  16539. * Particle emitter emitting particles from a point.
  16540. * It emits the particles randomly between 2 given directions.
  16541. */
  16542. export class PointParticleEmitter implements IParticleEmitterType {
  16543. /**
  16544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16545. */
  16546. direction1: Vector3;
  16547. /**
  16548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16549. */
  16550. direction2: Vector3;
  16551. /**
  16552. * Creates a new instance PointParticleEmitter
  16553. */
  16554. constructor();
  16555. /**
  16556. * Called by the particle System when the direction is computed for the created particle.
  16557. * @param worldMatrix is the world matrix of the particle system
  16558. * @param directionToUpdate is the direction vector to update with the result
  16559. * @param particle is the particle we are computed the direction for
  16560. * @param isLocal defines if the direction should be set in local space
  16561. */
  16562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16563. /**
  16564. * Called by the particle System when the position is computed for the created particle.
  16565. * @param worldMatrix is the world matrix of the particle system
  16566. * @param positionToUpdate is the position vector to update with the result
  16567. * @param particle is the particle we are computed the position for
  16568. * @param isLocal defines if the position should be set in local space
  16569. */
  16570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16571. /**
  16572. * Clones the current emitter and returns a copy of it
  16573. * @returns the new emitter
  16574. */
  16575. clone(): PointParticleEmitter;
  16576. /**
  16577. * Called by the GPUParticleSystem to setup the update shader
  16578. * @param effect defines the update shader
  16579. */
  16580. applyToShader(effect: Effect): void;
  16581. /**
  16582. * Returns a string to use to update the GPU particles update shader
  16583. * @returns a string containng the defines string
  16584. */
  16585. getEffectDefines(): string;
  16586. /**
  16587. * Returns the string "PointParticleEmitter"
  16588. * @returns a string containing the class name
  16589. */
  16590. getClassName(): string;
  16591. /**
  16592. * Serializes the particle system to a JSON object.
  16593. * @returns the JSON object
  16594. */
  16595. serialize(): any;
  16596. /**
  16597. * Parse properties from a JSON object
  16598. * @param serializationObject defines the JSON object
  16599. */
  16600. parse(serializationObject: any): void;
  16601. }
  16602. }
  16603. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16605. import { Effect } from "babylonjs/Materials/effect";
  16606. import { Particle } from "babylonjs/Particles/particle";
  16607. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16608. /**
  16609. * Particle emitter emitting particles from the inside of a sphere.
  16610. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16611. */
  16612. export class SphereParticleEmitter implements IParticleEmitterType {
  16613. /**
  16614. * The radius of the emission sphere.
  16615. */
  16616. radius: number;
  16617. /**
  16618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16619. */
  16620. radiusRange: number;
  16621. /**
  16622. * How much to randomize the particle direction [0-1].
  16623. */
  16624. directionRandomizer: number;
  16625. /**
  16626. * Creates a new instance SphereParticleEmitter
  16627. * @param radius the radius of the emission sphere (1 by default)
  16628. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16629. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16630. */
  16631. constructor(
  16632. /**
  16633. * The radius of the emission sphere.
  16634. */
  16635. radius?: number,
  16636. /**
  16637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16638. */
  16639. radiusRange?: number,
  16640. /**
  16641. * How much to randomize the particle direction [0-1].
  16642. */
  16643. directionRandomizer?: number);
  16644. /**
  16645. * Called by the particle System when the direction is computed for the created particle.
  16646. * @param worldMatrix is the world matrix of the particle system
  16647. * @param directionToUpdate is the direction vector to update with the result
  16648. * @param particle is the particle we are computed the direction for
  16649. * @param isLocal defines if the direction should be set in local space
  16650. */
  16651. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16652. /**
  16653. * Called by the particle System when the position is computed for the created particle.
  16654. * @param worldMatrix is the world matrix of the particle system
  16655. * @param positionToUpdate is the position vector to update with the result
  16656. * @param particle is the particle we are computed the position for
  16657. * @param isLocal defines if the position should be set in local space
  16658. */
  16659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16660. /**
  16661. * Clones the current emitter and returns a copy of it
  16662. * @returns the new emitter
  16663. */
  16664. clone(): SphereParticleEmitter;
  16665. /**
  16666. * Called by the GPUParticleSystem to setup the update shader
  16667. * @param effect defines the update shader
  16668. */
  16669. applyToShader(effect: Effect): void;
  16670. /**
  16671. * Returns a string to use to update the GPU particles update shader
  16672. * @returns a string containng the defines string
  16673. */
  16674. getEffectDefines(): string;
  16675. /**
  16676. * Returns the string "SphereParticleEmitter"
  16677. * @returns a string containing the class name
  16678. */
  16679. getClassName(): string;
  16680. /**
  16681. * Serializes the particle system to a JSON object.
  16682. * @returns the JSON object
  16683. */
  16684. serialize(): any;
  16685. /**
  16686. * Parse properties from a JSON object
  16687. * @param serializationObject defines the JSON object
  16688. */
  16689. parse(serializationObject: any): void;
  16690. }
  16691. /**
  16692. * Particle emitter emitting particles from the inside of a sphere.
  16693. * It emits the particles randomly between two vectors.
  16694. */
  16695. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16696. /**
  16697. * The min limit of the emission direction.
  16698. */
  16699. direction1: Vector3;
  16700. /**
  16701. * The max limit of the emission direction.
  16702. */
  16703. direction2: Vector3;
  16704. /**
  16705. * Creates a new instance SphereDirectedParticleEmitter
  16706. * @param radius the radius of the emission sphere (1 by default)
  16707. * @param direction1 the min limit of the emission direction (up vector by default)
  16708. * @param direction2 the max limit of the emission direction (up vector by default)
  16709. */
  16710. constructor(radius?: number,
  16711. /**
  16712. * The min limit of the emission direction.
  16713. */
  16714. direction1?: Vector3,
  16715. /**
  16716. * The max limit of the emission direction.
  16717. */
  16718. direction2?: Vector3);
  16719. /**
  16720. * Called by the particle System when the direction is computed for the created particle.
  16721. * @param worldMatrix is the world matrix of the particle system
  16722. * @param directionToUpdate is the direction vector to update with the result
  16723. * @param particle is the particle we are computed the direction for
  16724. */
  16725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16726. /**
  16727. * Clones the current emitter and returns a copy of it
  16728. * @returns the new emitter
  16729. */
  16730. clone(): SphereDirectedParticleEmitter;
  16731. /**
  16732. * Called by the GPUParticleSystem to setup the update shader
  16733. * @param effect defines the update shader
  16734. */
  16735. applyToShader(effect: Effect): void;
  16736. /**
  16737. * Returns a string to use to update the GPU particles update shader
  16738. * @returns a string containng the defines string
  16739. */
  16740. getEffectDefines(): string;
  16741. /**
  16742. * Returns the string "SphereDirectedParticleEmitter"
  16743. * @returns a string containing the class name
  16744. */
  16745. getClassName(): string;
  16746. /**
  16747. * Serializes the particle system to a JSON object.
  16748. * @returns the JSON object
  16749. */
  16750. serialize(): any;
  16751. /**
  16752. * Parse properties from a JSON object
  16753. * @param serializationObject defines the JSON object
  16754. */
  16755. parse(serializationObject: any): void;
  16756. }
  16757. }
  16758. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16760. import { Effect } from "babylonjs/Materials/effect";
  16761. import { Particle } from "babylonjs/Particles/particle";
  16762. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16763. import { Nullable } from "babylonjs/types";
  16764. /**
  16765. * Particle emitter emitting particles from a custom list of positions.
  16766. */
  16767. export class CustomParticleEmitter implements IParticleEmitterType {
  16768. /**
  16769. * Gets or sets the position generator that will create the inital position of each particle.
  16770. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16771. */
  16772. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16773. /**
  16774. * Gets or sets the destination generator that will create the final destination of each particle.
  16775. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16776. */
  16777. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16778. /**
  16779. * Creates a new instance CustomParticleEmitter
  16780. */
  16781. constructor();
  16782. /**
  16783. * Called by the particle System when the direction is computed for the created particle.
  16784. * @param worldMatrix is the world matrix of the particle system
  16785. * @param directionToUpdate is the direction vector to update with the result
  16786. * @param particle is the particle we are computed the direction for
  16787. * @param isLocal defines if the direction should be set in local space
  16788. */
  16789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16790. /**
  16791. * Called by the particle System when the position is computed for the created particle.
  16792. * @param worldMatrix is the world matrix of the particle system
  16793. * @param positionToUpdate is the position vector to update with the result
  16794. * @param particle is the particle we are computed the position for
  16795. * @param isLocal defines if the position should be set in local space
  16796. */
  16797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16798. /**
  16799. * Clones the current emitter and returns a copy of it
  16800. * @returns the new emitter
  16801. */
  16802. clone(): CustomParticleEmitter;
  16803. /**
  16804. * Called by the GPUParticleSystem to setup the update shader
  16805. * @param effect defines the update shader
  16806. */
  16807. applyToShader(effect: Effect): void;
  16808. /**
  16809. * Returns a string to use to update the GPU particles update shader
  16810. * @returns a string containng the defines string
  16811. */
  16812. getEffectDefines(): string;
  16813. /**
  16814. * Returns the string "PointParticleEmitter"
  16815. * @returns a string containing the class name
  16816. */
  16817. getClassName(): string;
  16818. /**
  16819. * Serializes the particle system to a JSON object.
  16820. * @returns the JSON object
  16821. */
  16822. serialize(): any;
  16823. /**
  16824. * Parse properties from a JSON object
  16825. * @param serializationObject defines the JSON object
  16826. */
  16827. parse(serializationObject: any): void;
  16828. }
  16829. }
  16830. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16832. import { Effect } from "babylonjs/Materials/effect";
  16833. import { Particle } from "babylonjs/Particles/particle";
  16834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16835. import { Nullable } from "babylonjs/types";
  16836. import { Scene } from "babylonjs/scene";
  16837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16838. /**
  16839. * Particle emitter emitting particles from the inside of a box.
  16840. * It emits the particles randomly between 2 given directions.
  16841. */
  16842. export class MeshParticleEmitter implements IParticleEmitterType {
  16843. private _indices;
  16844. private _positions;
  16845. private _normals;
  16846. private _storedNormal;
  16847. private _mesh;
  16848. /**
  16849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16850. */
  16851. direction1: Vector3;
  16852. /**
  16853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16854. */
  16855. direction2: Vector3;
  16856. /**
  16857. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16858. */
  16859. useMeshNormalsForDirection: boolean;
  16860. /** Defines the mesh to use as source */
  16861. get mesh(): Nullable<AbstractMesh>;
  16862. set mesh(value: Nullable<AbstractMesh>);
  16863. /**
  16864. * Creates a new instance MeshParticleEmitter
  16865. * @param mesh defines the mesh to use as source
  16866. */
  16867. constructor(mesh?: Nullable<AbstractMesh>);
  16868. /**
  16869. * Called by the particle System when the direction is computed for the created particle.
  16870. * @param worldMatrix is the world matrix of the particle system
  16871. * @param directionToUpdate is the direction vector to update with the result
  16872. * @param particle is the particle we are computed the direction for
  16873. * @param isLocal defines if the direction should be set in local space
  16874. */
  16875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16876. /**
  16877. * Called by the particle System when the position is computed for the created particle.
  16878. * @param worldMatrix is the world matrix of the particle system
  16879. * @param positionToUpdate is the position vector to update with the result
  16880. * @param particle is the particle we are computed the position for
  16881. * @param isLocal defines if the position should be set in local space
  16882. */
  16883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16884. /**
  16885. * Clones the current emitter and returns a copy of it
  16886. * @returns the new emitter
  16887. */
  16888. clone(): MeshParticleEmitter;
  16889. /**
  16890. * Called by the GPUParticleSystem to setup the update shader
  16891. * @param effect defines the update shader
  16892. */
  16893. applyToShader(effect: Effect): void;
  16894. /**
  16895. * Returns a string to use to update the GPU particles update shader
  16896. * @returns a string containng the defines string
  16897. */
  16898. getEffectDefines(): string;
  16899. /**
  16900. * Returns the string "BoxParticleEmitter"
  16901. * @returns a string containing the class name
  16902. */
  16903. getClassName(): string;
  16904. /**
  16905. * Serializes the particle system to a JSON object.
  16906. * @returns the JSON object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Parse properties from a JSON object
  16911. * @param serializationObject defines the JSON object
  16912. * @param scene defines the hosting scene
  16913. */
  16914. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16915. }
  16916. }
  16917. declare module "babylonjs/Particles/EmitterTypes/index" {
  16918. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16919. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16920. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16921. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16922. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16923. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16924. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16925. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16926. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16927. }
  16928. declare module "babylonjs/Particles/IParticleSystem" {
  16929. import { Nullable } from "babylonjs/types";
  16930. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16931. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16933. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16934. import { Scene } from "babylonjs/scene";
  16935. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16936. import { Effect } from "babylonjs/Materials/effect";
  16937. import { Observable } from "babylonjs/Misc/observable";
  16938. import { Animation } from "babylonjs/Animations/animation";
  16939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16940. /**
  16941. * Interface representing a particle system in Babylon.js.
  16942. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16943. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16944. */
  16945. export interface IParticleSystem {
  16946. /**
  16947. * List of animations used by the particle system.
  16948. */
  16949. animations: Animation[];
  16950. /**
  16951. * The id of the Particle system.
  16952. */
  16953. id: string;
  16954. /**
  16955. * The name of the Particle system.
  16956. */
  16957. name: string;
  16958. /**
  16959. * The emitter represents the Mesh or position we are attaching the particle system to.
  16960. */
  16961. emitter: Nullable<AbstractMesh | Vector3>;
  16962. /**
  16963. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16964. */
  16965. isBillboardBased: boolean;
  16966. /**
  16967. * The rendering group used by the Particle system to chose when to render.
  16968. */
  16969. renderingGroupId: number;
  16970. /**
  16971. * The layer mask we are rendering the particles through.
  16972. */
  16973. layerMask: number;
  16974. /**
  16975. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16976. */
  16977. updateSpeed: number;
  16978. /**
  16979. * The amount of time the particle system is running (depends of the overall update speed).
  16980. */
  16981. targetStopDuration: number;
  16982. /**
  16983. * The texture used to render each particle. (this can be a spritesheet)
  16984. */
  16985. particleTexture: Nullable<BaseTexture>;
  16986. /**
  16987. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16988. */
  16989. blendMode: number;
  16990. /**
  16991. * Minimum life time of emitting particles.
  16992. */
  16993. minLifeTime: number;
  16994. /**
  16995. * Maximum life time of emitting particles.
  16996. */
  16997. maxLifeTime: number;
  16998. /**
  16999. * Minimum Size of emitting particles.
  17000. */
  17001. minSize: number;
  17002. /**
  17003. * Maximum Size of emitting particles.
  17004. */
  17005. maxSize: number;
  17006. /**
  17007. * Minimum scale of emitting particles on X axis.
  17008. */
  17009. minScaleX: number;
  17010. /**
  17011. * Maximum scale of emitting particles on X axis.
  17012. */
  17013. maxScaleX: number;
  17014. /**
  17015. * Minimum scale of emitting particles on Y axis.
  17016. */
  17017. minScaleY: number;
  17018. /**
  17019. * Maximum scale of emitting particles on Y axis.
  17020. */
  17021. maxScaleY: number;
  17022. /**
  17023. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17024. */
  17025. color1: Color4;
  17026. /**
  17027. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17028. */
  17029. color2: Color4;
  17030. /**
  17031. * Color the particle will have at the end of its lifetime.
  17032. */
  17033. colorDead: Color4;
  17034. /**
  17035. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17036. */
  17037. emitRate: number;
  17038. /**
  17039. * You can use gravity if you want to give an orientation to your particles.
  17040. */
  17041. gravity: Vector3;
  17042. /**
  17043. * Minimum power of emitting particles.
  17044. */
  17045. minEmitPower: number;
  17046. /**
  17047. * Maximum power of emitting particles.
  17048. */
  17049. maxEmitPower: number;
  17050. /**
  17051. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17052. */
  17053. minAngularSpeed: number;
  17054. /**
  17055. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17056. */
  17057. maxAngularSpeed: number;
  17058. /**
  17059. * Gets or sets the minimal initial rotation in radians.
  17060. */
  17061. minInitialRotation: number;
  17062. /**
  17063. * Gets or sets the maximal initial rotation in radians.
  17064. */
  17065. maxInitialRotation: number;
  17066. /**
  17067. * The particle emitter type defines the emitter used by the particle system.
  17068. * It can be for example box, sphere, or cone...
  17069. */
  17070. particleEmitterType: Nullable<IParticleEmitterType>;
  17071. /**
  17072. * Defines the delay in milliseconds before starting the system (0 by default)
  17073. */
  17074. startDelay: number;
  17075. /**
  17076. * 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
  17077. */
  17078. preWarmCycles: number;
  17079. /**
  17080. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17081. */
  17082. preWarmStepOffset: number;
  17083. /**
  17084. * 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)
  17085. */
  17086. spriteCellChangeSpeed: number;
  17087. /**
  17088. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17089. */
  17090. startSpriteCellID: number;
  17091. /**
  17092. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17093. */
  17094. endSpriteCellID: number;
  17095. /**
  17096. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17097. */
  17098. spriteCellWidth: number;
  17099. /**
  17100. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17101. */
  17102. spriteCellHeight: number;
  17103. /**
  17104. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17105. */
  17106. spriteRandomStartCell: boolean;
  17107. /**
  17108. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17109. */
  17110. isAnimationSheetEnabled: boolean;
  17111. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17112. translationPivot: Vector2;
  17113. /**
  17114. * Gets or sets a texture used to add random noise to particle positions
  17115. */
  17116. noiseTexture: Nullable<BaseTexture>;
  17117. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17118. noiseStrength: Vector3;
  17119. /**
  17120. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17121. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17122. */
  17123. billboardMode: number;
  17124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17125. limitVelocityDamping: number;
  17126. /**
  17127. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17128. */
  17129. beginAnimationOnStart: boolean;
  17130. /**
  17131. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17132. */
  17133. beginAnimationFrom: number;
  17134. /**
  17135. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17136. */
  17137. beginAnimationTo: number;
  17138. /**
  17139. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17140. */
  17141. beginAnimationLoop: boolean;
  17142. /**
  17143. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17144. */
  17145. disposeOnStop: boolean;
  17146. /**
  17147. * Specifies if the particles are updated in emitter local space or world space
  17148. */
  17149. isLocal: boolean;
  17150. /** Snippet ID if the particle system was created from the snippet server */
  17151. snippetId: string;
  17152. /** Gets or sets a matrix to use to compute projection */
  17153. defaultProjectionMatrix: Matrix;
  17154. /**
  17155. * Gets the maximum number of particles active at the same time.
  17156. * @returns The max number of active particles.
  17157. */
  17158. getCapacity(): number;
  17159. /**
  17160. * Gets the number of particles active at the same time.
  17161. * @returns The number of active particles.
  17162. */
  17163. getActiveCount(): number;
  17164. /**
  17165. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17166. * @returns True if it has been started, otherwise false.
  17167. */
  17168. isStarted(): boolean;
  17169. /**
  17170. * Animates the particle system for this frame.
  17171. */
  17172. animate(): void;
  17173. /**
  17174. * Renders the particle system in its current state.
  17175. * @returns the current number of particles
  17176. */
  17177. render(): number;
  17178. /**
  17179. * Dispose the particle system and frees its associated resources.
  17180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17181. */
  17182. dispose(disposeTexture?: boolean): void;
  17183. /**
  17184. * An event triggered when the system is disposed
  17185. */
  17186. onDisposeObservable: Observable<IParticleSystem>;
  17187. /**
  17188. * An event triggered when the system is stopped
  17189. */
  17190. onStoppedObservable: Observable<IParticleSystem>;
  17191. /**
  17192. * Clones the particle system.
  17193. * @param name The name of the cloned object
  17194. * @param newEmitter The new emitter to use
  17195. * @returns the cloned particle system
  17196. */
  17197. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17198. /**
  17199. * Serializes the particle system to a JSON object
  17200. * @param serializeTexture defines if the texture must be serialized as well
  17201. * @returns the JSON object
  17202. */
  17203. serialize(serializeTexture: boolean): any;
  17204. /**
  17205. * Rebuild the particle system
  17206. */
  17207. rebuild(): void;
  17208. /** Force the system to rebuild all gradients that need to be resync */
  17209. forceRefreshGradients(): void;
  17210. /**
  17211. * Starts the particle system and begins to emit
  17212. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17213. */
  17214. start(delay?: number): void;
  17215. /**
  17216. * Stops the particle system.
  17217. */
  17218. stop(): void;
  17219. /**
  17220. * Remove all active particles
  17221. */
  17222. reset(): void;
  17223. /**
  17224. * Gets a boolean indicating that the system is stopping
  17225. * @returns true if the system is currently stopping
  17226. */
  17227. isStopping(): boolean;
  17228. /**
  17229. * Is this system ready to be used/rendered
  17230. * @return true if the system is ready
  17231. */
  17232. isReady(): boolean;
  17233. /**
  17234. * Returns the string "ParticleSystem"
  17235. * @returns a string containing the class name
  17236. */
  17237. getClassName(): string;
  17238. /**
  17239. * Gets the custom effect used to render the particles
  17240. * @param blendMode Blend mode for which the effect should be retrieved
  17241. * @returns The effect
  17242. */
  17243. getCustomEffect(blendMode: number): Nullable<Effect>;
  17244. /**
  17245. * Sets the custom effect used to render the particles
  17246. * @param effect The effect to set
  17247. * @param blendMode Blend mode for which the effect should be set
  17248. */
  17249. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17250. /**
  17251. * Fill the defines array according to the current settings of the particle system
  17252. * @param defines Array to be updated
  17253. * @param blendMode blend mode to take into account when updating the array
  17254. */
  17255. fillDefines(defines: Array<string>, blendMode: number): void;
  17256. /**
  17257. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17258. * @param uniforms Uniforms array to fill
  17259. * @param attributes Attributes array to fill
  17260. * @param samplers Samplers array to fill
  17261. */
  17262. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17263. /**
  17264. * Observable that will be called just before the particles are drawn
  17265. */
  17266. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17267. /**
  17268. * Gets the name of the particle vertex shader
  17269. */
  17270. vertexShaderName: string;
  17271. /**
  17272. * Adds a new color gradient
  17273. * @param gradient defines the gradient to use (between 0 and 1)
  17274. * @param color1 defines the color to affect to the specified gradient
  17275. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17276. * @returns the current particle system
  17277. */
  17278. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17279. /**
  17280. * Remove a specific color gradient
  17281. * @param gradient defines the gradient to remove
  17282. * @returns the current particle system
  17283. */
  17284. removeColorGradient(gradient: number): IParticleSystem;
  17285. /**
  17286. * Adds a new size gradient
  17287. * @param gradient defines the gradient to use (between 0 and 1)
  17288. * @param factor defines the size factor to affect to the specified gradient
  17289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17290. * @returns the current particle system
  17291. */
  17292. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17293. /**
  17294. * Remove a specific size gradient
  17295. * @param gradient defines the gradient to remove
  17296. * @returns the current particle system
  17297. */
  17298. removeSizeGradient(gradient: number): IParticleSystem;
  17299. /**
  17300. * Gets the current list of color gradients.
  17301. * You must use addColorGradient and removeColorGradient to udpate this list
  17302. * @returns the list of color gradients
  17303. */
  17304. getColorGradients(): Nullable<Array<ColorGradient>>;
  17305. /**
  17306. * Gets the current list of size gradients.
  17307. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17308. * @returns the list of size gradients
  17309. */
  17310. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17311. /**
  17312. * Gets the current list of angular speed gradients.
  17313. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17314. * @returns the list of angular speed gradients
  17315. */
  17316. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17317. /**
  17318. * Adds a new angular speed gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param factor defines the angular speed to affect to the specified gradient
  17321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17322. * @returns the current particle system
  17323. */
  17324. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific angular speed gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Gets the current list of velocity gradients.
  17333. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17334. * @returns the list of velocity gradients
  17335. */
  17336. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Adds a new velocity gradient
  17339. * @param gradient defines the gradient to use (between 0 and 1)
  17340. * @param factor defines the velocity to affect to the specified gradient
  17341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17342. * @returns the current particle system
  17343. */
  17344. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17345. /**
  17346. * Remove a specific velocity gradient
  17347. * @param gradient defines the gradient to remove
  17348. * @returns the current particle system
  17349. */
  17350. removeVelocityGradient(gradient: number): IParticleSystem;
  17351. /**
  17352. * Gets the current list of limit velocity gradients.
  17353. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17354. * @returns the list of limit velocity gradients
  17355. */
  17356. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17357. /**
  17358. * Adds a new limit velocity gradient
  17359. * @param gradient defines the gradient to use (between 0 and 1)
  17360. * @param factor defines the limit velocity to affect to the specified gradient
  17361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17362. * @returns the current particle system
  17363. */
  17364. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17365. /**
  17366. * Remove a specific limit velocity gradient
  17367. * @param gradient defines the gradient to remove
  17368. * @returns the current particle system
  17369. */
  17370. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17371. /**
  17372. * Adds a new drag gradient
  17373. * @param gradient defines the gradient to use (between 0 and 1)
  17374. * @param factor defines the drag to affect to the specified gradient
  17375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17376. * @returns the current particle system
  17377. */
  17378. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17379. /**
  17380. * Remove a specific drag gradient
  17381. * @param gradient defines the gradient to remove
  17382. * @returns the current particle system
  17383. */
  17384. removeDragGradient(gradient: number): IParticleSystem;
  17385. /**
  17386. * Gets the current list of drag gradients.
  17387. * You must use addDragGradient and removeDragGradient to udpate this list
  17388. * @returns the list of drag gradients
  17389. */
  17390. getDragGradients(): Nullable<Array<FactorGradient>>;
  17391. /**
  17392. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17393. * @param gradient defines the gradient to use (between 0 and 1)
  17394. * @param factor defines the emit rate to affect to the specified gradient
  17395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17396. * @returns the current particle system
  17397. */
  17398. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17399. /**
  17400. * Remove a specific emit rate gradient
  17401. * @param gradient defines the gradient to remove
  17402. * @returns the current particle system
  17403. */
  17404. removeEmitRateGradient(gradient: number): IParticleSystem;
  17405. /**
  17406. * Gets the current list of emit rate gradients.
  17407. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17408. * @returns the list of emit rate gradients
  17409. */
  17410. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17411. /**
  17412. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17413. * @param gradient defines the gradient to use (between 0 and 1)
  17414. * @param factor defines the start size to affect to the specified gradient
  17415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17416. * @returns the current particle system
  17417. */
  17418. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17419. /**
  17420. * Remove a specific start size gradient
  17421. * @param gradient defines the gradient to remove
  17422. * @returns the current particle system
  17423. */
  17424. removeStartSizeGradient(gradient: number): IParticleSystem;
  17425. /**
  17426. * Gets the current list of start size gradients.
  17427. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17428. * @returns the list of start size gradients
  17429. */
  17430. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17431. /**
  17432. * Adds a new life time gradient
  17433. * @param gradient defines the gradient to use (between 0 and 1)
  17434. * @param factor defines the life time factor to affect to the specified gradient
  17435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17436. * @returns the current particle system
  17437. */
  17438. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17439. /**
  17440. * Remove a specific life time gradient
  17441. * @param gradient defines the gradient to remove
  17442. * @returns the current particle system
  17443. */
  17444. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17445. /**
  17446. * Gets the current list of life time gradients.
  17447. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17448. * @returns the list of life time gradients
  17449. */
  17450. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17451. /**
  17452. * Gets the current list of color gradients.
  17453. * You must use addColorGradient and removeColorGradient to udpate this list
  17454. * @returns the list of color gradients
  17455. */
  17456. getColorGradients(): Nullable<Array<ColorGradient>>;
  17457. /**
  17458. * Adds a new ramp gradient used to remap particle colors
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param color defines the color to affect to the specified gradient
  17461. * @returns the current particle system
  17462. */
  17463. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17464. /**
  17465. * Gets the current list of ramp gradients.
  17466. * You must use addRampGradient and removeRampGradient to udpate this list
  17467. * @returns the list of ramp gradients
  17468. */
  17469. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17470. /** Gets or sets a boolean indicating that ramp gradients must be used
  17471. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17472. */
  17473. useRampGradients: boolean;
  17474. /**
  17475. * Adds a new color remap gradient
  17476. * @param gradient defines the gradient to use (between 0 and 1)
  17477. * @param min defines the color remap minimal range
  17478. * @param max defines the color remap maximal range
  17479. * @returns the current particle system
  17480. */
  17481. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17482. /**
  17483. * Gets the current list of color remap gradients.
  17484. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17485. * @returns the list of color remap gradients
  17486. */
  17487. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17488. /**
  17489. * Adds a new alpha remap gradient
  17490. * @param gradient defines the gradient to use (between 0 and 1)
  17491. * @param min defines the alpha remap minimal range
  17492. * @param max defines the alpha remap maximal range
  17493. * @returns the current particle system
  17494. */
  17495. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17496. /**
  17497. * Gets the current list of alpha remap gradients.
  17498. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17499. * @returns the list of alpha remap gradients
  17500. */
  17501. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17502. /**
  17503. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17506. * @returns the emitter
  17507. */
  17508. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17509. /**
  17510. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17511. * @param radius The radius of the hemisphere to emit from
  17512. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17513. * @returns the emitter
  17514. */
  17515. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17516. /**
  17517. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17518. * @param radius The radius of the sphere to emit from
  17519. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17520. * @returns the emitter
  17521. */
  17522. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17523. /**
  17524. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17525. * @param radius The radius of the sphere to emit from
  17526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17528. * @returns the emitter
  17529. */
  17530. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17531. /**
  17532. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17533. * @param radius The radius of the emission cylinder
  17534. * @param height The height of the emission cylinder
  17535. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17536. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17537. * @returns the emitter
  17538. */
  17539. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17540. /**
  17541. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17542. * @param radius The radius of the cylinder to emit from
  17543. * @param height The height of the emission cylinder
  17544. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17545. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17546. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17547. * @returns the emitter
  17548. */
  17549. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17550. /**
  17551. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17552. * @param radius The radius of the cone to emit from
  17553. * @param angle The base angle of the cone
  17554. * @returns the emitter
  17555. */
  17556. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17557. /**
  17558. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17561. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17562. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17563. * @returns the emitter
  17564. */
  17565. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17566. /**
  17567. * Get hosting scene
  17568. * @returns the scene
  17569. */
  17570. getScene(): Nullable<Scene>;
  17571. }
  17572. }
  17573. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17577. /**
  17578. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17579. */
  17580. export class ColorSplitterBlock extends NodeMaterialBlock {
  17581. /**
  17582. * Create a new ColorSplitterBlock
  17583. * @param name defines the block name
  17584. */
  17585. constructor(name: string);
  17586. /**
  17587. * Gets the current class name
  17588. * @returns the class name
  17589. */
  17590. getClassName(): string;
  17591. /**
  17592. * Gets the rgba component (input)
  17593. */
  17594. get rgba(): NodeMaterialConnectionPoint;
  17595. /**
  17596. * Gets the rgb component (input)
  17597. */
  17598. get rgbIn(): NodeMaterialConnectionPoint;
  17599. /**
  17600. * Gets the rgb component (output)
  17601. */
  17602. get rgbOut(): NodeMaterialConnectionPoint;
  17603. /**
  17604. * Gets the r component (output)
  17605. */
  17606. get r(): NodeMaterialConnectionPoint;
  17607. /**
  17608. * Gets the g component (output)
  17609. */
  17610. get g(): NodeMaterialConnectionPoint;
  17611. /**
  17612. * Gets the b component (output)
  17613. */
  17614. get b(): NodeMaterialConnectionPoint;
  17615. /**
  17616. * Gets the a component (output)
  17617. */
  17618. get a(): NodeMaterialConnectionPoint;
  17619. protected _inputRename(name: string): string;
  17620. protected _outputRename(name: string): string;
  17621. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17622. }
  17623. }
  17624. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17628. import { Scene } from "babylonjs/scene";
  17629. /**
  17630. * Operations supported by the Trigonometry block
  17631. */
  17632. export enum TrigonometryBlockOperations {
  17633. /** Cos */
  17634. Cos = 0,
  17635. /** Sin */
  17636. Sin = 1,
  17637. /** Abs */
  17638. Abs = 2,
  17639. /** Exp */
  17640. Exp = 3,
  17641. /** Exp2 */
  17642. Exp2 = 4,
  17643. /** Round */
  17644. Round = 5,
  17645. /** Floor */
  17646. Floor = 6,
  17647. /** Ceiling */
  17648. Ceiling = 7,
  17649. /** Square root */
  17650. Sqrt = 8,
  17651. /** Log */
  17652. Log = 9,
  17653. /** Tangent */
  17654. Tan = 10,
  17655. /** Arc tangent */
  17656. ArcTan = 11,
  17657. /** Arc cosinus */
  17658. ArcCos = 12,
  17659. /** Arc sinus */
  17660. ArcSin = 13,
  17661. /** Fraction */
  17662. Fract = 14,
  17663. /** Sign */
  17664. Sign = 15,
  17665. /** To radians (from degrees) */
  17666. Radians = 16,
  17667. /** To degrees (from radians) */
  17668. Degrees = 17
  17669. }
  17670. /**
  17671. * Block used to apply trigonometry operation to floats
  17672. */
  17673. export class TrigonometryBlock extends NodeMaterialBlock {
  17674. /**
  17675. * Gets or sets the operation applied by the block
  17676. */
  17677. operation: TrigonometryBlockOperations;
  17678. /**
  17679. * Creates a new TrigonometryBlock
  17680. * @param name defines the block name
  17681. */
  17682. constructor(name: string);
  17683. /**
  17684. * Gets the current class name
  17685. * @returns the class name
  17686. */
  17687. getClassName(): string;
  17688. /**
  17689. * Gets the input component
  17690. */
  17691. get input(): NodeMaterialConnectionPoint;
  17692. /**
  17693. * Gets the output component
  17694. */
  17695. get output(): NodeMaterialConnectionPoint;
  17696. protected _buildBlock(state: NodeMaterialBuildState): this;
  17697. serialize(): any;
  17698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17699. protected _dumpPropertiesCode(): string;
  17700. }
  17701. }
  17702. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17704. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17705. import { Scene } from "babylonjs/scene";
  17706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17707. import { Matrix } from "babylonjs/Maths/math.vector";
  17708. import { Mesh } from "babylonjs/Meshes/mesh";
  17709. import { Engine } from "babylonjs/Engines/engine";
  17710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17711. import { Observable } from "babylonjs/Misc/observable";
  17712. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17713. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17714. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17715. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17716. import { Nullable } from "babylonjs/types";
  17717. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17718. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17719. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17720. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17721. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17722. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17723. import { Effect } from "babylonjs/Materials/effect";
  17724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17725. import { Camera } from "babylonjs/Cameras/camera";
  17726. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17727. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17729. /**
  17730. * Interface used to configure the node material editor
  17731. */
  17732. export interface INodeMaterialEditorOptions {
  17733. /** Define the URl to load node editor script */
  17734. editorURL?: string;
  17735. }
  17736. /** @hidden */
  17737. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17738. NORMAL: boolean;
  17739. TANGENT: boolean;
  17740. UV1: boolean;
  17741. /** BONES */
  17742. NUM_BONE_INFLUENCERS: number;
  17743. BonesPerMesh: number;
  17744. BONETEXTURE: boolean;
  17745. /** MORPH TARGETS */
  17746. MORPHTARGETS: boolean;
  17747. MORPHTARGETS_NORMAL: boolean;
  17748. MORPHTARGETS_TANGENT: boolean;
  17749. MORPHTARGETS_UV: boolean;
  17750. NUM_MORPH_INFLUENCERS: number;
  17751. /** IMAGE PROCESSING */
  17752. IMAGEPROCESSING: boolean;
  17753. VIGNETTE: boolean;
  17754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17755. VIGNETTEBLENDMODEOPAQUE: boolean;
  17756. TONEMAPPING: boolean;
  17757. TONEMAPPING_ACES: boolean;
  17758. CONTRAST: boolean;
  17759. EXPOSURE: boolean;
  17760. COLORCURVES: boolean;
  17761. COLORGRADING: boolean;
  17762. COLORGRADING3D: boolean;
  17763. SAMPLER3DGREENDEPTH: boolean;
  17764. SAMPLER3DBGRMAP: boolean;
  17765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17766. /** MISC. */
  17767. BUMPDIRECTUV: number;
  17768. constructor();
  17769. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17770. }
  17771. /**
  17772. * Class used to configure NodeMaterial
  17773. */
  17774. export interface INodeMaterialOptions {
  17775. /**
  17776. * Defines if blocks should emit comments
  17777. */
  17778. emitComments: boolean;
  17779. }
  17780. /**
  17781. * Class used to create a node based material built by assembling shader blocks
  17782. */
  17783. export class NodeMaterial extends PushMaterial {
  17784. private static _BuildIdGenerator;
  17785. private _options;
  17786. private _vertexCompilationState;
  17787. private _fragmentCompilationState;
  17788. private _sharedData;
  17789. private _buildId;
  17790. private _buildWasSuccessful;
  17791. private _cachedWorldViewMatrix;
  17792. private _cachedWorldViewProjectionMatrix;
  17793. private _optimizers;
  17794. private _animationFrame;
  17795. /** Define the Url to load node editor script */
  17796. static EditorURL: string;
  17797. /** Define the Url to load snippets */
  17798. static SnippetUrl: string;
  17799. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17800. static IgnoreTexturesAtLoadTime: boolean;
  17801. private BJSNODEMATERIALEDITOR;
  17802. /** Get the inspector from bundle or global */
  17803. private _getGlobalNodeMaterialEditor;
  17804. /**
  17805. * Snippet ID if the material was created from the snippet server
  17806. */
  17807. snippetId: string;
  17808. /**
  17809. * Gets or sets data used by visual editor
  17810. * @see https://nme.babylonjs.com
  17811. */
  17812. editorData: any;
  17813. /**
  17814. * 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)
  17815. */
  17816. ignoreAlpha: boolean;
  17817. /**
  17818. * Defines the maximum number of lights that can be used in the material
  17819. */
  17820. maxSimultaneousLights: number;
  17821. /**
  17822. * Observable raised when the material is built
  17823. */
  17824. onBuildObservable: Observable<NodeMaterial>;
  17825. /**
  17826. * Gets or sets the root nodes of the material vertex shader
  17827. */
  17828. _vertexOutputNodes: NodeMaterialBlock[];
  17829. /**
  17830. * Gets or sets the root nodes of the material fragment (pixel) shader
  17831. */
  17832. _fragmentOutputNodes: NodeMaterialBlock[];
  17833. /** Gets or sets options to control the node material overall behavior */
  17834. get options(): INodeMaterialOptions;
  17835. set options(options: INodeMaterialOptions);
  17836. /**
  17837. * Default configuration related to image processing available in the standard Material.
  17838. */
  17839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17840. /**
  17841. * Gets the image processing configuration used either in this material.
  17842. */
  17843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17844. /**
  17845. * Sets the Default image processing configuration used either in the this material.
  17846. *
  17847. * If sets to null, the scene one is in use.
  17848. */
  17849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17850. /**
  17851. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17852. */
  17853. attachedBlocks: NodeMaterialBlock[];
  17854. /**
  17855. * Specifies the mode of the node material
  17856. * @hidden
  17857. */
  17858. _mode: NodeMaterialModes;
  17859. /**
  17860. * Gets the mode property
  17861. */
  17862. get mode(): NodeMaterialModes;
  17863. /**
  17864. * A free comment about the material
  17865. */
  17866. comment: string;
  17867. /**
  17868. * Create a new node based material
  17869. * @param name defines the material name
  17870. * @param scene defines the hosting scene
  17871. * @param options defines creation option
  17872. */
  17873. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17874. /**
  17875. * Gets the current class name of the material e.g. "NodeMaterial"
  17876. * @returns the class name
  17877. */
  17878. getClassName(): string;
  17879. /**
  17880. * Keep track of the image processing observer to allow dispose and replace.
  17881. */
  17882. private _imageProcessingObserver;
  17883. /**
  17884. * Attaches a new image processing configuration to the Standard Material.
  17885. * @param configuration
  17886. */
  17887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17888. /**
  17889. * Get a block by its name
  17890. * @param name defines the name of the block to retrieve
  17891. * @returns the required block or null if not found
  17892. */
  17893. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17894. /**
  17895. * Get a block by its name
  17896. * @param predicate defines the predicate used to find the good candidate
  17897. * @returns the required block or null if not found
  17898. */
  17899. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17900. /**
  17901. * Get an input block by its name
  17902. * @param predicate defines the predicate used to find the good candidate
  17903. * @returns the required input block or null if not found
  17904. */
  17905. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17906. /**
  17907. * Gets the list of input blocks attached to this material
  17908. * @returns an array of InputBlocks
  17909. */
  17910. getInputBlocks(): InputBlock[];
  17911. /**
  17912. * Adds a new optimizer to the list of optimizers
  17913. * @param optimizer defines the optimizers to add
  17914. * @returns the current material
  17915. */
  17916. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17917. /**
  17918. * Remove an optimizer from the list of optimizers
  17919. * @param optimizer defines the optimizers to remove
  17920. * @returns the current material
  17921. */
  17922. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17923. /**
  17924. * Add a new block to the list of output nodes
  17925. * @param node defines the node to add
  17926. * @returns the current material
  17927. */
  17928. addOutputNode(node: NodeMaterialBlock): this;
  17929. /**
  17930. * Remove a block from the list of root nodes
  17931. * @param node defines the node to remove
  17932. * @returns the current material
  17933. */
  17934. removeOutputNode(node: NodeMaterialBlock): this;
  17935. private _addVertexOutputNode;
  17936. private _removeVertexOutputNode;
  17937. private _addFragmentOutputNode;
  17938. private _removeFragmentOutputNode;
  17939. /**
  17940. * Specifies if the material will require alpha blending
  17941. * @returns a boolean specifying if alpha blending is needed
  17942. */
  17943. needAlphaBlending(): boolean;
  17944. /**
  17945. * Specifies if this material should be rendered in alpha test mode
  17946. * @returns a boolean specifying if an alpha test is needed.
  17947. */
  17948. needAlphaTesting(): boolean;
  17949. private _initializeBlock;
  17950. private _resetDualBlocks;
  17951. /**
  17952. * Remove a block from the current node material
  17953. * @param block defines the block to remove
  17954. */
  17955. removeBlock(block: NodeMaterialBlock): void;
  17956. /**
  17957. * Build the material and generates the inner effect
  17958. * @param verbose defines if the build should log activity
  17959. */
  17960. build(verbose?: boolean): void;
  17961. /**
  17962. * Runs an otpimization phase to try to improve the shader code
  17963. */
  17964. optimize(): void;
  17965. private _prepareDefinesForAttributes;
  17966. /**
  17967. * Create a post process from the material
  17968. * @param camera The camera to apply the render pass to.
  17969. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17971. * @param engine The engine which the post process will be applied. (default: current engine)
  17972. * @param reusable If the post process can be reused on the same frame. (default: false)
  17973. * @param textureType Type of textures used when performing the post process. (default: 0)
  17974. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17975. * @returns the post process created
  17976. */
  17977. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17978. /**
  17979. * Create the post process effect from the material
  17980. * @param postProcess The post process to create the effect for
  17981. */
  17982. createEffectForPostProcess(postProcess: PostProcess): void;
  17983. private _createEffectForPostProcess;
  17984. /**
  17985. * Create a new procedural texture based on this node material
  17986. * @param size defines the size of the texture
  17987. * @param scene defines the hosting scene
  17988. * @returns the new procedural texture attached to this node material
  17989. */
  17990. createProceduralTexture(size: number | {
  17991. width: number;
  17992. height: number;
  17993. layers?: number;
  17994. }, scene: Scene): Nullable<ProceduralTexture>;
  17995. private _createEffectForParticles;
  17996. private _checkInternals;
  17997. /**
  17998. * Create the effect to be used as the custom effect for a particle system
  17999. * @param particleSystem Particle system to create the effect for
  18000. * @param onCompiled defines a function to call when the effect creation is successful
  18001. * @param onError defines a function to call when the effect creation has failed
  18002. */
  18003. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18004. private _processDefines;
  18005. /**
  18006. * Get if the submesh is ready to be used and all its information available.
  18007. * Child classes can use it to update shaders
  18008. * @param mesh defines the mesh to check
  18009. * @param subMesh defines which submesh to check
  18010. * @param useInstances specifies that instances should be used
  18011. * @returns a boolean indicating that the submesh is ready or not
  18012. */
  18013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18014. /**
  18015. * Get a string representing the shaders built by the current node graph
  18016. */
  18017. get compiledShaders(): string;
  18018. /**
  18019. * Binds the world matrix to the material
  18020. * @param world defines the world transformation matrix
  18021. */
  18022. bindOnlyWorldMatrix(world: Matrix): void;
  18023. /**
  18024. * Binds the submesh to this material by preparing the effect and shader to draw
  18025. * @param world defines the world transformation matrix
  18026. * @param mesh defines the mesh containing the submesh
  18027. * @param subMesh defines the submesh to bind the material to
  18028. */
  18029. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18030. /**
  18031. * Gets the active textures from the material
  18032. * @returns an array of textures
  18033. */
  18034. getActiveTextures(): BaseTexture[];
  18035. /**
  18036. * Gets the list of texture blocks
  18037. * @returns an array of texture blocks
  18038. */
  18039. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18040. /**
  18041. * Specifies if the material uses a texture
  18042. * @param texture defines the texture to check against the material
  18043. * @returns a boolean specifying if the material uses the texture
  18044. */
  18045. hasTexture(texture: BaseTexture): boolean;
  18046. /**
  18047. * Disposes the material
  18048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18051. */
  18052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18053. /** Creates the node editor window. */
  18054. private _createNodeEditor;
  18055. /**
  18056. * Launch the node material editor
  18057. * @param config Define the configuration of the editor
  18058. * @return a promise fulfilled when the node editor is visible
  18059. */
  18060. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18061. /**
  18062. * Clear the current material
  18063. */
  18064. clear(): void;
  18065. /**
  18066. * Clear the current material and set it to a default state
  18067. */
  18068. setToDefault(): void;
  18069. /**
  18070. * Clear the current material and set it to a default state for post process
  18071. */
  18072. setToDefaultPostProcess(): void;
  18073. /**
  18074. * Clear the current material and set it to a default state for procedural texture
  18075. */
  18076. setToDefaultProceduralTexture(): void;
  18077. /**
  18078. * Clear the current material and set it to a default state for particle
  18079. */
  18080. setToDefaultParticle(): void;
  18081. /**
  18082. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18083. * @param url defines the url to load from
  18084. * @returns a promise that will fullfil when the material is fully loaded
  18085. */
  18086. loadAsync(url: string): Promise<void>;
  18087. private _gatherBlocks;
  18088. /**
  18089. * Generate a string containing the code declaration required to create an equivalent of this material
  18090. * @returns a string
  18091. */
  18092. generateCode(): string;
  18093. /**
  18094. * Serializes this material in a JSON representation
  18095. * @returns the serialized material object
  18096. */
  18097. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18098. private _restoreConnections;
  18099. /**
  18100. * Clear the current graph and load a new one from a serialization object
  18101. * @param source defines the JSON representation of the material
  18102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18103. * @param merge defines whether or not the source must be merged or replace the current content
  18104. */
  18105. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18106. /**
  18107. * Makes a duplicate of the current material.
  18108. * @param name - name to use for the new material.
  18109. */
  18110. clone(name: string): NodeMaterial;
  18111. /**
  18112. * Creates a node material from parsed material data
  18113. * @param source defines the JSON representation of the material
  18114. * @param scene defines the hosting scene
  18115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18116. * @returns a new node material
  18117. */
  18118. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18119. /**
  18120. * Creates a node material from a snippet saved in a remote file
  18121. * @param name defines the name of the material to create
  18122. * @param url defines the url to load from
  18123. * @param scene defines the hosting scene
  18124. * @returns a promise that will resolve to the new node material
  18125. */
  18126. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18127. /**
  18128. * Creates a node material from a snippet saved by the node material editor
  18129. * @param snippetId defines the snippet to load
  18130. * @param scene defines the hosting scene
  18131. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18132. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18133. * @returns a promise that will resolve to the new node material
  18134. */
  18135. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18136. /**
  18137. * Creates a new node material set to default basic configuration
  18138. * @param name defines the name of the material
  18139. * @param scene defines the hosting scene
  18140. * @returns a new NodeMaterial
  18141. */
  18142. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18143. }
  18144. }
  18145. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18146. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18147. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18148. import { Nullable } from "babylonjs/types";
  18149. module "babylonjs/Engines/thinEngine" {
  18150. interface ThinEngine {
  18151. /**
  18152. * Unbind a list of render target textures from the webGL context
  18153. * This is used only when drawBuffer extension or webGL2 are active
  18154. * @param textures defines the render target textures to unbind
  18155. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18156. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18157. */
  18158. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18159. /**
  18160. * Create a multi render target texture
  18161. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18162. * @param size defines the size of the texture
  18163. * @param options defines the creation options
  18164. * @returns the cube texture as an InternalTexture
  18165. */
  18166. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18167. /**
  18168. * Update the sample count for a given multiple render target texture
  18169. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18170. * @param textures defines the textures to update
  18171. * @param samples defines the sample count to set
  18172. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18173. */
  18174. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18175. /**
  18176. * Select a subsets of attachments to draw to.
  18177. * @param attachments gl attachments
  18178. */
  18179. bindAttachments(attachments: number[]): void;
  18180. /**
  18181. * Creates a layout object to draw/clear on specific textures in a MRT
  18182. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18183. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18184. */
  18185. buildTextureLayout(textureStatus: boolean[]): number[];
  18186. /**
  18187. * Restores the webgl state to only draw on the main color attachment
  18188. */
  18189. restoreSingleAttachment(): void;
  18190. }
  18191. }
  18192. }
  18193. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18194. import { Scene } from "babylonjs/scene";
  18195. import { Engine } from "babylonjs/Engines/engine";
  18196. import { Texture } from "babylonjs/Materials/Textures/texture";
  18197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18198. import "babylonjs/Engines/Extensions/engine.multiRender";
  18199. /**
  18200. * Creation options of the multi render target texture.
  18201. */
  18202. export interface IMultiRenderTargetOptions {
  18203. /**
  18204. * Define if the texture needs to create mip maps after render.
  18205. */
  18206. generateMipMaps?: boolean;
  18207. /**
  18208. * Define the types of all the draw buffers we want to create
  18209. */
  18210. types?: number[];
  18211. /**
  18212. * Define the sampling modes of all the draw buffers we want to create
  18213. */
  18214. samplingModes?: number[];
  18215. /**
  18216. * Define if a depth buffer is required
  18217. */
  18218. generateDepthBuffer?: boolean;
  18219. /**
  18220. * Define if a stencil buffer is required
  18221. */
  18222. generateStencilBuffer?: boolean;
  18223. /**
  18224. * Define if a depth texture is required instead of a depth buffer
  18225. */
  18226. generateDepthTexture?: boolean;
  18227. /**
  18228. * Define the number of desired draw buffers
  18229. */
  18230. textureCount?: number;
  18231. /**
  18232. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18233. */
  18234. doNotChangeAspectRatio?: boolean;
  18235. /**
  18236. * Define the default type of the buffers we are creating
  18237. */
  18238. defaultType?: number;
  18239. }
  18240. /**
  18241. * A multi render target, like a render target provides the ability to render to a texture.
  18242. * Unlike the render target, it can render to several draw buffers in one draw.
  18243. * This is specially interesting in deferred rendering or for any effects requiring more than
  18244. * just one color from a single pass.
  18245. */
  18246. export class MultiRenderTarget extends RenderTargetTexture {
  18247. private _internalTextures;
  18248. private _textures;
  18249. private _multiRenderTargetOptions;
  18250. private _count;
  18251. /**
  18252. * Get if draw buffers are currently supported by the used hardware and browser.
  18253. */
  18254. get isSupported(): boolean;
  18255. /**
  18256. * Get the list of textures generated by the multi render target.
  18257. */
  18258. get textures(): Texture[];
  18259. /**
  18260. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18261. */
  18262. get count(): number;
  18263. /**
  18264. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18265. */
  18266. get depthTexture(): Texture;
  18267. /**
  18268. * Set the wrapping mode on U of all the textures we are rendering to.
  18269. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18270. */
  18271. set wrapU(wrap: number);
  18272. /**
  18273. * Set the wrapping mode on V of all the textures we are rendering to.
  18274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18275. */
  18276. set wrapV(wrap: number);
  18277. /**
  18278. * Instantiate a new multi render target texture.
  18279. * A multi render target, like a render target provides the ability to render to a texture.
  18280. * Unlike the render target, it can render to several draw buffers in one draw.
  18281. * This is specially interesting in deferred rendering or for any effects requiring more than
  18282. * just one color from a single pass.
  18283. * @param name Define the name of the texture
  18284. * @param size Define the size of the buffers to render to
  18285. * @param count Define the number of target we are rendering into
  18286. * @param scene Define the scene the texture belongs to
  18287. * @param options Define the options used to create the multi render target
  18288. */
  18289. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18290. private _initTypes;
  18291. /** @hidden */
  18292. _rebuild(forceFullRebuild?: boolean): void;
  18293. private _createInternalTextures;
  18294. private _createTextures;
  18295. /**
  18296. * Replaces a texture within the MRT.
  18297. * @param texture The new texture to insert in the MRT
  18298. * @param index The index of the texture to replace
  18299. */
  18300. replaceTexture(texture: Texture, index: number): void;
  18301. /**
  18302. * Define the number of samples used if MSAA is enabled.
  18303. */
  18304. get samples(): number;
  18305. set samples(value: number);
  18306. /**
  18307. * Resize all the textures in the multi render target.
  18308. * Be careful as it will recreate all the data in the new texture.
  18309. * @param size Define the new size
  18310. */
  18311. resize(size: any): void;
  18312. /**
  18313. * Changes the number of render targets in this MRT
  18314. * Be careful as it will recreate all the data in the new texture.
  18315. * @param count new texture count
  18316. * @param options Specifies texture types and sampling modes for new textures
  18317. */
  18318. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18320. /**
  18321. * Dispose the render targets and their associated resources
  18322. */
  18323. dispose(): void;
  18324. /**
  18325. * Release all the underlying texture used as draw buffers.
  18326. */
  18327. releaseInternalTextures(): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18331. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18333. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18334. /** @hidden */
  18335. export var imageProcessingPixelShader: {
  18336. name: string;
  18337. shader: string;
  18338. };
  18339. }
  18340. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18341. import { Nullable } from "babylonjs/types";
  18342. import { Color4 } from "babylonjs/Maths/math.color";
  18343. import { Camera } from "babylonjs/Cameras/camera";
  18344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18345. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18346. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18348. import { Engine } from "babylonjs/Engines/engine";
  18349. import "babylonjs/Shaders/imageProcessing.fragment";
  18350. import "babylonjs/Shaders/postprocess.vertex";
  18351. /**
  18352. * ImageProcessingPostProcess
  18353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18354. */
  18355. export class ImageProcessingPostProcess extends PostProcess {
  18356. /**
  18357. * Default configuration related to image processing available in the PBR Material.
  18358. */
  18359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18360. /**
  18361. * Gets the image processing configuration used either in this material.
  18362. */
  18363. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18364. /**
  18365. * Sets the Default image processing configuration used either in the this material.
  18366. *
  18367. * If sets to null, the scene one is in use.
  18368. */
  18369. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18370. /**
  18371. * Keep track of the image processing observer to allow dispose and replace.
  18372. */
  18373. private _imageProcessingObserver;
  18374. /**
  18375. * Attaches a new image processing configuration to the PBR Material.
  18376. * @param configuration
  18377. */
  18378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18379. /**
  18380. * If the post process is supported.
  18381. */
  18382. get isSupported(): boolean;
  18383. /**
  18384. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18385. */
  18386. get colorCurves(): Nullable<ColorCurves>;
  18387. /**
  18388. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18389. */
  18390. set colorCurves(value: Nullable<ColorCurves>);
  18391. /**
  18392. * Gets wether the color curves effect is enabled.
  18393. */
  18394. get colorCurvesEnabled(): boolean;
  18395. /**
  18396. * Sets wether the color curves effect is enabled.
  18397. */
  18398. set colorCurvesEnabled(value: boolean);
  18399. /**
  18400. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18401. */
  18402. get colorGradingTexture(): Nullable<BaseTexture>;
  18403. /**
  18404. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18405. */
  18406. set colorGradingTexture(value: Nullable<BaseTexture>);
  18407. /**
  18408. * Gets wether the color grading effect is enabled.
  18409. */
  18410. get colorGradingEnabled(): boolean;
  18411. /**
  18412. * Gets wether the color grading effect is enabled.
  18413. */
  18414. set colorGradingEnabled(value: boolean);
  18415. /**
  18416. * Gets exposure used in the effect.
  18417. */
  18418. get exposure(): number;
  18419. /**
  18420. * Sets exposure used in the effect.
  18421. */
  18422. set exposure(value: number);
  18423. /**
  18424. * Gets wether tonemapping is enabled or not.
  18425. */
  18426. get toneMappingEnabled(): boolean;
  18427. /**
  18428. * Sets wether tonemapping is enabled or not
  18429. */
  18430. set toneMappingEnabled(value: boolean);
  18431. /**
  18432. * Gets the type of tone mapping effect.
  18433. */
  18434. get toneMappingType(): number;
  18435. /**
  18436. * Sets the type of tone mapping effect.
  18437. */
  18438. set toneMappingType(value: number);
  18439. /**
  18440. * Gets contrast used in the effect.
  18441. */
  18442. get contrast(): number;
  18443. /**
  18444. * Sets contrast used in the effect.
  18445. */
  18446. set contrast(value: number);
  18447. /**
  18448. * Gets Vignette stretch size.
  18449. */
  18450. get vignetteStretch(): number;
  18451. /**
  18452. * Sets Vignette stretch size.
  18453. */
  18454. set vignetteStretch(value: number);
  18455. /**
  18456. * Gets Vignette centre X Offset.
  18457. */
  18458. get vignetteCentreX(): number;
  18459. /**
  18460. * Sets Vignette centre X Offset.
  18461. */
  18462. set vignetteCentreX(value: number);
  18463. /**
  18464. * Gets Vignette centre Y Offset.
  18465. */
  18466. get vignetteCentreY(): number;
  18467. /**
  18468. * Sets Vignette centre Y Offset.
  18469. */
  18470. set vignetteCentreY(value: number);
  18471. /**
  18472. * Gets Vignette weight or intensity of the vignette effect.
  18473. */
  18474. get vignetteWeight(): number;
  18475. /**
  18476. * Sets Vignette weight or intensity of the vignette effect.
  18477. */
  18478. set vignetteWeight(value: number);
  18479. /**
  18480. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18481. * if vignetteEnabled is set to true.
  18482. */
  18483. get vignetteColor(): Color4;
  18484. /**
  18485. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18486. * if vignetteEnabled is set to true.
  18487. */
  18488. set vignetteColor(value: Color4);
  18489. /**
  18490. * Gets Camera field of view used by the Vignette effect.
  18491. */
  18492. get vignetteCameraFov(): number;
  18493. /**
  18494. * Sets Camera field of view used by the Vignette effect.
  18495. */
  18496. set vignetteCameraFov(value: number);
  18497. /**
  18498. * Gets the vignette blend mode allowing different kind of effect.
  18499. */
  18500. get vignetteBlendMode(): number;
  18501. /**
  18502. * Sets the vignette blend mode allowing different kind of effect.
  18503. */
  18504. set vignetteBlendMode(value: number);
  18505. /**
  18506. * Gets wether the vignette effect is enabled.
  18507. */
  18508. get vignetteEnabled(): boolean;
  18509. /**
  18510. * Sets wether the vignette effect is enabled.
  18511. */
  18512. set vignetteEnabled(value: boolean);
  18513. private _fromLinearSpace;
  18514. /**
  18515. * Gets wether the input of the processing is in Gamma or Linear Space.
  18516. */
  18517. get fromLinearSpace(): boolean;
  18518. /**
  18519. * Sets wether the input of the processing is in Gamma or Linear Space.
  18520. */
  18521. set fromLinearSpace(value: boolean);
  18522. /**
  18523. * Defines cache preventing GC.
  18524. */
  18525. private _defines;
  18526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18527. /**
  18528. * "ImageProcessingPostProcess"
  18529. * @returns "ImageProcessingPostProcess"
  18530. */
  18531. getClassName(): string;
  18532. /**
  18533. * @hidden
  18534. */
  18535. _updateParameters(): void;
  18536. dispose(camera?: Camera): void;
  18537. }
  18538. }
  18539. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18540. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18541. /**
  18542. * Interface for defining prepass effects in the prepass post-process pipeline
  18543. */
  18544. export interface PrePassEffectConfiguration {
  18545. /**
  18546. * Name of the effect
  18547. */
  18548. name: string;
  18549. /**
  18550. * Post process to attach for this effect
  18551. */
  18552. postProcess?: PostProcess;
  18553. /**
  18554. * Textures required in the MRT
  18555. */
  18556. texturesRequired: number[];
  18557. /**
  18558. * Is the effect enabled
  18559. */
  18560. enabled: boolean;
  18561. /**
  18562. * Disposes the effect configuration
  18563. */
  18564. dispose?: () => void;
  18565. /**
  18566. * Creates the associated post process
  18567. */
  18568. createPostProcess?: () => PostProcess;
  18569. }
  18570. }
  18571. declare module "babylonjs/Materials/fresnelParameters" {
  18572. import { DeepImmutable } from "babylonjs/types";
  18573. import { Color3 } from "babylonjs/Maths/math.color";
  18574. /**
  18575. * Options to be used when creating a FresnelParameters.
  18576. */
  18577. export type IFresnelParametersCreationOptions = {
  18578. /**
  18579. * Define the color used on edges (grazing angle)
  18580. */
  18581. leftColor?: Color3;
  18582. /**
  18583. * Define the color used on center
  18584. */
  18585. rightColor?: Color3;
  18586. /**
  18587. * Define bias applied to computed fresnel term
  18588. */
  18589. bias?: number;
  18590. /**
  18591. * Defined the power exponent applied to fresnel term
  18592. */
  18593. power?: number;
  18594. /**
  18595. * Define if the fresnel effect is enable or not.
  18596. */
  18597. isEnabled?: boolean;
  18598. };
  18599. /**
  18600. * Serialized format for FresnelParameters.
  18601. */
  18602. export type IFresnelParametersSerialized = {
  18603. /**
  18604. * Define the color used on edges (grazing angle) [as an array]
  18605. */
  18606. leftColor: number[];
  18607. /**
  18608. * Define the color used on center [as an array]
  18609. */
  18610. rightColor: number[];
  18611. /**
  18612. * Define bias applied to computed fresnel term
  18613. */
  18614. bias: number;
  18615. /**
  18616. * Defined the power exponent applied to fresnel term
  18617. */
  18618. power?: number;
  18619. /**
  18620. * Define if the fresnel effect is enable or not.
  18621. */
  18622. isEnabled: boolean;
  18623. };
  18624. /**
  18625. * This represents all the required information to add a fresnel effect on a material:
  18626. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18627. */
  18628. export class FresnelParameters {
  18629. private _isEnabled;
  18630. /**
  18631. * Define if the fresnel effect is enable or not.
  18632. */
  18633. get isEnabled(): boolean;
  18634. set isEnabled(value: boolean);
  18635. /**
  18636. * Define the color used on edges (grazing angle)
  18637. */
  18638. leftColor: Color3;
  18639. /**
  18640. * Define the color used on center
  18641. */
  18642. rightColor: Color3;
  18643. /**
  18644. * Define bias applied to computed fresnel term
  18645. */
  18646. bias: number;
  18647. /**
  18648. * Defined the power exponent applied to fresnel term
  18649. */
  18650. power: number;
  18651. /**
  18652. * Creates a new FresnelParameters object.
  18653. *
  18654. * @param options provide your own settings to optionally to override defaults
  18655. */
  18656. constructor(options?: IFresnelParametersCreationOptions);
  18657. /**
  18658. * Clones the current fresnel and its valuues
  18659. * @returns a clone fresnel configuration
  18660. */
  18661. clone(): FresnelParameters;
  18662. /**
  18663. * Determines equality between FresnelParameters objects
  18664. * @param otherFresnelParameters defines the second operand
  18665. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18666. */
  18667. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18668. /**
  18669. * Serializes the current fresnel parameters to a JSON representation.
  18670. * @return the JSON serialization
  18671. */
  18672. serialize(): IFresnelParametersSerialized;
  18673. /**
  18674. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18675. * @param parsedFresnelParameters Define the JSON representation
  18676. * @returns the parsed parameters
  18677. */
  18678. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18679. }
  18680. }
  18681. declare module "babylonjs/Materials/materialFlags" {
  18682. /**
  18683. * This groups all the flags used to control the materials channel.
  18684. */
  18685. export class MaterialFlags {
  18686. private static _DiffuseTextureEnabled;
  18687. /**
  18688. * Are diffuse textures enabled in the application.
  18689. */
  18690. static get DiffuseTextureEnabled(): boolean;
  18691. static set DiffuseTextureEnabled(value: boolean);
  18692. private static _DetailTextureEnabled;
  18693. /**
  18694. * Are detail textures enabled in the application.
  18695. */
  18696. static get DetailTextureEnabled(): boolean;
  18697. static set DetailTextureEnabled(value: boolean);
  18698. private static _AmbientTextureEnabled;
  18699. /**
  18700. * Are ambient textures enabled in the application.
  18701. */
  18702. static get AmbientTextureEnabled(): boolean;
  18703. static set AmbientTextureEnabled(value: boolean);
  18704. private static _OpacityTextureEnabled;
  18705. /**
  18706. * Are opacity textures enabled in the application.
  18707. */
  18708. static get OpacityTextureEnabled(): boolean;
  18709. static set OpacityTextureEnabled(value: boolean);
  18710. private static _ReflectionTextureEnabled;
  18711. /**
  18712. * Are reflection textures enabled in the application.
  18713. */
  18714. static get ReflectionTextureEnabled(): boolean;
  18715. static set ReflectionTextureEnabled(value: boolean);
  18716. private static _EmissiveTextureEnabled;
  18717. /**
  18718. * Are emissive textures enabled in the application.
  18719. */
  18720. static get EmissiveTextureEnabled(): boolean;
  18721. static set EmissiveTextureEnabled(value: boolean);
  18722. private static _SpecularTextureEnabled;
  18723. /**
  18724. * Are specular textures enabled in the application.
  18725. */
  18726. static get SpecularTextureEnabled(): boolean;
  18727. static set SpecularTextureEnabled(value: boolean);
  18728. private static _BumpTextureEnabled;
  18729. /**
  18730. * Are bump textures enabled in the application.
  18731. */
  18732. static get BumpTextureEnabled(): boolean;
  18733. static set BumpTextureEnabled(value: boolean);
  18734. private static _LightmapTextureEnabled;
  18735. /**
  18736. * Are lightmap textures enabled in the application.
  18737. */
  18738. static get LightmapTextureEnabled(): boolean;
  18739. static set LightmapTextureEnabled(value: boolean);
  18740. private static _RefractionTextureEnabled;
  18741. /**
  18742. * Are refraction textures enabled in the application.
  18743. */
  18744. static get RefractionTextureEnabled(): boolean;
  18745. static set RefractionTextureEnabled(value: boolean);
  18746. private static _ColorGradingTextureEnabled;
  18747. /**
  18748. * Are color grading textures enabled in the application.
  18749. */
  18750. static get ColorGradingTextureEnabled(): boolean;
  18751. static set ColorGradingTextureEnabled(value: boolean);
  18752. private static _FresnelEnabled;
  18753. /**
  18754. * Are fresnels enabled in the application.
  18755. */
  18756. static get FresnelEnabled(): boolean;
  18757. static set FresnelEnabled(value: boolean);
  18758. private static _ClearCoatTextureEnabled;
  18759. /**
  18760. * Are clear coat textures enabled in the application.
  18761. */
  18762. static get ClearCoatTextureEnabled(): boolean;
  18763. static set ClearCoatTextureEnabled(value: boolean);
  18764. private static _ClearCoatBumpTextureEnabled;
  18765. /**
  18766. * Are clear coat bump textures enabled in the application.
  18767. */
  18768. static get ClearCoatBumpTextureEnabled(): boolean;
  18769. static set ClearCoatBumpTextureEnabled(value: boolean);
  18770. private static _ClearCoatTintTextureEnabled;
  18771. /**
  18772. * Are clear coat tint textures enabled in the application.
  18773. */
  18774. static get ClearCoatTintTextureEnabled(): boolean;
  18775. static set ClearCoatTintTextureEnabled(value: boolean);
  18776. private static _SheenTextureEnabled;
  18777. /**
  18778. * Are sheen textures enabled in the application.
  18779. */
  18780. static get SheenTextureEnabled(): boolean;
  18781. static set SheenTextureEnabled(value: boolean);
  18782. private static _AnisotropicTextureEnabled;
  18783. /**
  18784. * Are anisotropic textures enabled in the application.
  18785. */
  18786. static get AnisotropicTextureEnabled(): boolean;
  18787. static set AnisotropicTextureEnabled(value: boolean);
  18788. private static _ThicknessTextureEnabled;
  18789. /**
  18790. * Are thickness textures enabled in the application.
  18791. */
  18792. static get ThicknessTextureEnabled(): boolean;
  18793. static set ThicknessTextureEnabled(value: boolean);
  18794. }
  18795. }
  18796. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18797. /** @hidden */
  18798. export var defaultFragmentDeclaration: {
  18799. name: string;
  18800. shader: string;
  18801. };
  18802. }
  18803. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18804. /** @hidden */
  18805. export var defaultUboDeclaration: {
  18806. name: string;
  18807. shader: string;
  18808. };
  18809. }
  18810. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18811. /** @hidden */
  18812. export var prePassDeclaration: {
  18813. name: string;
  18814. shader: string;
  18815. };
  18816. }
  18817. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18818. /** @hidden */
  18819. export var lightFragmentDeclaration: {
  18820. name: string;
  18821. shader: string;
  18822. };
  18823. }
  18824. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18825. /** @hidden */
  18826. export var lightUboDeclaration: {
  18827. name: string;
  18828. shader: string;
  18829. };
  18830. }
  18831. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18832. /** @hidden */
  18833. export var lightsFragmentFunctions: {
  18834. name: string;
  18835. shader: string;
  18836. };
  18837. }
  18838. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18839. /** @hidden */
  18840. export var shadowsFragmentFunctions: {
  18841. name: string;
  18842. shader: string;
  18843. };
  18844. }
  18845. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18846. /** @hidden */
  18847. export var fresnelFunction: {
  18848. name: string;
  18849. shader: string;
  18850. };
  18851. }
  18852. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18853. /** @hidden */
  18854. export var bumpFragmentMainFunctions: {
  18855. name: string;
  18856. shader: string;
  18857. };
  18858. }
  18859. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18860. /** @hidden */
  18861. export var bumpFragmentFunctions: {
  18862. name: string;
  18863. shader: string;
  18864. };
  18865. }
  18866. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18867. /** @hidden */
  18868. export var logDepthDeclaration: {
  18869. name: string;
  18870. shader: string;
  18871. };
  18872. }
  18873. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18874. /** @hidden */
  18875. export var fogFragmentDeclaration: {
  18876. name: string;
  18877. shader: string;
  18878. };
  18879. }
  18880. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18881. /** @hidden */
  18882. export var bumpFragment: {
  18883. name: string;
  18884. shader: string;
  18885. };
  18886. }
  18887. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18888. /** @hidden */
  18889. export var depthPrePass: {
  18890. name: string;
  18891. shader: string;
  18892. };
  18893. }
  18894. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18895. /** @hidden */
  18896. export var lightFragment: {
  18897. name: string;
  18898. shader: string;
  18899. };
  18900. }
  18901. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18902. /** @hidden */
  18903. export var logDepthFragment: {
  18904. name: string;
  18905. shader: string;
  18906. };
  18907. }
  18908. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18909. /** @hidden */
  18910. export var fogFragment: {
  18911. name: string;
  18912. shader: string;
  18913. };
  18914. }
  18915. declare module "babylonjs/Shaders/default.fragment" {
  18916. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18917. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18918. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18919. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18920. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18921. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18922. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18923. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18924. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18925. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18926. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18927. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18928. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18929. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18930. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18931. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18932. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18933. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18934. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18935. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18936. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18937. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18938. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18939. /** @hidden */
  18940. export var defaultPixelShader: {
  18941. name: string;
  18942. shader: string;
  18943. };
  18944. }
  18945. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18946. /** @hidden */
  18947. export var defaultVertexDeclaration: {
  18948. name: string;
  18949. shader: string;
  18950. };
  18951. }
  18952. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18953. /** @hidden */
  18954. export var bonesDeclaration: {
  18955. name: string;
  18956. shader: string;
  18957. };
  18958. }
  18959. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18960. /** @hidden */
  18961. export var instancesDeclaration: {
  18962. name: string;
  18963. shader: string;
  18964. };
  18965. }
  18966. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18967. /** @hidden */
  18968. export var prePassVertexDeclaration: {
  18969. name: string;
  18970. shader: string;
  18971. };
  18972. }
  18973. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18974. /** @hidden */
  18975. export var bumpVertexDeclaration: {
  18976. name: string;
  18977. shader: string;
  18978. };
  18979. }
  18980. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  18981. /** @hidden */
  18982. export var fogVertexDeclaration: {
  18983. name: string;
  18984. shader: string;
  18985. };
  18986. }
  18987. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  18988. /** @hidden */
  18989. export var morphTargetsVertexGlobalDeclaration: {
  18990. name: string;
  18991. shader: string;
  18992. };
  18993. }
  18994. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  18995. /** @hidden */
  18996. export var morphTargetsVertexDeclaration: {
  18997. name: string;
  18998. shader: string;
  18999. };
  19000. }
  19001. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19002. /** @hidden */
  19003. export var morphTargetsVertex: {
  19004. name: string;
  19005. shader: string;
  19006. };
  19007. }
  19008. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19009. /** @hidden */
  19010. export var instancesVertex: {
  19011. name: string;
  19012. shader: string;
  19013. };
  19014. }
  19015. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19016. /** @hidden */
  19017. export var bonesVertex: {
  19018. name: string;
  19019. shader: string;
  19020. };
  19021. }
  19022. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19023. /** @hidden */
  19024. export var prePassVertex: {
  19025. name: string;
  19026. shader: string;
  19027. };
  19028. }
  19029. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19030. /** @hidden */
  19031. export var bumpVertex: {
  19032. name: string;
  19033. shader: string;
  19034. };
  19035. }
  19036. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19037. /** @hidden */
  19038. export var fogVertex: {
  19039. name: string;
  19040. shader: string;
  19041. };
  19042. }
  19043. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19044. /** @hidden */
  19045. export var shadowsVertex: {
  19046. name: string;
  19047. shader: string;
  19048. };
  19049. }
  19050. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19051. /** @hidden */
  19052. export var pointCloudVertex: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19058. /** @hidden */
  19059. export var logDepthVertex: {
  19060. name: string;
  19061. shader: string;
  19062. };
  19063. }
  19064. declare module "babylonjs/Shaders/default.vertex" {
  19065. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19066. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19067. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19068. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19069. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19070. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19071. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19072. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19073. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19074. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19075. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19078. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19079. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19080. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19081. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19082. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19083. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19084. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19085. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19086. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19087. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19088. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19089. /** @hidden */
  19090. export var defaultVertexShader: {
  19091. name: string;
  19092. shader: string;
  19093. };
  19094. }
  19095. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19096. import { Nullable } from "babylonjs/types";
  19097. import { Scene } from "babylonjs/scene";
  19098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19100. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19101. /**
  19102. * @hidden
  19103. */
  19104. export interface IMaterialDetailMapDefines {
  19105. DETAIL: boolean;
  19106. DETAILDIRECTUV: number;
  19107. DETAIL_NORMALBLENDMETHOD: number;
  19108. /** @hidden */
  19109. _areTexturesDirty: boolean;
  19110. }
  19111. /**
  19112. * Define the code related to the detail map parameters of a material
  19113. *
  19114. * Inspired from:
  19115. * 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
  19116. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19117. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19118. */
  19119. export class DetailMapConfiguration {
  19120. private _texture;
  19121. /**
  19122. * The detail texture of the material.
  19123. */
  19124. texture: Nullable<BaseTexture>;
  19125. /**
  19126. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19127. * Bigger values mean stronger blending
  19128. */
  19129. diffuseBlendLevel: number;
  19130. /**
  19131. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19132. * Bigger values mean stronger blending. Only used with PBR materials
  19133. */
  19134. roughnessBlendLevel: number;
  19135. /**
  19136. * Defines how strong the bump effect from the detail map is
  19137. * Bigger values mean stronger effect
  19138. */
  19139. bumpLevel: number;
  19140. private _normalBlendMethod;
  19141. /**
  19142. * The method used to blend the bump and detail normals together
  19143. */
  19144. normalBlendMethod: number;
  19145. private _isEnabled;
  19146. /**
  19147. * Enable or disable the detail map on this material
  19148. */
  19149. isEnabled: boolean;
  19150. /** @hidden */
  19151. private _internalMarkAllSubMeshesAsTexturesDirty;
  19152. /** @hidden */
  19153. _markAllSubMeshesAsTexturesDirty(): void;
  19154. /**
  19155. * Instantiate a new detail map
  19156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19157. */
  19158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19159. /**
  19160. * Gets whether the submesh is ready to be used or not.
  19161. * @param defines the list of "defines" to update.
  19162. * @param scene defines the scene the material belongs to.
  19163. * @returns - boolean indicating that the submesh is ready or not.
  19164. */
  19165. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19166. /**
  19167. * Update the defines for detail map usage
  19168. * @param defines the list of "defines" to update.
  19169. * @param scene defines the scene the material belongs to.
  19170. */
  19171. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19172. /**
  19173. * Binds the material data.
  19174. * @param uniformBuffer defines the Uniform buffer to fill in.
  19175. * @param scene defines the scene the material belongs to.
  19176. * @param isFrozen defines whether the material is frozen or not.
  19177. */
  19178. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19179. /**
  19180. * Checks to see if a texture is used in the material.
  19181. * @param texture - Base texture to use.
  19182. * @returns - Boolean specifying if a texture is used in the material.
  19183. */
  19184. hasTexture(texture: BaseTexture): boolean;
  19185. /**
  19186. * Returns an array of the actively used textures.
  19187. * @param activeTextures Array of BaseTextures
  19188. */
  19189. getActiveTextures(activeTextures: BaseTexture[]): void;
  19190. /**
  19191. * Returns the animatable textures.
  19192. * @param animatables Array of animatable textures.
  19193. */
  19194. getAnimatables(animatables: IAnimatable[]): void;
  19195. /**
  19196. * Disposes the resources of the material.
  19197. * @param forceDisposeTextures - Forces the disposal of all textures.
  19198. */
  19199. dispose(forceDisposeTextures?: boolean): void;
  19200. /**
  19201. * Get the current class name useful for serialization or dynamic coding.
  19202. * @returns "DetailMap"
  19203. */
  19204. getClassName(): string;
  19205. /**
  19206. * Add the required uniforms to the current list.
  19207. * @param uniforms defines the current uniform list.
  19208. */
  19209. static AddUniforms(uniforms: string[]): void;
  19210. /**
  19211. * Add the required samplers to the current list.
  19212. * @param samplers defines the current sampler list.
  19213. */
  19214. static AddSamplers(samplers: string[]): void;
  19215. /**
  19216. * Add the required uniforms to the current buffer.
  19217. * @param uniformBuffer defines the current uniform buffer.
  19218. */
  19219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19220. /**
  19221. * Makes a duplicate of the current instance into another one.
  19222. * @param detailMap define the instance where to copy the info
  19223. */
  19224. copyTo(detailMap: DetailMapConfiguration): void;
  19225. /**
  19226. * Serializes this detail map instance
  19227. * @returns - An object with the serialized instance.
  19228. */
  19229. serialize(): any;
  19230. /**
  19231. * Parses a detail map setting from a serialized object.
  19232. * @param source - Serialized object.
  19233. * @param scene Defines the scene we are parsing for
  19234. * @param rootUrl Defines the rootUrl to load from
  19235. */
  19236. parse(source: any, scene: Scene, rootUrl: string): void;
  19237. }
  19238. }
  19239. declare module "babylonjs/Materials/standardMaterial" {
  19240. import { SmartArray } from "babylonjs/Misc/smartArray";
  19241. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19242. import { Nullable } from "babylonjs/types";
  19243. import { Scene } from "babylonjs/scene";
  19244. import { Matrix } from "babylonjs/Maths/math.vector";
  19245. import { Color3 } from "babylonjs/Maths/math.color";
  19246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19250. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19251. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19252. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19254. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19257. import "babylonjs/Shaders/default.fragment";
  19258. import "babylonjs/Shaders/default.vertex";
  19259. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19260. /** @hidden */
  19261. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19262. MAINUV1: boolean;
  19263. MAINUV2: boolean;
  19264. DIFFUSE: boolean;
  19265. DIFFUSEDIRECTUV: number;
  19266. DETAIL: boolean;
  19267. DETAILDIRECTUV: number;
  19268. DETAIL_NORMALBLENDMETHOD: number;
  19269. AMBIENT: boolean;
  19270. AMBIENTDIRECTUV: number;
  19271. OPACITY: boolean;
  19272. OPACITYDIRECTUV: number;
  19273. OPACITYRGB: boolean;
  19274. REFLECTION: boolean;
  19275. EMISSIVE: boolean;
  19276. EMISSIVEDIRECTUV: number;
  19277. SPECULAR: boolean;
  19278. SPECULARDIRECTUV: number;
  19279. BUMP: boolean;
  19280. BUMPDIRECTUV: number;
  19281. PARALLAX: boolean;
  19282. PARALLAXOCCLUSION: boolean;
  19283. SPECULAROVERALPHA: boolean;
  19284. CLIPPLANE: boolean;
  19285. CLIPPLANE2: boolean;
  19286. CLIPPLANE3: boolean;
  19287. CLIPPLANE4: boolean;
  19288. CLIPPLANE5: boolean;
  19289. CLIPPLANE6: boolean;
  19290. ALPHATEST: boolean;
  19291. DEPTHPREPASS: boolean;
  19292. ALPHAFROMDIFFUSE: boolean;
  19293. POINTSIZE: boolean;
  19294. FOG: boolean;
  19295. SPECULARTERM: boolean;
  19296. DIFFUSEFRESNEL: boolean;
  19297. OPACITYFRESNEL: boolean;
  19298. REFLECTIONFRESNEL: boolean;
  19299. REFRACTIONFRESNEL: boolean;
  19300. EMISSIVEFRESNEL: boolean;
  19301. FRESNEL: boolean;
  19302. NORMAL: boolean;
  19303. UV1: boolean;
  19304. UV2: boolean;
  19305. VERTEXCOLOR: boolean;
  19306. VERTEXALPHA: boolean;
  19307. NUM_BONE_INFLUENCERS: number;
  19308. BonesPerMesh: number;
  19309. BONETEXTURE: boolean;
  19310. BONES_VELOCITY_ENABLED: boolean;
  19311. INSTANCES: boolean;
  19312. THIN_INSTANCES: boolean;
  19313. GLOSSINESS: boolean;
  19314. ROUGHNESS: boolean;
  19315. EMISSIVEASILLUMINATION: boolean;
  19316. LINKEMISSIVEWITHDIFFUSE: boolean;
  19317. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19318. LIGHTMAP: boolean;
  19319. LIGHTMAPDIRECTUV: number;
  19320. OBJECTSPACE_NORMALMAP: boolean;
  19321. USELIGHTMAPASSHADOWMAP: boolean;
  19322. REFLECTIONMAP_3D: boolean;
  19323. REFLECTIONMAP_SPHERICAL: boolean;
  19324. REFLECTIONMAP_PLANAR: boolean;
  19325. REFLECTIONMAP_CUBIC: boolean;
  19326. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19327. REFLECTIONMAP_PROJECTION: boolean;
  19328. REFLECTIONMAP_SKYBOX: boolean;
  19329. REFLECTIONMAP_EXPLICIT: boolean;
  19330. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19331. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19332. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19333. INVERTCUBICMAP: boolean;
  19334. LOGARITHMICDEPTH: boolean;
  19335. REFRACTION: boolean;
  19336. REFRACTIONMAP_3D: boolean;
  19337. REFLECTIONOVERALPHA: boolean;
  19338. TWOSIDEDLIGHTING: boolean;
  19339. SHADOWFLOAT: boolean;
  19340. MORPHTARGETS: boolean;
  19341. MORPHTARGETS_NORMAL: boolean;
  19342. MORPHTARGETS_TANGENT: boolean;
  19343. MORPHTARGETS_UV: boolean;
  19344. NUM_MORPH_INFLUENCERS: number;
  19345. NONUNIFORMSCALING: boolean;
  19346. PREMULTIPLYALPHA: boolean;
  19347. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19348. ALPHABLEND: boolean;
  19349. PREPASS: boolean;
  19350. PREPASS_IRRADIANCE: boolean;
  19351. PREPASS_IRRADIANCE_INDEX: number;
  19352. PREPASS_ALBEDO: boolean;
  19353. PREPASS_ALBEDO_INDEX: number;
  19354. PREPASS_DEPTHNORMAL: boolean;
  19355. PREPASS_DEPTHNORMAL_INDEX: number;
  19356. PREPASS_POSITION: boolean;
  19357. PREPASS_POSITION_INDEX: number;
  19358. PREPASS_VELOCITY: boolean;
  19359. PREPASS_VELOCITY_INDEX: number;
  19360. PREPASS_REFLECTIVITY: boolean;
  19361. PREPASS_REFLECTIVITY_INDEX: number;
  19362. SCENE_MRT_COUNT: number;
  19363. RGBDLIGHTMAP: boolean;
  19364. RGBDREFLECTION: boolean;
  19365. RGBDREFRACTION: boolean;
  19366. IMAGEPROCESSING: boolean;
  19367. VIGNETTE: boolean;
  19368. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19369. VIGNETTEBLENDMODEOPAQUE: boolean;
  19370. TONEMAPPING: boolean;
  19371. TONEMAPPING_ACES: boolean;
  19372. CONTRAST: boolean;
  19373. COLORCURVES: boolean;
  19374. COLORGRADING: boolean;
  19375. COLORGRADING3D: boolean;
  19376. SAMPLER3DGREENDEPTH: boolean;
  19377. SAMPLER3DBGRMAP: boolean;
  19378. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19379. MULTIVIEW: boolean;
  19380. /**
  19381. * If the reflection texture on this material is in linear color space
  19382. * @hidden
  19383. */
  19384. IS_REFLECTION_LINEAR: boolean;
  19385. /**
  19386. * If the refraction texture on this material is in linear color space
  19387. * @hidden
  19388. */
  19389. IS_REFRACTION_LINEAR: boolean;
  19390. EXPOSURE: boolean;
  19391. constructor();
  19392. setReflectionMode(modeToEnable: string): void;
  19393. }
  19394. /**
  19395. * This is the default material used in Babylon. It is the best trade off between quality
  19396. * and performances.
  19397. * @see https://doc.babylonjs.com/babylon101/materials
  19398. */
  19399. export class StandardMaterial extends PushMaterial {
  19400. private _diffuseTexture;
  19401. /**
  19402. * The basic texture of the material as viewed under a light.
  19403. */
  19404. diffuseTexture: Nullable<BaseTexture>;
  19405. private _ambientTexture;
  19406. /**
  19407. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19408. */
  19409. ambientTexture: Nullable<BaseTexture>;
  19410. private _opacityTexture;
  19411. /**
  19412. * Define the transparency of the material from a texture.
  19413. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19414. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19415. */
  19416. opacityTexture: Nullable<BaseTexture>;
  19417. private _reflectionTexture;
  19418. /**
  19419. * Define the texture used to display the reflection.
  19420. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19421. */
  19422. reflectionTexture: Nullable<BaseTexture>;
  19423. private _emissiveTexture;
  19424. /**
  19425. * Define texture of the material as if self lit.
  19426. * This will be mixed in the final result even in the absence of light.
  19427. */
  19428. emissiveTexture: Nullable<BaseTexture>;
  19429. private _specularTexture;
  19430. /**
  19431. * Define how the color and intensity of the highlight given by the light in the material.
  19432. */
  19433. specularTexture: Nullable<BaseTexture>;
  19434. private _bumpTexture;
  19435. /**
  19436. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19437. * 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.
  19438. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19439. */
  19440. bumpTexture: Nullable<BaseTexture>;
  19441. private _lightmapTexture;
  19442. /**
  19443. * Complex lighting can be computationally expensive to compute at runtime.
  19444. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19445. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19446. */
  19447. lightmapTexture: Nullable<BaseTexture>;
  19448. private _refractionTexture;
  19449. /**
  19450. * Define the texture used to display the refraction.
  19451. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19452. */
  19453. refractionTexture: Nullable<BaseTexture>;
  19454. /**
  19455. * The color of the material lit by the environmental background lighting.
  19456. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19457. */
  19458. ambientColor: Color3;
  19459. /**
  19460. * The basic color of the material as viewed under a light.
  19461. */
  19462. diffuseColor: Color3;
  19463. /**
  19464. * Define how the color and intensity of the highlight given by the light in the material.
  19465. */
  19466. specularColor: Color3;
  19467. /**
  19468. * Define the color of the material as if self lit.
  19469. * This will be mixed in the final result even in the absence of light.
  19470. */
  19471. emissiveColor: Color3;
  19472. /**
  19473. * Defines how sharp are the highlights in the material.
  19474. * The bigger the value the sharper giving a more glossy feeling to the result.
  19475. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19476. */
  19477. specularPower: number;
  19478. private _useAlphaFromDiffuseTexture;
  19479. /**
  19480. * Does the transparency come from the diffuse texture alpha channel.
  19481. */
  19482. useAlphaFromDiffuseTexture: boolean;
  19483. private _useEmissiveAsIllumination;
  19484. /**
  19485. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19486. */
  19487. useEmissiveAsIllumination: boolean;
  19488. private _linkEmissiveWithDiffuse;
  19489. /**
  19490. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19491. * the emissive level when the final color is close to one.
  19492. */
  19493. linkEmissiveWithDiffuse: boolean;
  19494. private _useSpecularOverAlpha;
  19495. /**
  19496. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19497. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19498. */
  19499. useSpecularOverAlpha: boolean;
  19500. private _useReflectionOverAlpha;
  19501. /**
  19502. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19503. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19504. */
  19505. useReflectionOverAlpha: boolean;
  19506. private _disableLighting;
  19507. /**
  19508. * Does lights from the scene impacts this material.
  19509. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19510. */
  19511. disableLighting: boolean;
  19512. private _useObjectSpaceNormalMap;
  19513. /**
  19514. * Allows using an object space normal map (instead of tangent space).
  19515. */
  19516. useObjectSpaceNormalMap: boolean;
  19517. private _useParallax;
  19518. /**
  19519. * Is parallax enabled or not.
  19520. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19521. */
  19522. useParallax: boolean;
  19523. private _useParallaxOcclusion;
  19524. /**
  19525. * Is parallax occlusion enabled or not.
  19526. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19527. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19528. */
  19529. useParallaxOcclusion: boolean;
  19530. /**
  19531. * 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.
  19532. */
  19533. parallaxScaleBias: number;
  19534. private _roughness;
  19535. /**
  19536. * Helps to define how blurry the reflections should appears in the material.
  19537. */
  19538. roughness: number;
  19539. /**
  19540. * In case of refraction, define the value of the index of refraction.
  19541. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19542. */
  19543. indexOfRefraction: number;
  19544. /**
  19545. * Invert the refraction texture alongside the y axis.
  19546. * It can be useful with procedural textures or probe for instance.
  19547. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19548. */
  19549. invertRefractionY: boolean;
  19550. /**
  19551. * Defines the alpha limits in alpha test mode.
  19552. */
  19553. alphaCutOff: number;
  19554. private _useLightmapAsShadowmap;
  19555. /**
  19556. * In case of light mapping, define whether the map contains light or shadow informations.
  19557. */
  19558. useLightmapAsShadowmap: boolean;
  19559. private _diffuseFresnelParameters;
  19560. /**
  19561. * Define the diffuse fresnel parameters of the material.
  19562. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19563. */
  19564. diffuseFresnelParameters: FresnelParameters;
  19565. private _opacityFresnelParameters;
  19566. /**
  19567. * Define the opacity fresnel parameters of the material.
  19568. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19569. */
  19570. opacityFresnelParameters: FresnelParameters;
  19571. private _reflectionFresnelParameters;
  19572. /**
  19573. * Define the reflection fresnel parameters of the material.
  19574. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19575. */
  19576. reflectionFresnelParameters: FresnelParameters;
  19577. private _refractionFresnelParameters;
  19578. /**
  19579. * Define the refraction fresnel parameters of the material.
  19580. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19581. */
  19582. refractionFresnelParameters: FresnelParameters;
  19583. private _emissiveFresnelParameters;
  19584. /**
  19585. * Define the emissive fresnel parameters of the material.
  19586. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19587. */
  19588. emissiveFresnelParameters: FresnelParameters;
  19589. private _useReflectionFresnelFromSpecular;
  19590. /**
  19591. * If true automatically deducts the fresnels values from the material specularity.
  19592. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19593. */
  19594. useReflectionFresnelFromSpecular: boolean;
  19595. private _useGlossinessFromSpecularMapAlpha;
  19596. /**
  19597. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19598. */
  19599. useGlossinessFromSpecularMapAlpha: boolean;
  19600. private _maxSimultaneousLights;
  19601. /**
  19602. * Defines the maximum number of lights that can be used in the material
  19603. */
  19604. maxSimultaneousLights: number;
  19605. private _invertNormalMapX;
  19606. /**
  19607. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19608. */
  19609. invertNormalMapX: boolean;
  19610. private _invertNormalMapY;
  19611. /**
  19612. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19613. */
  19614. invertNormalMapY: boolean;
  19615. private _twoSidedLighting;
  19616. /**
  19617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19618. */
  19619. twoSidedLighting: boolean;
  19620. /**
  19621. * Default configuration related to image processing available in the standard Material.
  19622. */
  19623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19624. /**
  19625. * Gets the image processing configuration used either in this material.
  19626. */
  19627. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19628. /**
  19629. * Sets the Default image processing configuration used either in the this material.
  19630. *
  19631. * If sets to null, the scene one is in use.
  19632. */
  19633. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19634. /**
  19635. * Keep track of the image processing observer to allow dispose and replace.
  19636. */
  19637. private _imageProcessingObserver;
  19638. /**
  19639. * Attaches a new image processing configuration to the Standard Material.
  19640. * @param configuration
  19641. */
  19642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19643. /**
  19644. * Defines additionnal PrePass parameters for the material.
  19645. */
  19646. readonly prePassConfiguration: PrePassConfiguration;
  19647. /**
  19648. * Gets wether the color curves effect is enabled.
  19649. */
  19650. get cameraColorCurvesEnabled(): boolean;
  19651. /**
  19652. * Sets wether the color curves effect is enabled.
  19653. */
  19654. set cameraColorCurvesEnabled(value: boolean);
  19655. /**
  19656. * Gets wether the color grading effect is enabled.
  19657. */
  19658. get cameraColorGradingEnabled(): boolean;
  19659. /**
  19660. * Gets wether the color grading effect is enabled.
  19661. */
  19662. set cameraColorGradingEnabled(value: boolean);
  19663. /**
  19664. * Gets wether tonemapping is enabled or not.
  19665. */
  19666. get cameraToneMappingEnabled(): boolean;
  19667. /**
  19668. * Sets wether tonemapping is enabled or not
  19669. */
  19670. set cameraToneMappingEnabled(value: boolean);
  19671. /**
  19672. * The camera exposure used on this material.
  19673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19674. * This corresponds to a photographic exposure.
  19675. */
  19676. get cameraExposure(): number;
  19677. /**
  19678. * The camera exposure used on this material.
  19679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19680. * This corresponds to a photographic exposure.
  19681. */
  19682. set cameraExposure(value: number);
  19683. /**
  19684. * Gets The camera contrast used on this material.
  19685. */
  19686. get cameraContrast(): number;
  19687. /**
  19688. * Sets The camera contrast used on this material.
  19689. */
  19690. set cameraContrast(value: number);
  19691. /**
  19692. * Gets the Color Grading 2D Lookup Texture.
  19693. */
  19694. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19695. /**
  19696. * Sets the Color Grading 2D Lookup Texture.
  19697. */
  19698. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19699. /**
  19700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19702. * 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;
  19703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19704. */
  19705. get cameraColorCurves(): Nullable<ColorCurves>;
  19706. /**
  19707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19709. * 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;
  19710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19711. */
  19712. set cameraColorCurves(value: Nullable<ColorCurves>);
  19713. /**
  19714. * Can this material render to several textures at once
  19715. */
  19716. get canRenderToMRT(): boolean;
  19717. /**
  19718. * Defines the detail map parameters for the material.
  19719. */
  19720. readonly detailMap: DetailMapConfiguration;
  19721. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19722. protected _worldViewProjectionMatrix: Matrix;
  19723. protected _globalAmbientColor: Color3;
  19724. protected _useLogarithmicDepth: boolean;
  19725. protected _rebuildInParallel: boolean;
  19726. /**
  19727. * Instantiates a new standard material.
  19728. * This is the default material used in Babylon. It is the best trade off between quality
  19729. * and performances.
  19730. * @see https://doc.babylonjs.com/babylon101/materials
  19731. * @param name Define the name of the material in the scene
  19732. * @param scene Define the scene the material belong to
  19733. */
  19734. constructor(name: string, scene: Scene);
  19735. /**
  19736. * Gets a boolean indicating that current material needs to register RTT
  19737. */
  19738. get hasRenderTargetTextures(): boolean;
  19739. /**
  19740. * Gets the current class name of the material e.g. "StandardMaterial"
  19741. * Mainly use in serialization.
  19742. * @returns the class name
  19743. */
  19744. getClassName(): string;
  19745. /**
  19746. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19747. * You can try switching to logarithmic depth.
  19748. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19749. */
  19750. get useLogarithmicDepth(): boolean;
  19751. set useLogarithmicDepth(value: boolean);
  19752. /**
  19753. * Specifies if the material will require alpha blending
  19754. * @returns a boolean specifying if alpha blending is needed
  19755. */
  19756. needAlphaBlending(): boolean;
  19757. /**
  19758. * Specifies if this material should be rendered in alpha test mode
  19759. * @returns a boolean specifying if an alpha test is needed.
  19760. */
  19761. needAlphaTesting(): boolean;
  19762. /**
  19763. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19764. */
  19765. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19766. /**
  19767. * Specifies whether or not there is a usable alpha channel for transparency.
  19768. */
  19769. protected _hasAlphaChannel(): boolean;
  19770. /**
  19771. * Get the texture used for alpha test purpose.
  19772. * @returns the diffuse texture in case of the standard material.
  19773. */
  19774. getAlphaTestTexture(): Nullable<BaseTexture>;
  19775. /**
  19776. * Get if the submesh is ready to be used and all its information available.
  19777. * Child classes can use it to update shaders
  19778. * @param mesh defines the mesh to check
  19779. * @param subMesh defines which submesh to check
  19780. * @param useInstances specifies that instances should be used
  19781. * @returns a boolean indicating that the submesh is ready or not
  19782. */
  19783. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19784. /**
  19785. * Builds the material UBO layouts.
  19786. * Used internally during the effect preparation.
  19787. */
  19788. buildUniformLayout(): void;
  19789. /**
  19790. * Unbinds the material from the mesh
  19791. */
  19792. unbind(): void;
  19793. /**
  19794. * Binds the submesh to this material by preparing the effect and shader to draw
  19795. * @param world defines the world transformation matrix
  19796. * @param mesh defines the mesh containing the submesh
  19797. * @param subMesh defines the submesh to bind the material to
  19798. */
  19799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19800. /**
  19801. * Get the list of animatables in the material.
  19802. * @returns the list of animatables object used in the material
  19803. */
  19804. getAnimatables(): IAnimatable[];
  19805. /**
  19806. * Gets the active textures from the material
  19807. * @returns an array of textures
  19808. */
  19809. getActiveTextures(): BaseTexture[];
  19810. /**
  19811. * Specifies if the material uses a texture
  19812. * @param texture defines the texture to check against the material
  19813. * @returns a boolean specifying if the material uses the texture
  19814. */
  19815. hasTexture(texture: BaseTexture): boolean;
  19816. /**
  19817. * Disposes the material
  19818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19819. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19820. */
  19821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19822. /**
  19823. * Makes a duplicate of the material, and gives it a new name
  19824. * @param name defines the new name for the duplicated material
  19825. * @returns the cloned material
  19826. */
  19827. clone(name: string): StandardMaterial;
  19828. /**
  19829. * Serializes this material in a JSON representation
  19830. * @returns the serialized material object
  19831. */
  19832. serialize(): any;
  19833. /**
  19834. * Creates a standard material from parsed material data
  19835. * @param source defines the JSON representation of the material
  19836. * @param scene defines the hosting scene
  19837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19838. * @returns a new standard material
  19839. */
  19840. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19841. /**
  19842. * Are diffuse textures enabled in the application.
  19843. */
  19844. static get DiffuseTextureEnabled(): boolean;
  19845. static set DiffuseTextureEnabled(value: boolean);
  19846. /**
  19847. * Are detail textures enabled in the application.
  19848. */
  19849. static get DetailTextureEnabled(): boolean;
  19850. static set DetailTextureEnabled(value: boolean);
  19851. /**
  19852. * Are ambient textures enabled in the application.
  19853. */
  19854. static get AmbientTextureEnabled(): boolean;
  19855. static set AmbientTextureEnabled(value: boolean);
  19856. /**
  19857. * Are opacity textures enabled in the application.
  19858. */
  19859. static get OpacityTextureEnabled(): boolean;
  19860. static set OpacityTextureEnabled(value: boolean);
  19861. /**
  19862. * Are reflection textures enabled in the application.
  19863. */
  19864. static get ReflectionTextureEnabled(): boolean;
  19865. static set ReflectionTextureEnabled(value: boolean);
  19866. /**
  19867. * Are emissive textures enabled in the application.
  19868. */
  19869. static get EmissiveTextureEnabled(): boolean;
  19870. static set EmissiveTextureEnabled(value: boolean);
  19871. /**
  19872. * Are specular textures enabled in the application.
  19873. */
  19874. static get SpecularTextureEnabled(): boolean;
  19875. static set SpecularTextureEnabled(value: boolean);
  19876. /**
  19877. * Are bump textures enabled in the application.
  19878. */
  19879. static get BumpTextureEnabled(): boolean;
  19880. static set BumpTextureEnabled(value: boolean);
  19881. /**
  19882. * Are lightmap textures enabled in the application.
  19883. */
  19884. static get LightmapTextureEnabled(): boolean;
  19885. static set LightmapTextureEnabled(value: boolean);
  19886. /**
  19887. * Are refraction textures enabled in the application.
  19888. */
  19889. static get RefractionTextureEnabled(): boolean;
  19890. static set RefractionTextureEnabled(value: boolean);
  19891. /**
  19892. * Are color grading textures enabled in the application.
  19893. */
  19894. static get ColorGradingTextureEnabled(): boolean;
  19895. static set ColorGradingTextureEnabled(value: boolean);
  19896. /**
  19897. * Are fresnels enabled in the application.
  19898. */
  19899. static get FresnelEnabled(): boolean;
  19900. static set FresnelEnabled(value: boolean);
  19901. }
  19902. }
  19903. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19904. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19905. /** @hidden */
  19906. export var rgbdDecodePixelShader: {
  19907. name: string;
  19908. shader: string;
  19909. };
  19910. }
  19911. declare module "babylonjs/Misc/rgbdTextureTools" {
  19912. import "babylonjs/Shaders/rgbdDecode.fragment";
  19913. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19914. import { Texture } from "babylonjs/Materials/Textures/texture";
  19915. /**
  19916. * Class used to host RGBD texture specific utilities
  19917. */
  19918. export class RGBDTextureTools {
  19919. /**
  19920. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19921. * @param texture the texture to expand.
  19922. */
  19923. static ExpandRGBDTexture(texture: Texture): void;
  19924. }
  19925. }
  19926. declare module "babylonjs/Misc/brdfTextureTools" {
  19927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19928. import { Scene } from "babylonjs/scene";
  19929. /**
  19930. * Class used to host texture specific utilities
  19931. */
  19932. export class BRDFTextureTools {
  19933. /**
  19934. * Prevents texture cache collision
  19935. */
  19936. private static _instanceNumber;
  19937. /**
  19938. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19939. * @param scene defines the hosting scene
  19940. * @returns the environment BRDF texture
  19941. */
  19942. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19943. private static _environmentBRDFBase64Texture;
  19944. }
  19945. }
  19946. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19947. import { Nullable } from "babylonjs/types";
  19948. import { Color3 } from "babylonjs/Maths/math.color";
  19949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19950. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19951. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19952. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19954. import { Engine } from "babylonjs/Engines/engine";
  19955. import { Scene } from "babylonjs/scene";
  19956. /**
  19957. * @hidden
  19958. */
  19959. export interface IMaterialClearCoatDefines {
  19960. CLEARCOAT: boolean;
  19961. CLEARCOAT_DEFAULTIOR: boolean;
  19962. CLEARCOAT_TEXTURE: boolean;
  19963. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19964. CLEARCOAT_TEXTUREDIRECTUV: number;
  19965. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19966. CLEARCOAT_BUMP: boolean;
  19967. CLEARCOAT_BUMPDIRECTUV: number;
  19968. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19969. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19970. CLEARCOAT_REMAP_F0: boolean;
  19971. CLEARCOAT_TINT: boolean;
  19972. CLEARCOAT_TINT_TEXTURE: boolean;
  19973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19974. /** @hidden */
  19975. _areTexturesDirty: boolean;
  19976. }
  19977. /**
  19978. * Define the code related to the clear coat parameters of the pbr material.
  19979. */
  19980. export class PBRClearCoatConfiguration {
  19981. /**
  19982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19983. * The default fits with a polyurethane material.
  19984. * @hidden
  19985. */
  19986. static readonly _DefaultIndexOfRefraction: number;
  19987. private _isEnabled;
  19988. /**
  19989. * Defines if the clear coat is enabled in the material.
  19990. */
  19991. isEnabled: boolean;
  19992. /**
  19993. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19994. */
  19995. intensity: number;
  19996. /**
  19997. * Defines the clear coat layer roughness.
  19998. */
  19999. roughness: number;
  20000. private _indexOfRefraction;
  20001. /**
  20002. * Defines the index of refraction of the clear coat.
  20003. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20004. * The default fits with a polyurethane material.
  20005. * Changing the default value is more performance intensive.
  20006. */
  20007. indexOfRefraction: number;
  20008. private _texture;
  20009. /**
  20010. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20011. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20012. * if textureRoughness is not empty, else no texture roughness is used
  20013. */
  20014. texture: Nullable<BaseTexture>;
  20015. private _useRoughnessFromMainTexture;
  20016. /**
  20017. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20018. * If false, the green channel from textureRoughness is used for roughness
  20019. */
  20020. useRoughnessFromMainTexture: boolean;
  20021. private _textureRoughness;
  20022. /**
  20023. * Stores the clear coat roughness in a texture (green channel)
  20024. * Not used if useRoughnessFromMainTexture is true
  20025. */
  20026. textureRoughness: Nullable<BaseTexture>;
  20027. private _remapF0OnInterfaceChange;
  20028. /**
  20029. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20030. */
  20031. remapF0OnInterfaceChange: boolean;
  20032. private _bumpTexture;
  20033. /**
  20034. * Define the clear coat specific bump texture.
  20035. */
  20036. bumpTexture: Nullable<BaseTexture>;
  20037. private _isTintEnabled;
  20038. /**
  20039. * Defines if the clear coat tint is enabled in the material.
  20040. */
  20041. isTintEnabled: boolean;
  20042. /**
  20043. * Defines the clear coat tint of the material.
  20044. * This is only use if tint is enabled
  20045. */
  20046. tintColor: Color3;
  20047. /**
  20048. * Defines the distance at which the tint color should be found in the
  20049. * clear coat media.
  20050. * This is only use if tint is enabled
  20051. */
  20052. tintColorAtDistance: number;
  20053. /**
  20054. * Defines the clear coat layer thickness.
  20055. * This is only use if tint is enabled
  20056. */
  20057. tintThickness: number;
  20058. private _tintTexture;
  20059. /**
  20060. * Stores the clear tint values in a texture.
  20061. * rgb is tint
  20062. * a is a thickness factor
  20063. */
  20064. tintTexture: Nullable<BaseTexture>;
  20065. /** @hidden */
  20066. private _internalMarkAllSubMeshesAsTexturesDirty;
  20067. /** @hidden */
  20068. _markAllSubMeshesAsTexturesDirty(): void;
  20069. /**
  20070. * Instantiate a new istance of clear coat configuration.
  20071. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20072. */
  20073. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20074. /**
  20075. * Gets wehter the submesh is ready to be used or not.
  20076. * @param defines the list of "defines" to update.
  20077. * @param scene defines the scene the material belongs to.
  20078. * @param engine defines the engine the material belongs to.
  20079. * @param disableBumpMap defines wether the material disables bump or not.
  20080. * @returns - boolean indicating that the submesh is ready or not.
  20081. */
  20082. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20083. /**
  20084. * Checks to see if a texture is used in the material.
  20085. * @param defines the list of "defines" to update.
  20086. * @param scene defines the scene to the material belongs to.
  20087. */
  20088. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20089. /**
  20090. * Binds the material data.
  20091. * @param uniformBuffer defines the Uniform buffer to fill in.
  20092. * @param scene defines the scene the material belongs to.
  20093. * @param engine defines the engine the material belongs to.
  20094. * @param disableBumpMap defines wether the material disables bump or not.
  20095. * @param isFrozen defines wether the material is frozen or not.
  20096. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20097. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20098. * @param subMesh the submesh to bind data for
  20099. */
  20100. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20101. /**
  20102. * Checks to see if a texture is used in the material.
  20103. * @param texture - Base texture to use.
  20104. * @returns - Boolean specifying if a texture is used in the material.
  20105. */
  20106. hasTexture(texture: BaseTexture): boolean;
  20107. /**
  20108. * Returns an array of the actively used textures.
  20109. * @param activeTextures Array of BaseTextures
  20110. */
  20111. getActiveTextures(activeTextures: BaseTexture[]): void;
  20112. /**
  20113. * Returns the animatable textures.
  20114. * @param animatables Array of animatable textures.
  20115. */
  20116. getAnimatables(animatables: IAnimatable[]): void;
  20117. /**
  20118. * Disposes the resources of the material.
  20119. * @param forceDisposeTextures - Forces the disposal of all textures.
  20120. */
  20121. dispose(forceDisposeTextures?: boolean): void;
  20122. /**
  20123. * Get the current class name of the texture useful for serialization or dynamic coding.
  20124. * @returns "PBRClearCoatConfiguration"
  20125. */
  20126. getClassName(): string;
  20127. /**
  20128. * Add fallbacks to the effect fallbacks list.
  20129. * @param defines defines the Base texture to use.
  20130. * @param fallbacks defines the current fallback list.
  20131. * @param currentRank defines the current fallback rank.
  20132. * @returns the new fallback rank.
  20133. */
  20134. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20135. /**
  20136. * Add the required uniforms to the current list.
  20137. * @param uniforms defines the current uniform list.
  20138. */
  20139. static AddUniforms(uniforms: string[]): void;
  20140. /**
  20141. * Add the required samplers to the current list.
  20142. * @param samplers defines the current sampler list.
  20143. */
  20144. static AddSamplers(samplers: string[]): void;
  20145. /**
  20146. * Add the required uniforms to the current buffer.
  20147. * @param uniformBuffer defines the current uniform buffer.
  20148. */
  20149. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20150. /**
  20151. * Makes a duplicate of the current configuration into another one.
  20152. * @param clearCoatConfiguration define the config where to copy the info
  20153. */
  20154. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20155. /**
  20156. * Serializes this clear coat configuration.
  20157. * @returns - An object with the serialized config.
  20158. */
  20159. serialize(): any;
  20160. /**
  20161. * Parses a anisotropy Configuration from a serialized object.
  20162. * @param source - Serialized object.
  20163. * @param scene Defines the scene we are parsing for
  20164. * @param rootUrl Defines the rootUrl to load from
  20165. */
  20166. parse(source: any, scene: Scene, rootUrl: string): void;
  20167. }
  20168. }
  20169. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20170. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20172. import { Vector2 } from "babylonjs/Maths/math.vector";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20175. import { Nullable } from "babylonjs/types";
  20176. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20177. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20178. /**
  20179. * @hidden
  20180. */
  20181. export interface IMaterialAnisotropicDefines {
  20182. ANISOTROPIC: boolean;
  20183. ANISOTROPIC_TEXTURE: boolean;
  20184. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20185. MAINUV1: boolean;
  20186. _areTexturesDirty: boolean;
  20187. _needUVs: boolean;
  20188. }
  20189. /**
  20190. * Define the code related to the anisotropic parameters of the pbr material.
  20191. */
  20192. export class PBRAnisotropicConfiguration {
  20193. private _isEnabled;
  20194. /**
  20195. * Defines if the anisotropy is enabled in the material.
  20196. */
  20197. isEnabled: boolean;
  20198. /**
  20199. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20200. */
  20201. intensity: number;
  20202. /**
  20203. * Defines if the effect is along the tangents, bitangents or in between.
  20204. * By default, the effect is "strectching" the highlights along the tangents.
  20205. */
  20206. direction: Vector2;
  20207. private _texture;
  20208. /**
  20209. * Stores the anisotropy values in a texture.
  20210. * rg is direction (like normal from -1 to 1)
  20211. * b is a intensity
  20212. */
  20213. texture: Nullable<BaseTexture>;
  20214. /** @hidden */
  20215. private _internalMarkAllSubMeshesAsTexturesDirty;
  20216. /** @hidden */
  20217. _markAllSubMeshesAsTexturesDirty(): void;
  20218. /**
  20219. * Instantiate a new istance of anisotropy configuration.
  20220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20221. */
  20222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20223. /**
  20224. * Specifies that the submesh is ready to be used.
  20225. * @param defines the list of "defines" to update.
  20226. * @param scene defines the scene the material belongs to.
  20227. * @returns - boolean indicating that the submesh is ready or not.
  20228. */
  20229. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20230. /**
  20231. * Checks to see if a texture is used in the material.
  20232. * @param defines the list of "defines" to update.
  20233. * @param mesh the mesh we are preparing the defines for.
  20234. * @param scene defines the scene the material belongs to.
  20235. */
  20236. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20237. /**
  20238. * Binds the material data.
  20239. * @param uniformBuffer defines the Uniform buffer to fill in.
  20240. * @param scene defines the scene the material belongs to.
  20241. * @param isFrozen defines wether the material is frozen or not.
  20242. */
  20243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20244. /**
  20245. * Checks to see if a texture is used in the material.
  20246. * @param texture - Base texture to use.
  20247. * @returns - Boolean specifying if a texture is used in the material.
  20248. */
  20249. hasTexture(texture: BaseTexture): boolean;
  20250. /**
  20251. * Returns an array of the actively used textures.
  20252. * @param activeTextures Array of BaseTextures
  20253. */
  20254. getActiveTextures(activeTextures: BaseTexture[]): void;
  20255. /**
  20256. * Returns the animatable textures.
  20257. * @param animatables Array of animatable textures.
  20258. */
  20259. getAnimatables(animatables: IAnimatable[]): void;
  20260. /**
  20261. * Disposes the resources of the material.
  20262. * @param forceDisposeTextures - Forces the disposal of all textures.
  20263. */
  20264. dispose(forceDisposeTextures?: boolean): void;
  20265. /**
  20266. * Get the current class name of the texture useful for serialization or dynamic coding.
  20267. * @returns "PBRAnisotropicConfiguration"
  20268. */
  20269. getClassName(): string;
  20270. /**
  20271. * Add fallbacks to the effect fallbacks list.
  20272. * @param defines defines the Base texture to use.
  20273. * @param fallbacks defines the current fallback list.
  20274. * @param currentRank defines the current fallback rank.
  20275. * @returns the new fallback rank.
  20276. */
  20277. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20278. /**
  20279. * Add the required uniforms to the current list.
  20280. * @param uniforms defines the current uniform list.
  20281. */
  20282. static AddUniforms(uniforms: string[]): void;
  20283. /**
  20284. * Add the required uniforms to the current buffer.
  20285. * @param uniformBuffer defines the current uniform buffer.
  20286. */
  20287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20288. /**
  20289. * Add the required samplers to the current list.
  20290. * @param samplers defines the current sampler list.
  20291. */
  20292. static AddSamplers(samplers: string[]): void;
  20293. /**
  20294. * Makes a duplicate of the current configuration into another one.
  20295. * @param anisotropicConfiguration define the config where to copy the info
  20296. */
  20297. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20298. /**
  20299. * Serializes this anisotropy configuration.
  20300. * @returns - An object with the serialized config.
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Parses a anisotropy Configuration from a serialized object.
  20305. * @param source - Serialized object.
  20306. * @param scene Defines the scene we are parsing for
  20307. * @param rootUrl Defines the rootUrl to load from
  20308. */
  20309. parse(source: any, scene: Scene, rootUrl: string): void;
  20310. }
  20311. }
  20312. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20313. import { Scene } from "babylonjs/scene";
  20314. /**
  20315. * @hidden
  20316. */
  20317. export interface IMaterialBRDFDefines {
  20318. BRDF_V_HEIGHT_CORRELATED: boolean;
  20319. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20320. SPHERICAL_HARMONICS: boolean;
  20321. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20322. /** @hidden */
  20323. _areMiscDirty: boolean;
  20324. }
  20325. /**
  20326. * Define the code related to the BRDF parameters of the pbr material.
  20327. */
  20328. export class PBRBRDFConfiguration {
  20329. /**
  20330. * Default value used for the energy conservation.
  20331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20332. */
  20333. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20334. /**
  20335. * Default value used for the Smith Visibility Height Correlated mode.
  20336. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20337. */
  20338. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20339. /**
  20340. * Default value used for the IBL diffuse part.
  20341. * This can help switching back to the polynomials mode globally which is a tiny bit
  20342. * less GPU intensive at the drawback of a lower quality.
  20343. */
  20344. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20345. /**
  20346. * Default value used for activating energy conservation for the specular workflow.
  20347. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20348. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20349. */
  20350. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20351. private _useEnergyConservation;
  20352. /**
  20353. * Defines if the material uses energy conservation.
  20354. */
  20355. useEnergyConservation: boolean;
  20356. private _useSmithVisibilityHeightCorrelated;
  20357. /**
  20358. * LEGACY Mode set to false
  20359. * Defines if the material uses height smith correlated visibility term.
  20360. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20361. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20362. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20363. * Not relying on height correlated will also disable energy conservation.
  20364. */
  20365. useSmithVisibilityHeightCorrelated: boolean;
  20366. private _useSphericalHarmonics;
  20367. /**
  20368. * LEGACY Mode set to false
  20369. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20370. * diffuse part of the IBL.
  20371. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20372. * to the ground truth.
  20373. */
  20374. useSphericalHarmonics: boolean;
  20375. private _useSpecularGlossinessInputEnergyConservation;
  20376. /**
  20377. * Defines if the material uses energy conservation, when the specular workflow is active.
  20378. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20379. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20380. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20381. */
  20382. useSpecularGlossinessInputEnergyConservation: boolean;
  20383. /** @hidden */
  20384. private _internalMarkAllSubMeshesAsMiscDirty;
  20385. /** @hidden */
  20386. _markAllSubMeshesAsMiscDirty(): void;
  20387. /**
  20388. * Instantiate a new istance of clear coat configuration.
  20389. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20390. */
  20391. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20392. /**
  20393. * Checks to see if a texture is used in the material.
  20394. * @param defines the list of "defines" to update.
  20395. */
  20396. prepareDefines(defines: IMaterialBRDFDefines): void;
  20397. /**
  20398. * Get the current class name of the texture useful for serialization or dynamic coding.
  20399. * @returns "PBRClearCoatConfiguration"
  20400. */
  20401. getClassName(): string;
  20402. /**
  20403. * Makes a duplicate of the current configuration into another one.
  20404. * @param brdfConfiguration define the config where to copy the info
  20405. */
  20406. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20407. /**
  20408. * Serializes this BRDF configuration.
  20409. * @returns - An object with the serialized config.
  20410. */
  20411. serialize(): any;
  20412. /**
  20413. * Parses a anisotropy Configuration from a serialized object.
  20414. * @param source - Serialized object.
  20415. * @param scene Defines the scene we are parsing for
  20416. * @param rootUrl Defines the rootUrl to load from
  20417. */
  20418. parse(source: any, scene: Scene, rootUrl: string): void;
  20419. }
  20420. }
  20421. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20422. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20423. import { Color3 } from "babylonjs/Maths/math.color";
  20424. import { Scene } from "babylonjs/scene";
  20425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20426. import { Nullable } from "babylonjs/types";
  20427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20428. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20430. /**
  20431. * @hidden
  20432. */
  20433. export interface IMaterialSheenDefines {
  20434. SHEEN: boolean;
  20435. SHEEN_TEXTURE: boolean;
  20436. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20437. SHEEN_TEXTUREDIRECTUV: number;
  20438. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20439. SHEEN_LINKWITHALBEDO: boolean;
  20440. SHEEN_ROUGHNESS: boolean;
  20441. SHEEN_ALBEDOSCALING: boolean;
  20442. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20443. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20444. /** @hidden */
  20445. _areTexturesDirty: boolean;
  20446. }
  20447. /**
  20448. * Define the code related to the Sheen parameters of the pbr material.
  20449. */
  20450. export class PBRSheenConfiguration {
  20451. private _isEnabled;
  20452. /**
  20453. * Defines if the material uses sheen.
  20454. */
  20455. isEnabled: boolean;
  20456. private _linkSheenWithAlbedo;
  20457. /**
  20458. * Defines if the sheen is linked to the sheen color.
  20459. */
  20460. linkSheenWithAlbedo: boolean;
  20461. /**
  20462. * Defines the sheen intensity.
  20463. */
  20464. intensity: number;
  20465. /**
  20466. * Defines the sheen color.
  20467. */
  20468. color: Color3;
  20469. private _texture;
  20470. /**
  20471. * Stores the sheen tint values in a texture.
  20472. * rgb is tint
  20473. * 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)
  20474. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20475. */
  20476. texture: Nullable<BaseTexture>;
  20477. private _useRoughnessFromMainTexture;
  20478. /**
  20479. * Indicates that the alpha channel of the texture property will be used for roughness.
  20480. * Has no effect if the roughness (and texture!) property is not defined
  20481. */
  20482. useRoughnessFromMainTexture: boolean;
  20483. private _roughness;
  20484. /**
  20485. * Defines the sheen roughness.
  20486. * It is not taken into account if linkSheenWithAlbedo is true.
  20487. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20488. */
  20489. roughness: Nullable<number>;
  20490. private _textureRoughness;
  20491. /**
  20492. * Stores the sheen roughness in a texture.
  20493. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20494. */
  20495. textureRoughness: Nullable<BaseTexture>;
  20496. private _albedoScaling;
  20497. /**
  20498. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20499. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20500. * making it easier to setup and tweak the effect
  20501. */
  20502. albedoScaling: boolean;
  20503. /** @hidden */
  20504. private _internalMarkAllSubMeshesAsTexturesDirty;
  20505. /** @hidden */
  20506. _markAllSubMeshesAsTexturesDirty(): void;
  20507. /**
  20508. * Instantiate a new istance of clear coat configuration.
  20509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20510. */
  20511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20512. /**
  20513. * Specifies that the submesh is ready to be used.
  20514. * @param defines the list of "defines" to update.
  20515. * @param scene defines the scene the material belongs to.
  20516. * @returns - boolean indicating that the submesh is ready or not.
  20517. */
  20518. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20519. /**
  20520. * Checks to see if a texture is used in the material.
  20521. * @param defines the list of "defines" to update.
  20522. * @param scene defines the scene the material belongs to.
  20523. */
  20524. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20525. /**
  20526. * Binds the material data.
  20527. * @param uniformBuffer defines the Uniform buffer to fill in.
  20528. * @param scene defines the scene the material belongs to.
  20529. * @param isFrozen defines wether the material is frozen or not.
  20530. * @param subMesh the submesh to bind data for
  20531. */
  20532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20533. /**
  20534. * Checks to see if a texture is used in the material.
  20535. * @param texture - Base texture to use.
  20536. * @returns - Boolean specifying if a texture is used in the material.
  20537. */
  20538. hasTexture(texture: BaseTexture): boolean;
  20539. /**
  20540. * Returns an array of the actively used textures.
  20541. * @param activeTextures Array of BaseTextures
  20542. */
  20543. getActiveTextures(activeTextures: BaseTexture[]): void;
  20544. /**
  20545. * Returns the animatable textures.
  20546. * @param animatables Array of animatable textures.
  20547. */
  20548. getAnimatables(animatables: IAnimatable[]): void;
  20549. /**
  20550. * Disposes the resources of the material.
  20551. * @param forceDisposeTextures - Forces the disposal of all textures.
  20552. */
  20553. dispose(forceDisposeTextures?: boolean): void;
  20554. /**
  20555. * Get the current class name of the texture useful for serialization or dynamic coding.
  20556. * @returns "PBRSheenConfiguration"
  20557. */
  20558. getClassName(): string;
  20559. /**
  20560. * Add fallbacks to the effect fallbacks list.
  20561. * @param defines defines the Base texture to use.
  20562. * @param fallbacks defines the current fallback list.
  20563. * @param currentRank defines the current fallback rank.
  20564. * @returns the new fallback rank.
  20565. */
  20566. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20567. /**
  20568. * Add the required uniforms to the current list.
  20569. * @param uniforms defines the current uniform list.
  20570. */
  20571. static AddUniforms(uniforms: string[]): void;
  20572. /**
  20573. * Add the required uniforms to the current buffer.
  20574. * @param uniformBuffer defines the current uniform buffer.
  20575. */
  20576. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20577. /**
  20578. * Add the required samplers to the current list.
  20579. * @param samplers defines the current sampler list.
  20580. */
  20581. static AddSamplers(samplers: string[]): void;
  20582. /**
  20583. * Makes a duplicate of the current configuration into another one.
  20584. * @param sheenConfiguration define the config where to copy the info
  20585. */
  20586. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20587. /**
  20588. * Serializes this BRDF configuration.
  20589. * @returns - An object with the serialized config.
  20590. */
  20591. serialize(): any;
  20592. /**
  20593. * Parses a anisotropy Configuration from a serialized object.
  20594. * @param source - Serialized object.
  20595. * @param scene Defines the scene we are parsing for
  20596. * @param rootUrl Defines the rootUrl to load from
  20597. */
  20598. parse(source: any, scene: Scene, rootUrl: string): void;
  20599. }
  20600. }
  20601. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20602. import { Nullable } from "babylonjs/types";
  20603. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20604. import { Color3 } from "babylonjs/Maths/math.color";
  20605. import { SmartArray } from "babylonjs/Misc/smartArray";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { Effect } from "babylonjs/Materials/effect";
  20609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20610. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20611. import { Engine } from "babylonjs/Engines/engine";
  20612. import { Scene } from "babylonjs/scene";
  20613. /**
  20614. * @hidden
  20615. */
  20616. export interface IMaterialSubSurfaceDefines {
  20617. SUBSURFACE: boolean;
  20618. SS_REFRACTION: boolean;
  20619. SS_TRANSLUCENCY: boolean;
  20620. SS_SCATTERING: boolean;
  20621. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20622. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20623. SS_REFRACTIONMAP_3D: boolean;
  20624. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20625. SS_LODINREFRACTIONALPHA: boolean;
  20626. SS_GAMMAREFRACTION: boolean;
  20627. SS_RGBDREFRACTION: boolean;
  20628. SS_LINEARSPECULARREFRACTION: boolean;
  20629. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20630. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20631. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20632. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20633. /** @hidden */
  20634. _areTexturesDirty: boolean;
  20635. }
  20636. /**
  20637. * Define the code related to the sub surface parameters of the pbr material.
  20638. */
  20639. export class PBRSubSurfaceConfiguration {
  20640. private _isRefractionEnabled;
  20641. /**
  20642. * Defines if the refraction is enabled in the material.
  20643. */
  20644. isRefractionEnabled: boolean;
  20645. private _isTranslucencyEnabled;
  20646. /**
  20647. * Defines if the translucency is enabled in the material.
  20648. */
  20649. isTranslucencyEnabled: boolean;
  20650. private _isScatteringEnabled;
  20651. /**
  20652. * Defines if the sub surface scattering is enabled in the material.
  20653. */
  20654. isScatteringEnabled: boolean;
  20655. private _scatteringDiffusionProfileIndex;
  20656. /**
  20657. * Diffusion profile for subsurface scattering.
  20658. * Useful for better scattering in the skins or foliages.
  20659. */
  20660. get scatteringDiffusionProfile(): Nullable<Color3>;
  20661. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20662. /**
  20663. * Defines the refraction intensity of the material.
  20664. * The refraction when enabled replaces the Diffuse part of the material.
  20665. * The intensity helps transitionning between diffuse and refraction.
  20666. */
  20667. refractionIntensity: number;
  20668. /**
  20669. * Defines the translucency intensity of the material.
  20670. * When translucency has been enabled, this defines how much of the "translucency"
  20671. * is addded to the diffuse part of the material.
  20672. */
  20673. translucencyIntensity: number;
  20674. /**
  20675. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20676. */
  20677. useAlbedoToTintRefraction: boolean;
  20678. private _thicknessTexture;
  20679. /**
  20680. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20681. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20682. * 0 would mean minimumThickness
  20683. * 1 would mean maximumThickness
  20684. * The other channels might be use as a mask to vary the different effects intensity.
  20685. */
  20686. thicknessTexture: Nullable<BaseTexture>;
  20687. private _refractionTexture;
  20688. /**
  20689. * Defines the texture to use for refraction.
  20690. */
  20691. refractionTexture: Nullable<BaseTexture>;
  20692. private _indexOfRefraction;
  20693. /**
  20694. * Index of refraction of the material base layer.
  20695. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20696. *
  20697. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20698. *
  20699. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20700. */
  20701. indexOfRefraction: number;
  20702. private _volumeIndexOfRefraction;
  20703. /**
  20704. * Index of refraction of the material's volume.
  20705. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20706. *
  20707. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20708. * the volume will use the same IOR as the surface.
  20709. */
  20710. get volumeIndexOfRefraction(): number;
  20711. set volumeIndexOfRefraction(value: number);
  20712. private _invertRefractionY;
  20713. /**
  20714. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20715. */
  20716. invertRefractionY: boolean;
  20717. private _linkRefractionWithTransparency;
  20718. /**
  20719. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20720. * Materials half opaque for instance using refraction could benefit from this control.
  20721. */
  20722. linkRefractionWithTransparency: boolean;
  20723. /**
  20724. * Defines the minimum thickness stored in the thickness map.
  20725. * If no thickness map is defined, this value will be used to simulate thickness.
  20726. */
  20727. minimumThickness: number;
  20728. /**
  20729. * Defines the maximum thickness stored in the thickness map.
  20730. */
  20731. maximumThickness: number;
  20732. /**
  20733. * Defines the volume tint of the material.
  20734. * This is used for both translucency and scattering.
  20735. */
  20736. tintColor: Color3;
  20737. /**
  20738. * Defines the distance at which the tint color should be found in the media.
  20739. * This is used for refraction only.
  20740. */
  20741. tintColorAtDistance: number;
  20742. /**
  20743. * Defines how far each channel transmit through the media.
  20744. * It is defined as a color to simplify it selection.
  20745. */
  20746. diffusionDistance: Color3;
  20747. private _useMaskFromThicknessTexture;
  20748. /**
  20749. * Stores the intensity of the different subsurface effects in the thickness texture.
  20750. * * the green channel is the translucency intensity.
  20751. * * the blue channel is the scattering intensity.
  20752. * * the alpha channel is the refraction intensity.
  20753. */
  20754. useMaskFromThicknessTexture: boolean;
  20755. private _scene;
  20756. private _useMaskFromThicknessTextureGltf;
  20757. /**
  20758. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20759. * matches the channel-packing that is used by glTF.
  20760. * * the red channel is the transmission/translucency intensity.
  20761. * * the green channel is the thickness.
  20762. */
  20763. useMaskFromThicknessTextureGltf: boolean;
  20764. /** @hidden */
  20765. private _internalMarkAllSubMeshesAsTexturesDirty;
  20766. private _internalMarkScenePrePassDirty;
  20767. /** @hidden */
  20768. _markAllSubMeshesAsTexturesDirty(): void;
  20769. /** @hidden */
  20770. _markScenePrePassDirty(): void;
  20771. /**
  20772. * Instantiate a new istance of sub surface configuration.
  20773. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20774. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20775. * @param scene The scene
  20776. */
  20777. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20778. /**
  20779. * Gets wehter the submesh is ready to be used or not.
  20780. * @param defines the list of "defines" to update.
  20781. * @param scene defines the scene the material belongs to.
  20782. * @returns - boolean indicating that the submesh is ready or not.
  20783. */
  20784. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20785. /**
  20786. * Checks to see if a texture is used in the material.
  20787. * @param defines the list of "defines" to update.
  20788. * @param scene defines the scene to the material belongs to.
  20789. */
  20790. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20791. /**
  20792. * Binds the material data.
  20793. * @param uniformBuffer defines the Uniform buffer to fill in.
  20794. * @param scene defines the scene the material belongs to.
  20795. * @param engine defines the engine the material belongs to.
  20796. * @param isFrozen defines whether the material is frozen or not.
  20797. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20798. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20799. */
  20800. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20801. /**
  20802. * Unbinds the material from the mesh.
  20803. * @param activeEffect defines the effect that should be unbound from.
  20804. * @returns true if unbound, otherwise false
  20805. */
  20806. unbind(activeEffect: Effect): boolean;
  20807. /**
  20808. * Returns the texture used for refraction or null if none is used.
  20809. * @param scene defines the scene the material belongs to.
  20810. * @returns - Refraction texture if present. If no refraction texture and refraction
  20811. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20812. */
  20813. private _getRefractionTexture;
  20814. /**
  20815. * Returns true if alpha blending should be disabled.
  20816. */
  20817. get disableAlphaBlending(): boolean;
  20818. /**
  20819. * Fills the list of render target textures.
  20820. * @param renderTargets the list of render targets to update
  20821. */
  20822. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20823. /**
  20824. * Checks to see if a texture is used in the material.
  20825. * @param texture - Base texture to use.
  20826. * @returns - Boolean specifying if a texture is used in the material.
  20827. */
  20828. hasTexture(texture: BaseTexture): boolean;
  20829. /**
  20830. * Gets a boolean indicating that current material needs to register RTT
  20831. * @returns true if this uses a render target otherwise false.
  20832. */
  20833. hasRenderTargetTextures(): boolean;
  20834. /**
  20835. * Returns an array of the actively used textures.
  20836. * @param activeTextures Array of BaseTextures
  20837. */
  20838. getActiveTextures(activeTextures: BaseTexture[]): void;
  20839. /**
  20840. * Returns the animatable textures.
  20841. * @param animatables Array of animatable textures.
  20842. */
  20843. getAnimatables(animatables: IAnimatable[]): void;
  20844. /**
  20845. * Disposes the resources of the material.
  20846. * @param forceDisposeTextures - Forces the disposal of all textures.
  20847. */
  20848. dispose(forceDisposeTextures?: boolean): void;
  20849. /**
  20850. * Get the current class name of the texture useful for serialization or dynamic coding.
  20851. * @returns "PBRSubSurfaceConfiguration"
  20852. */
  20853. getClassName(): string;
  20854. /**
  20855. * Add fallbacks to the effect fallbacks list.
  20856. * @param defines defines the Base texture to use.
  20857. * @param fallbacks defines the current fallback list.
  20858. * @param currentRank defines the current fallback rank.
  20859. * @returns the new fallback rank.
  20860. */
  20861. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20862. /**
  20863. * Add the required uniforms to the current list.
  20864. * @param uniforms defines the current uniform list.
  20865. */
  20866. static AddUniforms(uniforms: string[]): void;
  20867. /**
  20868. * Add the required samplers to the current list.
  20869. * @param samplers defines the current sampler list.
  20870. */
  20871. static AddSamplers(samplers: string[]): void;
  20872. /**
  20873. * Add the required uniforms to the current buffer.
  20874. * @param uniformBuffer defines the current uniform buffer.
  20875. */
  20876. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20877. /**
  20878. * Makes a duplicate of the current configuration into another one.
  20879. * @param configuration define the config where to copy the info
  20880. */
  20881. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20882. /**
  20883. * Serializes this Sub Surface configuration.
  20884. * @returns - An object with the serialized config.
  20885. */
  20886. serialize(): any;
  20887. /**
  20888. * Parses a anisotropy Configuration from a serialized object.
  20889. * @param source - Serialized object.
  20890. * @param scene Defines the scene we are parsing for
  20891. * @param rootUrl Defines the rootUrl to load from
  20892. */
  20893. parse(source: any, scene: Scene, rootUrl: string): void;
  20894. }
  20895. }
  20896. declare module "babylonjs/Maths/sphericalPolynomial" {
  20897. import { Vector3 } from "babylonjs/Maths/math.vector";
  20898. import { Color3 } from "babylonjs/Maths/math.color";
  20899. /**
  20900. * Class representing spherical harmonics coefficients to the 3rd degree
  20901. */
  20902. export class SphericalHarmonics {
  20903. /**
  20904. * Defines whether or not the harmonics have been prescaled for rendering.
  20905. */
  20906. preScaled: boolean;
  20907. /**
  20908. * The l0,0 coefficients of the spherical harmonics
  20909. */
  20910. l00: Vector3;
  20911. /**
  20912. * The l1,-1 coefficients of the spherical harmonics
  20913. */
  20914. l1_1: Vector3;
  20915. /**
  20916. * The l1,0 coefficients of the spherical harmonics
  20917. */
  20918. l10: Vector3;
  20919. /**
  20920. * The l1,1 coefficients of the spherical harmonics
  20921. */
  20922. l11: Vector3;
  20923. /**
  20924. * The l2,-2 coefficients of the spherical harmonics
  20925. */
  20926. l2_2: Vector3;
  20927. /**
  20928. * The l2,-1 coefficients of the spherical harmonics
  20929. */
  20930. l2_1: Vector3;
  20931. /**
  20932. * The l2,0 coefficients of the spherical harmonics
  20933. */
  20934. l20: Vector3;
  20935. /**
  20936. * The l2,1 coefficients of the spherical harmonics
  20937. */
  20938. l21: Vector3;
  20939. /**
  20940. * The l2,2 coefficients of the spherical harmonics
  20941. */
  20942. l22: Vector3;
  20943. /**
  20944. * Adds a light to the spherical harmonics
  20945. * @param direction the direction of the light
  20946. * @param color the color of the light
  20947. * @param deltaSolidAngle the delta solid angle of the light
  20948. */
  20949. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20950. /**
  20951. * Scales the spherical harmonics by the given amount
  20952. * @param scale the amount to scale
  20953. */
  20954. scaleInPlace(scale: number): void;
  20955. /**
  20956. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20957. *
  20958. * ```
  20959. * E_lm = A_l * L_lm
  20960. * ```
  20961. *
  20962. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20963. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20964. * the scaling factors are given in equation 9.
  20965. */
  20966. convertIncidentRadianceToIrradiance(): void;
  20967. /**
  20968. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20969. *
  20970. * ```
  20971. * L = (1/pi) * E * rho
  20972. * ```
  20973. *
  20974. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20975. */
  20976. convertIrradianceToLambertianRadiance(): void;
  20977. /**
  20978. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20979. * required operations at run time.
  20980. *
  20981. * This is simply done by scaling back the SH with Ylm constants parameter.
  20982. * The trigonometric part being applied by the shader at run time.
  20983. */
  20984. preScaleForRendering(): void;
  20985. /**
  20986. * Constructs a spherical harmonics from an array.
  20987. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20988. * @returns the spherical harmonics
  20989. */
  20990. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20991. /**
  20992. * Gets the spherical harmonics from polynomial
  20993. * @param polynomial the spherical polynomial
  20994. * @returns the spherical harmonics
  20995. */
  20996. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20997. }
  20998. /**
  20999. * Class representing spherical polynomial coefficients to the 3rd degree
  21000. */
  21001. export class SphericalPolynomial {
  21002. private _harmonics;
  21003. /**
  21004. * The spherical harmonics used to create the polynomials.
  21005. */
  21006. get preScaledHarmonics(): SphericalHarmonics;
  21007. /**
  21008. * The x coefficients of the spherical polynomial
  21009. */
  21010. x: Vector3;
  21011. /**
  21012. * The y coefficients of the spherical polynomial
  21013. */
  21014. y: Vector3;
  21015. /**
  21016. * The z coefficients of the spherical polynomial
  21017. */
  21018. z: Vector3;
  21019. /**
  21020. * The xx coefficients of the spherical polynomial
  21021. */
  21022. xx: Vector3;
  21023. /**
  21024. * The yy coefficients of the spherical polynomial
  21025. */
  21026. yy: Vector3;
  21027. /**
  21028. * The zz coefficients of the spherical polynomial
  21029. */
  21030. zz: Vector3;
  21031. /**
  21032. * The xy coefficients of the spherical polynomial
  21033. */
  21034. xy: Vector3;
  21035. /**
  21036. * The yz coefficients of the spherical polynomial
  21037. */
  21038. yz: Vector3;
  21039. /**
  21040. * The zx coefficients of the spherical polynomial
  21041. */
  21042. zx: Vector3;
  21043. /**
  21044. * Adds an ambient color to the spherical polynomial
  21045. * @param color the color to add
  21046. */
  21047. addAmbient(color: Color3): void;
  21048. /**
  21049. * Scales the spherical polynomial by the given amount
  21050. * @param scale the amount to scale
  21051. */
  21052. scaleInPlace(scale: number): void;
  21053. /**
  21054. * Gets the spherical polynomial from harmonics
  21055. * @param harmonics the spherical harmonics
  21056. * @returns the spherical polynomial
  21057. */
  21058. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21059. /**
  21060. * Constructs a spherical polynomial from an array.
  21061. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21062. * @returns the spherical polynomial
  21063. */
  21064. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21065. }
  21066. }
  21067. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21068. import { Nullable } from "babylonjs/types";
  21069. /**
  21070. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21071. */
  21072. export interface CubeMapInfo {
  21073. /**
  21074. * The pixel array for the front face.
  21075. * This is stored in format, left to right, up to down format.
  21076. */
  21077. front: Nullable<ArrayBufferView>;
  21078. /**
  21079. * The pixel array for the back face.
  21080. * This is stored in format, left to right, up to down format.
  21081. */
  21082. back: Nullable<ArrayBufferView>;
  21083. /**
  21084. * The pixel array for the left face.
  21085. * This is stored in format, left to right, up to down format.
  21086. */
  21087. left: Nullable<ArrayBufferView>;
  21088. /**
  21089. * The pixel array for the right face.
  21090. * This is stored in format, left to right, up to down format.
  21091. */
  21092. right: Nullable<ArrayBufferView>;
  21093. /**
  21094. * The pixel array for the up face.
  21095. * This is stored in format, left to right, up to down format.
  21096. */
  21097. up: Nullable<ArrayBufferView>;
  21098. /**
  21099. * The pixel array for the down face.
  21100. * This is stored in format, left to right, up to down format.
  21101. */
  21102. down: Nullable<ArrayBufferView>;
  21103. /**
  21104. * The size of the cubemap stored.
  21105. *
  21106. * Each faces will be size * size pixels.
  21107. */
  21108. size: number;
  21109. /**
  21110. * The format of the texture.
  21111. *
  21112. * RGBA, RGB.
  21113. */
  21114. format: number;
  21115. /**
  21116. * The type of the texture data.
  21117. *
  21118. * UNSIGNED_INT, FLOAT.
  21119. */
  21120. type: number;
  21121. /**
  21122. * Specifies whether the texture is in gamma space.
  21123. */
  21124. gammaSpace: boolean;
  21125. }
  21126. /**
  21127. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21128. */
  21129. export class PanoramaToCubeMapTools {
  21130. private static FACE_LEFT;
  21131. private static FACE_RIGHT;
  21132. private static FACE_FRONT;
  21133. private static FACE_BACK;
  21134. private static FACE_DOWN;
  21135. private static FACE_UP;
  21136. /**
  21137. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21138. *
  21139. * @param float32Array The source data.
  21140. * @param inputWidth The width of the input panorama.
  21141. * @param inputHeight The height of the input panorama.
  21142. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21143. * @return The cubemap data
  21144. */
  21145. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21146. private static CreateCubemapTexture;
  21147. private static CalcProjectionSpherical;
  21148. }
  21149. }
  21150. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21153. import { Nullable } from "babylonjs/types";
  21154. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21155. /**
  21156. * Helper class dealing with the extraction of spherical polynomial dataArray
  21157. * from a cube map.
  21158. */
  21159. export class CubeMapToSphericalPolynomialTools {
  21160. private static FileFaces;
  21161. /**
  21162. * Converts a texture to the according Spherical Polynomial data.
  21163. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21164. *
  21165. * @param texture The texture to extract the information from.
  21166. * @return The Spherical Polynomial data.
  21167. */
  21168. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21169. /**
  21170. * Converts a cubemap to the according Spherical Polynomial data.
  21171. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21172. *
  21173. * @param cubeInfo The Cube map to extract the information from.
  21174. * @return The Spherical Polynomial data.
  21175. */
  21176. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21177. }
  21178. }
  21179. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21180. import { Nullable } from "babylonjs/types";
  21181. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21182. module "babylonjs/Materials/Textures/baseTexture" {
  21183. interface BaseTexture {
  21184. /**
  21185. * Get the polynomial representation of the texture data.
  21186. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21187. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21188. */
  21189. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21190. }
  21191. }
  21192. }
  21193. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21194. /** @hidden */
  21195. export var pbrFragmentDeclaration: {
  21196. name: string;
  21197. shader: string;
  21198. };
  21199. }
  21200. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21201. /** @hidden */
  21202. export var pbrUboDeclaration: {
  21203. name: string;
  21204. shader: string;
  21205. };
  21206. }
  21207. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21208. /** @hidden */
  21209. export var pbrFragmentExtraDeclaration: {
  21210. name: string;
  21211. shader: string;
  21212. };
  21213. }
  21214. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21215. /** @hidden */
  21216. export var pbrFragmentSamplersDeclaration: {
  21217. name: string;
  21218. shader: string;
  21219. };
  21220. }
  21221. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21222. /** @hidden */
  21223. export var subSurfaceScatteringFunctions: {
  21224. name: string;
  21225. shader: string;
  21226. };
  21227. }
  21228. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21229. /** @hidden */
  21230. export var importanceSampling: {
  21231. name: string;
  21232. shader: string;
  21233. };
  21234. }
  21235. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21236. /** @hidden */
  21237. export var pbrHelperFunctions: {
  21238. name: string;
  21239. shader: string;
  21240. };
  21241. }
  21242. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21243. /** @hidden */
  21244. export var harmonicsFunctions: {
  21245. name: string;
  21246. shader: string;
  21247. };
  21248. }
  21249. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21250. /** @hidden */
  21251. export var pbrDirectLightingSetupFunctions: {
  21252. name: string;
  21253. shader: string;
  21254. };
  21255. }
  21256. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21257. /** @hidden */
  21258. export var pbrDirectLightingFalloffFunctions: {
  21259. name: string;
  21260. shader: string;
  21261. };
  21262. }
  21263. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21264. /** @hidden */
  21265. export var pbrBRDFFunctions: {
  21266. name: string;
  21267. shader: string;
  21268. };
  21269. }
  21270. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21271. /** @hidden */
  21272. export var hdrFilteringFunctions: {
  21273. name: string;
  21274. shader: string;
  21275. };
  21276. }
  21277. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21278. /** @hidden */
  21279. export var pbrDirectLightingFunctions: {
  21280. name: string;
  21281. shader: string;
  21282. };
  21283. }
  21284. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21285. /** @hidden */
  21286. export var pbrIBLFunctions: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21292. /** @hidden */
  21293. export var pbrBlockAlbedoOpacity: {
  21294. name: string;
  21295. shader: string;
  21296. };
  21297. }
  21298. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21299. /** @hidden */
  21300. export var pbrBlockReflectivity: {
  21301. name: string;
  21302. shader: string;
  21303. };
  21304. }
  21305. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21306. /** @hidden */
  21307. export var pbrBlockAmbientOcclusion: {
  21308. name: string;
  21309. shader: string;
  21310. };
  21311. }
  21312. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21313. /** @hidden */
  21314. export var pbrBlockAlphaFresnel: {
  21315. name: string;
  21316. shader: string;
  21317. };
  21318. }
  21319. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21320. /** @hidden */
  21321. export var pbrBlockAnisotropic: {
  21322. name: string;
  21323. shader: string;
  21324. };
  21325. }
  21326. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21327. /** @hidden */
  21328. export var pbrBlockReflection: {
  21329. name: string;
  21330. shader: string;
  21331. };
  21332. }
  21333. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21334. /** @hidden */
  21335. export var pbrBlockSheen: {
  21336. name: string;
  21337. shader: string;
  21338. };
  21339. }
  21340. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21341. /** @hidden */
  21342. export var pbrBlockClearcoat: {
  21343. name: string;
  21344. shader: string;
  21345. };
  21346. }
  21347. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21348. /** @hidden */
  21349. export var pbrBlockSubSurface: {
  21350. name: string;
  21351. shader: string;
  21352. };
  21353. }
  21354. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21355. /** @hidden */
  21356. export var pbrBlockNormalGeometric: {
  21357. name: string;
  21358. shader: string;
  21359. };
  21360. }
  21361. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21362. /** @hidden */
  21363. export var pbrBlockNormalFinal: {
  21364. name: string;
  21365. shader: string;
  21366. };
  21367. }
  21368. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21369. /** @hidden */
  21370. export var pbrBlockLightmapInit: {
  21371. name: string;
  21372. shader: string;
  21373. };
  21374. }
  21375. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21376. /** @hidden */
  21377. export var pbrBlockGeometryInfo: {
  21378. name: string;
  21379. shader: string;
  21380. };
  21381. }
  21382. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21383. /** @hidden */
  21384. export var pbrBlockReflectance0: {
  21385. name: string;
  21386. shader: string;
  21387. };
  21388. }
  21389. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21390. /** @hidden */
  21391. export var pbrBlockReflectance: {
  21392. name: string;
  21393. shader: string;
  21394. };
  21395. }
  21396. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21397. /** @hidden */
  21398. export var pbrBlockDirectLighting: {
  21399. name: string;
  21400. shader: string;
  21401. };
  21402. }
  21403. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21404. /** @hidden */
  21405. export var pbrBlockFinalLitComponents: {
  21406. name: string;
  21407. shader: string;
  21408. };
  21409. }
  21410. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21411. /** @hidden */
  21412. export var pbrBlockFinalUnlitComponents: {
  21413. name: string;
  21414. shader: string;
  21415. };
  21416. }
  21417. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21418. /** @hidden */
  21419. export var pbrBlockFinalColorComposition: {
  21420. name: string;
  21421. shader: string;
  21422. };
  21423. }
  21424. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21425. /** @hidden */
  21426. export var pbrBlockImageProcessing: {
  21427. name: string;
  21428. shader: string;
  21429. };
  21430. }
  21431. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21432. /** @hidden */
  21433. export var pbrDebug: {
  21434. name: string;
  21435. shader: string;
  21436. };
  21437. }
  21438. declare module "babylonjs/Shaders/pbr.fragment" {
  21439. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21440. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21441. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21442. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21443. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21444. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21445. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21446. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21448. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21449. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21451. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21452. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21453. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21454. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21455. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21456. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21457. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21458. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21459. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21460. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21461. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21462. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21463. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21464. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21465. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21467. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21468. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21469. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21470. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21471. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21472. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21473. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21474. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21476. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21477. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21478. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21479. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21480. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21481. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21482. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21483. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21484. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21485. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21486. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21487. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21488. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21489. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21490. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21491. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21492. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21493. /** @hidden */
  21494. export var pbrPixelShader: {
  21495. name: string;
  21496. shader: string;
  21497. };
  21498. }
  21499. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21500. /** @hidden */
  21501. export var pbrVertexDeclaration: {
  21502. name: string;
  21503. shader: string;
  21504. };
  21505. }
  21506. declare module "babylonjs/Shaders/pbr.vertex" {
  21507. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21508. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21512. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21513. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21514. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21516. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21517. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21518. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21521. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21525. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21526. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21528. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21529. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21530. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21531. /** @hidden */
  21532. export var pbrVertexShader: {
  21533. name: string;
  21534. shader: string;
  21535. };
  21536. }
  21537. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21538. import { Nullable } from "babylonjs/types";
  21539. import { Scene } from "babylonjs/scene";
  21540. import { Matrix } from "babylonjs/Maths/math.vector";
  21541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21543. import { Mesh } from "babylonjs/Meshes/mesh";
  21544. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21545. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21546. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21547. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21548. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21549. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21550. import { Color3 } from "babylonjs/Maths/math.color";
  21551. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21552. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21554. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21556. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21557. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21558. import "babylonjs/Shaders/pbr.fragment";
  21559. import "babylonjs/Shaders/pbr.vertex";
  21560. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21561. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21562. /**
  21563. * Manages the defines for the PBR Material.
  21564. * @hidden
  21565. */
  21566. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21567. PBR: boolean;
  21568. NUM_SAMPLES: string;
  21569. REALTIME_FILTERING: boolean;
  21570. MAINUV1: boolean;
  21571. MAINUV2: boolean;
  21572. UV1: boolean;
  21573. UV2: boolean;
  21574. ALBEDO: boolean;
  21575. GAMMAALBEDO: boolean;
  21576. ALBEDODIRECTUV: number;
  21577. VERTEXCOLOR: boolean;
  21578. DETAIL: boolean;
  21579. DETAILDIRECTUV: number;
  21580. DETAIL_NORMALBLENDMETHOD: number;
  21581. AMBIENT: boolean;
  21582. AMBIENTDIRECTUV: number;
  21583. AMBIENTINGRAYSCALE: boolean;
  21584. OPACITY: boolean;
  21585. VERTEXALPHA: boolean;
  21586. OPACITYDIRECTUV: number;
  21587. OPACITYRGB: boolean;
  21588. ALPHATEST: boolean;
  21589. DEPTHPREPASS: boolean;
  21590. ALPHABLEND: boolean;
  21591. ALPHAFROMALBEDO: boolean;
  21592. ALPHATESTVALUE: string;
  21593. SPECULAROVERALPHA: boolean;
  21594. RADIANCEOVERALPHA: boolean;
  21595. ALPHAFRESNEL: boolean;
  21596. LINEARALPHAFRESNEL: boolean;
  21597. PREMULTIPLYALPHA: boolean;
  21598. EMISSIVE: boolean;
  21599. EMISSIVEDIRECTUV: number;
  21600. REFLECTIVITY: boolean;
  21601. REFLECTIVITYDIRECTUV: number;
  21602. SPECULARTERM: boolean;
  21603. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21604. MICROSURFACEAUTOMATIC: boolean;
  21605. LODBASEDMICROSFURACE: boolean;
  21606. MICROSURFACEMAP: boolean;
  21607. MICROSURFACEMAPDIRECTUV: number;
  21608. METALLICWORKFLOW: boolean;
  21609. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21610. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21611. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21612. AOSTOREINMETALMAPRED: boolean;
  21613. METALLIC_REFLECTANCE: boolean;
  21614. METALLIC_REFLECTANCEDIRECTUV: number;
  21615. ENVIRONMENTBRDF: boolean;
  21616. ENVIRONMENTBRDF_RGBD: boolean;
  21617. NORMAL: boolean;
  21618. TANGENT: boolean;
  21619. BUMP: boolean;
  21620. BUMPDIRECTUV: number;
  21621. OBJECTSPACE_NORMALMAP: boolean;
  21622. PARALLAX: boolean;
  21623. PARALLAXOCCLUSION: boolean;
  21624. NORMALXYSCALE: boolean;
  21625. LIGHTMAP: boolean;
  21626. LIGHTMAPDIRECTUV: number;
  21627. USELIGHTMAPASSHADOWMAP: boolean;
  21628. GAMMALIGHTMAP: boolean;
  21629. RGBDLIGHTMAP: boolean;
  21630. REFLECTION: boolean;
  21631. REFLECTIONMAP_3D: boolean;
  21632. REFLECTIONMAP_SPHERICAL: boolean;
  21633. REFLECTIONMAP_PLANAR: boolean;
  21634. REFLECTIONMAP_CUBIC: boolean;
  21635. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21636. REFLECTIONMAP_PROJECTION: boolean;
  21637. REFLECTIONMAP_SKYBOX: boolean;
  21638. REFLECTIONMAP_EXPLICIT: boolean;
  21639. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21640. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21641. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21642. INVERTCUBICMAP: boolean;
  21643. USESPHERICALFROMREFLECTIONMAP: boolean;
  21644. USEIRRADIANCEMAP: boolean;
  21645. SPHERICAL_HARMONICS: boolean;
  21646. USESPHERICALINVERTEX: boolean;
  21647. REFLECTIONMAP_OPPOSITEZ: boolean;
  21648. LODINREFLECTIONALPHA: boolean;
  21649. GAMMAREFLECTION: boolean;
  21650. RGBDREFLECTION: boolean;
  21651. LINEARSPECULARREFLECTION: boolean;
  21652. RADIANCEOCCLUSION: boolean;
  21653. HORIZONOCCLUSION: boolean;
  21654. INSTANCES: boolean;
  21655. THIN_INSTANCES: boolean;
  21656. PREPASS: boolean;
  21657. PREPASS_IRRADIANCE: boolean;
  21658. PREPASS_IRRADIANCE_INDEX: number;
  21659. PREPASS_ALBEDO: boolean;
  21660. PREPASS_ALBEDO_INDEX: number;
  21661. PREPASS_DEPTHNORMAL: boolean;
  21662. PREPASS_DEPTHNORMAL_INDEX: number;
  21663. PREPASS_POSITION: boolean;
  21664. PREPASS_POSITION_INDEX: number;
  21665. PREPASS_VELOCITY: boolean;
  21666. PREPASS_VELOCITY_INDEX: number;
  21667. PREPASS_REFLECTIVITY: boolean;
  21668. PREPASS_REFLECTIVITY_INDEX: number;
  21669. SCENE_MRT_COUNT: number;
  21670. NUM_BONE_INFLUENCERS: number;
  21671. BonesPerMesh: number;
  21672. BONETEXTURE: boolean;
  21673. BONES_VELOCITY_ENABLED: boolean;
  21674. NONUNIFORMSCALING: boolean;
  21675. MORPHTARGETS: boolean;
  21676. MORPHTARGETS_NORMAL: boolean;
  21677. MORPHTARGETS_TANGENT: boolean;
  21678. MORPHTARGETS_UV: boolean;
  21679. NUM_MORPH_INFLUENCERS: number;
  21680. IMAGEPROCESSING: boolean;
  21681. VIGNETTE: boolean;
  21682. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21683. VIGNETTEBLENDMODEOPAQUE: boolean;
  21684. TONEMAPPING: boolean;
  21685. TONEMAPPING_ACES: boolean;
  21686. CONTRAST: boolean;
  21687. COLORCURVES: boolean;
  21688. COLORGRADING: boolean;
  21689. COLORGRADING3D: boolean;
  21690. SAMPLER3DGREENDEPTH: boolean;
  21691. SAMPLER3DBGRMAP: boolean;
  21692. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21693. EXPOSURE: boolean;
  21694. MULTIVIEW: boolean;
  21695. USEPHYSICALLIGHTFALLOFF: boolean;
  21696. USEGLTFLIGHTFALLOFF: boolean;
  21697. TWOSIDEDLIGHTING: boolean;
  21698. SHADOWFLOAT: boolean;
  21699. CLIPPLANE: boolean;
  21700. CLIPPLANE2: boolean;
  21701. CLIPPLANE3: boolean;
  21702. CLIPPLANE4: boolean;
  21703. CLIPPLANE5: boolean;
  21704. CLIPPLANE6: boolean;
  21705. POINTSIZE: boolean;
  21706. FOG: boolean;
  21707. LOGARITHMICDEPTH: boolean;
  21708. FORCENORMALFORWARD: boolean;
  21709. SPECULARAA: boolean;
  21710. CLEARCOAT: boolean;
  21711. CLEARCOAT_DEFAULTIOR: boolean;
  21712. CLEARCOAT_TEXTURE: boolean;
  21713. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21714. CLEARCOAT_TEXTUREDIRECTUV: number;
  21715. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21716. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21717. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21718. CLEARCOAT_BUMP: boolean;
  21719. CLEARCOAT_BUMPDIRECTUV: number;
  21720. CLEARCOAT_REMAP_F0: boolean;
  21721. CLEARCOAT_TINT: boolean;
  21722. CLEARCOAT_TINT_TEXTURE: boolean;
  21723. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21724. ANISOTROPIC: boolean;
  21725. ANISOTROPIC_TEXTURE: boolean;
  21726. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21727. BRDF_V_HEIGHT_CORRELATED: boolean;
  21728. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21729. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21730. SHEEN: boolean;
  21731. SHEEN_TEXTURE: boolean;
  21732. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21733. SHEEN_TEXTUREDIRECTUV: number;
  21734. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21735. SHEEN_LINKWITHALBEDO: boolean;
  21736. SHEEN_ROUGHNESS: boolean;
  21737. SHEEN_ALBEDOSCALING: boolean;
  21738. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21739. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21740. SUBSURFACE: boolean;
  21741. SS_REFRACTION: boolean;
  21742. SS_TRANSLUCENCY: boolean;
  21743. SS_SCATTERING: boolean;
  21744. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21745. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21746. SS_REFRACTIONMAP_3D: boolean;
  21747. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21748. SS_LODINREFRACTIONALPHA: boolean;
  21749. SS_GAMMAREFRACTION: boolean;
  21750. SS_RGBDREFRACTION: boolean;
  21751. SS_LINEARSPECULARREFRACTION: boolean;
  21752. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21753. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21754. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21755. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21756. UNLIT: boolean;
  21757. DEBUGMODE: number;
  21758. /**
  21759. * Initializes the PBR Material defines.
  21760. */
  21761. constructor();
  21762. /**
  21763. * Resets the PBR Material defines.
  21764. */
  21765. reset(): void;
  21766. }
  21767. /**
  21768. * The Physically based material base class of BJS.
  21769. *
  21770. * This offers the main features of a standard PBR material.
  21771. * For more information, please refer to the documentation :
  21772. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21773. */
  21774. export abstract class PBRBaseMaterial extends PushMaterial {
  21775. /**
  21776. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21777. */
  21778. static readonly PBRMATERIAL_OPAQUE: number;
  21779. /**
  21780. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21781. */
  21782. static readonly PBRMATERIAL_ALPHATEST: number;
  21783. /**
  21784. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21785. */
  21786. static readonly PBRMATERIAL_ALPHABLEND: number;
  21787. /**
  21788. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21789. * They are also discarded below the alpha cutoff threshold to improve performances.
  21790. */
  21791. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21792. /**
  21793. * Defines the default value of how much AO map is occluding the analytical lights
  21794. * (point spot...).
  21795. */
  21796. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21797. /**
  21798. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21799. */
  21800. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21801. /**
  21802. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21803. * to enhance interoperability with other engines.
  21804. */
  21805. static readonly LIGHTFALLOFF_GLTF: number;
  21806. /**
  21807. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21808. * to enhance interoperability with other materials.
  21809. */
  21810. static readonly LIGHTFALLOFF_STANDARD: number;
  21811. /**
  21812. * Intensity of the direct lights e.g. the four lights available in your scene.
  21813. * This impacts both the direct diffuse and specular highlights.
  21814. */
  21815. protected _directIntensity: number;
  21816. /**
  21817. * Intensity of the emissive part of the material.
  21818. * This helps controlling the emissive effect without modifying the emissive color.
  21819. */
  21820. protected _emissiveIntensity: number;
  21821. /**
  21822. * Intensity of the environment e.g. how much the environment will light the object
  21823. * either through harmonics for rough material or through the refelction for shiny ones.
  21824. */
  21825. protected _environmentIntensity: number;
  21826. /**
  21827. * This is a special control allowing the reduction of the specular highlights coming from the
  21828. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21829. */
  21830. protected _specularIntensity: number;
  21831. /**
  21832. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21833. */
  21834. private _lightingInfos;
  21835. /**
  21836. * Debug Control allowing disabling the bump map on this material.
  21837. */
  21838. protected _disableBumpMap: boolean;
  21839. /**
  21840. * AKA Diffuse Texture in standard nomenclature.
  21841. */
  21842. protected _albedoTexture: Nullable<BaseTexture>;
  21843. /**
  21844. * AKA Occlusion Texture in other nomenclature.
  21845. */
  21846. protected _ambientTexture: Nullable<BaseTexture>;
  21847. /**
  21848. * AKA Occlusion Texture Intensity in other nomenclature.
  21849. */
  21850. protected _ambientTextureStrength: number;
  21851. /**
  21852. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21853. * 1 means it completely occludes it
  21854. * 0 mean it has no impact
  21855. */
  21856. protected _ambientTextureImpactOnAnalyticalLights: number;
  21857. /**
  21858. * Stores the alpha values in a texture.
  21859. */
  21860. protected _opacityTexture: Nullable<BaseTexture>;
  21861. /**
  21862. * Stores the reflection values in a texture.
  21863. */
  21864. protected _reflectionTexture: Nullable<BaseTexture>;
  21865. /**
  21866. * Stores the emissive values in a texture.
  21867. */
  21868. protected _emissiveTexture: Nullable<BaseTexture>;
  21869. /**
  21870. * AKA Specular texture in other nomenclature.
  21871. */
  21872. protected _reflectivityTexture: Nullable<BaseTexture>;
  21873. /**
  21874. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21875. */
  21876. protected _metallicTexture: Nullable<BaseTexture>;
  21877. /**
  21878. * Specifies the metallic scalar of the metallic/roughness workflow.
  21879. * Can also be used to scale the metalness values of the metallic texture.
  21880. */
  21881. protected _metallic: Nullable<number>;
  21882. /**
  21883. * Specifies the roughness scalar of the metallic/roughness workflow.
  21884. * Can also be used to scale the roughness values of the metallic texture.
  21885. */
  21886. protected _roughness: Nullable<number>;
  21887. /**
  21888. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21889. * By default the indexOfrefraction is used to compute F0;
  21890. *
  21891. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21892. *
  21893. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21894. * F90 = metallicReflectanceColor;
  21895. */
  21896. protected _metallicF0Factor: number;
  21897. /**
  21898. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21899. * By default the F90 is always 1;
  21900. *
  21901. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21902. *
  21903. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21904. * F90 = metallicReflectanceColor;
  21905. */
  21906. protected _metallicReflectanceColor: Color3;
  21907. /**
  21908. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21909. * This is multiply against the scalar values defined in the material.
  21910. */
  21911. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21912. /**
  21913. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21914. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21915. */
  21916. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21917. /**
  21918. * Stores surface normal data used to displace a mesh in a texture.
  21919. */
  21920. protected _bumpTexture: Nullable<BaseTexture>;
  21921. /**
  21922. * Stores the pre-calculated light information of a mesh in a texture.
  21923. */
  21924. protected _lightmapTexture: Nullable<BaseTexture>;
  21925. /**
  21926. * The color of a material in ambient lighting.
  21927. */
  21928. protected _ambientColor: Color3;
  21929. /**
  21930. * AKA Diffuse Color in other nomenclature.
  21931. */
  21932. protected _albedoColor: Color3;
  21933. /**
  21934. * AKA Specular Color in other nomenclature.
  21935. */
  21936. protected _reflectivityColor: Color3;
  21937. /**
  21938. * The color applied when light is reflected from a material.
  21939. */
  21940. protected _reflectionColor: Color3;
  21941. /**
  21942. * The color applied when light is emitted from a material.
  21943. */
  21944. protected _emissiveColor: Color3;
  21945. /**
  21946. * AKA Glossiness in other nomenclature.
  21947. */
  21948. protected _microSurface: number;
  21949. /**
  21950. * Specifies that the material will use the light map as a show map.
  21951. */
  21952. protected _useLightmapAsShadowmap: boolean;
  21953. /**
  21954. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21955. * makes the reflect vector face the model (under horizon).
  21956. */
  21957. protected _useHorizonOcclusion: boolean;
  21958. /**
  21959. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21960. * too much the area relying on ambient texture to define their ambient occlusion.
  21961. */
  21962. protected _useRadianceOcclusion: boolean;
  21963. /**
  21964. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21965. */
  21966. protected _useAlphaFromAlbedoTexture: boolean;
  21967. /**
  21968. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21969. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21970. */
  21971. protected _useSpecularOverAlpha: boolean;
  21972. /**
  21973. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21974. */
  21975. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21976. /**
  21977. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21978. */
  21979. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21980. /**
  21981. * Specifies if the metallic texture contains the roughness information in its green channel.
  21982. */
  21983. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21984. /**
  21985. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21986. */
  21987. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21988. /**
  21989. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21990. */
  21991. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21992. /**
  21993. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21994. */
  21995. protected _useAmbientInGrayScale: boolean;
  21996. /**
  21997. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21998. * The material will try to infer what glossiness each pixel should be.
  21999. */
  22000. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22001. /**
  22002. * Defines the falloff type used in this material.
  22003. * It by default is Physical.
  22004. */
  22005. protected _lightFalloff: number;
  22006. /**
  22007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22009. */
  22010. protected _useRadianceOverAlpha: boolean;
  22011. /**
  22012. * Allows using an object space normal map (instead of tangent space).
  22013. */
  22014. protected _useObjectSpaceNormalMap: boolean;
  22015. /**
  22016. * Allows using the bump map in parallax mode.
  22017. */
  22018. protected _useParallax: boolean;
  22019. /**
  22020. * Allows using the bump map in parallax occlusion mode.
  22021. */
  22022. protected _useParallaxOcclusion: boolean;
  22023. /**
  22024. * Controls the scale bias of the parallax mode.
  22025. */
  22026. protected _parallaxScaleBias: number;
  22027. /**
  22028. * If sets to true, disables all the lights affecting the material.
  22029. */
  22030. protected _disableLighting: boolean;
  22031. /**
  22032. * Number of Simultaneous lights allowed on the material.
  22033. */
  22034. protected _maxSimultaneousLights: number;
  22035. /**
  22036. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22037. */
  22038. protected _invertNormalMapX: boolean;
  22039. /**
  22040. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22041. */
  22042. protected _invertNormalMapY: boolean;
  22043. /**
  22044. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22045. */
  22046. protected _twoSidedLighting: boolean;
  22047. /**
  22048. * Defines the alpha limits in alpha test mode.
  22049. */
  22050. protected _alphaCutOff: number;
  22051. /**
  22052. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22053. */
  22054. protected _forceAlphaTest: boolean;
  22055. /**
  22056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22057. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22058. */
  22059. protected _useAlphaFresnel: boolean;
  22060. /**
  22061. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22062. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22063. */
  22064. protected _useLinearAlphaFresnel: boolean;
  22065. /**
  22066. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22067. * from cos thetav and roughness:
  22068. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22069. */
  22070. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22071. /**
  22072. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22073. */
  22074. protected _forceIrradianceInFragment: boolean;
  22075. private _realTimeFiltering;
  22076. /**
  22077. * Enables realtime filtering on the texture.
  22078. */
  22079. get realTimeFiltering(): boolean;
  22080. set realTimeFiltering(b: boolean);
  22081. private _realTimeFilteringQuality;
  22082. /**
  22083. * Quality switch for realtime filtering
  22084. */
  22085. get realTimeFilteringQuality(): number;
  22086. set realTimeFilteringQuality(n: number);
  22087. /**
  22088. * Can this material render to several textures at once
  22089. */
  22090. get canRenderToMRT(): boolean;
  22091. /**
  22092. * Force normal to face away from face.
  22093. */
  22094. protected _forceNormalForward: boolean;
  22095. /**
  22096. * Enables specular anti aliasing in the PBR shader.
  22097. * It will both interacts on the Geometry for analytical and IBL lighting.
  22098. * It also prefilter the roughness map based on the bump values.
  22099. */
  22100. protected _enableSpecularAntiAliasing: boolean;
  22101. /**
  22102. * Default configuration related to image processing available in the PBR Material.
  22103. */
  22104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22105. /**
  22106. * Keep track of the image processing observer to allow dispose and replace.
  22107. */
  22108. private _imageProcessingObserver;
  22109. /**
  22110. * Attaches a new image processing configuration to the PBR Material.
  22111. * @param configuration
  22112. */
  22113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22114. /**
  22115. * Stores the available render targets.
  22116. */
  22117. private _renderTargets;
  22118. /**
  22119. * Sets the global ambient color for the material used in lighting calculations.
  22120. */
  22121. private _globalAmbientColor;
  22122. /**
  22123. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22124. */
  22125. private _useLogarithmicDepth;
  22126. /**
  22127. * If set to true, no lighting calculations will be applied.
  22128. */
  22129. private _unlit;
  22130. private _debugMode;
  22131. /**
  22132. * @hidden
  22133. * This is reserved for the inspector.
  22134. * Defines the material debug mode.
  22135. * It helps seeing only some components of the material while troubleshooting.
  22136. */
  22137. debugMode: number;
  22138. /**
  22139. * @hidden
  22140. * This is reserved for the inspector.
  22141. * Specify from where on screen the debug mode should start.
  22142. * The value goes from -1 (full screen) to 1 (not visible)
  22143. * It helps with side by side comparison against the final render
  22144. * This defaults to -1
  22145. */
  22146. private debugLimit;
  22147. /**
  22148. * @hidden
  22149. * This is reserved for the inspector.
  22150. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22151. * You can use the factor to better multiply the final value.
  22152. */
  22153. private debugFactor;
  22154. /**
  22155. * Defines the clear coat layer parameters for the material.
  22156. */
  22157. readonly clearCoat: PBRClearCoatConfiguration;
  22158. /**
  22159. * Defines the anisotropic parameters for the material.
  22160. */
  22161. readonly anisotropy: PBRAnisotropicConfiguration;
  22162. /**
  22163. * Defines the BRDF parameters for the material.
  22164. */
  22165. readonly brdf: PBRBRDFConfiguration;
  22166. /**
  22167. * Defines the Sheen parameters for the material.
  22168. */
  22169. readonly sheen: PBRSheenConfiguration;
  22170. /**
  22171. * Defines the SubSurface parameters for the material.
  22172. */
  22173. readonly subSurface: PBRSubSurfaceConfiguration;
  22174. /**
  22175. * Defines additionnal PrePass parameters for the material.
  22176. */
  22177. readonly prePassConfiguration: PrePassConfiguration;
  22178. /**
  22179. * Defines the detail map parameters for the material.
  22180. */
  22181. readonly detailMap: DetailMapConfiguration;
  22182. protected _rebuildInParallel: boolean;
  22183. /**
  22184. * Instantiates a new PBRMaterial instance.
  22185. *
  22186. * @param name The material name
  22187. * @param scene The scene the material will be use in.
  22188. */
  22189. constructor(name: string, scene: Scene);
  22190. /**
  22191. * Gets a boolean indicating that current material needs to register RTT
  22192. */
  22193. get hasRenderTargetTextures(): boolean;
  22194. /**
  22195. * Gets the name of the material class.
  22196. */
  22197. getClassName(): string;
  22198. /**
  22199. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22200. */
  22201. get useLogarithmicDepth(): boolean;
  22202. /**
  22203. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22204. */
  22205. set useLogarithmicDepth(value: boolean);
  22206. /**
  22207. * Returns true if alpha blending should be disabled.
  22208. */
  22209. protected get _disableAlphaBlending(): boolean;
  22210. /**
  22211. * Specifies whether or not this material should be rendered in alpha blend mode.
  22212. */
  22213. needAlphaBlending(): boolean;
  22214. /**
  22215. * Specifies whether or not this material should be rendered in alpha test mode.
  22216. */
  22217. needAlphaTesting(): boolean;
  22218. /**
  22219. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22220. */
  22221. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22222. /**
  22223. * Specifies whether or not there is a usable alpha channel for transparency.
  22224. */
  22225. protected _hasAlphaChannel(): boolean;
  22226. /**
  22227. * Gets the texture used for the alpha test.
  22228. */
  22229. getAlphaTestTexture(): Nullable<BaseTexture>;
  22230. /**
  22231. * Specifies that the submesh is ready to be used.
  22232. * @param mesh - BJS mesh.
  22233. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22234. * @param useInstances - Specifies that instances should be used.
  22235. * @returns - boolean indicating that the submesh is ready or not.
  22236. */
  22237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22238. /**
  22239. * Specifies if the material uses metallic roughness workflow.
  22240. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22241. */
  22242. isMetallicWorkflow(): boolean;
  22243. private _prepareEffect;
  22244. private _prepareDefines;
  22245. /**
  22246. * Force shader compilation
  22247. */
  22248. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22249. /**
  22250. * Initializes the uniform buffer layout for the shader.
  22251. */
  22252. buildUniformLayout(): void;
  22253. /**
  22254. * Unbinds the material from the mesh
  22255. */
  22256. unbind(): void;
  22257. /**
  22258. * Binds the submesh data.
  22259. * @param world - The world matrix.
  22260. * @param mesh - The BJS mesh.
  22261. * @param subMesh - A submesh of the BJS mesh.
  22262. */
  22263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22264. /**
  22265. * Returns the animatable textures.
  22266. * @returns - Array of animatable textures.
  22267. */
  22268. getAnimatables(): IAnimatable[];
  22269. /**
  22270. * Returns the texture used for reflections.
  22271. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22272. */
  22273. private _getReflectionTexture;
  22274. /**
  22275. * Returns an array of the actively used textures.
  22276. * @returns - Array of BaseTextures
  22277. */
  22278. getActiveTextures(): BaseTexture[];
  22279. /**
  22280. * Checks to see if a texture is used in the material.
  22281. * @param texture - Base texture to use.
  22282. * @returns - Boolean specifying if a texture is used in the material.
  22283. */
  22284. hasTexture(texture: BaseTexture): boolean;
  22285. /**
  22286. * Sets the required values to the prepass renderer.
  22287. * @param prePassRenderer defines the prepass renderer to setup
  22288. */
  22289. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22290. /**
  22291. * Disposes the resources of the material.
  22292. * @param forceDisposeEffect - Forces the disposal of effects.
  22293. * @param forceDisposeTextures - Forces the disposal of all textures.
  22294. */
  22295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22296. }
  22297. }
  22298. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22299. import { Nullable } from "babylonjs/types";
  22300. import { Scene } from "babylonjs/scene";
  22301. import { Color3 } from "babylonjs/Maths/math.color";
  22302. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22303. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22305. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22306. /**
  22307. * The Physically based material of BJS.
  22308. *
  22309. * This offers the main features of a standard PBR material.
  22310. * For more information, please refer to the documentation :
  22311. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22312. */
  22313. export class PBRMaterial extends PBRBaseMaterial {
  22314. /**
  22315. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22316. */
  22317. static readonly PBRMATERIAL_OPAQUE: number;
  22318. /**
  22319. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22320. */
  22321. static readonly PBRMATERIAL_ALPHATEST: number;
  22322. /**
  22323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22324. */
  22325. static readonly PBRMATERIAL_ALPHABLEND: number;
  22326. /**
  22327. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22328. * They are also discarded below the alpha cutoff threshold to improve performances.
  22329. */
  22330. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22331. /**
  22332. * Defines the default value of how much AO map is occluding the analytical lights
  22333. * (point spot...).
  22334. */
  22335. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22336. /**
  22337. * Intensity of the direct lights e.g. the four lights available in your scene.
  22338. * This impacts both the direct diffuse and specular highlights.
  22339. */
  22340. directIntensity: number;
  22341. /**
  22342. * Intensity of the emissive part of the material.
  22343. * This helps controlling the emissive effect without modifying the emissive color.
  22344. */
  22345. emissiveIntensity: number;
  22346. /**
  22347. * Intensity of the environment e.g. how much the environment will light the object
  22348. * either through harmonics for rough material or through the refelction for shiny ones.
  22349. */
  22350. environmentIntensity: number;
  22351. /**
  22352. * This is a special control allowing the reduction of the specular highlights coming from the
  22353. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22354. */
  22355. specularIntensity: number;
  22356. /**
  22357. * Debug Control allowing disabling the bump map on this material.
  22358. */
  22359. disableBumpMap: boolean;
  22360. /**
  22361. * AKA Diffuse Texture in standard nomenclature.
  22362. */
  22363. albedoTexture: BaseTexture;
  22364. /**
  22365. * AKA Occlusion Texture in other nomenclature.
  22366. */
  22367. ambientTexture: BaseTexture;
  22368. /**
  22369. * AKA Occlusion Texture Intensity in other nomenclature.
  22370. */
  22371. ambientTextureStrength: number;
  22372. /**
  22373. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22374. * 1 means it completely occludes it
  22375. * 0 mean it has no impact
  22376. */
  22377. ambientTextureImpactOnAnalyticalLights: number;
  22378. /**
  22379. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22380. */
  22381. opacityTexture: BaseTexture;
  22382. /**
  22383. * Stores the reflection values in a texture.
  22384. */
  22385. reflectionTexture: Nullable<BaseTexture>;
  22386. /**
  22387. * Stores the emissive values in a texture.
  22388. */
  22389. emissiveTexture: BaseTexture;
  22390. /**
  22391. * AKA Specular texture in other nomenclature.
  22392. */
  22393. reflectivityTexture: BaseTexture;
  22394. /**
  22395. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22396. */
  22397. metallicTexture: BaseTexture;
  22398. /**
  22399. * Specifies the metallic scalar of the metallic/roughness workflow.
  22400. * Can also be used to scale the metalness values of the metallic texture.
  22401. */
  22402. metallic: Nullable<number>;
  22403. /**
  22404. * Specifies the roughness scalar of the metallic/roughness workflow.
  22405. * Can also be used to scale the roughness values of the metallic texture.
  22406. */
  22407. roughness: Nullable<number>;
  22408. /**
  22409. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22410. * By default the indexOfrefraction is used to compute F0;
  22411. *
  22412. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22413. *
  22414. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22415. * F90 = metallicReflectanceColor;
  22416. */
  22417. metallicF0Factor: number;
  22418. /**
  22419. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22420. * By default the F90 is always 1;
  22421. *
  22422. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22423. *
  22424. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22425. * F90 = metallicReflectanceColor;
  22426. */
  22427. metallicReflectanceColor: Color3;
  22428. /**
  22429. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22430. * This is multiply against the scalar values defined in the material.
  22431. */
  22432. metallicReflectanceTexture: Nullable<BaseTexture>;
  22433. /**
  22434. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22435. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22436. */
  22437. microSurfaceTexture: BaseTexture;
  22438. /**
  22439. * Stores surface normal data used to displace a mesh in a texture.
  22440. */
  22441. bumpTexture: BaseTexture;
  22442. /**
  22443. * Stores the pre-calculated light information of a mesh in a texture.
  22444. */
  22445. lightmapTexture: BaseTexture;
  22446. /**
  22447. * Stores the refracted light information in a texture.
  22448. */
  22449. get refractionTexture(): Nullable<BaseTexture>;
  22450. set refractionTexture(value: Nullable<BaseTexture>);
  22451. /**
  22452. * The color of a material in ambient lighting.
  22453. */
  22454. ambientColor: Color3;
  22455. /**
  22456. * AKA Diffuse Color in other nomenclature.
  22457. */
  22458. albedoColor: Color3;
  22459. /**
  22460. * AKA Specular Color in other nomenclature.
  22461. */
  22462. reflectivityColor: Color3;
  22463. /**
  22464. * The color reflected from the material.
  22465. */
  22466. reflectionColor: Color3;
  22467. /**
  22468. * The color emitted from the material.
  22469. */
  22470. emissiveColor: Color3;
  22471. /**
  22472. * AKA Glossiness in other nomenclature.
  22473. */
  22474. microSurface: number;
  22475. /**
  22476. * Index of refraction of the material base layer.
  22477. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22478. *
  22479. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22480. *
  22481. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22482. */
  22483. get indexOfRefraction(): number;
  22484. set indexOfRefraction(value: number);
  22485. /**
  22486. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22487. */
  22488. get invertRefractionY(): boolean;
  22489. set invertRefractionY(value: boolean);
  22490. /**
  22491. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22492. * Materials half opaque for instance using refraction could benefit from this control.
  22493. */
  22494. get linkRefractionWithTransparency(): boolean;
  22495. set linkRefractionWithTransparency(value: boolean);
  22496. /**
  22497. * If true, the light map contains occlusion information instead of lighting info.
  22498. */
  22499. useLightmapAsShadowmap: boolean;
  22500. /**
  22501. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22502. */
  22503. useAlphaFromAlbedoTexture: boolean;
  22504. /**
  22505. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22506. */
  22507. forceAlphaTest: boolean;
  22508. /**
  22509. * Defines the alpha limits in alpha test mode.
  22510. */
  22511. alphaCutOff: number;
  22512. /**
  22513. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22514. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22515. */
  22516. useSpecularOverAlpha: boolean;
  22517. /**
  22518. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22519. */
  22520. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22521. /**
  22522. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22523. */
  22524. useRoughnessFromMetallicTextureAlpha: boolean;
  22525. /**
  22526. * Specifies if the metallic texture contains the roughness information in its green channel.
  22527. */
  22528. useRoughnessFromMetallicTextureGreen: boolean;
  22529. /**
  22530. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22531. */
  22532. useMetallnessFromMetallicTextureBlue: boolean;
  22533. /**
  22534. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22535. */
  22536. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22537. /**
  22538. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22539. */
  22540. useAmbientInGrayScale: boolean;
  22541. /**
  22542. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22543. * The material will try to infer what glossiness each pixel should be.
  22544. */
  22545. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22546. /**
  22547. * BJS is using an harcoded light falloff based on a manually sets up range.
  22548. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22549. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22550. */
  22551. get usePhysicalLightFalloff(): boolean;
  22552. /**
  22553. * BJS is using an harcoded light falloff based on a manually sets up range.
  22554. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22555. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22556. */
  22557. set usePhysicalLightFalloff(value: boolean);
  22558. /**
  22559. * In order to support the falloff compatibility with gltf, a special mode has been added
  22560. * to reproduce the gltf light falloff.
  22561. */
  22562. get useGLTFLightFalloff(): boolean;
  22563. /**
  22564. * In order to support the falloff compatibility with gltf, a special mode has been added
  22565. * to reproduce the gltf light falloff.
  22566. */
  22567. set useGLTFLightFalloff(value: boolean);
  22568. /**
  22569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22571. */
  22572. useRadianceOverAlpha: boolean;
  22573. /**
  22574. * Allows using an object space normal map (instead of tangent space).
  22575. */
  22576. useObjectSpaceNormalMap: boolean;
  22577. /**
  22578. * Allows using the bump map in parallax mode.
  22579. */
  22580. useParallax: boolean;
  22581. /**
  22582. * Allows using the bump map in parallax occlusion mode.
  22583. */
  22584. useParallaxOcclusion: boolean;
  22585. /**
  22586. * Controls the scale bias of the parallax mode.
  22587. */
  22588. parallaxScaleBias: number;
  22589. /**
  22590. * If sets to true, disables all the lights affecting the material.
  22591. */
  22592. disableLighting: boolean;
  22593. /**
  22594. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22595. */
  22596. forceIrradianceInFragment: boolean;
  22597. /**
  22598. * Number of Simultaneous lights allowed on the material.
  22599. */
  22600. maxSimultaneousLights: number;
  22601. /**
  22602. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22603. */
  22604. invertNormalMapX: boolean;
  22605. /**
  22606. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22607. */
  22608. invertNormalMapY: boolean;
  22609. /**
  22610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22611. */
  22612. twoSidedLighting: boolean;
  22613. /**
  22614. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22615. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22616. */
  22617. useAlphaFresnel: boolean;
  22618. /**
  22619. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22620. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22621. */
  22622. useLinearAlphaFresnel: boolean;
  22623. /**
  22624. * Let user defines the brdf lookup texture used for IBL.
  22625. * A default 8bit version is embedded but you could point at :
  22626. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22627. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22628. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22629. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22630. */
  22631. environmentBRDFTexture: Nullable<BaseTexture>;
  22632. /**
  22633. * Force normal to face away from face.
  22634. */
  22635. forceNormalForward: boolean;
  22636. /**
  22637. * Enables specular anti aliasing in the PBR shader.
  22638. * It will both interacts on the Geometry for analytical and IBL lighting.
  22639. * It also prefilter the roughness map based on the bump values.
  22640. */
  22641. enableSpecularAntiAliasing: boolean;
  22642. /**
  22643. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22644. * makes the reflect vector face the model (under horizon).
  22645. */
  22646. useHorizonOcclusion: boolean;
  22647. /**
  22648. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22649. * too much the area relying on ambient texture to define their ambient occlusion.
  22650. */
  22651. useRadianceOcclusion: boolean;
  22652. /**
  22653. * If set to true, no lighting calculations will be applied.
  22654. */
  22655. unlit: boolean;
  22656. /**
  22657. * Gets the image processing configuration used either in this material.
  22658. */
  22659. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22660. /**
  22661. * Sets the Default image processing configuration used either in the this material.
  22662. *
  22663. * If sets to null, the scene one is in use.
  22664. */
  22665. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22666. /**
  22667. * Gets wether the color curves effect is enabled.
  22668. */
  22669. get cameraColorCurvesEnabled(): boolean;
  22670. /**
  22671. * Sets wether the color curves effect is enabled.
  22672. */
  22673. set cameraColorCurvesEnabled(value: boolean);
  22674. /**
  22675. * Gets wether the color grading effect is enabled.
  22676. */
  22677. get cameraColorGradingEnabled(): boolean;
  22678. /**
  22679. * Gets wether the color grading effect is enabled.
  22680. */
  22681. set cameraColorGradingEnabled(value: boolean);
  22682. /**
  22683. * Gets wether tonemapping is enabled or not.
  22684. */
  22685. get cameraToneMappingEnabled(): boolean;
  22686. /**
  22687. * Sets wether tonemapping is enabled or not
  22688. */
  22689. set cameraToneMappingEnabled(value: boolean);
  22690. /**
  22691. * The camera exposure used on this material.
  22692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22693. * This corresponds to a photographic exposure.
  22694. */
  22695. get cameraExposure(): number;
  22696. /**
  22697. * The camera exposure used on this material.
  22698. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22699. * This corresponds to a photographic exposure.
  22700. */
  22701. set cameraExposure(value: number);
  22702. /**
  22703. * Gets The camera contrast used on this material.
  22704. */
  22705. get cameraContrast(): number;
  22706. /**
  22707. * Sets The camera contrast used on this material.
  22708. */
  22709. set cameraContrast(value: number);
  22710. /**
  22711. * Gets the Color Grading 2D Lookup Texture.
  22712. */
  22713. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22714. /**
  22715. * Sets the Color Grading 2D Lookup Texture.
  22716. */
  22717. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22718. /**
  22719. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22720. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22721. * 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;
  22722. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22723. */
  22724. get cameraColorCurves(): Nullable<ColorCurves>;
  22725. /**
  22726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22728. * 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;
  22729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22730. */
  22731. set cameraColorCurves(value: Nullable<ColorCurves>);
  22732. /**
  22733. * Instantiates a new PBRMaterial instance.
  22734. *
  22735. * @param name The material name
  22736. * @param scene The scene the material will be use in.
  22737. */
  22738. constructor(name: string, scene: Scene);
  22739. /**
  22740. * Returns the name of this material class.
  22741. */
  22742. getClassName(): string;
  22743. /**
  22744. * Makes a duplicate of the current material.
  22745. * @param name - name to use for the new material.
  22746. */
  22747. clone(name: string): PBRMaterial;
  22748. /**
  22749. * Serializes this PBR Material.
  22750. * @returns - An object with the serialized material.
  22751. */
  22752. serialize(): any;
  22753. /**
  22754. * Parses a PBR Material from a serialized object.
  22755. * @param source - Serialized object.
  22756. * @param scene - BJS scene instance.
  22757. * @param rootUrl - url for the scene object
  22758. * @returns - PBRMaterial
  22759. */
  22760. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22761. }
  22762. }
  22763. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22764. /** @hidden */
  22765. export var mrtFragmentDeclaration: {
  22766. name: string;
  22767. shader: string;
  22768. };
  22769. }
  22770. declare module "babylonjs/Shaders/geometry.fragment" {
  22771. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22772. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22773. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22774. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22775. /** @hidden */
  22776. export var geometryPixelShader: {
  22777. name: string;
  22778. shader: string;
  22779. };
  22780. }
  22781. declare module "babylonjs/Shaders/geometry.vertex" {
  22782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22785. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22787. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22788. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22789. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22790. /** @hidden */
  22791. export var geometryVertexShader: {
  22792. name: string;
  22793. shader: string;
  22794. };
  22795. }
  22796. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22797. import { Matrix } from "babylonjs/Maths/math.vector";
  22798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22799. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22800. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22801. import { Effect } from "babylonjs/Materials/effect";
  22802. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22803. import { Scene } from "babylonjs/scene";
  22804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22805. import { Nullable } from "babylonjs/types";
  22806. import "babylonjs/Shaders/geometry.fragment";
  22807. import "babylonjs/Shaders/geometry.vertex";
  22808. /** @hidden */
  22809. interface ISavedTransformationMatrix {
  22810. world: Matrix;
  22811. viewProjection: Matrix;
  22812. }
  22813. /**
  22814. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22815. */
  22816. export class GeometryBufferRenderer {
  22817. /**
  22818. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22819. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22820. */
  22821. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22822. /**
  22823. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22824. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22825. */
  22826. static readonly POSITION_TEXTURE_TYPE: number;
  22827. /**
  22828. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22829. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22830. */
  22831. static readonly VELOCITY_TEXTURE_TYPE: number;
  22832. /**
  22833. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22834. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22835. */
  22836. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22837. /**
  22838. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22839. * in order to compute objects velocities when enableVelocity is set to "true"
  22840. * @hidden
  22841. */
  22842. _previousTransformationMatrices: {
  22843. [index: number]: ISavedTransformationMatrix;
  22844. };
  22845. /**
  22846. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22847. * in order to compute objects velocities when enableVelocity is set to "true"
  22848. * @hidden
  22849. */
  22850. _previousBonesTransformationMatrices: {
  22851. [index: number]: Float32Array;
  22852. };
  22853. /**
  22854. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22855. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22856. */
  22857. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22858. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22859. renderTransparentMeshes: boolean;
  22860. private _scene;
  22861. private _resizeObserver;
  22862. private _multiRenderTarget;
  22863. private _ratio;
  22864. private _enablePosition;
  22865. private _enableVelocity;
  22866. private _enableReflectivity;
  22867. private _positionIndex;
  22868. private _velocityIndex;
  22869. private _reflectivityIndex;
  22870. private _depthNormalIndex;
  22871. private _linkedWithPrePass;
  22872. private _prePassRenderer;
  22873. private _attachments;
  22874. protected _effect: Effect;
  22875. protected _cachedDefines: string;
  22876. /**
  22877. * @hidden
  22878. * Sets up internal structures to share outputs with PrePassRenderer
  22879. * This method should only be called by the PrePassRenderer itself
  22880. */
  22881. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22882. /**
  22883. * @hidden
  22884. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22885. * This method should only be called by the PrePassRenderer itself
  22886. */
  22887. _unlinkPrePassRenderer(): void;
  22888. /**
  22889. * @hidden
  22890. * Resets the geometry buffer layout
  22891. */
  22892. _resetLayout(): void;
  22893. /**
  22894. * @hidden
  22895. * Replaces a texture in the geometry buffer renderer
  22896. * Useful when linking textures of the prepass renderer
  22897. */
  22898. _forceTextureType(geometryBufferType: number, index: number): void;
  22899. /**
  22900. * @hidden
  22901. * Sets texture attachments
  22902. * Useful when linking textures of the prepass renderer
  22903. */
  22904. _setAttachments(attachments: number[]): void;
  22905. /**
  22906. * @hidden
  22907. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22908. * Useful when linking textures of the prepass renderer
  22909. */
  22910. _linkInternalTexture(internalTexture: InternalTexture): void;
  22911. /**
  22912. * Gets the render list (meshes to be rendered) used in the G buffer.
  22913. */
  22914. get renderList(): Nullable<AbstractMesh[]>;
  22915. /**
  22916. * Set the render list (meshes to be rendered) used in the G buffer.
  22917. */
  22918. set renderList(meshes: Nullable<AbstractMesh[]>);
  22919. /**
  22920. * Gets wether or not G buffer are supported by the running hardware.
  22921. * This requires draw buffer supports
  22922. */
  22923. get isSupported(): boolean;
  22924. /**
  22925. * Returns the index of the given texture type in the G-Buffer textures array
  22926. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22927. * @returns the index of the given texture type in the G-Buffer textures array
  22928. */
  22929. getTextureIndex(textureType: number): number;
  22930. /**
  22931. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22932. */
  22933. get enablePosition(): boolean;
  22934. /**
  22935. * Sets whether or not objects positions are enabled for the G buffer.
  22936. */
  22937. set enablePosition(enable: boolean);
  22938. /**
  22939. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22940. */
  22941. get enableVelocity(): boolean;
  22942. /**
  22943. * Sets wether or not objects velocities are enabled for the G buffer.
  22944. */
  22945. set enableVelocity(enable: boolean);
  22946. /**
  22947. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22948. */
  22949. get enableReflectivity(): boolean;
  22950. /**
  22951. * Sets wether or not objects roughness are enabled for the G buffer.
  22952. */
  22953. set enableReflectivity(enable: boolean);
  22954. /**
  22955. * Gets the scene associated with the buffer.
  22956. */
  22957. get scene(): Scene;
  22958. /**
  22959. * Gets the ratio used by the buffer during its creation.
  22960. * How big is the buffer related to the main canvas.
  22961. */
  22962. get ratio(): number;
  22963. /** @hidden */
  22964. static _SceneComponentInitialization: (scene: Scene) => void;
  22965. /**
  22966. * Creates a new G Buffer for the scene
  22967. * @param scene The scene the buffer belongs to
  22968. * @param ratio How big is the buffer related to the main canvas.
  22969. */
  22970. constructor(scene: Scene, ratio?: number);
  22971. /**
  22972. * Checks wether everything is ready to render a submesh to the G buffer.
  22973. * @param subMesh the submesh to check readiness for
  22974. * @param useInstances is the mesh drawn using instance or not
  22975. * @returns true if ready otherwise false
  22976. */
  22977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22978. /**
  22979. * Gets the current underlying G Buffer.
  22980. * @returns the buffer
  22981. */
  22982. getGBuffer(): MultiRenderTarget;
  22983. /**
  22984. * Gets the number of samples used to render the buffer (anti aliasing).
  22985. */
  22986. get samples(): number;
  22987. /**
  22988. * Sets the number of samples used to render the buffer (anti aliasing).
  22989. */
  22990. set samples(value: number);
  22991. /**
  22992. * Disposes the renderer and frees up associated resources.
  22993. */
  22994. dispose(): void;
  22995. private _assignRenderTargetIndices;
  22996. protected _createRenderTargets(): void;
  22997. private _copyBonesTransformationMatrices;
  22998. }
  22999. }
  23000. declare module "babylonjs/Rendering/prePassRenderer" {
  23001. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23002. import { Scene } from "babylonjs/scene";
  23003. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23004. import { Effect } from "babylonjs/Materials/effect";
  23005. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23007. import { Material } from "babylonjs/Materials/material";
  23008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23009. /**
  23010. * Renders a pre pass of the scene
  23011. * This means every mesh in the scene will be rendered to a render target texture
  23012. * And then this texture will be composited to the rendering canvas with post processes
  23013. * It is necessary for effects like subsurface scattering or deferred shading
  23014. */
  23015. export class PrePassRenderer {
  23016. /** @hidden */
  23017. static _SceneComponentInitialization: (scene: Scene) => void;
  23018. private _textureFormats;
  23019. /**
  23020. * To save performance, we can excluded skinned meshes from the prepass
  23021. */
  23022. excludedSkinnedMesh: AbstractMesh[];
  23023. /**
  23024. * Force material to be excluded from the prepass
  23025. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23026. * and you don't want a material to show in the effect.
  23027. */
  23028. excludedMaterials: Material[];
  23029. private _textureIndices;
  23030. private _scene;
  23031. private _engine;
  23032. private _isDirty;
  23033. /**
  23034. * Number of textures in the multi render target texture where the scene is directly rendered
  23035. */
  23036. mrtCount: number;
  23037. /**
  23038. * The render target where the scene is directly rendered
  23039. */
  23040. prePassRT: MultiRenderTarget;
  23041. private _multiRenderAttachments;
  23042. private _defaultAttachments;
  23043. private _clearAttachments;
  23044. private _postProcesses;
  23045. private readonly _clearColor;
  23046. /**
  23047. * Image processing post process for composition
  23048. */
  23049. imageProcessingPostProcess: ImageProcessingPostProcess;
  23050. /**
  23051. * Configuration for prepass effects
  23052. */
  23053. private _effectConfigurations;
  23054. private _mrtFormats;
  23055. private _mrtLayout;
  23056. private _enabled;
  23057. /**
  23058. * Indicates if the prepass is enabled
  23059. */
  23060. get enabled(): boolean;
  23061. /**
  23062. * How many samples are used for MSAA of the scene render target
  23063. */
  23064. get samples(): number;
  23065. set samples(n: number);
  23066. private _geometryBuffer;
  23067. private _useGeometryBufferFallback;
  23068. /**
  23069. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23070. */
  23071. get useGeometryBufferFallback(): boolean;
  23072. set useGeometryBufferFallback(value: boolean);
  23073. /**
  23074. * Set to true to disable gamma transform in PrePass.
  23075. * Can be useful in case you already proceed to gamma transform on a material level
  23076. * and your post processes don't need to be in linear color space.
  23077. */
  23078. disableGammaTransform: boolean;
  23079. /**
  23080. * Instanciates a prepass renderer
  23081. * @param scene The scene
  23082. */
  23083. constructor(scene: Scene);
  23084. private _initializeAttachments;
  23085. private _createCompositionEffect;
  23086. /**
  23087. * Indicates if rendering a prepass is supported
  23088. */
  23089. get isSupported(): boolean;
  23090. /**
  23091. * Sets the proper output textures to draw in the engine.
  23092. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23093. * @param subMesh Submesh on which the effect is applied
  23094. */
  23095. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23096. /**
  23097. * Restores attachments for single texture draw.
  23098. */
  23099. restoreAttachments(): void;
  23100. /**
  23101. * @hidden
  23102. */
  23103. _beforeCameraDraw(): void;
  23104. /**
  23105. * @hidden
  23106. */
  23107. _afterCameraDraw(): void;
  23108. private _checkRTSize;
  23109. private _bindFrameBuffer;
  23110. /**
  23111. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23112. */
  23113. clear(): void;
  23114. private _setState;
  23115. private _updateGeometryBufferLayout;
  23116. /**
  23117. * Adds an effect configuration to the prepass.
  23118. * If an effect has already been added, it won't add it twice and will return the configuration
  23119. * already present.
  23120. * @param cfg the effect configuration
  23121. * @return the effect configuration now used by the prepass
  23122. */
  23123. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23124. /**
  23125. * Returns the index of a texture in the multi render target texture array.
  23126. * @param type Texture type
  23127. * @return The index
  23128. */
  23129. getIndex(type: number): number;
  23130. private _enable;
  23131. private _disable;
  23132. private _resetLayout;
  23133. private _resetPostProcessChain;
  23134. private _bindPostProcessChain;
  23135. /**
  23136. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23137. */
  23138. markAsDirty(): void;
  23139. /**
  23140. * Enables a texture on the MultiRenderTarget for prepass
  23141. */
  23142. private _enableTextures;
  23143. private _update;
  23144. private _markAllMaterialsAsPrePassDirty;
  23145. /**
  23146. * Disposes the prepass renderer.
  23147. */
  23148. dispose(): void;
  23149. }
  23150. }
  23151. declare module "babylonjs/PostProcesses/postProcess" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { SmartArray } from "babylonjs/Misc/smartArray";
  23154. import { Observable } from "babylonjs/Misc/observable";
  23155. import { Vector2 } from "babylonjs/Maths/math.vector";
  23156. import { Camera } from "babylonjs/Cameras/camera";
  23157. import { Effect } from "babylonjs/Materials/effect";
  23158. import "babylonjs/Shaders/postprocess.vertex";
  23159. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23160. import { Engine } from "babylonjs/Engines/engine";
  23161. import { Color4 } from "babylonjs/Maths/math.color";
  23162. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23163. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23164. import { Scene } from "babylonjs/scene";
  23165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23166. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23167. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23168. /**
  23169. * Size options for a post process
  23170. */
  23171. export type PostProcessOptions = {
  23172. width: number;
  23173. height: number;
  23174. };
  23175. /**
  23176. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23177. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23178. */
  23179. export class PostProcess {
  23180. /**
  23181. * Gets or sets the unique id of the post process
  23182. */
  23183. uniqueId: number;
  23184. /** Name of the PostProcess. */
  23185. name: string;
  23186. /**
  23187. * Width of the texture to apply the post process on
  23188. */
  23189. width: number;
  23190. /**
  23191. * Height of the texture to apply the post process on
  23192. */
  23193. height: number;
  23194. /**
  23195. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23196. */
  23197. nodeMaterialSource: Nullable<NodeMaterial>;
  23198. /**
  23199. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23200. * @hidden
  23201. */
  23202. _outputTexture: Nullable<InternalTexture>;
  23203. /**
  23204. * Sampling mode used by the shader
  23205. * See https://doc.babylonjs.com/classes/3.1/texture
  23206. */
  23207. renderTargetSamplingMode: number;
  23208. /**
  23209. * Clear color to use when screen clearing
  23210. */
  23211. clearColor: Color4;
  23212. /**
  23213. * If the buffer needs to be cleared before applying the post process. (default: true)
  23214. * Should be set to false if shader will overwrite all previous pixels.
  23215. */
  23216. autoClear: boolean;
  23217. /**
  23218. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23219. */
  23220. alphaMode: number;
  23221. /**
  23222. * Sets the setAlphaBlendConstants of the babylon engine
  23223. */
  23224. alphaConstants: Color4;
  23225. /**
  23226. * Animations to be used for the post processing
  23227. */
  23228. animations: import("babylonjs/Animations/animation").Animation[];
  23229. /**
  23230. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23231. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23232. */
  23233. enablePixelPerfectMode: boolean;
  23234. /**
  23235. * Force the postprocess to be applied without taking in account viewport
  23236. */
  23237. forceFullscreenViewport: boolean;
  23238. /**
  23239. * List of inspectable custom properties (used by the Inspector)
  23240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23241. */
  23242. inspectableCustomProperties: IInspectable[];
  23243. /**
  23244. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23245. *
  23246. * | Value | Type | Description |
  23247. * | ----- | ----------------------------------- | ----------- |
  23248. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23249. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23250. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23251. *
  23252. */
  23253. scaleMode: number;
  23254. /**
  23255. * Force textures to be a power of two (default: false)
  23256. */
  23257. alwaysForcePOT: boolean;
  23258. private _samples;
  23259. /**
  23260. * Number of sample textures (default: 1)
  23261. */
  23262. get samples(): number;
  23263. set samples(n: number);
  23264. /**
  23265. * Modify the scale of the post process to be the same as the viewport (default: false)
  23266. */
  23267. adaptScaleToCurrentViewport: boolean;
  23268. private _camera;
  23269. protected _scene: Scene;
  23270. private _engine;
  23271. private _options;
  23272. private _reusable;
  23273. private _textureType;
  23274. private _textureFormat;
  23275. /**
  23276. * Smart array of input and output textures for the post process.
  23277. * @hidden
  23278. */
  23279. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23280. /**
  23281. * The index in _textures that corresponds to the output texture.
  23282. * @hidden
  23283. */
  23284. _currentRenderTextureInd: number;
  23285. private _effect;
  23286. private _samplers;
  23287. private _fragmentUrl;
  23288. private _vertexUrl;
  23289. private _parameters;
  23290. private _scaleRatio;
  23291. protected _indexParameters: any;
  23292. private _shareOutputWithPostProcess;
  23293. private _texelSize;
  23294. private _forcedOutputTexture;
  23295. /**
  23296. * Prepass configuration in case this post process needs a texture from prepass
  23297. * @hidden
  23298. */
  23299. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23300. /**
  23301. * Returns the fragment url or shader name used in the post process.
  23302. * @returns the fragment url or name in the shader store.
  23303. */
  23304. getEffectName(): string;
  23305. /**
  23306. * An event triggered when the postprocess is activated.
  23307. */
  23308. onActivateObservable: Observable<Camera>;
  23309. private _onActivateObserver;
  23310. /**
  23311. * A function that is added to the onActivateObservable
  23312. */
  23313. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23314. /**
  23315. * An event triggered when the postprocess changes its size.
  23316. */
  23317. onSizeChangedObservable: Observable<PostProcess>;
  23318. private _onSizeChangedObserver;
  23319. /**
  23320. * A function that is added to the onSizeChangedObservable
  23321. */
  23322. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23323. /**
  23324. * An event triggered when the postprocess applies its effect.
  23325. */
  23326. onApplyObservable: Observable<Effect>;
  23327. private _onApplyObserver;
  23328. /**
  23329. * A function that is added to the onApplyObservable
  23330. */
  23331. set onApply(callback: (effect: Effect) => void);
  23332. /**
  23333. * An event triggered before rendering the postprocess
  23334. */
  23335. onBeforeRenderObservable: Observable<Effect>;
  23336. private _onBeforeRenderObserver;
  23337. /**
  23338. * A function that is added to the onBeforeRenderObservable
  23339. */
  23340. set onBeforeRender(callback: (effect: Effect) => void);
  23341. /**
  23342. * An event triggered after rendering the postprocess
  23343. */
  23344. onAfterRenderObservable: Observable<Effect>;
  23345. private _onAfterRenderObserver;
  23346. /**
  23347. * A function that is added to the onAfterRenderObservable
  23348. */
  23349. set onAfterRender(callback: (efect: Effect) => void);
  23350. /**
  23351. * 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
  23352. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23353. */
  23354. get inputTexture(): InternalTexture;
  23355. set inputTexture(value: InternalTexture);
  23356. /**
  23357. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23358. * the only way to unset it is to use this function to restore its internal state
  23359. */
  23360. restoreDefaultInputTexture(): void;
  23361. /**
  23362. * Gets the camera which post process is applied to.
  23363. * @returns The camera the post process is applied to.
  23364. */
  23365. getCamera(): Camera;
  23366. /**
  23367. * Gets the texel size of the postprocess.
  23368. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23369. */
  23370. get texelSize(): Vector2;
  23371. /**
  23372. * Creates a new instance PostProcess
  23373. * @param name The name of the PostProcess.
  23374. * @param fragmentUrl The url of the fragment shader to be used.
  23375. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23376. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23377. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23378. * @param camera The camera to apply the render pass to.
  23379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23380. * @param engine The engine which the post process will be applied. (default: current engine)
  23381. * @param reusable If the post process can be reused on the same frame. (default: false)
  23382. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23383. * @param textureType Type of textures used when performing the post process. (default: 0)
  23384. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23385. * @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
  23386. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23387. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23388. */
  23389. 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);
  23390. /**
  23391. * Gets a string identifying the name of the class
  23392. * @returns "PostProcess" string
  23393. */
  23394. getClassName(): string;
  23395. /**
  23396. * Gets the engine which this post process belongs to.
  23397. * @returns The engine the post process was enabled with.
  23398. */
  23399. getEngine(): Engine;
  23400. /**
  23401. * The effect that is created when initializing the post process.
  23402. * @returns The created effect corresponding the the postprocess.
  23403. */
  23404. getEffect(): Effect;
  23405. /**
  23406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23407. * @param postProcess The post process to share the output with.
  23408. * @returns This post process.
  23409. */
  23410. shareOutputWith(postProcess: PostProcess): PostProcess;
  23411. /**
  23412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23414. */
  23415. useOwnOutput(): void;
  23416. /**
  23417. * Updates the effect with the current post process compile time values and recompiles the shader.
  23418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23421. * @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
  23422. * @param onCompiled Called when the shader has been compiled.
  23423. * @param onError Called if there is an error when compiling a shader.
  23424. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23425. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23426. */
  23427. 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;
  23428. /**
  23429. * The post process is reusable if it can be used multiple times within one frame.
  23430. * @returns If the post process is reusable
  23431. */
  23432. isReusable(): boolean;
  23433. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23434. markTextureDirty(): void;
  23435. /**
  23436. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23437. * 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.
  23438. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23439. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23440. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23441. * @returns The target texture that was bound to be written to.
  23442. */
  23443. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23444. /**
  23445. * If the post process is supported.
  23446. */
  23447. get isSupported(): boolean;
  23448. /**
  23449. * The aspect ratio of the output texture.
  23450. */
  23451. get aspectRatio(): number;
  23452. /**
  23453. * Get a value indicating if the post-process is ready to be used
  23454. * @returns true if the post-process is ready (shader is compiled)
  23455. */
  23456. isReady(): boolean;
  23457. /**
  23458. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23459. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23460. */
  23461. apply(): Nullable<Effect>;
  23462. private _disposeTextures;
  23463. /**
  23464. * Sets the required values to the prepass renderer.
  23465. * @param prePassRenderer defines the prepass renderer to setup.
  23466. * @returns true if the pre pass is needed.
  23467. */
  23468. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23469. /**
  23470. * Disposes the post process.
  23471. * @param camera The camera to dispose the post process on.
  23472. */
  23473. dispose(camera?: Camera): void;
  23474. /**
  23475. * Serializes the particle system to a JSON object
  23476. * @returns the JSON object
  23477. */
  23478. serialize(): any;
  23479. /**
  23480. * Creates a material from parsed material data
  23481. * @param parsedPostProcess defines parsed post process data
  23482. * @param scene defines the hosting scene
  23483. * @param rootUrl defines the root URL to use to load textures
  23484. * @returns a new post process
  23485. */
  23486. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23487. }
  23488. }
  23489. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23490. /** @hidden */
  23491. export var kernelBlurVaryingDeclaration: {
  23492. name: string;
  23493. shader: string;
  23494. };
  23495. }
  23496. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23497. /** @hidden */
  23498. export var packingFunctions: {
  23499. name: string;
  23500. shader: string;
  23501. };
  23502. }
  23503. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23504. /** @hidden */
  23505. export var kernelBlurFragment: {
  23506. name: string;
  23507. shader: string;
  23508. };
  23509. }
  23510. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23511. /** @hidden */
  23512. export var kernelBlurFragment2: {
  23513. name: string;
  23514. shader: string;
  23515. };
  23516. }
  23517. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23518. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23519. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23521. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23522. /** @hidden */
  23523. export var kernelBlurPixelShader: {
  23524. name: string;
  23525. shader: string;
  23526. };
  23527. }
  23528. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23529. /** @hidden */
  23530. export var kernelBlurVertex: {
  23531. name: string;
  23532. shader: string;
  23533. };
  23534. }
  23535. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23537. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23538. /** @hidden */
  23539. export var kernelBlurVertexShader: {
  23540. name: string;
  23541. shader: string;
  23542. };
  23543. }
  23544. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23545. import { Vector2 } from "babylonjs/Maths/math.vector";
  23546. import { Nullable } from "babylonjs/types";
  23547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23548. import { Camera } from "babylonjs/Cameras/camera";
  23549. import { Effect } from "babylonjs/Materials/effect";
  23550. import { Engine } from "babylonjs/Engines/engine";
  23551. import "babylonjs/Shaders/kernelBlur.fragment";
  23552. import "babylonjs/Shaders/kernelBlur.vertex";
  23553. import { Scene } from "babylonjs/scene";
  23554. /**
  23555. * The Blur Post Process which blurs an image based on a kernel and direction.
  23556. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23557. */
  23558. export class BlurPostProcess extends PostProcess {
  23559. private blockCompilation;
  23560. protected _kernel: number;
  23561. protected _idealKernel: number;
  23562. protected _packedFloat: boolean;
  23563. private _staticDefines;
  23564. /** The direction in which to blur the image. */
  23565. direction: Vector2;
  23566. /**
  23567. * Sets the length in pixels of the blur sample region
  23568. */
  23569. set kernel(v: number);
  23570. /**
  23571. * Gets the length in pixels of the blur sample region
  23572. */
  23573. get kernel(): number;
  23574. /**
  23575. * Sets wether or not the blur needs to unpack/repack floats
  23576. */
  23577. set packedFloat(v: boolean);
  23578. /**
  23579. * Gets wether or not the blur is unpacking/repacking floats
  23580. */
  23581. get packedFloat(): boolean;
  23582. /**
  23583. * Gets a string identifying the name of the class
  23584. * @returns "BlurPostProcess" string
  23585. */
  23586. getClassName(): string;
  23587. /**
  23588. * Creates a new instance BlurPostProcess
  23589. * @param name The name of the effect.
  23590. * @param direction The direction in which to blur the image.
  23591. * @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.
  23592. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23593. * @param camera The camera to apply the render pass to.
  23594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23595. * @param engine The engine which the post process will be applied. (default: current engine)
  23596. * @param reusable If the post process can be reused on the same frame. (default: false)
  23597. * @param textureType Type of textures used when performing the post process. (default: 0)
  23598. * @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)
  23599. */
  23600. 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);
  23601. /**
  23602. * Updates the effect with the current post process compile time values and recompiles the shader.
  23603. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23604. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23605. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23606. * @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
  23607. * @param onCompiled Called when the shader has been compiled.
  23608. * @param onError Called if there is an error when compiling a shader.
  23609. */
  23610. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23611. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23612. /**
  23613. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23614. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23615. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23616. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23617. * The gaps between physical kernels are compensated for in the weighting of the samples
  23618. * @param idealKernel Ideal blur kernel.
  23619. * @return Nearest best kernel.
  23620. */
  23621. protected _nearestBestKernel(idealKernel: number): number;
  23622. /**
  23623. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23624. * @param x The point on the Gaussian distribution to sample.
  23625. * @return the value of the Gaussian function at x.
  23626. */
  23627. protected _gaussianWeight(x: number): number;
  23628. /**
  23629. * Generates a string that can be used as a floating point number in GLSL.
  23630. * @param x Value to print.
  23631. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23632. * @return GLSL float string.
  23633. */
  23634. protected _glslFloat(x: number, decimalFigures?: number): string;
  23635. /** @hidden */
  23636. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23637. }
  23638. }
  23639. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23640. import { Scene } from "babylonjs/scene";
  23641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23642. import { Plane } from "babylonjs/Maths/math.plane";
  23643. /**
  23644. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23645. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23646. * You can then easily use it as a reflectionTexture on a flat surface.
  23647. * In case the surface is not a plane, please consider relying on reflection probes.
  23648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23649. */
  23650. export class MirrorTexture extends RenderTargetTexture {
  23651. private scene;
  23652. /**
  23653. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23654. * 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.
  23655. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23656. */
  23657. mirrorPlane: Plane;
  23658. /**
  23659. * Define the blur ratio used to blur the reflection if needed.
  23660. */
  23661. set blurRatio(value: number);
  23662. get blurRatio(): number;
  23663. /**
  23664. * Define the adaptive blur kernel used to blur the reflection if needed.
  23665. * This will autocompute the closest best match for the `blurKernel`
  23666. */
  23667. set adaptiveBlurKernel(value: number);
  23668. /**
  23669. * Define the blur kernel used to blur the reflection if needed.
  23670. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23671. */
  23672. set blurKernel(value: number);
  23673. /**
  23674. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23675. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23676. */
  23677. set blurKernelX(value: number);
  23678. get blurKernelX(): number;
  23679. /**
  23680. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23682. */
  23683. set blurKernelY(value: number);
  23684. get blurKernelY(): number;
  23685. private _autoComputeBlurKernel;
  23686. protected _onRatioRescale(): void;
  23687. private _updateGammaSpace;
  23688. private _imageProcessingConfigChangeObserver;
  23689. private _transformMatrix;
  23690. private _mirrorMatrix;
  23691. private _savedViewMatrix;
  23692. private _blurX;
  23693. private _blurY;
  23694. private _adaptiveBlurKernel;
  23695. private _blurKernelX;
  23696. private _blurKernelY;
  23697. private _blurRatio;
  23698. /**
  23699. * Instantiates a Mirror Texture.
  23700. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23701. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23702. * You can then easily use it as a reflectionTexture on a flat surface.
  23703. * In case the surface is not a plane, please consider relying on reflection probes.
  23704. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23705. * @param name
  23706. * @param size
  23707. * @param scene
  23708. * @param generateMipMaps
  23709. * @param type
  23710. * @param samplingMode
  23711. * @param generateDepthBuffer
  23712. */
  23713. constructor(name: string, size: number | {
  23714. width: number;
  23715. height: number;
  23716. } | {
  23717. ratio: number;
  23718. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23719. private _preparePostProcesses;
  23720. /**
  23721. * Clone the mirror texture.
  23722. * @returns the cloned texture
  23723. */
  23724. clone(): MirrorTexture;
  23725. /**
  23726. * Serialize the texture to a JSON representation you could use in Parse later on
  23727. * @returns the serialized JSON representation
  23728. */
  23729. serialize(): any;
  23730. /**
  23731. * Dispose the texture and release its associated resources.
  23732. */
  23733. dispose(): void;
  23734. }
  23735. }
  23736. declare module "babylonjs/Materials/Textures/texture" {
  23737. import { Observable } from "babylonjs/Misc/observable";
  23738. import { Nullable } from "babylonjs/types";
  23739. import { Matrix } from "babylonjs/Maths/math.vector";
  23740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23741. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23742. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23743. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23744. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23746. import { Scene } from "babylonjs/scene";
  23747. /**
  23748. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23749. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23750. */
  23751. export class Texture extends BaseTexture {
  23752. /**
  23753. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23754. */
  23755. static SerializeBuffers: boolean;
  23756. /**
  23757. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23758. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23759. */
  23760. static ForceSerializeBuffers: boolean;
  23761. /** @hidden */
  23762. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23763. /** @hidden */
  23764. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23765. /** @hidden */
  23766. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23767. /** nearest is mag = nearest and min = nearest and mip = linear */
  23768. static readonly NEAREST_SAMPLINGMODE: number;
  23769. /** nearest is mag = nearest and min = nearest and mip = linear */
  23770. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23772. static readonly BILINEAR_SAMPLINGMODE: number;
  23773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23774. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23775. /** Trilinear is mag = linear and min = linear and mip = linear */
  23776. static readonly TRILINEAR_SAMPLINGMODE: number;
  23777. /** Trilinear is mag = linear and min = linear and mip = linear */
  23778. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23779. /** mag = nearest and min = nearest and mip = nearest */
  23780. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23781. /** mag = nearest and min = linear and mip = nearest */
  23782. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23783. /** mag = nearest and min = linear and mip = linear */
  23784. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23785. /** mag = nearest and min = linear and mip = none */
  23786. static readonly NEAREST_LINEAR: number;
  23787. /** mag = nearest and min = nearest and mip = none */
  23788. static readonly NEAREST_NEAREST: number;
  23789. /** mag = linear and min = nearest and mip = nearest */
  23790. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23791. /** mag = linear and min = nearest and mip = linear */
  23792. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23793. /** mag = linear and min = linear and mip = none */
  23794. static readonly LINEAR_LINEAR: number;
  23795. /** mag = linear and min = nearest and mip = none */
  23796. static readonly LINEAR_NEAREST: number;
  23797. /** Explicit coordinates mode */
  23798. static readonly EXPLICIT_MODE: number;
  23799. /** Spherical coordinates mode */
  23800. static readonly SPHERICAL_MODE: number;
  23801. /** Planar coordinates mode */
  23802. static readonly PLANAR_MODE: number;
  23803. /** Cubic coordinates mode */
  23804. static readonly CUBIC_MODE: number;
  23805. /** Projection coordinates mode */
  23806. static readonly PROJECTION_MODE: number;
  23807. /** Inverse Cubic coordinates mode */
  23808. static readonly SKYBOX_MODE: number;
  23809. /** Inverse Cubic coordinates mode */
  23810. static readonly INVCUBIC_MODE: number;
  23811. /** Equirectangular coordinates mode */
  23812. static readonly EQUIRECTANGULAR_MODE: number;
  23813. /** Equirectangular Fixed coordinates mode */
  23814. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23815. /** Equirectangular Fixed Mirrored coordinates mode */
  23816. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23817. /** Texture is not repeating outside of 0..1 UVs */
  23818. static readonly CLAMP_ADDRESSMODE: number;
  23819. /** Texture is repeating outside of 0..1 UVs */
  23820. static readonly WRAP_ADDRESSMODE: number;
  23821. /** Texture is repeating and mirrored */
  23822. static readonly MIRROR_ADDRESSMODE: number;
  23823. /**
  23824. * 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
  23825. */
  23826. static UseSerializedUrlIfAny: boolean;
  23827. /**
  23828. * Define the url of the texture.
  23829. */
  23830. url: Nullable<string>;
  23831. /**
  23832. * Define an offset on the texture to offset the u coordinates of the UVs
  23833. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23834. */
  23835. uOffset: number;
  23836. /**
  23837. * Define an offset on the texture to offset the v coordinates of the UVs
  23838. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23839. */
  23840. vOffset: number;
  23841. /**
  23842. * Define an offset on the texture to scale the u coordinates of the UVs
  23843. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23844. */
  23845. uScale: number;
  23846. /**
  23847. * Define an offset on the texture to scale the v coordinates of the UVs
  23848. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23849. */
  23850. vScale: number;
  23851. /**
  23852. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23853. * @see https://doc.babylonjs.com/how_to/more_materials
  23854. */
  23855. uAng: number;
  23856. /**
  23857. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23858. * @see https://doc.babylonjs.com/how_to/more_materials
  23859. */
  23860. vAng: number;
  23861. /**
  23862. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23863. * @see https://doc.babylonjs.com/how_to/more_materials
  23864. */
  23865. wAng: number;
  23866. /**
  23867. * Defines the center of rotation (U)
  23868. */
  23869. uRotationCenter: number;
  23870. /**
  23871. * Defines the center of rotation (V)
  23872. */
  23873. vRotationCenter: number;
  23874. /**
  23875. * Defines the center of rotation (W)
  23876. */
  23877. wRotationCenter: number;
  23878. /**
  23879. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23880. */
  23881. homogeneousRotationInUVTransform: boolean;
  23882. /**
  23883. * Are mip maps generated for this texture or not.
  23884. */
  23885. get noMipmap(): boolean;
  23886. /**
  23887. * List of inspectable custom properties (used by the Inspector)
  23888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23889. */
  23890. inspectableCustomProperties: Nullable<IInspectable[]>;
  23891. private _noMipmap;
  23892. /** @hidden */
  23893. _invertY: boolean;
  23894. private _rowGenerationMatrix;
  23895. private _cachedTextureMatrix;
  23896. private _projectionModeMatrix;
  23897. private _t0;
  23898. private _t1;
  23899. private _t2;
  23900. private _cachedUOffset;
  23901. private _cachedVOffset;
  23902. private _cachedUScale;
  23903. private _cachedVScale;
  23904. private _cachedUAng;
  23905. private _cachedVAng;
  23906. private _cachedWAng;
  23907. private _cachedProjectionMatrixId;
  23908. private _cachedURotationCenter;
  23909. private _cachedVRotationCenter;
  23910. private _cachedWRotationCenter;
  23911. private _cachedHomogeneousRotationInUVTransform;
  23912. private _cachedCoordinatesMode;
  23913. /** @hidden */
  23914. protected _initialSamplingMode: number;
  23915. /** @hidden */
  23916. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23917. private _deleteBuffer;
  23918. protected _format: Nullable<number>;
  23919. private _delayedOnLoad;
  23920. private _delayedOnError;
  23921. private _mimeType?;
  23922. private _loaderOptions?;
  23923. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23924. get mimeType(): string | undefined;
  23925. /**
  23926. * Observable triggered once the texture has been loaded.
  23927. */
  23928. onLoadObservable: Observable<Texture>;
  23929. protected _isBlocking: boolean;
  23930. /**
  23931. * Is the texture preventing material to render while loading.
  23932. * If false, a default texture will be used instead of the loading one during the preparation step.
  23933. */
  23934. set isBlocking(value: boolean);
  23935. get isBlocking(): boolean;
  23936. /**
  23937. * Get the current sampling mode associated with the texture.
  23938. */
  23939. get samplingMode(): number;
  23940. /**
  23941. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23942. */
  23943. get invertY(): boolean;
  23944. /**
  23945. * Instantiates a new texture.
  23946. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23947. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23948. * @param url defines the url of the picture to load as a texture
  23949. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23950. * @param noMipmap defines if the texture will require mip maps or not
  23951. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23952. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23953. * @param onLoad defines a callback triggered when the texture has been loaded
  23954. * @param onError defines a callback triggered when an error occurred during the loading session
  23955. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23956. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23957. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23958. * @param mimeType defines an optional mime type information
  23959. * @param loaderOptions options to be passed to the loader
  23960. */
  23961. 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);
  23962. /**
  23963. * Update the url (and optional buffer) of this texture if url was null during construction.
  23964. * @param url the url of the texture
  23965. * @param buffer the buffer of the texture (defaults to null)
  23966. * @param onLoad callback called when the texture is loaded (defaults to null)
  23967. */
  23968. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23969. /**
  23970. * Finish the loading sequence of a texture flagged as delayed load.
  23971. * @hidden
  23972. */
  23973. delayLoad(): void;
  23974. private _prepareRowForTextureGeneration;
  23975. /**
  23976. * Checks if the texture has the same transform matrix than another texture
  23977. * @param texture texture to check against
  23978. * @returns true if the transforms are the same, else false
  23979. */
  23980. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23981. /**
  23982. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23983. * @returns the transform matrix of the texture.
  23984. */
  23985. getTextureMatrix(uBase?: number): Matrix;
  23986. /**
  23987. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23988. * @returns The reflection texture transform
  23989. */
  23990. getReflectionTextureMatrix(): Matrix;
  23991. /**
  23992. * Clones the texture.
  23993. * @returns the cloned texture
  23994. */
  23995. clone(): Texture;
  23996. /**
  23997. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23998. * @returns The JSON representation of the texture
  23999. */
  24000. serialize(): any;
  24001. /**
  24002. * Get the current class name of the texture useful for serialization or dynamic coding.
  24003. * @returns "Texture"
  24004. */
  24005. getClassName(): string;
  24006. /**
  24007. * Dispose the texture and release its associated resources.
  24008. */
  24009. dispose(): void;
  24010. /**
  24011. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24012. * @param parsedTexture Define the JSON representation of the texture
  24013. * @param scene Define the scene the parsed texture should be instantiated in
  24014. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24015. * @returns The parsed texture if successful
  24016. */
  24017. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24018. /**
  24019. * Creates a texture from its base 64 representation.
  24020. * @param data Define the base64 payload without the data: prefix
  24021. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24022. * @param scene Define the scene the texture should belong to
  24023. * @param noMipmap Forces the texture to not create mip map information if true
  24024. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24025. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24026. * @param onLoad define a callback triggered when the texture has been loaded
  24027. * @param onError define a callback triggered when an error occurred during the loading session
  24028. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24029. * @returns the created texture
  24030. */
  24031. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24032. /**
  24033. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24034. * @param data Define the base64 payload without the data: prefix
  24035. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24036. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24037. * @param scene Define the scene the texture should belong to
  24038. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24039. * @param noMipmap Forces the texture to not create mip map information if true
  24040. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24041. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24042. * @param onLoad define a callback triggered when the texture has been loaded
  24043. * @param onError define a callback triggered when an error occurred during the loading session
  24044. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24045. * @returns the created texture
  24046. */
  24047. 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;
  24048. }
  24049. }
  24050. declare module "babylonjs/Sprites/thinSprite" {
  24051. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24052. import { Nullable } from "babylonjs/types";
  24053. /**
  24054. * ThinSprite Class used to represent a thin sprite
  24055. * This is the base class for sprites but can also directly be used with ThinEngine
  24056. * @see https://doc.babylonjs.com/babylon101/sprites
  24057. */
  24058. export class ThinSprite {
  24059. /** Gets or sets the cell index in the sprite sheet */
  24060. cellIndex: number;
  24061. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24062. cellRef: string;
  24063. /** Gets or sets the current world position */
  24064. position: IVector3Like;
  24065. /** Gets or sets the main color */
  24066. color: IColor4Like;
  24067. /** Gets or sets the width */
  24068. width: number;
  24069. /** Gets or sets the height */
  24070. height: number;
  24071. /** Gets or sets rotation angle */
  24072. angle: number;
  24073. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24074. invertU: boolean;
  24075. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24076. invertV: boolean;
  24077. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24078. isVisible: boolean;
  24079. /**
  24080. * Returns a boolean indicating if the animation is started
  24081. */
  24082. get animationStarted(): boolean;
  24083. /** Gets the initial key for the animation (setting it will restart the animation) */
  24084. get fromIndex(): number;
  24085. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24086. get toIndex(): number;
  24087. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24088. get loopAnimation(): boolean;
  24089. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24090. get delay(): number;
  24091. /** @hidden */
  24092. _xOffset: number;
  24093. /** @hidden */
  24094. _yOffset: number;
  24095. /** @hidden */
  24096. _xSize: number;
  24097. /** @hidden */
  24098. _ySize: number;
  24099. private _animationStarted;
  24100. protected _loopAnimation: boolean;
  24101. protected _fromIndex: number;
  24102. protected _toIndex: number;
  24103. protected _delay: number;
  24104. private _direction;
  24105. private _time;
  24106. private _onBaseAnimationEnd;
  24107. /**
  24108. * Creates a new Thin Sprite
  24109. */
  24110. constructor();
  24111. /**
  24112. * Starts an animation
  24113. * @param from defines the initial key
  24114. * @param to defines the end key
  24115. * @param loop defines if the animation must loop
  24116. * @param delay defines the start delay (in ms)
  24117. * @param onAnimationEnd defines a callback for when the animation ends
  24118. */
  24119. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24120. /** Stops current animation (if any) */
  24121. stopAnimation(): void;
  24122. /** @hidden */
  24123. _animate(deltaTime: number): void;
  24124. }
  24125. }
  24126. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24127. /** @hidden */
  24128. export var imageProcessingCompatibility: {
  24129. name: string;
  24130. shader: string;
  24131. };
  24132. }
  24133. declare module "babylonjs/Shaders/sprites.fragment" {
  24134. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24135. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24136. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24137. /** @hidden */
  24138. export var spritesPixelShader: {
  24139. name: string;
  24140. shader: string;
  24141. };
  24142. }
  24143. declare module "babylonjs/Shaders/sprites.vertex" {
  24144. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24145. /** @hidden */
  24146. export var spritesVertexShader: {
  24147. name: string;
  24148. shader: string;
  24149. };
  24150. }
  24151. declare module "babylonjs/Sprites/spriteRenderer" {
  24152. import { Nullable } from "babylonjs/types";
  24153. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24155. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24156. import { ISize } from "babylonjs/Maths/math.size";
  24157. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24158. import { Scene } from "babylonjs/scene";
  24159. import "babylonjs/Engines/Extensions/engine.alpha";
  24160. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24161. import "babylonjs/Shaders/sprites.fragment";
  24162. import "babylonjs/Shaders/sprites.vertex";
  24163. /**
  24164. * Class used to render sprites.
  24165. *
  24166. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24167. */
  24168. export class SpriteRenderer {
  24169. /**
  24170. * Defines the texture of the spritesheet
  24171. */
  24172. texture: Nullable<ThinTexture>;
  24173. /**
  24174. * Defines the default width of a cell in the spritesheet
  24175. */
  24176. cellWidth: number;
  24177. /**
  24178. * Defines the default height of a cell in the spritesheet
  24179. */
  24180. cellHeight: number;
  24181. /**
  24182. * Blend mode use to render the particle, it can be any of
  24183. * the static Constants.ALPHA_x properties provided in this class.
  24184. * Default value is Constants.ALPHA_COMBINE
  24185. */
  24186. blendMode: number;
  24187. /**
  24188. * Gets or sets a boolean indicating if alpha mode is automatically
  24189. * reset.
  24190. */
  24191. autoResetAlpha: boolean;
  24192. /**
  24193. * Disables writing to the depth buffer when rendering the sprites.
  24194. * It can be handy to disable depth writing when using textures without alpha channel
  24195. * and setting some specific blend modes.
  24196. */
  24197. disableDepthWrite: boolean;
  24198. /**
  24199. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24200. */
  24201. fogEnabled: boolean;
  24202. /**
  24203. * Gets the capacity of the manager
  24204. */
  24205. get capacity(): number;
  24206. private readonly _engine;
  24207. private readonly _useVAO;
  24208. private readonly _useInstancing;
  24209. private readonly _scene;
  24210. private readonly _capacity;
  24211. private readonly _epsilon;
  24212. private _vertexBufferSize;
  24213. private _vertexData;
  24214. private _buffer;
  24215. private _vertexBuffers;
  24216. private _spriteBuffer;
  24217. private _indexBuffer;
  24218. private _effectBase;
  24219. private _effectFog;
  24220. private _vertexArrayObject;
  24221. /**
  24222. * Creates a new sprite Renderer
  24223. * @param engine defines the engine the renderer works with
  24224. * @param capacity defines the maximum allowed number of sprites
  24225. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24229. /**
  24230. * Render all child sprites
  24231. * @param sprites defines the list of sprites to render
  24232. * @param deltaTime defines the time since last frame
  24233. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24234. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24235. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24236. */
  24237. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24238. private _appendSpriteVertex;
  24239. /**
  24240. * Release associated resources
  24241. */
  24242. dispose(): void;
  24243. }
  24244. }
  24245. declare module "babylonjs/Sprites/spriteManager" {
  24246. import { IDisposable, Scene } from "babylonjs/scene";
  24247. import { Nullable } from "babylonjs/types";
  24248. import { Observable } from "babylonjs/Misc/observable";
  24249. import { Sprite } from "babylonjs/Sprites/sprite";
  24250. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24251. import { Camera } from "babylonjs/Cameras/camera";
  24252. import { Texture } from "babylonjs/Materials/Textures/texture";
  24253. import { Ray } from "babylonjs/Culling/ray";
  24254. /**
  24255. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24256. */
  24257. export interface ISpriteManager extends IDisposable {
  24258. /**
  24259. * Gets manager's name
  24260. */
  24261. name: string;
  24262. /**
  24263. * Restricts the camera to viewing objects with the same layerMask.
  24264. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24265. */
  24266. layerMask: number;
  24267. /**
  24268. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24269. */
  24270. isPickable: boolean;
  24271. /**
  24272. * Gets the hosting scene
  24273. */
  24274. scene: Scene;
  24275. /**
  24276. * Specifies the rendering group id for this mesh (0 by default)
  24277. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24278. */
  24279. renderingGroupId: number;
  24280. /**
  24281. * Defines the list of sprites managed by the manager.
  24282. */
  24283. sprites: Array<Sprite>;
  24284. /**
  24285. * Gets or sets the spritesheet texture
  24286. */
  24287. texture: Texture;
  24288. /** Defines the default width of a cell in the spritesheet */
  24289. cellWidth: number;
  24290. /** Defines the default height of a cell in the spritesheet */
  24291. cellHeight: number;
  24292. /**
  24293. * Tests the intersection of a sprite with a specific ray.
  24294. * @param ray The ray we are sending to test the collision
  24295. * @param camera The camera space we are sending rays in
  24296. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24297. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24298. * @returns picking info or null.
  24299. */
  24300. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24301. /**
  24302. * Intersects the sprites with a ray
  24303. * @param ray defines the ray to intersect with
  24304. * @param camera defines the current active camera
  24305. * @param predicate defines a predicate used to select candidate sprites
  24306. * @returns null if no hit or a PickingInfo array
  24307. */
  24308. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24309. /**
  24310. * Renders the list of sprites on screen.
  24311. */
  24312. render(): void;
  24313. }
  24314. /**
  24315. * Class used to manage multiple sprites on the same spritesheet
  24316. * @see https://doc.babylonjs.com/babylon101/sprites
  24317. */
  24318. export class SpriteManager implements ISpriteManager {
  24319. /** defines the manager's name */
  24320. name: string;
  24321. /** Define the Url to load snippets */
  24322. static SnippetUrl: string;
  24323. /** Snippet ID if the manager was created from the snippet server */
  24324. snippetId: string;
  24325. /** Gets the list of sprites */
  24326. sprites: Sprite[];
  24327. /** Gets or sets the rendering group id (0 by default) */
  24328. renderingGroupId: number;
  24329. /** Gets or sets camera layer mask */
  24330. layerMask: number;
  24331. /** Gets or sets a boolean indicating if the sprites are pickable */
  24332. isPickable: boolean;
  24333. /**
  24334. * An event triggered when the manager is disposed.
  24335. */
  24336. onDisposeObservable: Observable<SpriteManager>;
  24337. /**
  24338. * Callback called when the manager is disposed
  24339. */
  24340. set onDispose(callback: () => void);
  24341. /**
  24342. * Gets or sets the unique id of the sprite
  24343. */
  24344. uniqueId: number;
  24345. /**
  24346. * Gets the array of sprites
  24347. */
  24348. get children(): Sprite[];
  24349. /**
  24350. * Gets the hosting scene
  24351. */
  24352. get scene(): Scene;
  24353. /**
  24354. * Gets the capacity of the manager
  24355. */
  24356. get capacity(): number;
  24357. /**
  24358. * Gets or sets the spritesheet texture
  24359. */
  24360. get texture(): Texture;
  24361. set texture(value: Texture);
  24362. /** Defines the default width of a cell in the spritesheet */
  24363. get cellWidth(): number;
  24364. set cellWidth(value: number);
  24365. /** Defines the default height of a cell in the spritesheet */
  24366. get cellHeight(): number;
  24367. set cellHeight(value: number);
  24368. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24369. get fogEnabled(): boolean;
  24370. set fogEnabled(value: boolean);
  24371. /**
  24372. * Blend mode use to render the particle, it can be any of
  24373. * the static Constants.ALPHA_x properties provided in this class.
  24374. * Default value is Constants.ALPHA_COMBINE
  24375. */
  24376. get blendMode(): number;
  24377. set blendMode(blendMode: number);
  24378. /** Disables writing to the depth buffer when rendering the sprites.
  24379. * It can be handy to disable depth writing when using textures without alpha channel
  24380. * and setting some specific blend modes.
  24381. */
  24382. disableDepthWrite: boolean;
  24383. private _spriteRenderer;
  24384. /** Associative array from JSON sprite data file */
  24385. private _cellData;
  24386. /** Array of sprite names from JSON sprite data file */
  24387. private _spriteMap;
  24388. /** True when packed cell data from JSON file is ready*/
  24389. private _packedAndReady;
  24390. private _textureContent;
  24391. private _onDisposeObserver;
  24392. private _fromPacked;
  24393. private _scene;
  24394. /**
  24395. * Creates a new sprite manager
  24396. * @param name defines the manager's name
  24397. * @param imgUrl defines the sprite sheet url
  24398. * @param capacity defines the maximum allowed number of sprites
  24399. * @param cellSize defines the size of a sprite cell
  24400. * @param scene defines the hosting scene
  24401. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24402. * @param samplingMode defines the smapling mode to use with spritesheet
  24403. * @param fromPacked set to false; do not alter
  24404. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24405. */
  24406. constructor(
  24407. /** defines the manager's name */
  24408. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24409. /**
  24410. * Returns the string "SpriteManager"
  24411. * @returns "SpriteManager"
  24412. */
  24413. getClassName(): string;
  24414. private _makePacked;
  24415. private _checkTextureAlpha;
  24416. /**
  24417. * Intersects the sprites with a ray
  24418. * @param ray defines the ray to intersect with
  24419. * @param camera defines the current active camera
  24420. * @param predicate defines a predicate used to select candidate sprites
  24421. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24422. * @returns null if no hit or a PickingInfo
  24423. */
  24424. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24425. /**
  24426. * Intersects the sprites with a ray
  24427. * @param ray defines the ray to intersect with
  24428. * @param camera defines the current active camera
  24429. * @param predicate defines a predicate used to select candidate sprites
  24430. * @returns null if no hit or a PickingInfo array
  24431. */
  24432. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24433. /**
  24434. * Render all child sprites
  24435. */
  24436. render(): void;
  24437. private _customUpdate;
  24438. /**
  24439. * Release associated resources
  24440. */
  24441. dispose(): void;
  24442. /**
  24443. * Serializes the sprite manager to a JSON object
  24444. * @param serializeTexture defines if the texture must be serialized as well
  24445. * @returns the JSON object
  24446. */
  24447. serialize(serializeTexture?: boolean): any;
  24448. /**
  24449. * Parses a JSON object to create a new sprite manager.
  24450. * @param parsedManager The JSON object to parse
  24451. * @param scene The scene to create the sprite managerin
  24452. * @param rootUrl The root url to use to load external dependencies like texture
  24453. * @returns the new sprite manager
  24454. */
  24455. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24456. /**
  24457. * Creates a sprite manager from a snippet saved in a remote file
  24458. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24459. * @param url defines the url to load from
  24460. * @param scene defines the hosting scene
  24461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24462. * @returns a promise that will resolve to the new sprite manager
  24463. */
  24464. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24465. /**
  24466. * Creates a sprite manager from a snippet saved by the sprite editor
  24467. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24468. * @param scene defines the hosting scene
  24469. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24470. * @returns a promise that will resolve to the new sprite manager
  24471. */
  24472. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24473. }
  24474. }
  24475. declare module "babylonjs/Sprites/sprite" {
  24476. import { Vector3 } from "babylonjs/Maths/math.vector";
  24477. import { Nullable } from "babylonjs/types";
  24478. import { ActionManager } from "babylonjs/Actions/actionManager";
  24479. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24480. import { Color4 } from "babylonjs/Maths/math.color";
  24481. import { Observable } from "babylonjs/Misc/observable";
  24482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24483. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24484. import { Animation } from "babylonjs/Animations/animation";
  24485. /**
  24486. * Class used to represent a sprite
  24487. * @see https://doc.babylonjs.com/babylon101/sprites
  24488. */
  24489. export class Sprite extends ThinSprite implements IAnimatable {
  24490. /** defines the name */
  24491. name: string;
  24492. /** Gets or sets the current world position */
  24493. position: Vector3;
  24494. /** Gets or sets the main color */
  24495. color: Color4;
  24496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24497. disposeWhenFinishedAnimating: boolean;
  24498. /** Gets the list of attached animations */
  24499. animations: Nullable<Array<Animation>>;
  24500. /** Gets or sets a boolean indicating if the sprite can be picked */
  24501. isPickable: boolean;
  24502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24503. useAlphaForPicking: boolean;
  24504. /**
  24505. * Gets or sets the associated action manager
  24506. */
  24507. actionManager: Nullable<ActionManager>;
  24508. /**
  24509. * An event triggered when the control has been disposed
  24510. */
  24511. onDisposeObservable: Observable<Sprite>;
  24512. private _manager;
  24513. private _onAnimationEnd;
  24514. /**
  24515. * Gets or sets the sprite size
  24516. */
  24517. get size(): number;
  24518. set size(value: number);
  24519. /**
  24520. * Gets or sets the unique id of the sprite
  24521. */
  24522. uniqueId: number;
  24523. /**
  24524. * Gets the manager of this sprite
  24525. */
  24526. get manager(): ISpriteManager;
  24527. /**
  24528. * Creates a new Sprite
  24529. * @param name defines the name
  24530. * @param manager defines the manager
  24531. */
  24532. constructor(
  24533. /** defines the name */
  24534. name: string, manager: ISpriteManager);
  24535. /**
  24536. * Returns the string "Sprite"
  24537. * @returns "Sprite"
  24538. */
  24539. getClassName(): string;
  24540. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24541. get fromIndex(): number;
  24542. set fromIndex(value: number);
  24543. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24544. get toIndex(): number;
  24545. set toIndex(value: number);
  24546. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24547. get loopAnimation(): boolean;
  24548. set loopAnimation(value: boolean);
  24549. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24550. get delay(): number;
  24551. set delay(value: number);
  24552. /**
  24553. * Starts an animation
  24554. * @param from defines the initial key
  24555. * @param to defines the end key
  24556. * @param loop defines if the animation must loop
  24557. * @param delay defines the start delay (in ms)
  24558. * @param onAnimationEnd defines a callback to call when animation ends
  24559. */
  24560. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24561. private _endAnimation;
  24562. /** Release associated resources */
  24563. dispose(): void;
  24564. /**
  24565. * Serializes the sprite to a JSON object
  24566. * @returns the JSON object
  24567. */
  24568. serialize(): any;
  24569. /**
  24570. * Parses a JSON object to create a new sprite
  24571. * @param parsedSprite The JSON object to parse
  24572. * @param manager defines the hosting manager
  24573. * @returns the new sprite
  24574. */
  24575. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24576. }
  24577. }
  24578. declare module "babylonjs/Collisions/pickingInfo" {
  24579. import { Nullable } from "babylonjs/types";
  24580. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24582. import { Sprite } from "babylonjs/Sprites/sprite";
  24583. import { Ray } from "babylonjs/Culling/ray";
  24584. /**
  24585. * Information about the result of picking within a scene
  24586. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24587. */
  24588. export class PickingInfo {
  24589. /** @hidden */
  24590. _pickingUnavailable: boolean;
  24591. /**
  24592. * If the pick collided with an object
  24593. */
  24594. hit: boolean;
  24595. /**
  24596. * Distance away where the pick collided
  24597. */
  24598. distance: number;
  24599. /**
  24600. * The location of pick collision
  24601. */
  24602. pickedPoint: Nullable<Vector3>;
  24603. /**
  24604. * The mesh corresponding the the pick collision
  24605. */
  24606. pickedMesh: Nullable<AbstractMesh>;
  24607. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24608. bu: number;
  24609. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24610. bv: number;
  24611. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24612. faceId: number;
  24613. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24614. subMeshFaceId: number;
  24615. /** Id of the the submesh that was picked */
  24616. subMeshId: number;
  24617. /** If a sprite was picked, this will be the sprite the pick collided with */
  24618. pickedSprite: Nullable<Sprite>;
  24619. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24620. thinInstanceIndex: number;
  24621. /**
  24622. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24623. */
  24624. originMesh: Nullable<AbstractMesh>;
  24625. /**
  24626. * The ray that was used to perform the picking.
  24627. */
  24628. ray: Nullable<Ray>;
  24629. /**
  24630. * Gets the normal correspodning to the face the pick collided with
  24631. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24632. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24633. * @returns The normal correspodning to the face the pick collided with
  24634. */
  24635. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24636. /**
  24637. * Gets the texture coordinates of where the pick occured
  24638. * @returns the vector containing the coordnates of the texture
  24639. */
  24640. getTextureCoordinates(): Nullable<Vector2>;
  24641. }
  24642. }
  24643. declare module "babylonjs/Events/pointerEvents" {
  24644. import { Nullable } from "babylonjs/types";
  24645. import { Vector2 } from "babylonjs/Maths/math.vector";
  24646. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24647. import { Ray } from "babylonjs/Culling/ray";
  24648. /**
  24649. * Gather the list of pointer event types as constants.
  24650. */
  24651. export class PointerEventTypes {
  24652. /**
  24653. * 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.
  24654. */
  24655. static readonly POINTERDOWN: number;
  24656. /**
  24657. * The pointerup event is fired when a pointer is no longer active.
  24658. */
  24659. static readonly POINTERUP: number;
  24660. /**
  24661. * The pointermove event is fired when a pointer changes coordinates.
  24662. */
  24663. static readonly POINTERMOVE: number;
  24664. /**
  24665. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24666. */
  24667. static readonly POINTERWHEEL: number;
  24668. /**
  24669. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24670. */
  24671. static readonly POINTERPICK: number;
  24672. /**
  24673. * The pointertap event is fired when a the object has been touched and released without drag.
  24674. */
  24675. static readonly POINTERTAP: number;
  24676. /**
  24677. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24678. */
  24679. static readonly POINTERDOUBLETAP: number;
  24680. }
  24681. /**
  24682. * Base class of pointer info types.
  24683. */
  24684. export class PointerInfoBase {
  24685. /**
  24686. * Defines the type of event (PointerEventTypes)
  24687. */
  24688. type: number;
  24689. /**
  24690. * Defines the related dom event
  24691. */
  24692. event: PointerEvent | MouseWheelEvent;
  24693. /**
  24694. * Instantiates the base class of pointers info.
  24695. * @param type Defines the type of event (PointerEventTypes)
  24696. * @param event Defines the related dom event
  24697. */
  24698. constructor(
  24699. /**
  24700. * Defines the type of event (PointerEventTypes)
  24701. */
  24702. type: number,
  24703. /**
  24704. * Defines the related dom event
  24705. */
  24706. event: PointerEvent | MouseWheelEvent);
  24707. }
  24708. /**
  24709. * This class is used to store pointer related info for the onPrePointerObservable event.
  24710. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24711. */
  24712. export class PointerInfoPre extends PointerInfoBase {
  24713. /**
  24714. * Ray from a pointer if availible (eg. 6dof controller)
  24715. */
  24716. ray: Nullable<Ray>;
  24717. /**
  24718. * Defines the local position of the pointer on the canvas.
  24719. */
  24720. localPosition: Vector2;
  24721. /**
  24722. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24723. */
  24724. skipOnPointerObservable: boolean;
  24725. /**
  24726. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24727. * @param type Defines the type of event (PointerEventTypes)
  24728. * @param event Defines the related dom event
  24729. * @param localX Defines the local x coordinates of the pointer when the event occured
  24730. * @param localY Defines the local y coordinates of the pointer when the event occured
  24731. */
  24732. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24733. }
  24734. /**
  24735. * This type contains all the data related to a pointer event in Babylon.js.
  24736. * 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.
  24737. */
  24738. export class PointerInfo extends PointerInfoBase {
  24739. /**
  24740. * Defines the picking info associated to the info (if any)\
  24741. */
  24742. pickInfo: Nullable<PickingInfo>;
  24743. /**
  24744. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24745. * @param type Defines the type of event (PointerEventTypes)
  24746. * @param event Defines the related dom event
  24747. * @param pickInfo Defines the picking info associated to the info (if any)\
  24748. */
  24749. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24750. /**
  24751. * Defines the picking info associated to the info (if any)\
  24752. */
  24753. pickInfo: Nullable<PickingInfo>);
  24754. }
  24755. /**
  24756. * Data relating to a touch event on the screen.
  24757. */
  24758. export interface PointerTouch {
  24759. /**
  24760. * X coordinate of touch.
  24761. */
  24762. x: number;
  24763. /**
  24764. * Y coordinate of touch.
  24765. */
  24766. y: number;
  24767. /**
  24768. * Id of touch. Unique for each finger.
  24769. */
  24770. pointerId: number;
  24771. /**
  24772. * Event type passed from DOM.
  24773. */
  24774. type: any;
  24775. }
  24776. }
  24777. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24778. import { Observable } from "babylonjs/Misc/observable";
  24779. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24780. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24781. /**
  24782. * Manage the mouse inputs to control the movement of a free camera.
  24783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24784. */
  24785. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24786. /**
  24787. * Define if touch is enabled in the mouse input
  24788. */
  24789. touchEnabled: boolean;
  24790. /**
  24791. * Defines the camera the input is attached to.
  24792. */
  24793. camera: FreeCamera;
  24794. /**
  24795. * Defines the buttons associated with the input to handle camera move.
  24796. */
  24797. buttons: number[];
  24798. /**
  24799. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24800. */
  24801. angularSensibility: number;
  24802. private _pointerInput;
  24803. private _onMouseMove;
  24804. private _observer;
  24805. private previousPosition;
  24806. /**
  24807. * Observable for when a pointer move event occurs containing the move offset
  24808. */
  24809. onPointerMovedObservable: Observable<{
  24810. offsetX: number;
  24811. offsetY: number;
  24812. }>;
  24813. /**
  24814. * @hidden
  24815. * If the camera should be rotated automatically based on pointer movement
  24816. */
  24817. _allowCameraRotation: boolean;
  24818. /**
  24819. * Manage the mouse inputs to control the movement of a free camera.
  24820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24821. * @param touchEnabled Defines if touch is enabled or not
  24822. */
  24823. constructor(
  24824. /**
  24825. * Define if touch is enabled in the mouse input
  24826. */
  24827. touchEnabled?: boolean);
  24828. /**
  24829. * Attach the input controls to a specific dom element to get the input from.
  24830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24831. */
  24832. attachControl(noPreventDefault?: boolean): void;
  24833. /**
  24834. * Called on JS contextmenu event.
  24835. * Override this method to provide functionality.
  24836. */
  24837. protected onContextMenu(evt: PointerEvent): void;
  24838. /**
  24839. * Detach the current controls from the specified dom element.
  24840. */
  24841. detachControl(): void;
  24842. /**
  24843. * Gets the class name of the current intput.
  24844. * @returns the class name
  24845. */
  24846. getClassName(): string;
  24847. /**
  24848. * Get the friendly name associated with the input class.
  24849. * @returns the input friendly name
  24850. */
  24851. getSimpleName(): string;
  24852. }
  24853. }
  24854. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24855. import { Observable } from "babylonjs/Misc/observable";
  24856. import { Camera } from "babylonjs/Cameras/camera";
  24857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24858. /**
  24859. * Base class for mouse wheel input..
  24860. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24861. * for example usage.
  24862. */
  24863. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24864. /**
  24865. * Defines the camera the input is attached to.
  24866. */
  24867. abstract camera: Camera;
  24868. /**
  24869. * How fast is the camera moves in relation to X axis mouseWheel events.
  24870. * Use negative value to reverse direction.
  24871. */
  24872. wheelPrecisionX: number;
  24873. /**
  24874. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24875. * Use negative value to reverse direction.
  24876. */
  24877. wheelPrecisionY: number;
  24878. /**
  24879. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24880. * Use negative value to reverse direction.
  24881. */
  24882. wheelPrecisionZ: number;
  24883. /**
  24884. * Observable for when a mouse wheel move event occurs.
  24885. */
  24886. onChangedObservable: Observable<{
  24887. wheelDeltaX: number;
  24888. wheelDeltaY: number;
  24889. wheelDeltaZ: number;
  24890. }>;
  24891. private _wheel;
  24892. private _observer;
  24893. /**
  24894. * Attach the input controls to a specific dom element to get the input from.
  24895. * @param noPreventDefault Defines whether event caught by the controls
  24896. * should call preventdefault().
  24897. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24898. */
  24899. attachControl(noPreventDefault?: boolean): void;
  24900. /**
  24901. * Detach the current controls from the specified dom element.
  24902. */
  24903. detachControl(): void;
  24904. /**
  24905. * Called for each rendered frame.
  24906. */
  24907. checkInputs(): void;
  24908. /**
  24909. * Gets the class name of the current intput.
  24910. * @returns the class name
  24911. */
  24912. getClassName(): string;
  24913. /**
  24914. * Get the friendly name associated with the input class.
  24915. * @returns the input friendly name
  24916. */
  24917. getSimpleName(): string;
  24918. /**
  24919. * Incremental value of multiple mouse wheel movements of the X axis.
  24920. * Should be zero-ed when read.
  24921. */
  24922. protected _wheelDeltaX: number;
  24923. /**
  24924. * Incremental value of multiple mouse wheel movements of the Y axis.
  24925. * Should be zero-ed when read.
  24926. */
  24927. protected _wheelDeltaY: number;
  24928. /**
  24929. * Incremental value of multiple mouse wheel movements of the Z axis.
  24930. * Should be zero-ed when read.
  24931. */
  24932. protected _wheelDeltaZ: number;
  24933. /**
  24934. * Firefox uses a different scheme to report scroll distances to other
  24935. * browsers. Rather than use complicated methods to calculate the exact
  24936. * multiple we need to apply, let's just cheat and use a constant.
  24937. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24938. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24939. */
  24940. private readonly _ffMultiplier;
  24941. /**
  24942. * Different event attributes for wheel data fall into a few set ranges.
  24943. * Some relevant but dated date here:
  24944. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24945. */
  24946. private readonly _normalize;
  24947. }
  24948. }
  24949. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24950. import { Nullable } from "babylonjs/types";
  24951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24952. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24953. import { Coordinate } from "babylonjs/Maths/math.axis";
  24954. /**
  24955. * Manage the mouse wheel inputs to control a free camera.
  24956. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24957. */
  24958. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24959. /**
  24960. * Defines the camera the input is attached to.
  24961. */
  24962. camera: FreeCamera;
  24963. /**
  24964. * Gets the class name of the current input.
  24965. * @returns the class name
  24966. */
  24967. getClassName(): string;
  24968. /**
  24969. * Set which movement axis (relative to camera's orientation) the mouse
  24970. * wheel's X axis controls.
  24971. * @param axis The axis to be moved. Set null to clear.
  24972. */
  24973. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24974. /**
  24975. * Get the configured movement axis (relative to camera's orientation) the
  24976. * mouse wheel's X axis controls.
  24977. * @returns The configured axis or null if none.
  24978. */
  24979. get wheelXMoveRelative(): Nullable<Coordinate>;
  24980. /**
  24981. * Set which movement axis (relative to camera's orientation) the mouse
  24982. * wheel's Y axis controls.
  24983. * @param axis The axis to be moved. Set null to clear.
  24984. */
  24985. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24986. /**
  24987. * Get the configured movement axis (relative to camera's orientation) the
  24988. * mouse wheel's Y axis controls.
  24989. * @returns The configured axis or null if none.
  24990. */
  24991. get wheelYMoveRelative(): Nullable<Coordinate>;
  24992. /**
  24993. * Set which movement axis (relative to camera's orientation) the mouse
  24994. * wheel's Z axis controls.
  24995. * @param axis The axis to be moved. Set null to clear.
  24996. */
  24997. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24998. /**
  24999. * Get the configured movement axis (relative to camera's orientation) the
  25000. * mouse wheel's Z axis controls.
  25001. * @returns The configured axis or null if none.
  25002. */
  25003. get wheelZMoveRelative(): Nullable<Coordinate>;
  25004. /**
  25005. * Set which rotation axis (relative to camera's orientation) the mouse
  25006. * wheel's X axis controls.
  25007. * @param axis The axis to be moved. Set null to clear.
  25008. */
  25009. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25010. /**
  25011. * Get the configured rotation axis (relative to camera's orientation) the
  25012. * mouse wheel's X axis controls.
  25013. * @returns The configured axis or null if none.
  25014. */
  25015. get wheelXRotateRelative(): Nullable<Coordinate>;
  25016. /**
  25017. * Set which rotation axis (relative to camera's orientation) the mouse
  25018. * wheel's Y axis controls.
  25019. * @param axis The axis to be moved. Set null to clear.
  25020. */
  25021. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25022. /**
  25023. * Get the configured rotation axis (relative to camera's orientation) the
  25024. * mouse wheel's Y axis controls.
  25025. * @returns The configured axis or null if none.
  25026. */
  25027. get wheelYRotateRelative(): Nullable<Coordinate>;
  25028. /**
  25029. * Set which rotation axis (relative to camera's orientation) the mouse
  25030. * wheel's Z axis controls.
  25031. * @param axis The axis to be moved. Set null to clear.
  25032. */
  25033. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25034. /**
  25035. * Get the configured rotation axis (relative to camera's orientation) the
  25036. * mouse wheel's Z axis controls.
  25037. * @returns The configured axis or null if none.
  25038. */
  25039. get wheelZRotateRelative(): Nullable<Coordinate>;
  25040. /**
  25041. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25042. * controls.
  25043. * @param axis The axis to be moved. Set null to clear.
  25044. */
  25045. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25046. /**
  25047. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25048. * X axis controls.
  25049. * @returns The configured axis or null if none.
  25050. */
  25051. get wheelXMoveScene(): Nullable<Coordinate>;
  25052. /**
  25053. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25054. * controls.
  25055. * @param axis The axis to be moved. Set null to clear.
  25056. */
  25057. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25058. /**
  25059. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25060. * Y axis controls.
  25061. * @returns The configured axis or null if none.
  25062. */
  25063. get wheelYMoveScene(): Nullable<Coordinate>;
  25064. /**
  25065. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25066. * controls.
  25067. * @param axis The axis to be moved. Set null to clear.
  25068. */
  25069. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25070. /**
  25071. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25072. * Z axis controls.
  25073. * @returns The configured axis or null if none.
  25074. */
  25075. get wheelZMoveScene(): Nullable<Coordinate>;
  25076. /**
  25077. * Called for each rendered frame.
  25078. */
  25079. checkInputs(): void;
  25080. private _moveRelative;
  25081. private _rotateRelative;
  25082. private _moveScene;
  25083. /**
  25084. * These are set to the desired default behaviour.
  25085. */
  25086. private _wheelXAction;
  25087. private _wheelXActionCoordinate;
  25088. private _wheelYAction;
  25089. private _wheelYActionCoordinate;
  25090. private _wheelZAction;
  25091. private _wheelZActionCoordinate;
  25092. /**
  25093. * Update the camera according to any configured properties for the 3
  25094. * mouse-wheel axis.
  25095. */
  25096. private _updateCamera;
  25097. }
  25098. }
  25099. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25100. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25101. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25102. /**
  25103. * Manage the touch inputs to control the movement of a free camera.
  25104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25105. */
  25106. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25107. /**
  25108. * Define if mouse events can be treated as touch events
  25109. */
  25110. allowMouse: boolean;
  25111. /**
  25112. * Defines the camera the input is attached to.
  25113. */
  25114. camera: FreeCamera;
  25115. /**
  25116. * Defines the touch sensibility for rotation.
  25117. * The higher the faster.
  25118. */
  25119. touchAngularSensibility: number;
  25120. /**
  25121. * Defines the touch sensibility for move.
  25122. * The higher the faster.
  25123. */
  25124. touchMoveSensibility: number;
  25125. private _offsetX;
  25126. private _offsetY;
  25127. private _pointerPressed;
  25128. private _pointerInput?;
  25129. private _observer;
  25130. private _onLostFocus;
  25131. /**
  25132. * Manage the touch inputs to control the movement of a free camera.
  25133. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25134. * @param allowMouse Defines if mouse events can be treated as touch events
  25135. */
  25136. constructor(
  25137. /**
  25138. * Define if mouse events can be treated as touch events
  25139. */
  25140. allowMouse?: boolean);
  25141. /**
  25142. * Attach the input controls to a specific dom element to get the input from.
  25143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25144. */
  25145. attachControl(noPreventDefault?: boolean): void;
  25146. /**
  25147. * Detach the current controls from the specified dom element.
  25148. */
  25149. detachControl(): void;
  25150. /**
  25151. * Update the current camera state depending on the inputs that have been used this frame.
  25152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25153. */
  25154. checkInputs(): void;
  25155. /**
  25156. * Gets the class name of the current intput.
  25157. * @returns the class name
  25158. */
  25159. getClassName(): string;
  25160. /**
  25161. * Get the friendly name associated with the input class.
  25162. * @returns the input friendly name
  25163. */
  25164. getSimpleName(): string;
  25165. }
  25166. }
  25167. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25170. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25171. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25172. import { Nullable } from "babylonjs/types";
  25173. /**
  25174. * Default Inputs manager for the FreeCamera.
  25175. * It groups all the default supported inputs for ease of use.
  25176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25177. */
  25178. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25179. /**
  25180. * @hidden
  25181. */
  25182. _mouseInput: Nullable<FreeCameraMouseInput>;
  25183. /**
  25184. * @hidden
  25185. */
  25186. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25187. /**
  25188. * Instantiates a new FreeCameraInputsManager.
  25189. * @param camera Defines the camera the inputs belong to
  25190. */
  25191. constructor(camera: FreeCamera);
  25192. /**
  25193. * Add keyboard input support to the input manager.
  25194. * @returns the current input manager
  25195. */
  25196. addKeyboard(): FreeCameraInputsManager;
  25197. /**
  25198. * Add mouse input support to the input manager.
  25199. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25200. * @returns the current input manager
  25201. */
  25202. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25203. /**
  25204. * Removes the mouse input support from the manager
  25205. * @returns the current input manager
  25206. */
  25207. removeMouse(): FreeCameraInputsManager;
  25208. /**
  25209. * Add mouse wheel input support to the input manager.
  25210. * @returns the current input manager
  25211. */
  25212. addMouseWheel(): FreeCameraInputsManager;
  25213. /**
  25214. * Removes the mouse wheel input support from the manager
  25215. * @returns the current input manager
  25216. */
  25217. removeMouseWheel(): FreeCameraInputsManager;
  25218. /**
  25219. * Add touch input support to the input manager.
  25220. * @returns the current input manager
  25221. */
  25222. addTouch(): FreeCameraInputsManager;
  25223. /**
  25224. * Remove all attached input methods from a camera
  25225. */
  25226. clear(): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/freeCamera" {
  25230. import { Vector3 } from "babylonjs/Maths/math.vector";
  25231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25232. import { Scene } from "babylonjs/scene";
  25233. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25234. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25235. /**
  25236. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25237. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25238. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25239. */
  25240. export class FreeCamera extends TargetCamera {
  25241. /**
  25242. * Define the collision ellipsoid of the camera.
  25243. * This is helpful to simulate a camera body like the player body around the camera
  25244. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25245. */
  25246. ellipsoid: Vector3;
  25247. /**
  25248. * Define an offset for the position of the ellipsoid around the camera.
  25249. * This can be helpful to determine the center of the body near the gravity center of the body
  25250. * instead of its head.
  25251. */
  25252. ellipsoidOffset: Vector3;
  25253. /**
  25254. * Enable or disable collisions of the camera with the rest of the scene objects.
  25255. */
  25256. checkCollisions: boolean;
  25257. /**
  25258. * Enable or disable gravity on the camera.
  25259. */
  25260. applyGravity: boolean;
  25261. /**
  25262. * Define the input manager associated to the camera.
  25263. */
  25264. inputs: FreeCameraInputsManager;
  25265. /**
  25266. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25267. * Higher values reduce sensitivity.
  25268. */
  25269. get angularSensibility(): number;
  25270. /**
  25271. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25272. * Higher values reduce sensitivity.
  25273. */
  25274. set angularSensibility(value: number);
  25275. /**
  25276. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25277. */
  25278. get keysUp(): number[];
  25279. set keysUp(value: number[]);
  25280. /**
  25281. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25282. */
  25283. get keysUpward(): number[];
  25284. set keysUpward(value: number[]);
  25285. /**
  25286. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25287. */
  25288. get keysDown(): number[];
  25289. set keysDown(value: number[]);
  25290. /**
  25291. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25292. */
  25293. get keysDownward(): number[];
  25294. set keysDownward(value: number[]);
  25295. /**
  25296. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25297. */
  25298. get keysLeft(): number[];
  25299. set keysLeft(value: number[]);
  25300. /**
  25301. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25302. */
  25303. get keysRight(): number[];
  25304. set keysRight(value: number[]);
  25305. /**
  25306. * Event raised when the camera collide with a mesh in the scene.
  25307. */
  25308. onCollide: (collidedMesh: AbstractMesh) => void;
  25309. private _collider;
  25310. private _needMoveForGravity;
  25311. private _oldPosition;
  25312. private _diffPosition;
  25313. private _newPosition;
  25314. /** @hidden */
  25315. _localDirection: Vector3;
  25316. /** @hidden */
  25317. _transformedDirection: Vector3;
  25318. /**
  25319. * Instantiates a Free Camera.
  25320. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25321. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25322. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25323. * @param name Define the name of the camera in the scene
  25324. * @param position Define the start position of the camera in the scene
  25325. * @param scene Define the scene the camera belongs to
  25326. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25327. */
  25328. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25329. /**
  25330. * Attach the input controls to a specific dom element to get the input from.
  25331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25332. */
  25333. attachControl(noPreventDefault?: boolean): void;
  25334. /**
  25335. * Attach the input controls to a specific dom element to get the input from.
  25336. * @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
  25337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25338. * BACK COMPAT SIGNATURE ONLY.
  25339. */
  25340. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25341. /**
  25342. * Detach the current controls from the specified dom element.
  25343. */
  25344. detachControl(): void;
  25345. /**
  25346. * Detach the current controls from the specified dom element.
  25347. * @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
  25348. */
  25349. detachControl(ignored: any): void;
  25350. private _collisionMask;
  25351. /**
  25352. * Define a collision mask to limit the list of object the camera can collide with
  25353. */
  25354. get collisionMask(): number;
  25355. set collisionMask(mask: number);
  25356. /** @hidden */
  25357. _collideWithWorld(displacement: Vector3): void;
  25358. private _onCollisionPositionChange;
  25359. /** @hidden */
  25360. _checkInputs(): void;
  25361. /** @hidden */
  25362. _decideIfNeedsToMove(): boolean;
  25363. /** @hidden */
  25364. _updatePosition(): void;
  25365. /**
  25366. * Destroy the camera and release the current resources hold by it.
  25367. */
  25368. dispose(): void;
  25369. /**
  25370. * Gets the current object class name.
  25371. * @return the class name
  25372. */
  25373. getClassName(): string;
  25374. }
  25375. }
  25376. declare module "babylonjs/Gamepads/gamepad" {
  25377. import { Observable } from "babylonjs/Misc/observable";
  25378. /**
  25379. * Represents a gamepad control stick position
  25380. */
  25381. export class StickValues {
  25382. /**
  25383. * The x component of the control stick
  25384. */
  25385. x: number;
  25386. /**
  25387. * The y component of the control stick
  25388. */
  25389. y: number;
  25390. /**
  25391. * Initializes the gamepad x and y control stick values
  25392. * @param x The x component of the gamepad control stick value
  25393. * @param y The y component of the gamepad control stick value
  25394. */
  25395. constructor(
  25396. /**
  25397. * The x component of the control stick
  25398. */
  25399. x: number,
  25400. /**
  25401. * The y component of the control stick
  25402. */
  25403. y: number);
  25404. }
  25405. /**
  25406. * An interface which manages callbacks for gamepad button changes
  25407. */
  25408. export interface GamepadButtonChanges {
  25409. /**
  25410. * Called when a gamepad has been changed
  25411. */
  25412. changed: boolean;
  25413. /**
  25414. * Called when a gamepad press event has been triggered
  25415. */
  25416. pressChanged: boolean;
  25417. /**
  25418. * Called when a touch event has been triggered
  25419. */
  25420. touchChanged: boolean;
  25421. /**
  25422. * Called when a value has changed
  25423. */
  25424. valueChanged: boolean;
  25425. }
  25426. /**
  25427. * Represents a gamepad
  25428. */
  25429. export class Gamepad {
  25430. /**
  25431. * The id of the gamepad
  25432. */
  25433. id: string;
  25434. /**
  25435. * The index of the gamepad
  25436. */
  25437. index: number;
  25438. /**
  25439. * The browser gamepad
  25440. */
  25441. browserGamepad: any;
  25442. /**
  25443. * Specifies what type of gamepad this represents
  25444. */
  25445. type: number;
  25446. private _leftStick;
  25447. private _rightStick;
  25448. /** @hidden */
  25449. _isConnected: boolean;
  25450. private _leftStickAxisX;
  25451. private _leftStickAxisY;
  25452. private _rightStickAxisX;
  25453. private _rightStickAxisY;
  25454. /**
  25455. * Triggered when the left control stick has been changed
  25456. */
  25457. private _onleftstickchanged;
  25458. /**
  25459. * Triggered when the right control stick has been changed
  25460. */
  25461. private _onrightstickchanged;
  25462. /**
  25463. * Represents a gamepad controller
  25464. */
  25465. static GAMEPAD: number;
  25466. /**
  25467. * Represents a generic controller
  25468. */
  25469. static GENERIC: number;
  25470. /**
  25471. * Represents an XBox controller
  25472. */
  25473. static XBOX: number;
  25474. /**
  25475. * Represents a pose-enabled controller
  25476. */
  25477. static POSE_ENABLED: number;
  25478. /**
  25479. * Represents an Dual Shock controller
  25480. */
  25481. static DUALSHOCK: number;
  25482. /**
  25483. * Specifies whether the left control stick should be Y-inverted
  25484. */
  25485. protected _invertLeftStickY: boolean;
  25486. /**
  25487. * Specifies if the gamepad has been connected
  25488. */
  25489. get isConnected(): boolean;
  25490. /**
  25491. * Initializes the gamepad
  25492. * @param id The id of the gamepad
  25493. * @param index The index of the gamepad
  25494. * @param browserGamepad The browser gamepad
  25495. * @param leftStickX The x component of the left joystick
  25496. * @param leftStickY The y component of the left joystick
  25497. * @param rightStickX The x component of the right joystick
  25498. * @param rightStickY The y component of the right joystick
  25499. */
  25500. constructor(
  25501. /**
  25502. * The id of the gamepad
  25503. */
  25504. id: string,
  25505. /**
  25506. * The index of the gamepad
  25507. */
  25508. index: number,
  25509. /**
  25510. * The browser gamepad
  25511. */
  25512. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25513. /**
  25514. * Callback triggered when the left joystick has changed
  25515. * @param callback
  25516. */
  25517. onleftstickchanged(callback: (values: StickValues) => void): void;
  25518. /**
  25519. * Callback triggered when the right joystick has changed
  25520. * @param callback
  25521. */
  25522. onrightstickchanged(callback: (values: StickValues) => void): void;
  25523. /**
  25524. * Gets the left joystick
  25525. */
  25526. get leftStick(): StickValues;
  25527. /**
  25528. * Sets the left joystick values
  25529. */
  25530. set leftStick(newValues: StickValues);
  25531. /**
  25532. * Gets the right joystick
  25533. */
  25534. get rightStick(): StickValues;
  25535. /**
  25536. * Sets the right joystick value
  25537. */
  25538. set rightStick(newValues: StickValues);
  25539. /**
  25540. * Updates the gamepad joystick positions
  25541. */
  25542. update(): void;
  25543. /**
  25544. * Disposes the gamepad
  25545. */
  25546. dispose(): void;
  25547. }
  25548. /**
  25549. * Represents a generic gamepad
  25550. */
  25551. export class GenericPad extends Gamepad {
  25552. private _buttons;
  25553. private _onbuttondown;
  25554. private _onbuttonup;
  25555. /**
  25556. * Observable triggered when a button has been pressed
  25557. */
  25558. onButtonDownObservable: Observable<number>;
  25559. /**
  25560. * Observable triggered when a button has been released
  25561. */
  25562. onButtonUpObservable: Observable<number>;
  25563. /**
  25564. * Callback triggered when a button has been pressed
  25565. * @param callback Called when a button has been pressed
  25566. */
  25567. onbuttondown(callback: (buttonPressed: number) => void): void;
  25568. /**
  25569. * Callback triggered when a button has been released
  25570. * @param callback Called when a button has been released
  25571. */
  25572. onbuttonup(callback: (buttonReleased: number) => void): void;
  25573. /**
  25574. * Initializes the generic gamepad
  25575. * @param id The id of the generic gamepad
  25576. * @param index The index of the generic gamepad
  25577. * @param browserGamepad The browser gamepad
  25578. */
  25579. constructor(id: string, index: number, browserGamepad: any);
  25580. private _setButtonValue;
  25581. /**
  25582. * Updates the generic gamepad
  25583. */
  25584. update(): void;
  25585. /**
  25586. * Disposes the generic gamepad
  25587. */
  25588. dispose(): void;
  25589. }
  25590. }
  25591. declare module "babylonjs/Animations/runtimeAnimation" {
  25592. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25593. import { Animatable } from "babylonjs/Animations/animatable";
  25594. import { Scene } from "babylonjs/scene";
  25595. /**
  25596. * Defines a runtime animation
  25597. */
  25598. export class RuntimeAnimation {
  25599. private _events;
  25600. /**
  25601. * The current frame of the runtime animation
  25602. */
  25603. private _currentFrame;
  25604. /**
  25605. * The animation used by the runtime animation
  25606. */
  25607. private _animation;
  25608. /**
  25609. * The target of the runtime animation
  25610. */
  25611. private _target;
  25612. /**
  25613. * The initiating animatable
  25614. */
  25615. private _host;
  25616. /**
  25617. * The original value of the runtime animation
  25618. */
  25619. private _originalValue;
  25620. /**
  25621. * The original blend value of the runtime animation
  25622. */
  25623. private _originalBlendValue;
  25624. /**
  25625. * The offsets cache of the runtime animation
  25626. */
  25627. private _offsetsCache;
  25628. /**
  25629. * The high limits cache of the runtime animation
  25630. */
  25631. private _highLimitsCache;
  25632. /**
  25633. * Specifies if the runtime animation has been stopped
  25634. */
  25635. private _stopped;
  25636. /**
  25637. * The blending factor of the runtime animation
  25638. */
  25639. private _blendingFactor;
  25640. /**
  25641. * The BabylonJS scene
  25642. */
  25643. private _scene;
  25644. /**
  25645. * The current value of the runtime animation
  25646. */
  25647. private _currentValue;
  25648. /** @hidden */
  25649. _animationState: _IAnimationState;
  25650. /**
  25651. * The active target of the runtime animation
  25652. */
  25653. private _activeTargets;
  25654. private _currentActiveTarget;
  25655. private _directTarget;
  25656. /**
  25657. * The target path of the runtime animation
  25658. */
  25659. private _targetPath;
  25660. /**
  25661. * The weight of the runtime animation
  25662. */
  25663. private _weight;
  25664. /**
  25665. * The ratio offset of the runtime animation
  25666. */
  25667. private _ratioOffset;
  25668. /**
  25669. * The previous delay of the runtime animation
  25670. */
  25671. private _previousDelay;
  25672. /**
  25673. * The previous ratio of the runtime animation
  25674. */
  25675. private _previousRatio;
  25676. private _enableBlending;
  25677. private _keys;
  25678. private _minFrame;
  25679. private _maxFrame;
  25680. private _minValue;
  25681. private _maxValue;
  25682. private _targetIsArray;
  25683. /**
  25684. * Gets the current frame of the runtime animation
  25685. */
  25686. get currentFrame(): number;
  25687. /**
  25688. * Gets the weight of the runtime animation
  25689. */
  25690. get weight(): number;
  25691. /**
  25692. * Gets the current value of the runtime animation
  25693. */
  25694. get currentValue(): any;
  25695. /**
  25696. * Gets the target path of the runtime animation
  25697. */
  25698. get targetPath(): string;
  25699. /**
  25700. * Gets the actual target of the runtime animation
  25701. */
  25702. get target(): any;
  25703. /**
  25704. * Gets the additive state of the runtime animation
  25705. */
  25706. get isAdditive(): boolean;
  25707. /** @hidden */
  25708. _onLoop: () => void;
  25709. /**
  25710. * Create a new RuntimeAnimation object
  25711. * @param target defines the target of the animation
  25712. * @param animation defines the source animation object
  25713. * @param scene defines the hosting scene
  25714. * @param host defines the initiating Animatable
  25715. */
  25716. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25717. private _preparePath;
  25718. /**
  25719. * Gets the animation from the runtime animation
  25720. */
  25721. get animation(): Animation;
  25722. /**
  25723. * Resets the runtime animation to the beginning
  25724. * @param restoreOriginal defines whether to restore the target property to the original value
  25725. */
  25726. reset(restoreOriginal?: boolean): void;
  25727. /**
  25728. * Specifies if the runtime animation is stopped
  25729. * @returns Boolean specifying if the runtime animation is stopped
  25730. */
  25731. isStopped(): boolean;
  25732. /**
  25733. * Disposes of the runtime animation
  25734. */
  25735. dispose(): void;
  25736. /**
  25737. * Apply the interpolated value to the target
  25738. * @param currentValue defines the value computed by the animation
  25739. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25740. */
  25741. setValue(currentValue: any, weight: number): void;
  25742. private _getOriginalValues;
  25743. private _setValue;
  25744. /**
  25745. * Gets the loop pmode of the runtime animation
  25746. * @returns Loop Mode
  25747. */
  25748. private _getCorrectLoopMode;
  25749. /**
  25750. * Move the current animation to a given frame
  25751. * @param frame defines the frame to move to
  25752. */
  25753. goToFrame(frame: number): void;
  25754. /**
  25755. * @hidden Internal use only
  25756. */
  25757. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25758. /**
  25759. * Execute the current animation
  25760. * @param delay defines the delay to add to the current frame
  25761. * @param from defines the lower bound of the animation range
  25762. * @param to defines the upper bound of the animation range
  25763. * @param loop defines if the current animation must loop
  25764. * @param speedRatio defines the current speed ratio
  25765. * @param weight defines the weight of the animation (default is -1 so no weight)
  25766. * @param onLoop optional callback called when animation loops
  25767. * @returns a boolean indicating if the animation is running
  25768. */
  25769. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25770. }
  25771. }
  25772. declare module "babylonjs/Animations/animatable" {
  25773. import { Animation } from "babylonjs/Animations/animation";
  25774. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25775. import { Nullable } from "babylonjs/types";
  25776. import { Observable } from "babylonjs/Misc/observable";
  25777. import { Scene } from "babylonjs/scene";
  25778. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25779. import { Node } from "babylonjs/node";
  25780. /**
  25781. * Class used to store an actual running animation
  25782. */
  25783. export class Animatable {
  25784. /** defines the target object */
  25785. target: any;
  25786. /** defines the starting frame number (default is 0) */
  25787. fromFrame: number;
  25788. /** defines the ending frame number (default is 100) */
  25789. toFrame: number;
  25790. /** defines if the animation must loop (default is false) */
  25791. loopAnimation: boolean;
  25792. /** defines a callback to call when animation ends if it is not looping */
  25793. onAnimationEnd?: (() => void) | null | undefined;
  25794. /** defines a callback to call when animation loops */
  25795. onAnimationLoop?: (() => void) | null | undefined;
  25796. /** defines whether the animation should be evaluated additively */
  25797. isAdditive: boolean;
  25798. private _localDelayOffset;
  25799. private _pausedDelay;
  25800. private _runtimeAnimations;
  25801. private _paused;
  25802. private _scene;
  25803. private _speedRatio;
  25804. private _weight;
  25805. private _syncRoot;
  25806. /**
  25807. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25808. * This will only apply for non looping animation (default is true)
  25809. */
  25810. disposeOnEnd: boolean;
  25811. /**
  25812. * Gets a boolean indicating if the animation has started
  25813. */
  25814. animationStarted: boolean;
  25815. /**
  25816. * Observer raised when the animation ends
  25817. */
  25818. onAnimationEndObservable: Observable<Animatable>;
  25819. /**
  25820. * Observer raised when the animation loops
  25821. */
  25822. onAnimationLoopObservable: Observable<Animatable>;
  25823. /**
  25824. * Gets the root Animatable used to synchronize and normalize animations
  25825. */
  25826. get syncRoot(): Nullable<Animatable>;
  25827. /**
  25828. * Gets the current frame of the first RuntimeAnimation
  25829. * Used to synchronize Animatables
  25830. */
  25831. get masterFrame(): number;
  25832. /**
  25833. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25834. */
  25835. get weight(): number;
  25836. set weight(value: number);
  25837. /**
  25838. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25839. */
  25840. get speedRatio(): number;
  25841. set speedRatio(value: number);
  25842. /**
  25843. * Creates a new Animatable
  25844. * @param scene defines the hosting scene
  25845. * @param target defines the target object
  25846. * @param fromFrame defines the starting frame number (default is 0)
  25847. * @param toFrame defines the ending frame number (default is 100)
  25848. * @param loopAnimation defines if the animation must loop (default is false)
  25849. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25850. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25851. * @param animations defines a group of animation to add to the new Animatable
  25852. * @param onAnimationLoop defines a callback to call when animation loops
  25853. * @param isAdditive defines whether the animation should be evaluated additively
  25854. */
  25855. constructor(scene: Scene,
  25856. /** defines the target object */
  25857. target: any,
  25858. /** defines the starting frame number (default is 0) */
  25859. fromFrame?: number,
  25860. /** defines the ending frame number (default is 100) */
  25861. toFrame?: number,
  25862. /** defines if the animation must loop (default is false) */
  25863. loopAnimation?: boolean, speedRatio?: number,
  25864. /** defines a callback to call when animation ends if it is not looping */
  25865. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25866. /** defines a callback to call when animation loops */
  25867. onAnimationLoop?: (() => void) | null | undefined,
  25868. /** defines whether the animation should be evaluated additively */
  25869. isAdditive?: boolean);
  25870. /**
  25871. * Synchronize and normalize current Animatable with a source Animatable
  25872. * This is useful when using animation weights and when animations are not of the same length
  25873. * @param root defines the root Animatable to synchronize with
  25874. * @returns the current Animatable
  25875. */
  25876. syncWith(root: Animatable): Animatable;
  25877. /**
  25878. * Gets the list of runtime animations
  25879. * @returns an array of RuntimeAnimation
  25880. */
  25881. getAnimations(): RuntimeAnimation[];
  25882. /**
  25883. * Adds more animations to the current animatable
  25884. * @param target defines the target of the animations
  25885. * @param animations defines the new animations to add
  25886. */
  25887. appendAnimations(target: any, animations: Animation[]): void;
  25888. /**
  25889. * Gets the source animation for a specific property
  25890. * @param property defines the propertyu to look for
  25891. * @returns null or the source animation for the given property
  25892. */
  25893. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25894. /**
  25895. * Gets the runtime animation for a specific property
  25896. * @param property defines the propertyu to look for
  25897. * @returns null or the runtime animation for the given property
  25898. */
  25899. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25900. /**
  25901. * Resets the animatable to its original state
  25902. */
  25903. reset(): void;
  25904. /**
  25905. * Allows the animatable to blend with current running animations
  25906. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25907. * @param blendingSpeed defines the blending speed to use
  25908. */
  25909. enableBlending(blendingSpeed: number): void;
  25910. /**
  25911. * Disable animation blending
  25912. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25913. */
  25914. disableBlending(): void;
  25915. /**
  25916. * Jump directly to a given frame
  25917. * @param frame defines the frame to jump to
  25918. */
  25919. goToFrame(frame: number): void;
  25920. /**
  25921. * Pause the animation
  25922. */
  25923. pause(): void;
  25924. /**
  25925. * Restart the animation
  25926. */
  25927. restart(): void;
  25928. private _raiseOnAnimationEnd;
  25929. /**
  25930. * Stop and delete the current animation
  25931. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25932. * @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)
  25933. */
  25934. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25935. /**
  25936. * Wait asynchronously for the animation to end
  25937. * @returns a promise which will be fullfilled when the animation ends
  25938. */
  25939. waitAsync(): Promise<Animatable>;
  25940. /** @hidden */
  25941. _animate(delay: number): boolean;
  25942. }
  25943. module "babylonjs/scene" {
  25944. interface Scene {
  25945. /** @hidden */
  25946. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25947. /** @hidden */
  25948. _processLateAnimationBindingsForMatrices(holder: {
  25949. totalWeight: number;
  25950. totalAdditiveWeight: number;
  25951. animations: RuntimeAnimation[];
  25952. additiveAnimations: RuntimeAnimation[];
  25953. originalValue: Matrix;
  25954. }): any;
  25955. /** @hidden */
  25956. _processLateAnimationBindingsForQuaternions(holder: {
  25957. totalWeight: number;
  25958. totalAdditiveWeight: number;
  25959. animations: RuntimeAnimation[];
  25960. additiveAnimations: RuntimeAnimation[];
  25961. originalValue: Quaternion;
  25962. }, refQuaternion: Quaternion): Quaternion;
  25963. /** @hidden */
  25964. _processLateAnimationBindings(): void;
  25965. /**
  25966. * Will start the animation sequence of a given target
  25967. * @param target defines the target
  25968. * @param from defines from which frame should animation start
  25969. * @param to defines until which frame should animation run.
  25970. * @param weight defines the weight to apply to the animation (1.0 by default)
  25971. * @param loop defines if the animation loops
  25972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25973. * @param onAnimationEnd defines the function to be executed when the animation ends
  25974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25976. * @param onAnimationLoop defines the callback to call when an animation loops
  25977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25978. * @returns the animatable object created for this animation
  25979. */
  25980. 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;
  25981. /**
  25982. * Will start the animation sequence of a given target
  25983. * @param target defines the target
  25984. * @param from defines from which frame should animation start
  25985. * @param to defines until which frame should animation run.
  25986. * @param loop defines if the animation loops
  25987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25988. * @param onAnimationEnd defines the function to be executed when the animation ends
  25989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25991. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25992. * @param onAnimationLoop defines the callback to call when an animation loops
  25993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25994. * @returns the animatable object created for this animation
  25995. */
  25996. 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;
  25997. /**
  25998. * Will start the animation sequence of a given target and its hierarchy
  25999. * @param target defines the target
  26000. * @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.
  26001. * @param from defines from which frame should animation start
  26002. * @param to defines until which frame should animation run.
  26003. * @param loop defines if the animation loops
  26004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26005. * @param onAnimationEnd defines the function to be executed when the animation ends
  26006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26008. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26009. * @param onAnimationLoop defines the callback to call when an animation loops
  26010. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26011. * @returns the list of created animatables
  26012. */
  26013. 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[];
  26014. /**
  26015. * Begin a new animation on a given node
  26016. * @param target defines the target where the animation will take place
  26017. * @param animations defines the list of animations to start
  26018. * @param from defines the initial value
  26019. * @param to defines the final value
  26020. * @param loop defines if you want animation to loop (off by default)
  26021. * @param speedRatio defines the speed ratio to apply to all animations
  26022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26023. * @param onAnimationLoop defines the callback to call when an animation loops
  26024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26025. * @returns the list of created animatables
  26026. */
  26027. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26028. /**
  26029. * Begin a new animation on a given node and its hierarchy
  26030. * @param target defines the root node where the animation will take place
  26031. * @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.
  26032. * @param animations defines the list of animations to start
  26033. * @param from defines the initial value
  26034. * @param to defines the final value
  26035. * @param loop defines if you want animation to loop (off by default)
  26036. * @param speedRatio defines the speed ratio to apply to all animations
  26037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26038. * @param onAnimationLoop defines the callback to call when an animation loops
  26039. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26040. * @returns the list of animatables created for all nodes
  26041. */
  26042. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26043. /**
  26044. * Gets the animatable associated with a specific target
  26045. * @param target defines the target of the animatable
  26046. * @returns the required animatable if found
  26047. */
  26048. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26049. /**
  26050. * Gets all animatables associated with a given target
  26051. * @param target defines the target to look animatables for
  26052. * @returns an array of Animatables
  26053. */
  26054. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26055. /**
  26056. * Stops and removes all animations that have been applied to the scene
  26057. */
  26058. stopAllAnimations(): void;
  26059. /**
  26060. * Gets the current delta time used by animation engine
  26061. */
  26062. deltaTime: number;
  26063. }
  26064. }
  26065. module "babylonjs/Bones/bone" {
  26066. interface Bone {
  26067. /**
  26068. * Copy an animation range from another bone
  26069. * @param source defines the source bone
  26070. * @param rangeName defines the range name to copy
  26071. * @param frameOffset defines the frame offset
  26072. * @param rescaleAsRequired defines if rescaling must be applied if required
  26073. * @param skelDimensionsRatio defines the scaling ratio
  26074. * @returns true if operation was successful
  26075. */
  26076. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26077. }
  26078. }
  26079. }
  26080. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26081. /**
  26082. * Class used to override all child animations of a given target
  26083. */
  26084. export class AnimationPropertiesOverride {
  26085. /**
  26086. * Gets or sets a value indicating if animation blending must be used
  26087. */
  26088. enableBlending: boolean;
  26089. /**
  26090. * Gets or sets the blending speed to use when enableBlending is true
  26091. */
  26092. blendingSpeed: number;
  26093. /**
  26094. * Gets or sets the default loop mode to use
  26095. */
  26096. loopMode: number;
  26097. }
  26098. }
  26099. declare module "babylonjs/Bones/skeleton" {
  26100. import { Bone } from "babylonjs/Bones/bone";
  26101. import { Observable } from "babylonjs/Misc/observable";
  26102. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26103. import { Scene } from "babylonjs/scene";
  26104. import { Nullable } from "babylonjs/types";
  26105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26106. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26107. import { Animatable } from "babylonjs/Animations/animatable";
  26108. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26109. import { Animation } from "babylonjs/Animations/animation";
  26110. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26111. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26113. /**
  26114. * Class used to handle skinning animations
  26115. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26116. */
  26117. export class Skeleton implements IAnimatable {
  26118. /** defines the skeleton name */
  26119. name: string;
  26120. /** defines the skeleton Id */
  26121. id: string;
  26122. /**
  26123. * Defines the list of child bones
  26124. */
  26125. bones: Bone[];
  26126. /**
  26127. * Defines an estimate of the dimension of the skeleton at rest
  26128. */
  26129. dimensionsAtRest: Vector3;
  26130. /**
  26131. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26132. */
  26133. needInitialSkinMatrix: boolean;
  26134. /**
  26135. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26136. */
  26137. overrideMesh: Nullable<AbstractMesh>;
  26138. /**
  26139. * Gets the list of animations attached to this skeleton
  26140. */
  26141. animations: Array<Animation>;
  26142. private _scene;
  26143. private _isDirty;
  26144. private _transformMatrices;
  26145. private _transformMatrixTexture;
  26146. private _meshesWithPoseMatrix;
  26147. private _animatables;
  26148. private _identity;
  26149. private _synchronizedWithMesh;
  26150. private _ranges;
  26151. private _lastAbsoluteTransformsUpdateId;
  26152. private _canUseTextureForBones;
  26153. private _uniqueId;
  26154. /** @hidden */
  26155. _numBonesWithLinkedTransformNode: number;
  26156. /** @hidden */
  26157. _hasWaitingData: Nullable<boolean>;
  26158. /** @hidden */
  26159. _waitingOverrideMeshId: Nullable<string>;
  26160. /**
  26161. * Specifies if the skeleton should be serialized
  26162. */
  26163. doNotSerialize: boolean;
  26164. private _useTextureToStoreBoneMatrices;
  26165. /**
  26166. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26167. * Please note that this option is not available if the hardware does not support it
  26168. */
  26169. get useTextureToStoreBoneMatrices(): boolean;
  26170. set useTextureToStoreBoneMatrices(value: boolean);
  26171. private _animationPropertiesOverride;
  26172. /**
  26173. * Gets or sets the animation properties override
  26174. */
  26175. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26176. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26177. /**
  26178. * List of inspectable custom properties (used by the Inspector)
  26179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26180. */
  26181. inspectableCustomProperties: IInspectable[];
  26182. /**
  26183. * An observable triggered before computing the skeleton's matrices
  26184. */
  26185. onBeforeComputeObservable: Observable<Skeleton>;
  26186. /**
  26187. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26188. */
  26189. get isUsingTextureForMatrices(): boolean;
  26190. /**
  26191. * Gets the unique ID of this skeleton
  26192. */
  26193. get uniqueId(): number;
  26194. /**
  26195. * Creates a new skeleton
  26196. * @param name defines the skeleton name
  26197. * @param id defines the skeleton Id
  26198. * @param scene defines the hosting scene
  26199. */
  26200. constructor(
  26201. /** defines the skeleton name */
  26202. name: string,
  26203. /** defines the skeleton Id */
  26204. id: string, scene: Scene);
  26205. /**
  26206. * Gets the current object class name.
  26207. * @return the class name
  26208. */
  26209. getClassName(): string;
  26210. /**
  26211. * Returns an array containing the root bones
  26212. * @returns an array containing the root bones
  26213. */
  26214. getChildren(): Array<Bone>;
  26215. /**
  26216. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26217. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26218. * @returns a Float32Array containing matrices data
  26219. */
  26220. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26221. /**
  26222. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26223. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26224. * @returns a raw texture containing the data
  26225. */
  26226. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26227. /**
  26228. * Gets the current hosting scene
  26229. * @returns a scene object
  26230. */
  26231. getScene(): Scene;
  26232. /**
  26233. * Gets a string representing the current skeleton data
  26234. * @param fullDetails defines a boolean indicating if we want a verbose version
  26235. * @returns a string representing the current skeleton data
  26236. */
  26237. toString(fullDetails?: boolean): string;
  26238. /**
  26239. * Get bone's index searching by name
  26240. * @param name defines bone's name to search for
  26241. * @return the indice of the bone. Returns -1 if not found
  26242. */
  26243. getBoneIndexByName(name: string): number;
  26244. /**
  26245. * Creater a new animation range
  26246. * @param name defines the name of the range
  26247. * @param from defines the start key
  26248. * @param to defines the end key
  26249. */
  26250. createAnimationRange(name: string, from: number, to: number): void;
  26251. /**
  26252. * Delete a specific animation range
  26253. * @param name defines the name of the range
  26254. * @param deleteFrames defines if frames must be removed as well
  26255. */
  26256. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26257. /**
  26258. * Gets a specific animation range
  26259. * @param name defines the name of the range to look for
  26260. * @returns the requested animation range or null if not found
  26261. */
  26262. getAnimationRange(name: string): Nullable<AnimationRange>;
  26263. /**
  26264. * Gets the list of all animation ranges defined on this skeleton
  26265. * @returns an array
  26266. */
  26267. getAnimationRanges(): Nullable<AnimationRange>[];
  26268. /**
  26269. * Copy animation range from a source skeleton.
  26270. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26271. * @param source defines the source skeleton
  26272. * @param name defines the name of the range to copy
  26273. * @param rescaleAsRequired defines if rescaling must be applied if required
  26274. * @returns true if operation was successful
  26275. */
  26276. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26277. /**
  26278. * Forces the skeleton to go to rest pose
  26279. */
  26280. returnToRest(): void;
  26281. private _getHighestAnimationFrame;
  26282. /**
  26283. * Begin a specific animation range
  26284. * @param name defines the name of the range to start
  26285. * @param loop defines if looping must be turned on (false by default)
  26286. * @param speedRatio defines the speed ratio to apply (1 by default)
  26287. * @param onAnimationEnd defines a callback which will be called when animation will end
  26288. * @returns a new animatable
  26289. */
  26290. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26291. /**
  26292. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26293. * @param skeleton defines the Skeleton containing the animation range to convert
  26294. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26295. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26296. * @returns the original skeleton
  26297. */
  26298. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26299. /** @hidden */
  26300. _markAsDirty(): void;
  26301. /** @hidden */
  26302. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26303. /** @hidden */
  26304. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26305. private _computeTransformMatrices;
  26306. /**
  26307. * Build all resources required to render a skeleton
  26308. */
  26309. prepare(): void;
  26310. /**
  26311. * Gets the list of animatables currently running for this skeleton
  26312. * @returns an array of animatables
  26313. */
  26314. getAnimatables(): IAnimatable[];
  26315. /**
  26316. * Clone the current skeleton
  26317. * @param name defines the name of the new skeleton
  26318. * @param id defines the id of the new skeleton
  26319. * @returns the new skeleton
  26320. */
  26321. clone(name: string, id?: string): Skeleton;
  26322. /**
  26323. * Enable animation blending for this skeleton
  26324. * @param blendingSpeed defines the blending speed to apply
  26325. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26326. */
  26327. enableBlending(blendingSpeed?: number): void;
  26328. /**
  26329. * Releases all resources associated with the current skeleton
  26330. */
  26331. dispose(): void;
  26332. /**
  26333. * Serialize the skeleton in a JSON object
  26334. * @returns a JSON object
  26335. */
  26336. serialize(): any;
  26337. /**
  26338. * Creates a new skeleton from serialized data
  26339. * @param parsedSkeleton defines the serialized data
  26340. * @param scene defines the hosting scene
  26341. * @returns a new skeleton
  26342. */
  26343. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26344. /**
  26345. * Compute all node absolute transforms
  26346. * @param forceUpdate defines if computation must be done even if cache is up to date
  26347. */
  26348. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26349. /**
  26350. * Gets the root pose matrix
  26351. * @returns a matrix
  26352. */
  26353. getPoseMatrix(): Nullable<Matrix>;
  26354. /**
  26355. * Sorts bones per internal index
  26356. */
  26357. sortBones(): void;
  26358. private _sortBones;
  26359. /**
  26360. * Set the current local matrix as the restPose for all bones in the skeleton.
  26361. */
  26362. setCurrentPoseAsRest(): void;
  26363. }
  26364. }
  26365. declare module "babylonjs/Bones/bone" {
  26366. import { Skeleton } from "babylonjs/Bones/skeleton";
  26367. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26368. import { Nullable } from "babylonjs/types";
  26369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26371. import { Node } from "babylonjs/node";
  26372. import { Space } from "babylonjs/Maths/math.axis";
  26373. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26374. /**
  26375. * Class used to store bone information
  26376. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26377. */
  26378. export class Bone extends Node {
  26379. /**
  26380. * defines the bone name
  26381. */
  26382. name: string;
  26383. private static _tmpVecs;
  26384. private static _tmpQuat;
  26385. private static _tmpMats;
  26386. /**
  26387. * Gets the list of child bones
  26388. */
  26389. children: Bone[];
  26390. /** Gets the animations associated with this bone */
  26391. animations: import("babylonjs/Animations/animation").Animation[];
  26392. /**
  26393. * Gets or sets bone length
  26394. */
  26395. length: number;
  26396. /**
  26397. * @hidden Internal only
  26398. * Set this value to map this bone to a different index in the transform matrices
  26399. * Set this value to -1 to exclude the bone from the transform matrices
  26400. */
  26401. _index: Nullable<number>;
  26402. private _skeleton;
  26403. private _localMatrix;
  26404. private _restPose;
  26405. private _bindPose;
  26406. private _baseMatrix;
  26407. private _absoluteTransform;
  26408. private _invertedAbsoluteTransform;
  26409. private _parent;
  26410. private _scalingDeterminant;
  26411. private _worldTransform;
  26412. private _localScaling;
  26413. private _localRotation;
  26414. private _localPosition;
  26415. private _needToDecompose;
  26416. private _needToCompose;
  26417. /** @hidden */
  26418. _linkedTransformNode: Nullable<TransformNode>;
  26419. /** @hidden */
  26420. _waitingTransformNodeId: Nullable<string>;
  26421. /** @hidden */
  26422. get _matrix(): Matrix;
  26423. /** @hidden */
  26424. set _matrix(value: Matrix);
  26425. /**
  26426. * Create a new bone
  26427. * @param name defines the bone name
  26428. * @param skeleton defines the parent skeleton
  26429. * @param parentBone defines the parent (can be null if the bone is the root)
  26430. * @param localMatrix defines the local matrix
  26431. * @param restPose defines the rest pose matrix
  26432. * @param baseMatrix defines the base matrix
  26433. * @param index defines index of the bone in the hiearchy
  26434. */
  26435. constructor(
  26436. /**
  26437. * defines the bone name
  26438. */
  26439. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26440. /**
  26441. * Gets the current object class name.
  26442. * @return the class name
  26443. */
  26444. getClassName(): string;
  26445. /**
  26446. * Gets the parent skeleton
  26447. * @returns a skeleton
  26448. */
  26449. getSkeleton(): Skeleton;
  26450. /**
  26451. * Gets parent bone
  26452. * @returns a bone or null if the bone is the root of the bone hierarchy
  26453. */
  26454. getParent(): Nullable<Bone>;
  26455. /**
  26456. * Returns an array containing the root bones
  26457. * @returns an array containing the root bones
  26458. */
  26459. getChildren(): Array<Bone>;
  26460. /**
  26461. * Gets the node index in matrix array generated for rendering
  26462. * @returns the node index
  26463. */
  26464. getIndex(): number;
  26465. /**
  26466. * Sets the parent bone
  26467. * @param parent defines the parent (can be null if the bone is the root)
  26468. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26469. */
  26470. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26471. /**
  26472. * Gets the local matrix
  26473. * @returns a matrix
  26474. */
  26475. getLocalMatrix(): Matrix;
  26476. /**
  26477. * Gets the base matrix (initial matrix which remains unchanged)
  26478. * @returns a matrix
  26479. */
  26480. getBaseMatrix(): Matrix;
  26481. /**
  26482. * Gets the rest pose matrix
  26483. * @returns a matrix
  26484. */
  26485. getRestPose(): Matrix;
  26486. /**
  26487. * Sets the rest pose matrix
  26488. * @param matrix the local-space rest pose to set for this bone
  26489. */
  26490. setRestPose(matrix: Matrix): void;
  26491. /**
  26492. * Gets the bind pose matrix
  26493. * @returns the bind pose matrix
  26494. */
  26495. getBindPose(): Matrix;
  26496. /**
  26497. * Sets the bind pose matrix
  26498. * @param matrix the local-space bind pose to set for this bone
  26499. */
  26500. setBindPose(matrix: Matrix): void;
  26501. /**
  26502. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26503. */
  26504. getWorldMatrix(): Matrix;
  26505. /**
  26506. * Sets the local matrix to rest pose matrix
  26507. */
  26508. returnToRest(): void;
  26509. /**
  26510. * Gets the inverse of the absolute transform matrix.
  26511. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26512. * @returns a matrix
  26513. */
  26514. getInvertedAbsoluteTransform(): Matrix;
  26515. /**
  26516. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26517. * @returns a matrix
  26518. */
  26519. getAbsoluteTransform(): Matrix;
  26520. /**
  26521. * Links with the given transform node.
  26522. * The local matrix of this bone is copied from the transform node every frame.
  26523. * @param transformNode defines the transform node to link to
  26524. */
  26525. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26526. /**
  26527. * Gets the node used to drive the bone's transformation
  26528. * @returns a transform node or null
  26529. */
  26530. getTransformNode(): Nullable<TransformNode>;
  26531. /** Gets or sets current position (in local space) */
  26532. get position(): Vector3;
  26533. set position(newPosition: Vector3);
  26534. /** Gets or sets current rotation (in local space) */
  26535. get rotation(): Vector3;
  26536. set rotation(newRotation: Vector3);
  26537. /** Gets or sets current rotation quaternion (in local space) */
  26538. get rotationQuaternion(): Quaternion;
  26539. set rotationQuaternion(newRotation: Quaternion);
  26540. /** Gets or sets current scaling (in local space) */
  26541. get scaling(): Vector3;
  26542. set scaling(newScaling: Vector3);
  26543. /**
  26544. * Gets the animation properties override
  26545. */
  26546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26547. private _decompose;
  26548. private _compose;
  26549. /**
  26550. * Update the base and local matrices
  26551. * @param matrix defines the new base or local matrix
  26552. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26553. * @param updateLocalMatrix defines if the local matrix should be updated
  26554. */
  26555. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26556. /** @hidden */
  26557. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26558. /**
  26559. * Flag the bone as dirty (Forcing it to update everything)
  26560. */
  26561. markAsDirty(): void;
  26562. /** @hidden */
  26563. _markAsDirtyAndCompose(): void;
  26564. private _markAsDirtyAndDecompose;
  26565. /**
  26566. * Translate the bone in local or world space
  26567. * @param vec The amount to translate the bone
  26568. * @param space The space that the translation is in
  26569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26570. */
  26571. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26572. /**
  26573. * Set the postion of the bone in local or world space
  26574. * @param position The position to set the bone
  26575. * @param space The space that the position is in
  26576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26577. */
  26578. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26579. /**
  26580. * Set the absolute position of the bone (world space)
  26581. * @param position The position to set the bone
  26582. * @param mesh The mesh that this bone is attached to
  26583. */
  26584. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26585. /**
  26586. * Scale the bone on the x, y and z axes (in local space)
  26587. * @param x The amount to scale the bone on the x axis
  26588. * @param y The amount to scale the bone on the y axis
  26589. * @param z The amount to scale the bone on the z axis
  26590. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26591. */
  26592. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26593. /**
  26594. * Set the bone scaling in local space
  26595. * @param scale defines the scaling vector
  26596. */
  26597. setScale(scale: Vector3): void;
  26598. /**
  26599. * Gets the current scaling in local space
  26600. * @returns the current scaling vector
  26601. */
  26602. getScale(): Vector3;
  26603. /**
  26604. * Gets the current scaling in local space and stores it in a target vector
  26605. * @param result defines the target vector
  26606. */
  26607. getScaleToRef(result: Vector3): void;
  26608. /**
  26609. * Set the yaw, pitch, and roll of the bone in local or world space
  26610. * @param yaw The rotation of the bone on the y axis
  26611. * @param pitch The rotation of the bone on the x axis
  26612. * @param roll The rotation of the bone on the z axis
  26613. * @param space The space that the axes of rotation are in
  26614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26615. */
  26616. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26617. /**
  26618. * Add a rotation to the bone on an axis in local or world space
  26619. * @param axis The axis to rotate the bone on
  26620. * @param amount The amount to rotate the bone
  26621. * @param space The space that the axis is in
  26622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26623. */
  26624. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26625. /**
  26626. * Set the rotation of the bone to a particular axis angle in local or world space
  26627. * @param axis The axis to rotate the bone on
  26628. * @param angle The angle that the bone should be rotated to
  26629. * @param space The space that the axis is in
  26630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26631. */
  26632. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26633. /**
  26634. * Set the euler rotation of the bone in local or world space
  26635. * @param rotation The euler rotation that the bone should be set to
  26636. * @param space The space that the rotation is in
  26637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26638. */
  26639. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26640. /**
  26641. * Set the quaternion rotation of the bone in local or world space
  26642. * @param quat The quaternion rotation that the bone should be set to
  26643. * @param space The space that the rotation is in
  26644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26645. */
  26646. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26647. /**
  26648. * Set the rotation matrix of the bone in local or world space
  26649. * @param rotMat The rotation matrix that the bone should be set to
  26650. * @param space The space that the rotation is in
  26651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26652. */
  26653. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26654. private _rotateWithMatrix;
  26655. private _getNegativeRotationToRef;
  26656. /**
  26657. * Get the position of the bone in local or world space
  26658. * @param space The space that the returned position is in
  26659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26660. * @returns The position of the bone
  26661. */
  26662. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26663. /**
  26664. * Copy the position of the bone to a vector3 in local or world space
  26665. * @param space The space that the returned position is in
  26666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26667. * @param result The vector3 to copy the position to
  26668. */
  26669. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26670. /**
  26671. * Get the absolute position of the bone (world space)
  26672. * @param mesh The mesh that this bone is attached to
  26673. * @returns The absolute position of the bone
  26674. */
  26675. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26676. /**
  26677. * Copy the absolute position of the bone (world space) to the result param
  26678. * @param mesh The mesh that this bone is attached to
  26679. * @param result The vector3 to copy the absolute position to
  26680. */
  26681. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26682. /**
  26683. * Compute the absolute transforms of this bone and its children
  26684. */
  26685. computeAbsoluteTransforms(): void;
  26686. /**
  26687. * Get the world direction from an axis that is in the local space of the bone
  26688. * @param localAxis The local direction that is used to compute the world direction
  26689. * @param mesh The mesh that this bone is attached to
  26690. * @returns The world direction
  26691. */
  26692. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26693. /**
  26694. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26695. * @param localAxis The local direction that is used to compute the world direction
  26696. * @param mesh The mesh that this bone is attached to
  26697. * @param result The vector3 that the world direction will be copied to
  26698. */
  26699. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26700. /**
  26701. * Get the euler rotation of the bone in local or world space
  26702. * @param space The space that the rotation should be in
  26703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26704. * @returns The euler rotation
  26705. */
  26706. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26707. /**
  26708. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26709. * @param space The space that the rotation should be in
  26710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26711. * @param result The vector3 that the rotation should be copied to
  26712. */
  26713. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26714. /**
  26715. * Get the quaternion rotation of the bone in either local or world space
  26716. * @param space The space that the rotation should be in
  26717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26718. * @returns The quaternion rotation
  26719. */
  26720. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26721. /**
  26722. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26723. * @param space The space that the rotation should be in
  26724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26725. * @param result The quaternion that the rotation should be copied to
  26726. */
  26727. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26728. /**
  26729. * Get the rotation matrix of the bone in local or world space
  26730. * @param space The space that the rotation should be in
  26731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26732. * @returns The rotation matrix
  26733. */
  26734. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26735. /**
  26736. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26737. * @param space The space that the rotation should be in
  26738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26739. * @param result The quaternion that the rotation should be copied to
  26740. */
  26741. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26742. /**
  26743. * Get the world position of a point that is in the local space of the bone
  26744. * @param position The local position
  26745. * @param mesh The mesh that this bone is attached to
  26746. * @returns The world position
  26747. */
  26748. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26749. /**
  26750. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26751. * @param position The local position
  26752. * @param mesh The mesh that this bone is attached to
  26753. * @param result The vector3 that the world position should be copied to
  26754. */
  26755. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26756. /**
  26757. * Get the local position of a point that is in world space
  26758. * @param position The world position
  26759. * @param mesh The mesh that this bone is attached to
  26760. * @returns The local position
  26761. */
  26762. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26763. /**
  26764. * Get the local position of a point that is in world space and copy it to the result param
  26765. * @param position The world position
  26766. * @param mesh The mesh that this bone is attached to
  26767. * @param result The vector3 that the local position should be copied to
  26768. */
  26769. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26770. /**
  26771. * Set the current local matrix as the restPose for this bone.
  26772. */
  26773. setCurrentPoseAsRest(): void;
  26774. }
  26775. }
  26776. declare module "babylonjs/Meshes/transformNode" {
  26777. import { DeepImmutable } from "babylonjs/types";
  26778. import { Observable } from "babylonjs/Misc/observable";
  26779. import { Nullable } from "babylonjs/types";
  26780. import { Camera } from "babylonjs/Cameras/camera";
  26781. import { Scene } from "babylonjs/scene";
  26782. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26783. import { Node } from "babylonjs/node";
  26784. import { Bone } from "babylonjs/Bones/bone";
  26785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26786. import { Space } from "babylonjs/Maths/math.axis";
  26787. /**
  26788. * 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.
  26789. * @see https://doc.babylonjs.com/how_to/transformnode
  26790. */
  26791. export class TransformNode extends Node {
  26792. /**
  26793. * Object will not rotate to face the camera
  26794. */
  26795. static BILLBOARDMODE_NONE: number;
  26796. /**
  26797. * Object will rotate to face the camera but only on the x axis
  26798. */
  26799. static BILLBOARDMODE_X: number;
  26800. /**
  26801. * Object will rotate to face the camera but only on the y axis
  26802. */
  26803. static BILLBOARDMODE_Y: number;
  26804. /**
  26805. * Object will rotate to face the camera but only on the z axis
  26806. */
  26807. static BILLBOARDMODE_Z: number;
  26808. /**
  26809. * Object will rotate to face the camera
  26810. */
  26811. static BILLBOARDMODE_ALL: number;
  26812. /**
  26813. * Object will rotate to face the camera's position instead of orientation
  26814. */
  26815. static BILLBOARDMODE_USE_POSITION: number;
  26816. private static _TmpRotation;
  26817. private static _TmpScaling;
  26818. private static _TmpTranslation;
  26819. private _forward;
  26820. private _forwardInverted;
  26821. private _up;
  26822. private _right;
  26823. private _rightInverted;
  26824. private _position;
  26825. private _rotation;
  26826. private _rotationQuaternion;
  26827. protected _scaling: Vector3;
  26828. protected _isDirty: boolean;
  26829. private _transformToBoneReferal;
  26830. private _isAbsoluteSynced;
  26831. private _billboardMode;
  26832. /**
  26833. * Gets or sets the billboard mode. Default is 0.
  26834. *
  26835. * | Value | Type | Description |
  26836. * | --- | --- | --- |
  26837. * | 0 | BILLBOARDMODE_NONE | |
  26838. * | 1 | BILLBOARDMODE_X | |
  26839. * | 2 | BILLBOARDMODE_Y | |
  26840. * | 4 | BILLBOARDMODE_Z | |
  26841. * | 7 | BILLBOARDMODE_ALL | |
  26842. *
  26843. */
  26844. get billboardMode(): number;
  26845. set billboardMode(value: number);
  26846. private _preserveParentRotationForBillboard;
  26847. /**
  26848. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26849. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26850. */
  26851. get preserveParentRotationForBillboard(): boolean;
  26852. set preserveParentRotationForBillboard(value: boolean);
  26853. /**
  26854. * 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
  26855. */
  26856. scalingDeterminant: number;
  26857. private _infiniteDistance;
  26858. /**
  26859. * Gets or sets the distance of the object to max, often used by skybox
  26860. */
  26861. get infiniteDistance(): boolean;
  26862. set infiniteDistance(value: boolean);
  26863. /**
  26864. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26865. * By default the system will update normals to compensate
  26866. */
  26867. ignoreNonUniformScaling: boolean;
  26868. /**
  26869. * 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
  26870. */
  26871. reIntegrateRotationIntoRotationQuaternion: boolean;
  26872. /** @hidden */
  26873. _poseMatrix: Nullable<Matrix>;
  26874. /** @hidden */
  26875. _localMatrix: Matrix;
  26876. private _usePivotMatrix;
  26877. private _absolutePosition;
  26878. private _absoluteScaling;
  26879. private _absoluteRotationQuaternion;
  26880. private _pivotMatrix;
  26881. private _pivotMatrixInverse;
  26882. /** @hidden */
  26883. _postMultiplyPivotMatrix: boolean;
  26884. protected _isWorldMatrixFrozen: boolean;
  26885. /** @hidden */
  26886. _indexInSceneTransformNodesArray: number;
  26887. /**
  26888. * An event triggered after the world matrix is updated
  26889. */
  26890. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26891. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26892. /**
  26893. * Gets a string identifying the name of the class
  26894. * @returns "TransformNode" string
  26895. */
  26896. getClassName(): string;
  26897. /**
  26898. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26899. */
  26900. get position(): Vector3;
  26901. set position(newPosition: Vector3);
  26902. /**
  26903. * 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)).
  26904. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26905. */
  26906. get rotation(): Vector3;
  26907. set rotation(newRotation: Vector3);
  26908. /**
  26909. * 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)).
  26910. */
  26911. get scaling(): Vector3;
  26912. set scaling(newScaling: Vector3);
  26913. /**
  26914. * 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).
  26915. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26916. */
  26917. get rotationQuaternion(): Nullable<Quaternion>;
  26918. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26919. /**
  26920. * The forward direction of that transform in world space.
  26921. */
  26922. get forward(): Vector3;
  26923. /**
  26924. * The up direction of that transform in world space.
  26925. */
  26926. get up(): Vector3;
  26927. /**
  26928. * The right direction of that transform in world space.
  26929. */
  26930. get right(): Vector3;
  26931. /**
  26932. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26933. * @param matrix the matrix to copy the pose from
  26934. * @returns this TransformNode.
  26935. */
  26936. updatePoseMatrix(matrix: Matrix): TransformNode;
  26937. /**
  26938. * Returns the mesh Pose matrix.
  26939. * @returns the pose matrix
  26940. */
  26941. getPoseMatrix(): Matrix;
  26942. /** @hidden */
  26943. _isSynchronized(): boolean;
  26944. /** @hidden */
  26945. _initCache(): void;
  26946. /**
  26947. * Flag the transform node as dirty (Forcing it to update everything)
  26948. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26949. * @returns this transform node
  26950. */
  26951. markAsDirty(property: string): TransformNode;
  26952. /**
  26953. * Returns the current mesh absolute position.
  26954. * Returns a Vector3.
  26955. */
  26956. get absolutePosition(): Vector3;
  26957. /**
  26958. * Returns the current mesh absolute scaling.
  26959. * Returns a Vector3.
  26960. */
  26961. get absoluteScaling(): Vector3;
  26962. /**
  26963. * Returns the current mesh absolute rotation.
  26964. * Returns a Quaternion.
  26965. */
  26966. get absoluteRotationQuaternion(): Quaternion;
  26967. /**
  26968. * Sets a new matrix to apply before all other transformation
  26969. * @param matrix defines the transform matrix
  26970. * @returns the current TransformNode
  26971. */
  26972. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26973. /**
  26974. * Sets a new pivot matrix to the current node
  26975. * @param matrix defines the new pivot matrix to use
  26976. * @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
  26977. * @returns the current TransformNode
  26978. */
  26979. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26980. /**
  26981. * Returns the mesh pivot matrix.
  26982. * Default : Identity.
  26983. * @returns the matrix
  26984. */
  26985. getPivotMatrix(): Matrix;
  26986. /**
  26987. * Instantiate (when possible) or clone that node with its hierarchy
  26988. * @param newParent defines the new parent to use for the instance (or clone)
  26989. * @param options defines options to configure how copy is done
  26990. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26991. * @returns an instance (or a clone) of the current node with its hiearchy
  26992. */
  26993. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26994. doNotInstantiate: boolean;
  26995. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26996. /**
  26997. * Prevents the World matrix to be computed any longer
  26998. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26999. * @returns the TransformNode.
  27000. */
  27001. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27002. /**
  27003. * Allows back the World matrix computation.
  27004. * @returns the TransformNode.
  27005. */
  27006. unfreezeWorldMatrix(): this;
  27007. /**
  27008. * True if the World matrix has been frozen.
  27009. */
  27010. get isWorldMatrixFrozen(): boolean;
  27011. /**
  27012. * Retuns the mesh absolute position in the World.
  27013. * @returns a Vector3.
  27014. */
  27015. getAbsolutePosition(): Vector3;
  27016. /**
  27017. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27018. * @param absolutePosition the absolute position to set
  27019. * @returns the TransformNode.
  27020. */
  27021. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27022. /**
  27023. * Sets the mesh position in its local space.
  27024. * @param vector3 the position to set in localspace
  27025. * @returns the TransformNode.
  27026. */
  27027. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27028. /**
  27029. * Returns the mesh position in the local space from the current World matrix values.
  27030. * @returns a new Vector3.
  27031. */
  27032. getPositionExpressedInLocalSpace(): Vector3;
  27033. /**
  27034. * Translates the mesh along the passed Vector3 in its local space.
  27035. * @param vector3 the distance to translate in localspace
  27036. * @returns the TransformNode.
  27037. */
  27038. locallyTranslate(vector3: Vector3): TransformNode;
  27039. private static _lookAtVectorCache;
  27040. /**
  27041. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27042. * @param targetPoint the position (must be in same space as current mesh) to look at
  27043. * @param yawCor optional yaw (y-axis) correction in radians
  27044. * @param pitchCor optional pitch (x-axis) correction in radians
  27045. * @param rollCor optional roll (z-axis) correction in radians
  27046. * @param space the choosen space of the target
  27047. * @returns the TransformNode.
  27048. */
  27049. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27050. /**
  27051. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27052. * This Vector3 is expressed in the World space.
  27053. * @param localAxis axis to rotate
  27054. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27055. */
  27056. getDirection(localAxis: Vector3): Vector3;
  27057. /**
  27058. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27059. * localAxis is expressed in the mesh local space.
  27060. * result is computed in the Wordl space from the mesh World matrix.
  27061. * @param localAxis axis to rotate
  27062. * @param result the resulting transformnode
  27063. * @returns this TransformNode.
  27064. */
  27065. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27066. /**
  27067. * Sets this transform node rotation to the given local axis.
  27068. * @param localAxis the axis in local space
  27069. * @param yawCor optional yaw (y-axis) correction in radians
  27070. * @param pitchCor optional pitch (x-axis) correction in radians
  27071. * @param rollCor optional roll (z-axis) correction in radians
  27072. * @returns this TransformNode
  27073. */
  27074. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27075. /**
  27076. * Sets a new pivot point to the current node
  27077. * @param point defines the new pivot point to use
  27078. * @param space defines if the point is in world or local space (local by default)
  27079. * @returns the current TransformNode
  27080. */
  27081. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27082. /**
  27083. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27084. * @returns the pivot point
  27085. */
  27086. getPivotPoint(): Vector3;
  27087. /**
  27088. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27089. * @param result the vector3 to store the result
  27090. * @returns this TransformNode.
  27091. */
  27092. getPivotPointToRef(result: Vector3): TransformNode;
  27093. /**
  27094. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27095. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27096. */
  27097. getAbsolutePivotPoint(): Vector3;
  27098. /**
  27099. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27100. * @param result vector3 to store the result
  27101. * @returns this TransformNode.
  27102. */
  27103. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27104. /**
  27105. * Defines the passed node as the parent of the current node.
  27106. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27107. * @see https://doc.babylonjs.com/how_to/parenting
  27108. * @param node the node ot set as the parent
  27109. * @returns this TransformNode.
  27110. */
  27111. setParent(node: Nullable<Node>): TransformNode;
  27112. private _nonUniformScaling;
  27113. /**
  27114. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27115. */
  27116. get nonUniformScaling(): boolean;
  27117. /** @hidden */
  27118. _updateNonUniformScalingState(value: boolean): boolean;
  27119. /**
  27120. * Attach the current TransformNode to another TransformNode associated with a bone
  27121. * @param bone Bone affecting the TransformNode
  27122. * @param affectedTransformNode TransformNode associated with the bone
  27123. * @returns this object
  27124. */
  27125. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27126. /**
  27127. * Detach the transform node if its associated with a bone
  27128. * @returns this object
  27129. */
  27130. detachFromBone(): TransformNode;
  27131. private static _rotationAxisCache;
  27132. /**
  27133. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27134. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27135. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27136. * The passed axis is also normalized.
  27137. * @param axis the axis to rotate around
  27138. * @param amount the amount to rotate in radians
  27139. * @param space Space to rotate in (Default: local)
  27140. * @returns the TransformNode.
  27141. */
  27142. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27143. /**
  27144. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27145. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27146. * The passed axis is also normalized. .
  27147. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27148. * @param point the point to rotate around
  27149. * @param axis the axis to rotate around
  27150. * @param amount the amount to rotate in radians
  27151. * @returns the TransformNode
  27152. */
  27153. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27154. /**
  27155. * Translates the mesh along the axis vector for the passed distance in the given space.
  27156. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27157. * @param axis the axis to translate in
  27158. * @param distance the distance to translate
  27159. * @param space Space to rotate in (Default: local)
  27160. * @returns the TransformNode.
  27161. */
  27162. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27163. /**
  27164. * Adds a rotation step to the mesh current rotation.
  27165. * x, y, z are Euler angles expressed in radians.
  27166. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27167. * This means this rotation is made in the mesh local space only.
  27168. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27169. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27170. * ```javascript
  27171. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27172. * ```
  27173. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27174. * 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.
  27175. * @param x Rotation to add
  27176. * @param y Rotation to add
  27177. * @param z Rotation to add
  27178. * @returns the TransformNode.
  27179. */
  27180. addRotation(x: number, y: number, z: number): TransformNode;
  27181. /**
  27182. * @hidden
  27183. */
  27184. protected _getEffectiveParent(): Nullable<Node>;
  27185. /**
  27186. * Computes the world matrix of the node
  27187. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27188. * @returns the world matrix
  27189. */
  27190. computeWorldMatrix(force?: boolean): Matrix;
  27191. /**
  27192. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27193. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27194. */
  27195. resetLocalMatrix(independentOfChildren?: boolean): void;
  27196. protected _afterComputeWorldMatrix(): void;
  27197. /**
  27198. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27199. * @param func callback function to add
  27200. *
  27201. * @returns the TransformNode.
  27202. */
  27203. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27204. /**
  27205. * Removes a registered callback function.
  27206. * @param func callback function to remove
  27207. * @returns the TransformNode.
  27208. */
  27209. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27210. /**
  27211. * Gets the position of the current mesh in camera space
  27212. * @param camera defines the camera to use
  27213. * @returns a position
  27214. */
  27215. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27216. /**
  27217. * Returns the distance from the mesh to the active camera
  27218. * @param camera defines the camera to use
  27219. * @returns the distance
  27220. */
  27221. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27222. /**
  27223. * Clone the current transform node
  27224. * @param name Name of the new clone
  27225. * @param newParent New parent for the clone
  27226. * @param doNotCloneChildren Do not clone children hierarchy
  27227. * @returns the new transform node
  27228. */
  27229. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27230. /**
  27231. * Serializes the objects information.
  27232. * @param currentSerializationObject defines the object to serialize in
  27233. * @returns the serialized object
  27234. */
  27235. serialize(currentSerializationObject?: any): any;
  27236. /**
  27237. * Returns a new TransformNode object parsed from the source provided.
  27238. * @param parsedTransformNode is the source.
  27239. * @param scene the scne the object belongs to
  27240. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27241. * @returns a new TransformNode object parsed from the source provided.
  27242. */
  27243. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27244. /**
  27245. * Get all child-transformNodes of this node
  27246. * @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
  27247. * @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
  27248. * @returns an array of TransformNode
  27249. */
  27250. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27251. /**
  27252. * Releases resources associated with this transform node.
  27253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27255. */
  27256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27257. /**
  27258. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27259. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27260. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27261. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27262. * @returns the current mesh
  27263. */
  27264. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27265. private _syncAbsoluteScalingAndRotation;
  27266. }
  27267. }
  27268. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27269. import { Observable } from "babylonjs/Misc/observable";
  27270. import { Nullable } from "babylonjs/types";
  27271. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27272. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27274. import { Ray } from "babylonjs/Culling/ray";
  27275. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27276. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27278. /**
  27279. * Defines the types of pose enabled controllers that are supported
  27280. */
  27281. export enum PoseEnabledControllerType {
  27282. /**
  27283. * HTC Vive
  27284. */
  27285. VIVE = 0,
  27286. /**
  27287. * Oculus Rift
  27288. */
  27289. OCULUS = 1,
  27290. /**
  27291. * Windows mixed reality
  27292. */
  27293. WINDOWS = 2,
  27294. /**
  27295. * Samsung gear VR
  27296. */
  27297. GEAR_VR = 3,
  27298. /**
  27299. * Google Daydream
  27300. */
  27301. DAYDREAM = 4,
  27302. /**
  27303. * Generic
  27304. */
  27305. GENERIC = 5
  27306. }
  27307. /**
  27308. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27309. */
  27310. export interface MutableGamepadButton {
  27311. /**
  27312. * Value of the button/trigger
  27313. */
  27314. value: number;
  27315. /**
  27316. * If the button/trigger is currently touched
  27317. */
  27318. touched: boolean;
  27319. /**
  27320. * If the button/trigger is currently pressed
  27321. */
  27322. pressed: boolean;
  27323. }
  27324. /**
  27325. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27326. * @hidden
  27327. */
  27328. export interface ExtendedGamepadButton extends GamepadButton {
  27329. /**
  27330. * If the button/trigger is currently pressed
  27331. */
  27332. readonly pressed: boolean;
  27333. /**
  27334. * If the button/trigger is currently touched
  27335. */
  27336. readonly touched: boolean;
  27337. /**
  27338. * Value of the button/trigger
  27339. */
  27340. readonly value: number;
  27341. }
  27342. /** @hidden */
  27343. export interface _GamePadFactory {
  27344. /**
  27345. * Returns whether or not the current gamepad can be created for this type of controller.
  27346. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27347. * @returns true if it can be created, otherwise false
  27348. */
  27349. canCreate(gamepadInfo: any): boolean;
  27350. /**
  27351. * Creates a new instance of the Gamepad.
  27352. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27353. * @returns the new gamepad instance
  27354. */
  27355. create(gamepadInfo: any): Gamepad;
  27356. }
  27357. /**
  27358. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27359. */
  27360. export class PoseEnabledControllerHelper {
  27361. /** @hidden */
  27362. static _ControllerFactories: _GamePadFactory[];
  27363. /** @hidden */
  27364. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27365. /**
  27366. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27367. * @param vrGamepad the gamepad to initialized
  27368. * @returns a vr controller of the type the gamepad identified as
  27369. */
  27370. static InitiateController(vrGamepad: any): Gamepad;
  27371. }
  27372. /**
  27373. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27374. */
  27375. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27376. /**
  27377. * If the controller is used in a webXR session
  27378. */
  27379. isXR: boolean;
  27380. private _deviceRoomPosition;
  27381. private _deviceRoomRotationQuaternion;
  27382. /**
  27383. * The device position in babylon space
  27384. */
  27385. devicePosition: Vector3;
  27386. /**
  27387. * The device rotation in babylon space
  27388. */
  27389. deviceRotationQuaternion: Quaternion;
  27390. /**
  27391. * The scale factor of the device in babylon space
  27392. */
  27393. deviceScaleFactor: number;
  27394. /**
  27395. * (Likely devicePosition should be used instead) The device position in its room space
  27396. */
  27397. position: Vector3;
  27398. /**
  27399. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27400. */
  27401. rotationQuaternion: Quaternion;
  27402. /**
  27403. * The type of controller (Eg. Windows mixed reality)
  27404. */
  27405. controllerType: PoseEnabledControllerType;
  27406. protected _calculatedPosition: Vector3;
  27407. private _calculatedRotation;
  27408. /**
  27409. * The raw pose from the device
  27410. */
  27411. rawPose: DevicePose;
  27412. private _trackPosition;
  27413. private _maxRotationDistFromHeadset;
  27414. private _draggedRoomRotation;
  27415. /**
  27416. * @hidden
  27417. */
  27418. _disableTrackPosition(fixedPosition: Vector3): void;
  27419. /**
  27420. * Internal, the mesh attached to the controller
  27421. * @hidden
  27422. */
  27423. _mesh: Nullable<AbstractMesh>;
  27424. private _poseControlledCamera;
  27425. private _leftHandSystemQuaternion;
  27426. /**
  27427. * Internal, matrix used to convert room space to babylon space
  27428. * @hidden
  27429. */
  27430. _deviceToWorld: Matrix;
  27431. /**
  27432. * Node to be used when casting a ray from the controller
  27433. * @hidden
  27434. */
  27435. _pointingPoseNode: Nullable<TransformNode>;
  27436. /**
  27437. * Name of the child mesh that can be used to cast a ray from the controller
  27438. */
  27439. static readonly POINTING_POSE: string;
  27440. /**
  27441. * Creates a new PoseEnabledController from a gamepad
  27442. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27443. */
  27444. constructor(browserGamepad: any);
  27445. private _workingMatrix;
  27446. /**
  27447. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27448. */
  27449. update(): void;
  27450. /**
  27451. * Updates only the pose device and mesh without doing any button event checking
  27452. */
  27453. protected _updatePoseAndMesh(): void;
  27454. /**
  27455. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27456. * @param poseData raw pose fromthe device
  27457. */
  27458. updateFromDevice(poseData: DevicePose): void;
  27459. /**
  27460. * @hidden
  27461. */
  27462. _meshAttachedObservable: Observable<AbstractMesh>;
  27463. /**
  27464. * Attaches a mesh to the controller
  27465. * @param mesh the mesh to be attached
  27466. */
  27467. attachToMesh(mesh: AbstractMesh): void;
  27468. /**
  27469. * Attaches the controllers mesh to a camera
  27470. * @param camera the camera the mesh should be attached to
  27471. */
  27472. attachToPoseControlledCamera(camera: TargetCamera): void;
  27473. /**
  27474. * Disposes of the controller
  27475. */
  27476. dispose(): void;
  27477. /**
  27478. * The mesh that is attached to the controller
  27479. */
  27480. get mesh(): Nullable<AbstractMesh>;
  27481. /**
  27482. * Gets the ray of the controller in the direction the controller is pointing
  27483. * @param length the length the resulting ray should be
  27484. * @returns a ray in the direction the controller is pointing
  27485. */
  27486. getForwardRay(length?: number): Ray;
  27487. }
  27488. }
  27489. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27490. import { Observable } from "babylonjs/Misc/observable";
  27491. import { Scene } from "babylonjs/scene";
  27492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27493. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27494. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27495. import { Nullable } from "babylonjs/types";
  27496. /**
  27497. * Defines the WebVRController object that represents controllers tracked in 3D space
  27498. */
  27499. export abstract class WebVRController extends PoseEnabledController {
  27500. /**
  27501. * Internal, the default controller model for the controller
  27502. */
  27503. protected _defaultModel: Nullable<AbstractMesh>;
  27504. /**
  27505. * Fired when the trigger state has changed
  27506. */
  27507. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27508. /**
  27509. * Fired when the main button state has changed
  27510. */
  27511. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27512. /**
  27513. * Fired when the secondary button state has changed
  27514. */
  27515. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27516. /**
  27517. * Fired when the pad state has changed
  27518. */
  27519. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27520. /**
  27521. * Fired when controllers stick values have changed
  27522. */
  27523. onPadValuesChangedObservable: Observable<StickValues>;
  27524. /**
  27525. * Array of button availible on the controller
  27526. */
  27527. protected _buttons: Array<MutableGamepadButton>;
  27528. private _onButtonStateChange;
  27529. /**
  27530. * Fired when a controller button's state has changed
  27531. * @param callback the callback containing the button that was modified
  27532. */
  27533. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27534. /**
  27535. * X and Y axis corresponding to the controllers joystick
  27536. */
  27537. pad: StickValues;
  27538. /**
  27539. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27540. */
  27541. hand: string;
  27542. /**
  27543. * The default controller model for the controller
  27544. */
  27545. get defaultModel(): Nullable<AbstractMesh>;
  27546. /**
  27547. * Creates a new WebVRController from a gamepad
  27548. * @param vrGamepad the gamepad that the WebVRController should be created from
  27549. */
  27550. constructor(vrGamepad: any);
  27551. /**
  27552. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27553. */
  27554. update(): void;
  27555. /**
  27556. * Function to be called when a button is modified
  27557. */
  27558. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27559. /**
  27560. * Loads a mesh and attaches it to the controller
  27561. * @param scene the scene the mesh should be added to
  27562. * @param meshLoaded callback for when the mesh has been loaded
  27563. */
  27564. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27565. private _setButtonValue;
  27566. private _changes;
  27567. private _checkChanges;
  27568. /**
  27569. * Disposes of th webVRCOntroller
  27570. */
  27571. dispose(): void;
  27572. }
  27573. }
  27574. declare module "babylonjs/Lights/hemisphericLight" {
  27575. import { Nullable } from "babylonjs/types";
  27576. import { Scene } from "babylonjs/scene";
  27577. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27578. import { Color3 } from "babylonjs/Maths/math.color";
  27579. import { Effect } from "babylonjs/Materials/effect";
  27580. import { Light } from "babylonjs/Lights/light";
  27581. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27582. /**
  27583. * The HemisphericLight simulates the ambient environment light,
  27584. * so the passed direction is the light reflection direction, not the incoming direction.
  27585. */
  27586. export class HemisphericLight extends Light {
  27587. /**
  27588. * The groundColor is the light in the opposite direction to the one specified during creation.
  27589. * 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.
  27590. */
  27591. groundColor: Color3;
  27592. /**
  27593. * The light reflection direction, not the incoming direction.
  27594. */
  27595. direction: Vector3;
  27596. /**
  27597. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27598. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27599. * The HemisphericLight can't cast shadows.
  27600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27601. * @param name The friendly name of the light
  27602. * @param direction The direction of the light reflection
  27603. * @param scene The scene the light belongs to
  27604. */
  27605. constructor(name: string, direction: Vector3, scene: Scene);
  27606. protected _buildUniformLayout(): void;
  27607. /**
  27608. * Returns the string "HemisphericLight".
  27609. * @return The class name
  27610. */
  27611. getClassName(): string;
  27612. /**
  27613. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27614. * Returns the updated direction.
  27615. * @param target The target the direction should point to
  27616. * @return The computed direction
  27617. */
  27618. setDirectionToTarget(target: Vector3): Vector3;
  27619. /**
  27620. * Returns the shadow generator associated to the light.
  27621. * @returns Always null for hemispheric lights because it does not support shadows.
  27622. */
  27623. getShadowGenerator(): Nullable<IShadowGenerator>;
  27624. /**
  27625. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27626. * @param effect The effect to update
  27627. * @param lightIndex The index of the light in the effect to update
  27628. * @returns The hemispheric light
  27629. */
  27630. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27631. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27632. /**
  27633. * Computes the world matrix of the node
  27634. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27635. * @param useWasUpdatedFlag defines a reserved property
  27636. * @returns the world matrix
  27637. */
  27638. computeWorldMatrix(): Matrix;
  27639. /**
  27640. * Returns the integer 3.
  27641. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27642. */
  27643. getTypeID(): number;
  27644. /**
  27645. * Prepares the list of defines specific to the light type.
  27646. * @param defines the list of defines
  27647. * @param lightIndex defines the index of the light for the effect
  27648. */
  27649. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27650. }
  27651. }
  27652. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27653. /** @hidden */
  27654. export var vrMultiviewToSingleviewPixelShader: {
  27655. name: string;
  27656. shader: string;
  27657. };
  27658. }
  27659. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27660. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27661. import { Scene } from "babylonjs/scene";
  27662. /**
  27663. * Renders to multiple views with a single draw call
  27664. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27665. */
  27666. export class MultiviewRenderTarget extends RenderTargetTexture {
  27667. /**
  27668. * Creates a multiview render target
  27669. * @param scene scene used with the render target
  27670. * @param size the size of the render target (used for each view)
  27671. */
  27672. constructor(scene: Scene, size?: number | {
  27673. width: number;
  27674. height: number;
  27675. } | {
  27676. ratio: number;
  27677. });
  27678. /**
  27679. * @hidden
  27680. * @param faceIndex the face index, if its a cube texture
  27681. */
  27682. _bindFrameBuffer(faceIndex?: number): void;
  27683. /**
  27684. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27685. * @returns the view count
  27686. */
  27687. getViewCount(): number;
  27688. }
  27689. }
  27690. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27691. import { Camera } from "babylonjs/Cameras/camera";
  27692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27693. import { Nullable } from "babylonjs/types";
  27694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27695. import { Matrix } from "babylonjs/Maths/math.vector";
  27696. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27697. module "babylonjs/Engines/engine" {
  27698. interface Engine {
  27699. /**
  27700. * Creates a new multiview render target
  27701. * @param width defines the width of the texture
  27702. * @param height defines the height of the texture
  27703. * @returns the created multiview texture
  27704. */
  27705. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27706. /**
  27707. * Binds a multiview framebuffer to be drawn to
  27708. * @param multiviewTexture texture to bind
  27709. */
  27710. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27711. }
  27712. }
  27713. module "babylonjs/Cameras/camera" {
  27714. interface Camera {
  27715. /**
  27716. * @hidden
  27717. * 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)
  27718. */
  27719. _useMultiviewToSingleView: boolean;
  27720. /**
  27721. * @hidden
  27722. * 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)
  27723. */
  27724. _multiviewTexture: Nullable<RenderTargetTexture>;
  27725. /**
  27726. * @hidden
  27727. * ensures the multiview texture of the camera exists and has the specified width/height
  27728. * @param width height to set on the multiview texture
  27729. * @param height width to set on the multiview texture
  27730. */
  27731. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27732. }
  27733. }
  27734. module "babylonjs/scene" {
  27735. interface Scene {
  27736. /** @hidden */
  27737. _transformMatrixR: Matrix;
  27738. /** @hidden */
  27739. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27740. /** @hidden */
  27741. _createMultiviewUbo(): void;
  27742. /** @hidden */
  27743. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27744. /** @hidden */
  27745. _renderMultiviewToSingleView(camera: Camera): void;
  27746. }
  27747. }
  27748. }
  27749. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27750. import { Camera } from "babylonjs/Cameras/camera";
  27751. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27752. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27753. import "babylonjs/Engines/Extensions/engine.multiview";
  27754. /**
  27755. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27756. * This will not be used for webXR as it supports displaying texture arrays directly
  27757. */
  27758. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27759. /**
  27760. * Gets a string identifying the name of the class
  27761. * @returns "VRMultiviewToSingleviewPostProcess" string
  27762. */
  27763. getClassName(): string;
  27764. /**
  27765. * Initializes a VRMultiviewToSingleview
  27766. * @param name name of the post process
  27767. * @param camera camera to be applied to
  27768. * @param scaleFactor scaling factor to the size of the output texture
  27769. */
  27770. constructor(name: string, camera: Camera, scaleFactor: number);
  27771. }
  27772. }
  27773. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27774. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27775. import { Nullable } from "babylonjs/types";
  27776. import { Size } from "babylonjs/Maths/math.size";
  27777. import { Observable } from "babylonjs/Misc/observable";
  27778. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27779. /**
  27780. * Interface used to define additional presentation attributes
  27781. */
  27782. export interface IVRPresentationAttributes {
  27783. /**
  27784. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27785. */
  27786. highRefreshRate: boolean;
  27787. /**
  27788. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27789. */
  27790. foveationLevel: number;
  27791. }
  27792. module "babylonjs/Engines/engine" {
  27793. interface Engine {
  27794. /** @hidden */
  27795. _vrDisplay: any;
  27796. /** @hidden */
  27797. _vrSupported: boolean;
  27798. /** @hidden */
  27799. _oldSize: Size;
  27800. /** @hidden */
  27801. _oldHardwareScaleFactor: number;
  27802. /** @hidden */
  27803. _vrExclusivePointerMode: boolean;
  27804. /** @hidden */
  27805. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27806. /** @hidden */
  27807. _onVRDisplayPointerRestricted: () => void;
  27808. /** @hidden */
  27809. _onVRDisplayPointerUnrestricted: () => void;
  27810. /** @hidden */
  27811. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27812. /** @hidden */
  27813. _onVrDisplayDisconnect: Nullable<() => void>;
  27814. /** @hidden */
  27815. _onVrDisplayPresentChange: Nullable<() => void>;
  27816. /**
  27817. * Observable signaled when VR display mode changes
  27818. */
  27819. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27820. /**
  27821. * Observable signaled when VR request present is complete
  27822. */
  27823. onVRRequestPresentComplete: Observable<boolean>;
  27824. /**
  27825. * Observable signaled when VR request present starts
  27826. */
  27827. onVRRequestPresentStart: Observable<Engine>;
  27828. /**
  27829. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27830. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27831. */
  27832. isInVRExclusivePointerMode: boolean;
  27833. /**
  27834. * Gets a boolean indicating if a webVR device was detected
  27835. * @returns true if a webVR device was detected
  27836. */
  27837. isVRDevicePresent(): boolean;
  27838. /**
  27839. * Gets the current webVR device
  27840. * @returns the current webVR device (or null)
  27841. */
  27842. getVRDevice(): any;
  27843. /**
  27844. * Initializes a webVR display and starts listening to display change events
  27845. * The onVRDisplayChangedObservable will be notified upon these changes
  27846. * @returns A promise containing a VRDisplay and if vr is supported
  27847. */
  27848. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27849. /** @hidden */
  27850. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27851. /**
  27852. * Gets or sets the presentation attributes used to configure VR rendering
  27853. */
  27854. vrPresentationAttributes?: IVRPresentationAttributes;
  27855. /**
  27856. * Call this function to switch to webVR mode
  27857. * Will do nothing if webVR is not supported or if there is no webVR device
  27858. * @param options the webvr options provided to the camera. mainly used for multiview
  27859. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27860. */
  27861. enableVR(options: WebVROptions): void;
  27862. /** @hidden */
  27863. _onVRFullScreenTriggered(): void;
  27864. }
  27865. }
  27866. }
  27867. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27868. import { Nullable } from "babylonjs/types";
  27869. import { Observable } from "babylonjs/Misc/observable";
  27870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27871. import { Scene } from "babylonjs/scene";
  27872. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27873. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27874. import { Node } from "babylonjs/node";
  27875. import { Ray } from "babylonjs/Culling/ray";
  27876. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27877. import "babylonjs/Engines/Extensions/engine.webVR";
  27878. /**
  27879. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27880. * IMPORTANT!! The data is right-hand data.
  27881. * @export
  27882. * @interface DevicePose
  27883. */
  27884. export interface DevicePose {
  27885. /**
  27886. * The position of the device, values in array are [x,y,z].
  27887. */
  27888. readonly position: Nullable<Float32Array>;
  27889. /**
  27890. * The linearVelocity of the device, values in array are [x,y,z].
  27891. */
  27892. readonly linearVelocity: Nullable<Float32Array>;
  27893. /**
  27894. * The linearAcceleration of the device, values in array are [x,y,z].
  27895. */
  27896. readonly linearAcceleration: Nullable<Float32Array>;
  27897. /**
  27898. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27899. */
  27900. readonly orientation: Nullable<Float32Array>;
  27901. /**
  27902. * The angularVelocity of the device, values in array are [x,y,z].
  27903. */
  27904. readonly angularVelocity: Nullable<Float32Array>;
  27905. /**
  27906. * The angularAcceleration of the device, values in array are [x,y,z].
  27907. */
  27908. readonly angularAcceleration: Nullable<Float32Array>;
  27909. }
  27910. /**
  27911. * Interface representing a pose controlled object in Babylon.
  27912. * A pose controlled object has both regular pose values as well as pose values
  27913. * from an external device such as a VR head mounted display
  27914. */
  27915. export interface PoseControlled {
  27916. /**
  27917. * The position of the object in babylon space.
  27918. */
  27919. position: Vector3;
  27920. /**
  27921. * The rotation quaternion of the object in babylon space.
  27922. */
  27923. rotationQuaternion: Quaternion;
  27924. /**
  27925. * The position of the device in babylon space.
  27926. */
  27927. devicePosition?: Vector3;
  27928. /**
  27929. * The rotation quaternion of the device in babylon space.
  27930. */
  27931. deviceRotationQuaternion: Quaternion;
  27932. /**
  27933. * The raw pose coming from the device.
  27934. */
  27935. rawPose: Nullable<DevicePose>;
  27936. /**
  27937. * The scale of the device to be used when translating from device space to babylon space.
  27938. */
  27939. deviceScaleFactor: number;
  27940. /**
  27941. * Updates the poseControlled values based on the input device pose.
  27942. * @param poseData the pose data to update the object with
  27943. */
  27944. updateFromDevice(poseData: DevicePose): void;
  27945. }
  27946. /**
  27947. * Set of options to customize the webVRCamera
  27948. */
  27949. export interface WebVROptions {
  27950. /**
  27951. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27952. */
  27953. trackPosition?: boolean;
  27954. /**
  27955. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27956. */
  27957. positionScale?: number;
  27958. /**
  27959. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27960. */
  27961. displayName?: string;
  27962. /**
  27963. * Should the native controller meshes be initialized. (default: true)
  27964. */
  27965. controllerMeshes?: boolean;
  27966. /**
  27967. * Creating a default HemiLight only on controllers. (default: true)
  27968. */
  27969. defaultLightingOnControllers?: boolean;
  27970. /**
  27971. * If you don't want to use the default VR button of the helper. (default: false)
  27972. */
  27973. useCustomVRButton?: boolean;
  27974. /**
  27975. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27976. */
  27977. customVRButton?: HTMLButtonElement;
  27978. /**
  27979. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27980. */
  27981. rayLength?: number;
  27982. /**
  27983. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27984. */
  27985. defaultHeight?: number;
  27986. /**
  27987. * If multiview should be used if availible (default: false)
  27988. */
  27989. useMultiview?: boolean;
  27990. }
  27991. /**
  27992. * This represents a WebVR camera.
  27993. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27994. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27995. */
  27996. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27997. private webVROptions;
  27998. /**
  27999. * @hidden
  28000. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28001. */
  28002. _vrDevice: any;
  28003. /**
  28004. * The rawPose of the vrDevice.
  28005. */
  28006. rawPose: Nullable<DevicePose>;
  28007. private _onVREnabled;
  28008. private _specsVersion;
  28009. private _attached;
  28010. private _frameData;
  28011. protected _descendants: Array<Node>;
  28012. private _deviceRoomPosition;
  28013. /** @hidden */
  28014. _deviceRoomRotationQuaternion: Quaternion;
  28015. private _standingMatrix;
  28016. /**
  28017. * Represents device position in babylon space.
  28018. */
  28019. devicePosition: Vector3;
  28020. /**
  28021. * Represents device rotation in babylon space.
  28022. */
  28023. deviceRotationQuaternion: Quaternion;
  28024. /**
  28025. * The scale of the device to be used when translating from device space to babylon space.
  28026. */
  28027. deviceScaleFactor: number;
  28028. private _deviceToWorld;
  28029. private _worldToDevice;
  28030. /**
  28031. * References to the webVR controllers for the vrDevice.
  28032. */
  28033. controllers: Array<WebVRController>;
  28034. /**
  28035. * Emits an event when a controller is attached.
  28036. */
  28037. onControllersAttachedObservable: Observable<WebVRController[]>;
  28038. /**
  28039. * Emits an event when a controller's mesh has been loaded;
  28040. */
  28041. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28042. /**
  28043. * Emits an event when the HMD's pose has been updated.
  28044. */
  28045. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28046. private _poseSet;
  28047. /**
  28048. * If the rig cameras be used as parent instead of this camera.
  28049. */
  28050. rigParenting: boolean;
  28051. private _lightOnControllers;
  28052. private _defaultHeight?;
  28053. /**
  28054. * Instantiates a WebVRFreeCamera.
  28055. * @param name The name of the WebVRFreeCamera
  28056. * @param position The starting anchor position for the camera
  28057. * @param scene The scene the camera belongs to
  28058. * @param webVROptions a set of customizable options for the webVRCamera
  28059. */
  28060. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28061. /**
  28062. * Gets the device distance from the ground in meters.
  28063. * @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.
  28064. */
  28065. deviceDistanceToRoomGround(): number;
  28066. /**
  28067. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28068. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28069. */
  28070. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28071. /**
  28072. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28073. * @returns A promise with a boolean set to if the standing matrix is supported.
  28074. */
  28075. useStandingMatrixAsync(): Promise<boolean>;
  28076. /**
  28077. * Disposes the camera
  28078. */
  28079. dispose(): void;
  28080. /**
  28081. * Gets a vrController by name.
  28082. * @param name The name of the controller to retreive
  28083. * @returns the controller matching the name specified or null if not found
  28084. */
  28085. getControllerByName(name: string): Nullable<WebVRController>;
  28086. private _leftController;
  28087. /**
  28088. * The controller corresponding to the users left hand.
  28089. */
  28090. get leftController(): Nullable<WebVRController>;
  28091. private _rightController;
  28092. /**
  28093. * The controller corresponding to the users right hand.
  28094. */
  28095. get rightController(): Nullable<WebVRController>;
  28096. /**
  28097. * Casts a ray forward from the vrCamera's gaze.
  28098. * @param length Length of the ray (default: 100)
  28099. * @returns the ray corresponding to the gaze
  28100. */
  28101. getForwardRay(length?: number): Ray;
  28102. /**
  28103. * @hidden
  28104. * Updates the camera based on device's frame data
  28105. */
  28106. _checkInputs(): void;
  28107. /**
  28108. * Updates the poseControlled values based on the input device pose.
  28109. * @param poseData Pose coming from the device
  28110. */
  28111. updateFromDevice(poseData: DevicePose): void;
  28112. private _detachIfAttached;
  28113. /**
  28114. * WebVR's attach control will start broadcasting frames to the device.
  28115. * Note that in certain browsers (chrome for example) this function must be called
  28116. * within a user-interaction callback. Example:
  28117. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28118. *
  28119. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28120. */
  28121. attachControl(noPreventDefault?: boolean): void;
  28122. /**
  28123. * Detach the current controls from the specified dom element.
  28124. */
  28125. detachControl(): void;
  28126. /**
  28127. * @returns the name of this class
  28128. */
  28129. getClassName(): string;
  28130. /**
  28131. * Calls resetPose on the vrDisplay
  28132. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28133. */
  28134. resetToCurrentRotation(): void;
  28135. /**
  28136. * @hidden
  28137. * Updates the rig cameras (left and right eye)
  28138. */
  28139. _updateRigCameras(): void;
  28140. private _workingVector;
  28141. private _oneVector;
  28142. private _workingMatrix;
  28143. private updateCacheCalled;
  28144. private _correctPositionIfNotTrackPosition;
  28145. /**
  28146. * @hidden
  28147. * Updates the cached values of the camera
  28148. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28149. */
  28150. _updateCache(ignoreParentClass?: boolean): void;
  28151. /**
  28152. * @hidden
  28153. * Get current device position in babylon world
  28154. */
  28155. _computeDevicePosition(): void;
  28156. /**
  28157. * Updates the current device position and rotation in the babylon world
  28158. */
  28159. update(): void;
  28160. /**
  28161. * @hidden
  28162. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28163. * @returns an identity matrix
  28164. */
  28165. _getViewMatrix(): Matrix;
  28166. private _tmpMatrix;
  28167. /**
  28168. * This function is called by the two RIG cameras.
  28169. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28170. * @hidden
  28171. */
  28172. _getWebVRViewMatrix(): Matrix;
  28173. /** @hidden */
  28174. _getWebVRProjectionMatrix(): Matrix;
  28175. private _onGamepadConnectedObserver;
  28176. private _onGamepadDisconnectedObserver;
  28177. private _updateCacheWhenTrackingDisabledObserver;
  28178. /**
  28179. * Initializes the controllers and their meshes
  28180. */
  28181. initControllers(): void;
  28182. }
  28183. }
  28184. declare module "babylonjs/Materials/materialHelper" {
  28185. import { Nullable } from "babylonjs/types";
  28186. import { Scene } from "babylonjs/scene";
  28187. import { Engine } from "babylonjs/Engines/engine";
  28188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28189. import { Light } from "babylonjs/Lights/light";
  28190. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28191. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28192. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28194. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28195. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28196. /**
  28197. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28198. *
  28199. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28200. *
  28201. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28202. */
  28203. export class MaterialHelper {
  28204. /**
  28205. * Bind the current view position to an effect.
  28206. * @param effect The effect to be bound
  28207. * @param scene The scene the eyes position is used from
  28208. * @param variableName name of the shader variable that will hold the eye position
  28209. */
  28210. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28211. /**
  28212. * Helps preparing the defines values about the UVs in used in the effect.
  28213. * UVs are shared as much as we can accross channels in the shaders.
  28214. * @param texture The texture we are preparing the UVs for
  28215. * @param defines The defines to update
  28216. * @param key The channel key "diffuse", "specular"... used in the shader
  28217. */
  28218. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28219. /**
  28220. * Binds a texture matrix value to its corrsponding uniform
  28221. * @param texture The texture to bind the matrix for
  28222. * @param uniformBuffer The uniform buffer receivin the data
  28223. * @param key The channel key "diffuse", "specular"... used in the shader
  28224. */
  28225. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28226. /**
  28227. * Gets the current status of the fog (should it be enabled?)
  28228. * @param mesh defines the mesh to evaluate for fog support
  28229. * @param scene defines the hosting scene
  28230. * @returns true if fog must be enabled
  28231. */
  28232. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28233. /**
  28234. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28235. * @param mesh defines the current mesh
  28236. * @param scene defines the current scene
  28237. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28238. * @param pointsCloud defines if point cloud rendering has to be turned on
  28239. * @param fogEnabled defines if fog has to be turned on
  28240. * @param alphaTest defines if alpha testing has to be turned on
  28241. * @param defines defines the current list of defines
  28242. */
  28243. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28244. /**
  28245. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28246. * @param scene defines the current scene
  28247. * @param engine defines the current engine
  28248. * @param defines specifies the list of active defines
  28249. * @param useInstances defines if instances have to be turned on
  28250. * @param useClipPlane defines if clip plane have to be turned on
  28251. * @param useInstances defines if instances have to be turned on
  28252. * @param useThinInstances defines if thin instances have to be turned on
  28253. */
  28254. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28255. /**
  28256. * Prepares the defines for bones
  28257. * @param mesh The mesh containing the geometry data we will draw
  28258. * @param defines The defines to update
  28259. */
  28260. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28261. /**
  28262. * Prepares the defines for morph targets
  28263. * @param mesh The mesh containing the geometry data we will draw
  28264. * @param defines The defines to update
  28265. */
  28266. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28267. /**
  28268. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28269. * @param mesh The mesh containing the geometry data we will draw
  28270. * @param defines The defines to update
  28271. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28272. * @param useBones Precise whether bones should be used or not (override mesh info)
  28273. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28274. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28275. * @returns false if defines are considered not dirty and have not been checked
  28276. */
  28277. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28278. /**
  28279. * Prepares the defines related to multiview
  28280. * @param scene The scene we are intending to draw
  28281. * @param defines The defines to update
  28282. */
  28283. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28284. /**
  28285. * Prepares the defines related to the prepass
  28286. * @param scene The scene we are intending to draw
  28287. * @param defines The defines to update
  28288. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28289. */
  28290. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28291. /**
  28292. * Prepares the defines related to the light information passed in parameter
  28293. * @param scene The scene we are intending to draw
  28294. * @param mesh The mesh the effect is compiling for
  28295. * @param light The light the effect is compiling for
  28296. * @param lightIndex The index of the light
  28297. * @param defines The defines to update
  28298. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28299. * @param state Defines the current state regarding what is needed (normals, etc...)
  28300. */
  28301. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28302. needNormals: boolean;
  28303. needRebuild: boolean;
  28304. shadowEnabled: boolean;
  28305. specularEnabled: boolean;
  28306. lightmapMode: boolean;
  28307. }): void;
  28308. /**
  28309. * Prepares the defines related to the light information passed in parameter
  28310. * @param scene The scene we are intending to draw
  28311. * @param mesh The mesh the effect is compiling for
  28312. * @param defines The defines to update
  28313. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28314. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28315. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28316. * @returns true if normals will be required for the rest of the effect
  28317. */
  28318. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28319. /**
  28320. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28321. * @param lightIndex defines the light index
  28322. * @param uniformsList The uniform list
  28323. * @param samplersList The sampler list
  28324. * @param projectedLightTexture defines if projected texture must be used
  28325. * @param uniformBuffersList defines an optional list of uniform buffers
  28326. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28327. */
  28328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28329. /**
  28330. * Prepares the uniforms and samplers list to be used in the effect
  28331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28332. * @param samplersList The sampler list
  28333. * @param defines The defines helping in the list generation
  28334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28335. */
  28336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28337. /**
  28338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28339. * @param defines The defines to update while falling back
  28340. * @param fallbacks The authorized effect fallbacks
  28341. * @param maxSimultaneousLights The maximum number of lights allowed
  28342. * @param rank the current rank of the Effect
  28343. * @returns The newly affected rank
  28344. */
  28345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28346. private static _TmpMorphInfluencers;
  28347. /**
  28348. * Prepares the list of attributes required for morph targets according to the effect defines.
  28349. * @param attribs The current list of supported attribs
  28350. * @param mesh The mesh to prepare the morph targets attributes for
  28351. * @param influencers The number of influencers
  28352. */
  28353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28354. /**
  28355. * Prepares the list of attributes required for morph targets according to the effect defines.
  28356. * @param attribs The current list of supported attribs
  28357. * @param mesh The mesh to prepare the morph targets attributes for
  28358. * @param defines The current Defines of the effect
  28359. */
  28360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28361. /**
  28362. * Prepares the list of attributes required for bones according to the effect defines.
  28363. * @param attribs The current list of supported attribs
  28364. * @param mesh The mesh to prepare the bones attributes for
  28365. * @param defines The current Defines of the effect
  28366. * @param fallbacks The current efffect fallback strategy
  28367. */
  28368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28369. /**
  28370. * Check and prepare the list of attributes required for instances according to the effect defines.
  28371. * @param attribs The current list of supported attribs
  28372. * @param defines The current MaterialDefines of the effect
  28373. */
  28374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28375. /**
  28376. * Add the list of attributes required for instances to the attribs array.
  28377. * @param attribs The current list of supported attribs
  28378. */
  28379. static PushAttributesForInstances(attribs: string[]): void;
  28380. /**
  28381. * Binds the light information to the effect.
  28382. * @param light The light containing the generator
  28383. * @param effect The effect we are binding the data to
  28384. * @param lightIndex The light index in the effect used to render
  28385. */
  28386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28387. /**
  28388. * Binds the lights information from the scene to the effect for the given mesh.
  28389. * @param light Light to bind
  28390. * @param lightIndex Light index
  28391. * @param scene The scene where the light belongs to
  28392. * @param effect The effect we are binding the data to
  28393. * @param useSpecular Defines if specular is supported
  28394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28395. */
  28396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28397. /**
  28398. * Binds the lights information from the scene to the effect for the given mesh.
  28399. * @param scene The scene the lights belongs to
  28400. * @param mesh The mesh we are binding the information to render
  28401. * @param effect The effect we are binding the data to
  28402. * @param defines The generated defines for the effect
  28403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28405. */
  28406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28407. private static _tempFogColor;
  28408. /**
  28409. * Binds the fog information from the scene to the effect for the given mesh.
  28410. * @param scene The scene the lights belongs to
  28411. * @param mesh The mesh we are binding the information to render
  28412. * @param effect The effect we are binding the data to
  28413. * @param linearSpace Defines if the fog effect is applied in linear space
  28414. */
  28415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28416. /**
  28417. * Binds the bones information from the mesh to the effect.
  28418. * @param mesh The mesh we are binding the information to render
  28419. * @param effect The effect we are binding the data to
  28420. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28421. */
  28422. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28423. private static _CopyBonesTransformationMatrices;
  28424. /**
  28425. * Binds the morph targets information from the mesh to the effect.
  28426. * @param abstractMesh The mesh we are binding the information to render
  28427. * @param effect The effect we are binding the data to
  28428. */
  28429. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28430. /**
  28431. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28432. * @param defines The generated defines used in the effect
  28433. * @param effect The effect we are binding the data to
  28434. * @param scene The scene we are willing to render with logarithmic scale for
  28435. */
  28436. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28437. /**
  28438. * Binds the clip plane information from the scene to the effect.
  28439. * @param scene The scene the clip plane information are extracted from
  28440. * @param effect The effect we are binding the data to
  28441. */
  28442. static BindClipPlane(effect: Effect, scene: Scene): void;
  28443. }
  28444. }
  28445. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28446. /** @hidden */
  28447. export var bayerDitherFunctions: {
  28448. name: string;
  28449. shader: string;
  28450. };
  28451. }
  28452. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28453. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28454. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28455. /** @hidden */
  28456. export var shadowMapFragmentDeclaration: {
  28457. name: string;
  28458. shader: string;
  28459. };
  28460. }
  28461. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28462. /** @hidden */
  28463. export var shadowMapFragment: {
  28464. name: string;
  28465. shader: string;
  28466. };
  28467. }
  28468. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28469. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28470. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28471. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28472. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28473. /** @hidden */
  28474. export var shadowMapPixelShader: {
  28475. name: string;
  28476. shader: string;
  28477. };
  28478. }
  28479. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28480. /** @hidden */
  28481. export var shadowMapVertexDeclaration: {
  28482. name: string;
  28483. shader: string;
  28484. };
  28485. }
  28486. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28487. /** @hidden */
  28488. export var shadowMapVertexNormalBias: {
  28489. name: string;
  28490. shader: string;
  28491. };
  28492. }
  28493. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28494. /** @hidden */
  28495. export var shadowMapVertexMetric: {
  28496. name: string;
  28497. shader: string;
  28498. };
  28499. }
  28500. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28501. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28504. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28506. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28507. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28510. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28511. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28512. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28513. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28514. /** @hidden */
  28515. export var shadowMapVertexShader: {
  28516. name: string;
  28517. shader: string;
  28518. };
  28519. }
  28520. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28521. /** @hidden */
  28522. export var depthBoxBlurPixelShader: {
  28523. name: string;
  28524. shader: string;
  28525. };
  28526. }
  28527. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28528. /** @hidden */
  28529. export var shadowMapFragmentSoftTransparentShadow: {
  28530. name: string;
  28531. shader: string;
  28532. };
  28533. }
  28534. declare module "babylonjs/Meshes/instancedMesh" {
  28535. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28536. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28537. import { Camera } from "babylonjs/Cameras/camera";
  28538. import { Node } from "babylonjs/node";
  28539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28540. import { Mesh } from "babylonjs/Meshes/mesh";
  28541. import { Material } from "babylonjs/Materials/material";
  28542. import { Skeleton } from "babylonjs/Bones/skeleton";
  28543. import { Light } from "babylonjs/Lights/light";
  28544. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28545. /**
  28546. * Creates an instance based on a source mesh.
  28547. */
  28548. export class InstancedMesh extends AbstractMesh {
  28549. private _sourceMesh;
  28550. private _currentLOD;
  28551. /** @hidden */
  28552. _indexInSourceMeshInstanceArray: number;
  28553. constructor(name: string, source: Mesh);
  28554. /**
  28555. * Returns the string "InstancedMesh".
  28556. */
  28557. getClassName(): string;
  28558. /** Gets the list of lights affecting that mesh */
  28559. get lightSources(): Light[];
  28560. _resyncLightSources(): void;
  28561. _resyncLightSource(light: Light): void;
  28562. _removeLightSource(light: Light, dispose: boolean): void;
  28563. /**
  28564. * If the source mesh receives shadows
  28565. */
  28566. get receiveShadows(): boolean;
  28567. /**
  28568. * The material of the source mesh
  28569. */
  28570. get material(): Nullable<Material>;
  28571. /**
  28572. * Visibility of the source mesh
  28573. */
  28574. get visibility(): number;
  28575. /**
  28576. * Skeleton of the source mesh
  28577. */
  28578. get skeleton(): Nullable<Skeleton>;
  28579. /**
  28580. * Rendering ground id of the source mesh
  28581. */
  28582. get renderingGroupId(): number;
  28583. set renderingGroupId(value: number);
  28584. /**
  28585. * Returns the total number of vertices (integer).
  28586. */
  28587. getTotalVertices(): number;
  28588. /**
  28589. * Returns a positive integer : the total number of indices in this mesh geometry.
  28590. * @returns the numner of indices or zero if the mesh has no geometry.
  28591. */
  28592. getTotalIndices(): number;
  28593. /**
  28594. * The source mesh of the instance
  28595. */
  28596. get sourceMesh(): Mesh;
  28597. /**
  28598. * Creates a new InstancedMesh object from the mesh model.
  28599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28600. * @param name defines the name of the new instance
  28601. * @returns a new InstancedMesh
  28602. */
  28603. createInstance(name: string): InstancedMesh;
  28604. /**
  28605. * Is this node ready to be used/rendered
  28606. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28607. * @return {boolean} is it ready
  28608. */
  28609. isReady(completeCheck?: boolean): boolean;
  28610. /**
  28611. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28612. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28613. * @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.
  28614. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28615. */
  28616. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28617. /**
  28618. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28619. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28620. * The `data` are either a numeric array either a Float32Array.
  28621. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28622. * 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).
  28623. * Note that a new underlying VertexBuffer object is created each call.
  28624. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28625. *
  28626. * Possible `kind` values :
  28627. * - VertexBuffer.PositionKind
  28628. * - VertexBuffer.UVKind
  28629. * - VertexBuffer.UV2Kind
  28630. * - VertexBuffer.UV3Kind
  28631. * - VertexBuffer.UV4Kind
  28632. * - VertexBuffer.UV5Kind
  28633. * - VertexBuffer.UV6Kind
  28634. * - VertexBuffer.ColorKind
  28635. * - VertexBuffer.MatricesIndicesKind
  28636. * - VertexBuffer.MatricesIndicesExtraKind
  28637. * - VertexBuffer.MatricesWeightsKind
  28638. * - VertexBuffer.MatricesWeightsExtraKind
  28639. *
  28640. * Returns the Mesh.
  28641. */
  28642. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28643. /**
  28644. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28645. * If the mesh has no geometry, it is simply returned as it is.
  28646. * The `data` are either a numeric array either a Float32Array.
  28647. * No new underlying VertexBuffer object is created.
  28648. * 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.
  28649. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28650. *
  28651. * Possible `kind` values :
  28652. * - VertexBuffer.PositionKind
  28653. * - VertexBuffer.UVKind
  28654. * - VertexBuffer.UV2Kind
  28655. * - VertexBuffer.UV3Kind
  28656. * - VertexBuffer.UV4Kind
  28657. * - VertexBuffer.UV5Kind
  28658. * - VertexBuffer.UV6Kind
  28659. * - VertexBuffer.ColorKind
  28660. * - VertexBuffer.MatricesIndicesKind
  28661. * - VertexBuffer.MatricesIndicesExtraKind
  28662. * - VertexBuffer.MatricesWeightsKind
  28663. * - VertexBuffer.MatricesWeightsExtraKind
  28664. *
  28665. * Returns the Mesh.
  28666. */
  28667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28668. /**
  28669. * Sets the mesh indices.
  28670. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28671. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28672. * This method creates a new index buffer each call.
  28673. * Returns the Mesh.
  28674. */
  28675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28676. /**
  28677. * Boolean : True if the mesh owns the requested kind of data.
  28678. */
  28679. isVerticesDataPresent(kind: string): boolean;
  28680. /**
  28681. * Returns an array of indices (IndicesArray).
  28682. */
  28683. getIndices(): Nullable<IndicesArray>;
  28684. get _positions(): Nullable<Vector3[]>;
  28685. /**
  28686. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28687. * This means the mesh underlying bounding box and sphere are recomputed.
  28688. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28689. * @returns the current mesh
  28690. */
  28691. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28692. /** @hidden */
  28693. _preActivate(): InstancedMesh;
  28694. /** @hidden */
  28695. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28696. /** @hidden */
  28697. _postActivate(): void;
  28698. getWorldMatrix(): Matrix;
  28699. get isAnInstance(): boolean;
  28700. /**
  28701. * Returns the current associated LOD AbstractMesh.
  28702. */
  28703. getLOD(camera: Camera): AbstractMesh;
  28704. /** @hidden */
  28705. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28706. /** @hidden */
  28707. _syncSubMeshes(): InstancedMesh;
  28708. /** @hidden */
  28709. _generatePointsArray(): boolean;
  28710. /** @hidden */
  28711. _updateBoundingInfo(): AbstractMesh;
  28712. /**
  28713. * Creates a new InstancedMesh from the current mesh.
  28714. * - name (string) : the cloned mesh name
  28715. * - newParent (optional Node) : the optional Node to parent the clone to.
  28716. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28717. *
  28718. * Returns the clone.
  28719. */
  28720. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28721. /**
  28722. * Disposes the InstancedMesh.
  28723. * Returns nothing.
  28724. */
  28725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28726. }
  28727. module "babylonjs/Meshes/mesh" {
  28728. interface Mesh {
  28729. /**
  28730. * Register a custom buffer that will be instanced
  28731. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28732. * @param kind defines the buffer kind
  28733. * @param stride defines the stride in floats
  28734. */
  28735. registerInstancedBuffer(kind: string, stride: number): void;
  28736. /**
  28737. * true to use the edge renderer for all instances of this mesh
  28738. */
  28739. edgesShareWithInstances: boolean;
  28740. /** @hidden */
  28741. _userInstancedBuffersStorage: {
  28742. data: {
  28743. [key: string]: Float32Array;
  28744. };
  28745. sizes: {
  28746. [key: string]: number;
  28747. };
  28748. vertexBuffers: {
  28749. [key: string]: Nullable<VertexBuffer>;
  28750. };
  28751. strides: {
  28752. [key: string]: number;
  28753. };
  28754. };
  28755. }
  28756. }
  28757. module "babylonjs/Meshes/abstractMesh" {
  28758. interface AbstractMesh {
  28759. /**
  28760. * Object used to store instanced buffers defined by user
  28761. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28762. */
  28763. instancedBuffers: {
  28764. [key: string]: any;
  28765. };
  28766. }
  28767. }
  28768. }
  28769. declare module "babylonjs/Materials/shaderMaterial" {
  28770. import { Nullable } from "babylonjs/types";
  28771. import { Scene } from "babylonjs/scene";
  28772. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28774. import { Mesh } from "babylonjs/Meshes/mesh";
  28775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28777. import { Effect } from "babylonjs/Materials/effect";
  28778. import { Material } from "babylonjs/Materials/material";
  28779. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28780. /**
  28781. * Defines the options associated with the creation of a shader material.
  28782. */
  28783. export interface IShaderMaterialOptions {
  28784. /**
  28785. * Does the material work in alpha blend mode
  28786. */
  28787. needAlphaBlending: boolean;
  28788. /**
  28789. * Does the material work in alpha test mode
  28790. */
  28791. needAlphaTesting: boolean;
  28792. /**
  28793. * The list of attribute names used in the shader
  28794. */
  28795. attributes: string[];
  28796. /**
  28797. * The list of unifrom names used in the shader
  28798. */
  28799. uniforms: string[];
  28800. /**
  28801. * The list of UBO names used in the shader
  28802. */
  28803. uniformBuffers: string[];
  28804. /**
  28805. * The list of sampler names used in the shader
  28806. */
  28807. samplers: string[];
  28808. /**
  28809. * The list of defines used in the shader
  28810. */
  28811. defines: string[];
  28812. }
  28813. /**
  28814. * 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.
  28815. *
  28816. * This returned material effects how the mesh will look based on the code in the shaders.
  28817. *
  28818. * @see https://doc.babylonjs.com/how_to/shader_material
  28819. */
  28820. export class ShaderMaterial extends Material {
  28821. private _shaderPath;
  28822. private _options;
  28823. private _textures;
  28824. private _textureArrays;
  28825. private _floats;
  28826. private _ints;
  28827. private _floatsArrays;
  28828. private _colors3;
  28829. private _colors3Arrays;
  28830. private _colors4;
  28831. private _colors4Arrays;
  28832. private _vectors2;
  28833. private _vectors3;
  28834. private _vectors4;
  28835. private _matrices;
  28836. private _matrixArrays;
  28837. private _matrices3x3;
  28838. private _matrices2x2;
  28839. private _vectors2Arrays;
  28840. private _vectors3Arrays;
  28841. private _vectors4Arrays;
  28842. private _cachedWorldViewMatrix;
  28843. private _cachedWorldViewProjectionMatrix;
  28844. private _renderId;
  28845. private _multiview;
  28846. private _cachedDefines;
  28847. /** Define the Url to load snippets */
  28848. static SnippetUrl: string;
  28849. /** Snippet ID if the material was created from the snippet server */
  28850. snippetId: string;
  28851. /**
  28852. * Instantiate a new shader material.
  28853. * 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.
  28854. * This returned material effects how the mesh will look based on the code in the shaders.
  28855. * @see https://doc.babylonjs.com/how_to/shader_material
  28856. * @param name Define the name of the material in the scene
  28857. * @param scene Define the scene the material belongs to
  28858. * @param shaderPath Defines the route to the shader code in one of three ways:
  28859. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28860. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28861. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28862. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28863. * @param options Define the options used to create the shader
  28864. */
  28865. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28866. /**
  28867. * Gets the shader path used to define the shader code
  28868. * It can be modified to trigger a new compilation
  28869. */
  28870. get shaderPath(): any;
  28871. /**
  28872. * Sets the shader path used to define the shader code
  28873. * It can be modified to trigger a new compilation
  28874. */
  28875. set shaderPath(shaderPath: any);
  28876. /**
  28877. * Gets the options used to compile the shader.
  28878. * They can be modified to trigger a new compilation
  28879. */
  28880. get options(): IShaderMaterialOptions;
  28881. /**
  28882. * Gets the current class name of the material e.g. "ShaderMaterial"
  28883. * Mainly use in serialization.
  28884. * @returns the class name
  28885. */
  28886. getClassName(): string;
  28887. /**
  28888. * Specifies if the material will require alpha blending
  28889. * @returns a boolean specifying if alpha blending is needed
  28890. */
  28891. needAlphaBlending(): boolean;
  28892. /**
  28893. * Specifies if this material should be rendered in alpha test mode
  28894. * @returns a boolean specifying if an alpha test is needed.
  28895. */
  28896. needAlphaTesting(): boolean;
  28897. private _checkUniform;
  28898. /**
  28899. * Set a texture in the shader.
  28900. * @param name Define the name of the uniform samplers as defined in the shader
  28901. * @param texture Define the texture to bind to this sampler
  28902. * @return the material itself allowing "fluent" like uniform updates
  28903. */
  28904. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28905. /**
  28906. * Set a texture array in the shader.
  28907. * @param name Define the name of the uniform sampler array as defined in the shader
  28908. * @param textures Define the list of textures to bind to this sampler
  28909. * @return the material itself allowing "fluent" like uniform updates
  28910. */
  28911. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28912. /**
  28913. * Set a float in the shader.
  28914. * @param name Define the name of the uniform as defined in the shader
  28915. * @param value Define the value to give to the uniform
  28916. * @return the material itself allowing "fluent" like uniform updates
  28917. */
  28918. setFloat(name: string, value: number): ShaderMaterial;
  28919. /**
  28920. * Set a int in the shader.
  28921. * @param name Define the name of the uniform as defined in the shader
  28922. * @param value Define the value to give to the uniform
  28923. * @return the material itself allowing "fluent" like uniform updates
  28924. */
  28925. setInt(name: string, value: number): ShaderMaterial;
  28926. /**
  28927. * Set an array of floats in the shader.
  28928. * @param name Define the name of the uniform as defined in the shader
  28929. * @param value Define the value to give to the uniform
  28930. * @return the material itself allowing "fluent" like uniform updates
  28931. */
  28932. setFloats(name: string, value: number[]): ShaderMaterial;
  28933. /**
  28934. * Set a vec3 in the shader from a Color3.
  28935. * @param name Define the name of the uniform as defined in the shader
  28936. * @param value Define the value to give to the uniform
  28937. * @return the material itself allowing "fluent" like uniform updates
  28938. */
  28939. setColor3(name: string, value: Color3): ShaderMaterial;
  28940. /**
  28941. * Set a vec3 array in the shader from a Color3 array.
  28942. * @param name Define the name of the uniform as defined in the shader
  28943. * @param value Define the value to give to the uniform
  28944. * @return the material itself allowing "fluent" like uniform updates
  28945. */
  28946. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28947. /**
  28948. * Set a vec4 in the shader from a Color4.
  28949. * @param name Define the name of the uniform as defined in the shader
  28950. * @param value Define the value to give to the uniform
  28951. * @return the material itself allowing "fluent" like uniform updates
  28952. */
  28953. setColor4(name: string, value: Color4): ShaderMaterial;
  28954. /**
  28955. * Set a vec4 array in the shader from a Color4 array.
  28956. * @param name Define the name of the uniform as defined in the shader
  28957. * @param value Define the value to give to the uniform
  28958. * @return the material itself allowing "fluent" like uniform updates
  28959. */
  28960. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28961. /**
  28962. * Set a vec2 in the shader from a Vector2.
  28963. * @param name Define the name of the uniform as defined in the shader
  28964. * @param value Define the value to give to the uniform
  28965. * @return the material itself allowing "fluent" like uniform updates
  28966. */
  28967. setVector2(name: string, value: Vector2): ShaderMaterial;
  28968. /**
  28969. * Set a vec3 in the shader from a Vector3.
  28970. * @param name Define the name of the uniform as defined in the shader
  28971. * @param value Define the value to give to the uniform
  28972. * @return the material itself allowing "fluent" like uniform updates
  28973. */
  28974. setVector3(name: string, value: Vector3): ShaderMaterial;
  28975. /**
  28976. * Set a vec4 in the shader from a Vector4.
  28977. * @param name Define the name of the uniform as defined in the shader
  28978. * @param value Define the value to give to the uniform
  28979. * @return the material itself allowing "fluent" like uniform updates
  28980. */
  28981. setVector4(name: string, value: Vector4): ShaderMaterial;
  28982. /**
  28983. * Set a mat4 in the shader from a Matrix.
  28984. * @param name Define the name of the uniform as defined in the shader
  28985. * @param value Define the value to give to the uniform
  28986. * @return the material itself allowing "fluent" like uniform updates
  28987. */
  28988. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28989. /**
  28990. * Set a float32Array in the shader from a matrix array.
  28991. * @param name Define the name of the uniform as defined in the shader
  28992. * @param value Define the value to give to the uniform
  28993. * @return the material itself allowing "fluent" like uniform updates
  28994. */
  28995. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28996. /**
  28997. * Set a mat3 in the shader from a Float32Array.
  28998. * @param name Define the name of the uniform as defined in the shader
  28999. * @param value Define the value to give to the uniform
  29000. * @return the material itself allowing "fluent" like uniform updates
  29001. */
  29002. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29003. /**
  29004. * Set a mat2 in the shader from a Float32Array.
  29005. * @param name Define the name of the uniform as defined in the shader
  29006. * @param value Define the value to give to the uniform
  29007. * @return the material itself allowing "fluent" like uniform updates
  29008. */
  29009. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29010. /**
  29011. * Set a vec2 array in the shader from a number array.
  29012. * @param name Define the name of the uniform as defined in the shader
  29013. * @param value Define the value to give to the uniform
  29014. * @return the material itself allowing "fluent" like uniform updates
  29015. */
  29016. setArray2(name: string, value: number[]): ShaderMaterial;
  29017. /**
  29018. * Set a vec3 array in the shader from a number array.
  29019. * @param name Define the name of the uniform as defined in the shader
  29020. * @param value Define the value to give to the uniform
  29021. * @return the material itself allowing "fluent" like uniform updates
  29022. */
  29023. setArray3(name: string, value: number[]): ShaderMaterial;
  29024. /**
  29025. * Set a vec4 array in the shader from a number array.
  29026. * @param name Define the name of the uniform as defined in the shader
  29027. * @param value Define the value to give to the uniform
  29028. * @return the material itself allowing "fluent" like uniform updates
  29029. */
  29030. setArray4(name: string, value: number[]): ShaderMaterial;
  29031. private _checkCache;
  29032. /**
  29033. * Specifies that the submesh is ready to be used
  29034. * @param mesh defines the mesh to check
  29035. * @param subMesh defines which submesh to check
  29036. * @param useInstances specifies that instances should be used
  29037. * @returns a boolean indicating that the submesh is ready or not
  29038. */
  29039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29040. /**
  29041. * Checks if the material is ready to render the requested mesh
  29042. * @param mesh Define the mesh to render
  29043. * @param useInstances Define whether or not the material is used with instances
  29044. * @returns true if ready, otherwise false
  29045. */
  29046. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29047. /**
  29048. * Binds the world matrix to the material
  29049. * @param world defines the world transformation matrix
  29050. * @param effectOverride - If provided, use this effect instead of internal effect
  29051. */
  29052. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29053. /**
  29054. * Binds the submesh to this material by preparing the effect and shader to draw
  29055. * @param world defines the world transformation matrix
  29056. * @param mesh defines the mesh containing the submesh
  29057. * @param subMesh defines the submesh to bind the material to
  29058. */
  29059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29060. /**
  29061. * Binds the material to the mesh
  29062. * @param world defines the world transformation matrix
  29063. * @param mesh defines the mesh to bind the material to
  29064. * @param effectOverride - If provided, use this effect instead of internal effect
  29065. */
  29066. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29067. protected _afterBind(mesh?: Mesh): void;
  29068. /**
  29069. * Gets the active textures from the material
  29070. * @returns an array of textures
  29071. */
  29072. getActiveTextures(): BaseTexture[];
  29073. /**
  29074. * Specifies if the material uses a texture
  29075. * @param texture defines the texture to check against the material
  29076. * @returns a boolean specifying if the material uses the texture
  29077. */
  29078. hasTexture(texture: BaseTexture): boolean;
  29079. /**
  29080. * Makes a duplicate of the material, and gives it a new name
  29081. * @param name defines the new name for the duplicated material
  29082. * @returns the cloned material
  29083. */
  29084. clone(name: string): ShaderMaterial;
  29085. /**
  29086. * Disposes the material
  29087. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29088. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29089. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29090. */
  29091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29092. /**
  29093. * Serializes this material in a JSON representation
  29094. * @returns the serialized material object
  29095. */
  29096. serialize(): any;
  29097. /**
  29098. * Creates a shader material from parsed shader material data
  29099. * @param source defines the JSON represnetation of the material
  29100. * @param scene defines the hosting scene
  29101. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29102. * @returns a new material
  29103. */
  29104. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29105. /**
  29106. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29107. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29108. * @param url defines the url to load from
  29109. * @param scene defines the hosting scene
  29110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29111. * @returns a promise that will resolve to the new ShaderMaterial
  29112. */
  29113. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29114. /**
  29115. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29116. * @param snippetId defines the snippet to load
  29117. * @param scene defines the hosting scene
  29118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29119. * @returns a promise that will resolve to the new ShaderMaterial
  29120. */
  29121. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29122. }
  29123. }
  29124. declare module "babylonjs/Shaders/color.fragment" {
  29125. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29127. /** @hidden */
  29128. export var colorPixelShader: {
  29129. name: string;
  29130. shader: string;
  29131. };
  29132. }
  29133. declare module "babylonjs/Shaders/color.vertex" {
  29134. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29136. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29137. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29138. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29139. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29140. /** @hidden */
  29141. export var colorVertexShader: {
  29142. name: string;
  29143. shader: string;
  29144. };
  29145. }
  29146. declare module "babylonjs/Meshes/linesMesh" {
  29147. import { Nullable } from "babylonjs/types";
  29148. import { Scene } from "babylonjs/scene";
  29149. import { Color3 } from "babylonjs/Maths/math.color";
  29150. import { Node } from "babylonjs/node";
  29151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29152. import { Mesh } from "babylonjs/Meshes/mesh";
  29153. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29154. import { Effect } from "babylonjs/Materials/effect";
  29155. import { Material } from "babylonjs/Materials/material";
  29156. import "babylonjs/Shaders/color.fragment";
  29157. import "babylonjs/Shaders/color.vertex";
  29158. /**
  29159. * Line mesh
  29160. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29161. */
  29162. export class LinesMesh extends Mesh {
  29163. /**
  29164. * If vertex color should be applied to the mesh
  29165. */
  29166. readonly useVertexColor?: boolean | undefined;
  29167. /**
  29168. * If vertex alpha should be applied to the mesh
  29169. */
  29170. readonly useVertexAlpha?: boolean | undefined;
  29171. /**
  29172. * Color of the line (Default: White)
  29173. */
  29174. color: Color3;
  29175. /**
  29176. * Alpha of the line (Default: 1)
  29177. */
  29178. alpha: number;
  29179. /**
  29180. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29181. * This margin is expressed in world space coordinates, so its value may vary.
  29182. * Default value is 0.1
  29183. */
  29184. intersectionThreshold: number;
  29185. private _colorShader;
  29186. private color4;
  29187. /**
  29188. * Creates a new LinesMesh
  29189. * @param name defines the name
  29190. * @param scene defines the hosting scene
  29191. * @param parent defines the parent mesh if any
  29192. * @param source defines the optional source LinesMesh used to clone data from
  29193. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29194. * When false, achieved by calling a clone(), also passing False.
  29195. * This will make creation of children, recursive.
  29196. * @param useVertexColor defines if this LinesMesh supports vertex color
  29197. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29198. */
  29199. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29200. /**
  29201. * If vertex color should be applied to the mesh
  29202. */
  29203. useVertexColor?: boolean | undefined,
  29204. /**
  29205. * If vertex alpha should be applied to the mesh
  29206. */
  29207. useVertexAlpha?: boolean | undefined);
  29208. private _addClipPlaneDefine;
  29209. private _removeClipPlaneDefine;
  29210. isReady(): boolean;
  29211. /**
  29212. * Returns the string "LineMesh"
  29213. */
  29214. getClassName(): string;
  29215. /**
  29216. * @hidden
  29217. */
  29218. get material(): Material;
  29219. /**
  29220. * @hidden
  29221. */
  29222. set material(value: Material);
  29223. /**
  29224. * @hidden
  29225. */
  29226. get checkCollisions(): boolean;
  29227. /** @hidden */
  29228. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29229. /** @hidden */
  29230. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29231. /**
  29232. * Disposes of the line mesh
  29233. * @param doNotRecurse If children should be disposed
  29234. */
  29235. dispose(doNotRecurse?: boolean): void;
  29236. /**
  29237. * Returns a new LineMesh object cloned from the current one.
  29238. */
  29239. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29240. /**
  29241. * Creates a new InstancedLinesMesh object from the mesh model.
  29242. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29243. * @param name defines the name of the new instance
  29244. * @returns a new InstancedLinesMesh
  29245. */
  29246. createInstance(name: string): InstancedLinesMesh;
  29247. }
  29248. /**
  29249. * Creates an instance based on a source LinesMesh
  29250. */
  29251. export class InstancedLinesMesh extends InstancedMesh {
  29252. /**
  29253. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29254. * This margin is expressed in world space coordinates, so its value may vary.
  29255. * Initilized with the intersectionThreshold value of the source LinesMesh
  29256. */
  29257. intersectionThreshold: number;
  29258. constructor(name: string, source: LinesMesh);
  29259. /**
  29260. * Returns the string "InstancedLinesMesh".
  29261. */
  29262. getClassName(): string;
  29263. }
  29264. }
  29265. declare module "babylonjs/Shaders/line.fragment" {
  29266. /** @hidden */
  29267. export var linePixelShader: {
  29268. name: string;
  29269. shader: string;
  29270. };
  29271. }
  29272. declare module "babylonjs/Shaders/line.vertex" {
  29273. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29274. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29275. /** @hidden */
  29276. export var lineVertexShader: {
  29277. name: string;
  29278. shader: string;
  29279. };
  29280. }
  29281. declare module "babylonjs/Rendering/edgesRenderer" {
  29282. import { Immutable, Nullable } from "babylonjs/types";
  29283. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29285. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29286. import { IDisposable } from "babylonjs/scene";
  29287. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29288. import "babylonjs/Shaders/line.fragment";
  29289. import "babylonjs/Shaders/line.vertex";
  29290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29291. import { SmartArray } from "babylonjs/Misc/smartArray";
  29292. module "babylonjs/scene" {
  29293. interface Scene {
  29294. /** @hidden */
  29295. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29296. }
  29297. }
  29298. module "babylonjs/Meshes/abstractMesh" {
  29299. interface AbstractMesh {
  29300. /**
  29301. * Gets the edgesRenderer associated with the mesh
  29302. */
  29303. edgesRenderer: Nullable<EdgesRenderer>;
  29304. }
  29305. }
  29306. module "babylonjs/Meshes/linesMesh" {
  29307. interface LinesMesh {
  29308. /**
  29309. * Enables the edge rendering mode on the mesh.
  29310. * This mode makes the mesh edges visible
  29311. * @param epsilon defines the maximal distance between two angles to detect a face
  29312. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29313. * @returns the currentAbstractMesh
  29314. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29315. */
  29316. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29317. }
  29318. }
  29319. module "babylonjs/Meshes/linesMesh" {
  29320. interface InstancedLinesMesh {
  29321. /**
  29322. * Enables the edge rendering mode on the mesh.
  29323. * This mode makes the mesh edges visible
  29324. * @param epsilon defines the maximal distance between two angles to detect a face
  29325. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29326. * @returns the current InstancedLinesMesh
  29327. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29328. */
  29329. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29330. }
  29331. }
  29332. /**
  29333. * Defines the minimum contract an Edges renderer should follow.
  29334. */
  29335. export interface IEdgesRenderer extends IDisposable {
  29336. /**
  29337. * Gets or sets a boolean indicating if the edgesRenderer is active
  29338. */
  29339. isEnabled: boolean;
  29340. /**
  29341. * Renders the edges of the attached mesh,
  29342. */
  29343. render(): void;
  29344. /**
  29345. * Checks wether or not the edges renderer is ready to render.
  29346. * @return true if ready, otherwise false.
  29347. */
  29348. isReady(): boolean;
  29349. /**
  29350. * List of instances to render in case the source mesh has instances
  29351. */
  29352. customInstances: SmartArray<Matrix>;
  29353. }
  29354. /**
  29355. * Defines the additional options of the edges renderer
  29356. */
  29357. export interface IEdgesRendererOptions {
  29358. /**
  29359. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29360. * If not defined, the default value is true
  29361. */
  29362. useAlternateEdgeFinder?: boolean;
  29363. /**
  29364. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29365. * If not defined, the default value is true.
  29366. * 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)
  29367. * This option is used only if useAlternateEdgeFinder = true
  29368. */
  29369. useFastVertexMerger?: boolean;
  29370. /**
  29371. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29372. * The default value is 1e-6
  29373. * This option is used only if useAlternateEdgeFinder = true
  29374. */
  29375. epsilonVertexMerge?: number;
  29376. /**
  29377. * 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
  29378. * 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.
  29379. * This option is used only if useAlternateEdgeFinder = true
  29380. */
  29381. applyTessellation?: boolean;
  29382. /**
  29383. * 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
  29384. * The default value is 1e-6
  29385. * This option is used only if useAlternateEdgeFinder = true
  29386. */
  29387. epsilonVertexAligned?: number;
  29388. }
  29389. /**
  29390. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29391. */
  29392. export class EdgesRenderer implements IEdgesRenderer {
  29393. /**
  29394. * Define the size of the edges with an orthographic camera
  29395. */
  29396. edgesWidthScalerForOrthographic: number;
  29397. /**
  29398. * Define the size of the edges with a perspective camera
  29399. */
  29400. edgesWidthScalerForPerspective: number;
  29401. protected _source: AbstractMesh;
  29402. protected _linesPositions: number[];
  29403. protected _linesNormals: number[];
  29404. protected _linesIndices: number[];
  29405. protected _epsilon: number;
  29406. protected _indicesCount: number;
  29407. protected _lineShader: ShaderMaterial;
  29408. protected _ib: DataBuffer;
  29409. protected _buffers: {
  29410. [key: string]: Nullable<VertexBuffer>;
  29411. };
  29412. protected _buffersForInstances: {
  29413. [key: string]: Nullable<VertexBuffer>;
  29414. };
  29415. protected _checkVerticesInsteadOfIndices: boolean;
  29416. protected _options: Nullable<IEdgesRendererOptions>;
  29417. private _meshRebuildObserver;
  29418. private _meshDisposeObserver;
  29419. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29420. isEnabled: boolean;
  29421. /** Gets the vertices generated by the edge renderer */
  29422. get linesPositions(): Immutable<Array<number>>;
  29423. /** Gets the normals generated by the edge renderer */
  29424. get linesNormals(): Immutable<Array<number>>;
  29425. /** Gets the indices generated by the edge renderer */
  29426. get linesIndices(): Immutable<Array<number>>;
  29427. /**
  29428. * List of instances to render in case the source mesh has instances
  29429. */
  29430. customInstances: SmartArray<Matrix>;
  29431. private static GetShader;
  29432. /**
  29433. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29434. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29435. * @param source Mesh used to create edges
  29436. * @param epsilon sum of angles in adjacency to check for edge
  29437. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29438. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29439. * @param options The options to apply when generating the edges
  29440. */
  29441. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29442. protected _prepareRessources(): void;
  29443. /** @hidden */
  29444. _rebuild(): void;
  29445. /**
  29446. * Releases the required resources for the edges renderer
  29447. */
  29448. dispose(): void;
  29449. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29450. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29451. /**
  29452. * Checks if the pair of p0 and p1 is en edge
  29453. * @param faceIndex
  29454. * @param edge
  29455. * @param faceNormals
  29456. * @param p0
  29457. * @param p1
  29458. * @private
  29459. */
  29460. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29461. /**
  29462. * push line into the position, normal and index buffer
  29463. * @protected
  29464. */
  29465. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29466. /**
  29467. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29468. */
  29469. private _tessellateTriangle;
  29470. private _generateEdgesLinesAlternate;
  29471. /**
  29472. * Generates lines edges from adjacencjes
  29473. * @private
  29474. */
  29475. _generateEdgesLines(): void;
  29476. /**
  29477. * Checks wether or not the edges renderer is ready to render.
  29478. * @return true if ready, otherwise false.
  29479. */
  29480. isReady(): boolean;
  29481. /**
  29482. * Renders the edges of the attached mesh,
  29483. */
  29484. render(): void;
  29485. }
  29486. /**
  29487. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29488. */
  29489. export class LineEdgesRenderer extends EdgesRenderer {
  29490. /**
  29491. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29492. * @param source LineMesh used to generate edges
  29493. * @param epsilon not important (specified angle for edge detection)
  29494. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29495. */
  29496. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29497. /**
  29498. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29499. */
  29500. _generateEdgesLines(): void;
  29501. }
  29502. }
  29503. declare module "babylonjs/Rendering/renderingGroup" {
  29504. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29507. import { Nullable } from "babylonjs/types";
  29508. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29509. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29510. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29511. import { Material } from "babylonjs/Materials/material";
  29512. import { Scene } from "babylonjs/scene";
  29513. /**
  29514. * This represents the object necessary to create a rendering group.
  29515. * This is exclusively used and created by the rendering manager.
  29516. * To modify the behavior, you use the available helpers in your scene or meshes.
  29517. * @hidden
  29518. */
  29519. export class RenderingGroup {
  29520. index: number;
  29521. private static _zeroVector;
  29522. private _scene;
  29523. private _opaqueSubMeshes;
  29524. private _transparentSubMeshes;
  29525. private _alphaTestSubMeshes;
  29526. private _depthOnlySubMeshes;
  29527. private _particleSystems;
  29528. private _spriteManagers;
  29529. private _opaqueSortCompareFn;
  29530. private _alphaTestSortCompareFn;
  29531. private _transparentSortCompareFn;
  29532. private _renderOpaque;
  29533. private _renderAlphaTest;
  29534. private _renderTransparent;
  29535. /** @hidden */
  29536. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29537. onBeforeTransparentRendering: () => void;
  29538. /**
  29539. * Set the opaque sort comparison function.
  29540. * If null the sub meshes will be render in the order they were created
  29541. */
  29542. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29543. /**
  29544. * Set the alpha test sort comparison function.
  29545. * If null the sub meshes will be render in the order they were created
  29546. */
  29547. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29548. /**
  29549. * Set the transparent sort comparison function.
  29550. * If null the sub meshes will be render in the order they were created
  29551. */
  29552. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29553. /**
  29554. * Creates a new rendering group.
  29555. * @param index The rendering group index
  29556. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29557. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29558. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29559. */
  29560. 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>);
  29561. /**
  29562. * Render all the sub meshes contained in the group.
  29563. * @param customRenderFunction Used to override the default render behaviour of the group.
  29564. * @returns true if rendered some submeshes.
  29565. */
  29566. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29567. /**
  29568. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29569. * @param subMeshes The submeshes to render
  29570. */
  29571. private renderOpaqueSorted;
  29572. /**
  29573. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29574. * @param subMeshes The submeshes to render
  29575. */
  29576. private renderAlphaTestSorted;
  29577. /**
  29578. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29579. * @param subMeshes The submeshes to render
  29580. */
  29581. private renderTransparentSorted;
  29582. /**
  29583. * Renders the submeshes in a specified order.
  29584. * @param subMeshes The submeshes to sort before render
  29585. * @param sortCompareFn The comparison function use to sort
  29586. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29587. * @param transparent Specifies to activate blending if true
  29588. */
  29589. private static renderSorted;
  29590. /**
  29591. * Renders the submeshes in the order they were dispatched (no sort applied).
  29592. * @param subMeshes The submeshes to render
  29593. */
  29594. private static renderUnsorted;
  29595. /**
  29596. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29597. * are rendered back to front if in the same alpha index.
  29598. *
  29599. * @param a The first submesh
  29600. * @param b The second submesh
  29601. * @returns The result of the comparison
  29602. */
  29603. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29604. /**
  29605. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29606. * are rendered back to front.
  29607. *
  29608. * @param a The first submesh
  29609. * @param b The second submesh
  29610. * @returns The result of the comparison
  29611. */
  29612. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29613. /**
  29614. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29615. * are rendered front to back (prevent overdraw).
  29616. *
  29617. * @param a The first submesh
  29618. * @param b The second submesh
  29619. * @returns The result of the comparison
  29620. */
  29621. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29622. /**
  29623. * Resets the different lists of submeshes to prepare a new frame.
  29624. */
  29625. prepare(): void;
  29626. dispose(): void;
  29627. /**
  29628. * Inserts the submesh in its correct queue depending on its material.
  29629. * @param subMesh The submesh to dispatch
  29630. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29631. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29632. */
  29633. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29634. dispatchSprites(spriteManager: ISpriteManager): void;
  29635. dispatchParticles(particleSystem: IParticleSystem): void;
  29636. private _renderParticles;
  29637. private _renderSprites;
  29638. }
  29639. }
  29640. declare module "babylonjs/Rendering/renderingManager" {
  29641. import { Nullable } from "babylonjs/types";
  29642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29644. import { SmartArray } from "babylonjs/Misc/smartArray";
  29645. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29647. import { Material } from "babylonjs/Materials/material";
  29648. import { Scene } from "babylonjs/scene";
  29649. import { Camera } from "babylonjs/Cameras/camera";
  29650. /**
  29651. * Interface describing the different options available in the rendering manager
  29652. * regarding Auto Clear between groups.
  29653. */
  29654. export interface IRenderingManagerAutoClearSetup {
  29655. /**
  29656. * Defines whether or not autoclear is enable.
  29657. */
  29658. autoClear: boolean;
  29659. /**
  29660. * Defines whether or not to autoclear the depth buffer.
  29661. */
  29662. depth: boolean;
  29663. /**
  29664. * Defines whether or not to autoclear the stencil buffer.
  29665. */
  29666. stencil: boolean;
  29667. }
  29668. /**
  29669. * This class is used by the onRenderingGroupObservable
  29670. */
  29671. export class RenderingGroupInfo {
  29672. /**
  29673. * The Scene that being rendered
  29674. */
  29675. scene: Scene;
  29676. /**
  29677. * The camera currently used for the rendering pass
  29678. */
  29679. camera: Nullable<Camera>;
  29680. /**
  29681. * The ID of the renderingGroup being processed
  29682. */
  29683. renderingGroupId: number;
  29684. }
  29685. /**
  29686. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29687. * It is enable to manage the different groups as well as the different necessary sort functions.
  29688. * This should not be used directly aside of the few static configurations
  29689. */
  29690. export class RenderingManager {
  29691. /**
  29692. * The max id used for rendering groups (not included)
  29693. */
  29694. static MAX_RENDERINGGROUPS: number;
  29695. /**
  29696. * The min id used for rendering groups (included)
  29697. */
  29698. static MIN_RENDERINGGROUPS: number;
  29699. /**
  29700. * Used to globally prevent autoclearing scenes.
  29701. */
  29702. static AUTOCLEAR: boolean;
  29703. /**
  29704. * @hidden
  29705. */
  29706. _useSceneAutoClearSetup: boolean;
  29707. private _scene;
  29708. private _renderingGroups;
  29709. private _depthStencilBufferAlreadyCleaned;
  29710. private _autoClearDepthStencil;
  29711. private _customOpaqueSortCompareFn;
  29712. private _customAlphaTestSortCompareFn;
  29713. private _customTransparentSortCompareFn;
  29714. private _renderingGroupInfo;
  29715. /**
  29716. * Instantiates a new rendering group for a particular scene
  29717. * @param scene Defines the scene the groups belongs to
  29718. */
  29719. constructor(scene: Scene);
  29720. private _clearDepthStencilBuffer;
  29721. /**
  29722. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29723. * @hidden
  29724. */
  29725. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29726. /**
  29727. * Resets the different information of the group to prepare a new frame
  29728. * @hidden
  29729. */
  29730. reset(): void;
  29731. /**
  29732. * Dispose and release the group and its associated resources.
  29733. * @hidden
  29734. */
  29735. dispose(): void;
  29736. /**
  29737. * Clear the info related to rendering groups preventing retention points during dispose.
  29738. */
  29739. freeRenderingGroups(): void;
  29740. private _prepareRenderingGroup;
  29741. /**
  29742. * Add a sprite manager to the rendering manager in order to render it this frame.
  29743. * @param spriteManager Define the sprite manager to render
  29744. */
  29745. dispatchSprites(spriteManager: ISpriteManager): void;
  29746. /**
  29747. * Add a particle system to the rendering manager in order to render it this frame.
  29748. * @param particleSystem Define the particle system to render
  29749. */
  29750. dispatchParticles(particleSystem: IParticleSystem): void;
  29751. /**
  29752. * Add a submesh to the manager in order to render it this frame
  29753. * @param subMesh The submesh to dispatch
  29754. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29755. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29756. */
  29757. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29758. /**
  29759. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29760. * This allowed control for front to back rendering or reversly depending of the special needs.
  29761. *
  29762. * @param renderingGroupId The rendering group id corresponding to its index
  29763. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29764. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29765. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29766. */
  29767. 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;
  29768. /**
  29769. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29770. *
  29771. * @param renderingGroupId The rendering group id corresponding to its index
  29772. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29773. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29774. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29775. */
  29776. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29777. /**
  29778. * Gets the current auto clear configuration for one rendering group of the rendering
  29779. * manager.
  29780. * @param index the rendering group index to get the information for
  29781. * @returns The auto clear setup for the requested rendering group
  29782. */
  29783. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29784. }
  29785. }
  29786. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29787. import { SmartArray } from "babylonjs/Misc/smartArray";
  29788. import { Nullable } from "babylonjs/types";
  29789. import { Scene } from "babylonjs/scene";
  29790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29791. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29793. import { Mesh } from "babylonjs/Meshes/mesh";
  29794. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29795. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29796. import { Effect } from "babylonjs/Materials/effect";
  29797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29798. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29799. import "babylonjs/Shaders/shadowMap.fragment";
  29800. import "babylonjs/Shaders/shadowMap.vertex";
  29801. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29802. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29803. import { Observable } from "babylonjs/Misc/observable";
  29804. /**
  29805. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29806. */
  29807. export interface ICustomShaderOptions {
  29808. /**
  29809. * Gets or sets the custom shader name to use
  29810. */
  29811. shaderName: string;
  29812. /**
  29813. * The list of attribute names used in the shader
  29814. */
  29815. attributes?: string[];
  29816. /**
  29817. * The list of unifrom names used in the shader
  29818. */
  29819. uniforms?: string[];
  29820. /**
  29821. * The list of sampler names used in the shader
  29822. */
  29823. samplers?: string[];
  29824. /**
  29825. * The list of defines used in the shader
  29826. */
  29827. defines?: string[];
  29828. }
  29829. /**
  29830. * Interface to implement to create a shadow generator compatible with BJS.
  29831. */
  29832. export interface IShadowGenerator {
  29833. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29834. id: string;
  29835. /**
  29836. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29837. * @returns The render target texture if present otherwise, null
  29838. */
  29839. getShadowMap(): Nullable<RenderTargetTexture>;
  29840. /**
  29841. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29842. * @param subMesh The submesh we want to render in the shadow map
  29843. * @param useInstances Defines wether will draw in the map using instances
  29844. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29845. * @returns true if ready otherwise, false
  29846. */
  29847. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29848. /**
  29849. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29850. * @param defines Defines of the material we want to update
  29851. * @param lightIndex Index of the light in the enabled light list of the material
  29852. */
  29853. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29854. /**
  29855. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29856. * defined in the generator but impacting the effect).
  29857. * It implies the unifroms available on the materials are the standard BJS ones.
  29858. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29859. * @param effect The effect we are binfing the information for
  29860. */
  29861. bindShadowLight(lightIndex: string, effect: Effect): void;
  29862. /**
  29863. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29864. * (eq to shadow prjection matrix * light transform matrix)
  29865. * @returns The transform matrix used to create the shadow map
  29866. */
  29867. getTransformMatrix(): Matrix;
  29868. /**
  29869. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29870. * Cube and 2D textures for instance.
  29871. */
  29872. recreateShadowMap(): void;
  29873. /**
  29874. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29875. * @param onCompiled Callback triggered at the and of the effects compilation
  29876. * @param options Sets of optional options forcing the compilation with different modes
  29877. */
  29878. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29879. useInstances: boolean;
  29880. }>): void;
  29881. /**
  29882. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29883. * @param options Sets of optional options forcing the compilation with different modes
  29884. * @returns A promise that resolves when the compilation completes
  29885. */
  29886. forceCompilationAsync(options?: Partial<{
  29887. useInstances: boolean;
  29888. }>): Promise<void>;
  29889. /**
  29890. * Serializes the shadow generator setup to a json object.
  29891. * @returns The serialized JSON object
  29892. */
  29893. serialize(): any;
  29894. /**
  29895. * Disposes the Shadow map and related Textures and effects.
  29896. */
  29897. dispose(): void;
  29898. }
  29899. /**
  29900. * Default implementation IShadowGenerator.
  29901. * This is the main object responsible of generating shadows in the framework.
  29902. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29903. */
  29904. export class ShadowGenerator implements IShadowGenerator {
  29905. /**
  29906. * Name of the shadow generator class
  29907. */
  29908. static CLASSNAME: string;
  29909. /**
  29910. * Shadow generator mode None: no filtering applied.
  29911. */
  29912. static readonly FILTER_NONE: number;
  29913. /**
  29914. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29915. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29916. */
  29917. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29918. /**
  29919. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29920. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29921. */
  29922. static readonly FILTER_POISSONSAMPLING: number;
  29923. /**
  29924. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29926. */
  29927. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29928. /**
  29929. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29930. * edge artifacts on steep falloff.
  29931. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29932. */
  29933. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29934. /**
  29935. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29936. * edge artifacts on steep falloff.
  29937. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29938. */
  29939. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29940. /**
  29941. * Shadow generator mode PCF: Percentage Closer Filtering
  29942. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29943. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29944. */
  29945. static readonly FILTER_PCF: number;
  29946. /**
  29947. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29948. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29949. * Contact Hardening
  29950. */
  29951. static readonly FILTER_PCSS: number;
  29952. /**
  29953. * Reserved for PCF and PCSS
  29954. * Highest Quality.
  29955. *
  29956. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29957. *
  29958. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29959. */
  29960. static readonly QUALITY_HIGH: number;
  29961. /**
  29962. * Reserved for PCF and PCSS
  29963. * Good tradeoff for quality/perf cross devices
  29964. *
  29965. * Execute PCF on a 3*3 kernel.
  29966. *
  29967. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29968. */
  29969. static readonly QUALITY_MEDIUM: number;
  29970. /**
  29971. * Reserved for PCF and PCSS
  29972. * The lowest quality but the fastest.
  29973. *
  29974. * Execute PCF on a 1*1 kernel.
  29975. *
  29976. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29977. */
  29978. static readonly QUALITY_LOW: number;
  29979. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29980. id: string;
  29981. /** Gets or sets the custom shader name to use */
  29982. customShaderOptions: ICustomShaderOptions;
  29983. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29984. customAllowRendering: (subMesh: SubMesh) => boolean;
  29985. /**
  29986. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29987. */
  29988. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29989. /**
  29990. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29991. */
  29992. onAfterShadowMapRenderObservable: Observable<Effect>;
  29993. /**
  29994. * Observable triggered before a mesh is rendered in the shadow map.
  29995. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29996. */
  29997. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29998. /**
  29999. * Observable triggered after a mesh is rendered in the shadow map.
  30000. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30001. */
  30002. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30003. protected _bias: number;
  30004. /**
  30005. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30006. */
  30007. get bias(): number;
  30008. /**
  30009. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30010. */
  30011. set bias(bias: number);
  30012. protected _normalBias: number;
  30013. /**
  30014. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30015. */
  30016. get normalBias(): number;
  30017. /**
  30018. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30019. */
  30020. set normalBias(normalBias: number);
  30021. protected _blurBoxOffset: number;
  30022. /**
  30023. * Gets the blur box offset: offset applied during the blur pass.
  30024. * Only useful if useKernelBlur = false
  30025. */
  30026. get blurBoxOffset(): number;
  30027. /**
  30028. * Sets the blur box offset: offset applied during the blur pass.
  30029. * Only useful if useKernelBlur = false
  30030. */
  30031. set blurBoxOffset(value: number);
  30032. protected _blurScale: number;
  30033. /**
  30034. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30035. * 2 means half of the size.
  30036. */
  30037. get blurScale(): number;
  30038. /**
  30039. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30040. * 2 means half of the size.
  30041. */
  30042. set blurScale(value: number);
  30043. protected _blurKernel: number;
  30044. /**
  30045. * Gets the blur kernel: kernel size of the blur pass.
  30046. * Only useful if useKernelBlur = true
  30047. */
  30048. get blurKernel(): number;
  30049. /**
  30050. * Sets the blur kernel: kernel size of the blur pass.
  30051. * Only useful if useKernelBlur = true
  30052. */
  30053. set blurKernel(value: number);
  30054. protected _useKernelBlur: boolean;
  30055. /**
  30056. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30057. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30058. */
  30059. get useKernelBlur(): boolean;
  30060. /**
  30061. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30062. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30063. */
  30064. set useKernelBlur(value: boolean);
  30065. protected _depthScale: number;
  30066. /**
  30067. * Gets the depth scale used in ESM mode.
  30068. */
  30069. get depthScale(): number;
  30070. /**
  30071. * Sets the depth scale used in ESM mode.
  30072. * This can override the scale stored on the light.
  30073. */
  30074. set depthScale(value: number);
  30075. protected _validateFilter(filter: number): number;
  30076. protected _filter: number;
  30077. /**
  30078. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30079. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30080. */
  30081. get filter(): number;
  30082. /**
  30083. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30084. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30085. */
  30086. set filter(value: number);
  30087. /**
  30088. * Gets if the current filter is set to Poisson Sampling.
  30089. */
  30090. get usePoissonSampling(): boolean;
  30091. /**
  30092. * Sets the current filter to Poisson Sampling.
  30093. */
  30094. set usePoissonSampling(value: boolean);
  30095. /**
  30096. * Gets if the current filter is set to ESM.
  30097. */
  30098. get useExponentialShadowMap(): boolean;
  30099. /**
  30100. * Sets the current filter is to ESM.
  30101. */
  30102. set useExponentialShadowMap(value: boolean);
  30103. /**
  30104. * Gets if the current filter is set to filtered ESM.
  30105. */
  30106. get useBlurExponentialShadowMap(): boolean;
  30107. /**
  30108. * Gets if the current filter is set to filtered ESM.
  30109. */
  30110. set useBlurExponentialShadowMap(value: boolean);
  30111. /**
  30112. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30113. * exponential to prevent steep falloff artifacts).
  30114. */
  30115. get useCloseExponentialShadowMap(): boolean;
  30116. /**
  30117. * Sets the current filter to "close ESM" (using the inverse of the
  30118. * exponential to prevent steep falloff artifacts).
  30119. */
  30120. set useCloseExponentialShadowMap(value: boolean);
  30121. /**
  30122. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30123. * exponential to prevent steep falloff artifacts).
  30124. */
  30125. get useBlurCloseExponentialShadowMap(): boolean;
  30126. /**
  30127. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30128. * exponential to prevent steep falloff artifacts).
  30129. */
  30130. set useBlurCloseExponentialShadowMap(value: boolean);
  30131. /**
  30132. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30133. */
  30134. get usePercentageCloserFiltering(): boolean;
  30135. /**
  30136. * Sets the current filter to "PCF" (percentage closer filtering).
  30137. */
  30138. set usePercentageCloserFiltering(value: boolean);
  30139. protected _filteringQuality: number;
  30140. /**
  30141. * Gets the PCF or PCSS Quality.
  30142. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30143. */
  30144. get filteringQuality(): number;
  30145. /**
  30146. * Sets the PCF or PCSS Quality.
  30147. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30148. */
  30149. set filteringQuality(filteringQuality: number);
  30150. /**
  30151. * Gets if the current filter is set to "PCSS" (contact hardening).
  30152. */
  30153. get useContactHardeningShadow(): boolean;
  30154. /**
  30155. * Sets the current filter to "PCSS" (contact hardening).
  30156. */
  30157. set useContactHardeningShadow(value: boolean);
  30158. protected _contactHardeningLightSizeUVRatio: number;
  30159. /**
  30160. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30161. * Using a ratio helps keeping shape stability independently of the map size.
  30162. *
  30163. * It does not account for the light projection as it was having too much
  30164. * instability during the light setup or during light position changes.
  30165. *
  30166. * Only valid if useContactHardeningShadow is true.
  30167. */
  30168. get contactHardeningLightSizeUVRatio(): number;
  30169. /**
  30170. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30171. * Using a ratio helps keeping shape stability independently of the map size.
  30172. *
  30173. * It does not account for the light projection as it was having too much
  30174. * instability during the light setup or during light position changes.
  30175. *
  30176. * Only valid if useContactHardeningShadow is true.
  30177. */
  30178. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30179. protected _darkness: number;
  30180. /** Gets or sets the actual darkness of a shadow */
  30181. get darkness(): number;
  30182. set darkness(value: number);
  30183. /**
  30184. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30185. * 0 means strongest and 1 would means no shadow.
  30186. * @returns the darkness.
  30187. */
  30188. getDarkness(): number;
  30189. /**
  30190. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30191. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30192. * @returns the shadow generator allowing fluent coding.
  30193. */
  30194. setDarkness(darkness: number): ShadowGenerator;
  30195. protected _transparencyShadow: boolean;
  30196. /** Gets or sets the ability to have transparent shadow */
  30197. get transparencyShadow(): boolean;
  30198. set transparencyShadow(value: boolean);
  30199. /**
  30200. * Sets the ability to have transparent shadow (boolean).
  30201. * @param transparent True if transparent else False
  30202. * @returns the shadow generator allowing fluent coding
  30203. */
  30204. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30205. /**
  30206. * Enables or disables shadows with varying strength based on the transparency
  30207. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30208. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30209. * mesh.visibility * alphaTexture.a
  30210. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30211. */
  30212. enableSoftTransparentShadow: boolean;
  30213. protected _shadowMap: Nullable<RenderTargetTexture>;
  30214. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30215. /**
  30216. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30217. * @returns The render target texture if present otherwise, null
  30218. */
  30219. getShadowMap(): Nullable<RenderTargetTexture>;
  30220. /**
  30221. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30222. * @returns The render target texture if the shadow map is present otherwise, null
  30223. */
  30224. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30225. /**
  30226. * Gets the class name of that object
  30227. * @returns "ShadowGenerator"
  30228. */
  30229. getClassName(): string;
  30230. /**
  30231. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30232. * @param mesh Mesh to add
  30233. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30234. * @returns the Shadow Generator itself
  30235. */
  30236. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30237. /**
  30238. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30239. * @param mesh Mesh to remove
  30240. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30241. * @returns the Shadow Generator itself
  30242. */
  30243. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30244. /**
  30245. * Controls the extent to which the shadows fade out at the edge of the frustum
  30246. */
  30247. frustumEdgeFalloff: number;
  30248. protected _light: IShadowLight;
  30249. /**
  30250. * Returns the associated light object.
  30251. * @returns the light generating the shadow
  30252. */
  30253. getLight(): IShadowLight;
  30254. /**
  30255. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30256. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30257. * It might on the other hand introduce peter panning.
  30258. */
  30259. forceBackFacesOnly: boolean;
  30260. protected _scene: Scene;
  30261. protected _lightDirection: Vector3;
  30262. protected _effect: Effect;
  30263. protected _viewMatrix: Matrix;
  30264. protected _projectionMatrix: Matrix;
  30265. protected _transformMatrix: Matrix;
  30266. protected _cachedPosition: Vector3;
  30267. protected _cachedDirection: Vector3;
  30268. protected _cachedDefines: string;
  30269. protected _currentRenderID: number;
  30270. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30271. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30272. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30273. protected _blurPostProcesses: PostProcess[];
  30274. protected _mapSize: number;
  30275. protected _currentFaceIndex: number;
  30276. protected _currentFaceIndexCache: number;
  30277. protected _textureType: number;
  30278. protected _defaultTextureMatrix: Matrix;
  30279. protected _storedUniqueId: Nullable<number>;
  30280. /** @hidden */
  30281. static _SceneComponentInitialization: (scene: Scene) => void;
  30282. /**
  30283. * Gets or sets the size of the texture what stores the shadows
  30284. */
  30285. get mapSize(): number;
  30286. set mapSize(size: number);
  30287. /**
  30288. * Creates a ShadowGenerator object.
  30289. * A ShadowGenerator is the required tool to use the shadows.
  30290. * Each light casting shadows needs to use its own ShadowGenerator.
  30291. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30292. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30293. * @param light The light object generating the shadows.
  30294. * @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.
  30295. */
  30296. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30297. protected _initializeGenerator(): void;
  30298. protected _createTargetRenderTexture(): void;
  30299. protected _initializeShadowMap(): void;
  30300. protected _initializeBlurRTTAndPostProcesses(): void;
  30301. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30302. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30303. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30304. protected _applyFilterValues(): void;
  30305. /**
  30306. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30307. * @param onCompiled Callback triggered at the and of the effects compilation
  30308. * @param options Sets of optional options forcing the compilation with different modes
  30309. */
  30310. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30311. useInstances: boolean;
  30312. }>): void;
  30313. /**
  30314. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30315. * @param options Sets of optional options forcing the compilation with different modes
  30316. * @returns A promise that resolves when the compilation completes
  30317. */
  30318. forceCompilationAsync(options?: Partial<{
  30319. useInstances: boolean;
  30320. }>): Promise<void>;
  30321. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30322. private _prepareShadowDefines;
  30323. /**
  30324. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30325. * @param subMesh The submesh we want to render in the shadow map
  30326. * @param useInstances Defines wether will draw in the map using instances
  30327. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30328. * @returns true if ready otherwise, false
  30329. */
  30330. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30331. /**
  30332. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30333. * @param defines Defines of the material we want to update
  30334. * @param lightIndex Index of the light in the enabled light list of the material
  30335. */
  30336. prepareDefines(defines: any, lightIndex: number): void;
  30337. /**
  30338. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30339. * defined in the generator but impacting the effect).
  30340. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30341. * @param effect The effect we are binfing the information for
  30342. */
  30343. bindShadowLight(lightIndex: string, effect: Effect): void;
  30344. /**
  30345. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30346. * (eq to shadow prjection matrix * light transform matrix)
  30347. * @returns The transform matrix used to create the shadow map
  30348. */
  30349. getTransformMatrix(): Matrix;
  30350. /**
  30351. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30352. * Cube and 2D textures for instance.
  30353. */
  30354. recreateShadowMap(): void;
  30355. protected _disposeBlurPostProcesses(): void;
  30356. protected _disposeRTTandPostProcesses(): void;
  30357. /**
  30358. * Disposes the ShadowGenerator.
  30359. * Returns nothing.
  30360. */
  30361. dispose(): void;
  30362. /**
  30363. * Serializes the shadow generator setup to a json object.
  30364. * @returns The serialized JSON object
  30365. */
  30366. serialize(): any;
  30367. /**
  30368. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30369. * @param parsedShadowGenerator The JSON object to parse
  30370. * @param scene The scene to create the shadow map for
  30371. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30372. * @returns The parsed shadow generator
  30373. */
  30374. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30375. }
  30376. }
  30377. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30378. import { Nullable } from "babylonjs/types";
  30379. import { Scene } from "babylonjs/scene";
  30380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30381. import { Material } from "babylonjs/Materials/material";
  30382. import { Effect } from "babylonjs/Materials/effect";
  30383. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30384. /**
  30385. * Options to be used when creating a shadow depth material
  30386. */
  30387. export interface IIOptionShadowDepthMaterial {
  30388. /** Variables in the vertex shader code that need to have their names remapped.
  30389. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30390. * "var_name" should be either: worldPos or vNormalW
  30391. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30392. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30393. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30394. */
  30395. remappedVariables?: string[];
  30396. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30397. standalone?: boolean;
  30398. }
  30399. /**
  30400. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30401. */
  30402. export class ShadowDepthWrapper {
  30403. private _scene;
  30404. private _options?;
  30405. private _baseMaterial;
  30406. private _onEffectCreatedObserver;
  30407. private _subMeshToEffect;
  30408. private _subMeshToDepthEffect;
  30409. private _meshes;
  30410. /** @hidden */
  30411. _matriceNames: any;
  30412. /** Gets the standalone status of the wrapper */
  30413. get standalone(): boolean;
  30414. /** Gets the base material the wrapper is built upon */
  30415. get baseMaterial(): Material;
  30416. /**
  30417. * Instantiate a new shadow depth wrapper.
  30418. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30419. * generate the shadow depth map. For more information, please refer to the documentation:
  30420. * https://doc.babylonjs.com/babylon101/shadows
  30421. * @param baseMaterial Material to wrap
  30422. * @param scene Define the scene the material belongs to
  30423. * @param options Options used to create the wrapper
  30424. */
  30425. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30426. /**
  30427. * Gets the effect to use to generate the depth map
  30428. * @param subMesh subMesh to get the effect for
  30429. * @param shadowGenerator shadow generator to get the effect for
  30430. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30431. */
  30432. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30433. /**
  30434. * Specifies that the submesh is ready to be used for depth rendering
  30435. * @param subMesh submesh to check
  30436. * @param defines the list of defines to take into account when checking the effect
  30437. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30438. * @param useInstances specifies that instances should be used
  30439. * @returns a boolean indicating that the submesh is ready or not
  30440. */
  30441. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30442. /**
  30443. * Disposes the resources
  30444. */
  30445. dispose(): void;
  30446. private _makeEffect;
  30447. }
  30448. }
  30449. declare module "babylonjs/Materials/material" {
  30450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30451. import { SmartArray } from "babylonjs/Misc/smartArray";
  30452. import { Observable } from "babylonjs/Misc/observable";
  30453. import { Nullable } from "babylonjs/types";
  30454. import { Scene } from "babylonjs/scene";
  30455. import { Matrix } from "babylonjs/Maths/math.vector";
  30456. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30458. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30459. import { Effect } from "babylonjs/Materials/effect";
  30460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30462. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30463. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30464. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30465. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30466. import { Mesh } from "babylonjs/Meshes/mesh";
  30467. import { Animation } from "babylonjs/Animations/animation";
  30468. /**
  30469. * Options for compiling materials.
  30470. */
  30471. export interface IMaterialCompilationOptions {
  30472. /**
  30473. * Defines whether clip planes are enabled.
  30474. */
  30475. clipPlane: boolean;
  30476. /**
  30477. * Defines whether instances are enabled.
  30478. */
  30479. useInstances: boolean;
  30480. }
  30481. /**
  30482. * Options passed when calling customShaderNameResolve
  30483. */
  30484. export interface ICustomShaderNameResolveOptions {
  30485. /**
  30486. * 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
  30487. */
  30488. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30489. }
  30490. /**
  30491. * Base class for the main features of a material in Babylon.js
  30492. */
  30493. export class Material implements IAnimatable {
  30494. /**
  30495. * Returns the triangle fill mode
  30496. */
  30497. static readonly TriangleFillMode: number;
  30498. /**
  30499. * Returns the wireframe mode
  30500. */
  30501. static readonly WireFrameFillMode: number;
  30502. /**
  30503. * Returns the point fill mode
  30504. */
  30505. static readonly PointFillMode: number;
  30506. /**
  30507. * Returns the point list draw mode
  30508. */
  30509. static readonly PointListDrawMode: number;
  30510. /**
  30511. * Returns the line list draw mode
  30512. */
  30513. static readonly LineListDrawMode: number;
  30514. /**
  30515. * Returns the line loop draw mode
  30516. */
  30517. static readonly LineLoopDrawMode: number;
  30518. /**
  30519. * Returns the line strip draw mode
  30520. */
  30521. static readonly LineStripDrawMode: number;
  30522. /**
  30523. * Returns the triangle strip draw mode
  30524. */
  30525. static readonly TriangleStripDrawMode: number;
  30526. /**
  30527. * Returns the triangle fan draw mode
  30528. */
  30529. static readonly TriangleFanDrawMode: number;
  30530. /**
  30531. * Stores the clock-wise side orientation
  30532. */
  30533. static readonly ClockWiseSideOrientation: number;
  30534. /**
  30535. * Stores the counter clock-wise side orientation
  30536. */
  30537. static readonly CounterClockWiseSideOrientation: number;
  30538. /**
  30539. * The dirty texture flag value
  30540. */
  30541. static readonly TextureDirtyFlag: number;
  30542. /**
  30543. * The dirty light flag value
  30544. */
  30545. static readonly LightDirtyFlag: number;
  30546. /**
  30547. * The dirty fresnel flag value
  30548. */
  30549. static readonly FresnelDirtyFlag: number;
  30550. /**
  30551. * The dirty attribute flag value
  30552. */
  30553. static readonly AttributesDirtyFlag: number;
  30554. /**
  30555. * The dirty misc flag value
  30556. */
  30557. static readonly MiscDirtyFlag: number;
  30558. /**
  30559. * The dirty prepass flag value
  30560. */
  30561. static readonly PrePassDirtyFlag: number;
  30562. /**
  30563. * The all dirty flag value
  30564. */
  30565. static readonly AllDirtyFlag: number;
  30566. /**
  30567. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30568. */
  30569. static readonly MATERIAL_OPAQUE: number;
  30570. /**
  30571. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30572. */
  30573. static readonly MATERIAL_ALPHATEST: number;
  30574. /**
  30575. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30576. */
  30577. static readonly MATERIAL_ALPHABLEND: number;
  30578. /**
  30579. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30580. * They are also discarded below the alpha cutoff threshold to improve performances.
  30581. */
  30582. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30583. /**
  30584. * The Whiteout method is used to blend normals.
  30585. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30586. */
  30587. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30588. /**
  30589. * The Reoriented Normal Mapping method is used to blend normals.
  30590. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30591. */
  30592. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30593. /**
  30594. * Custom callback helping to override the default shader used in the material.
  30595. */
  30596. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30597. /**
  30598. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30599. */
  30600. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30601. /**
  30602. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30603. * This means that the material can keep using a previous shader while a new one is being compiled.
  30604. * This is mostly used when shader parallel compilation is supported (true by default)
  30605. */
  30606. allowShaderHotSwapping: boolean;
  30607. /**
  30608. * The ID of the material
  30609. */
  30610. id: string;
  30611. /**
  30612. * Gets or sets the unique id of the material
  30613. */
  30614. uniqueId: number;
  30615. /**
  30616. * The name of the material
  30617. */
  30618. name: string;
  30619. /**
  30620. * Gets or sets user defined metadata
  30621. */
  30622. metadata: any;
  30623. /**
  30624. * For internal use only. Please do not use.
  30625. */
  30626. reservedDataStore: any;
  30627. /**
  30628. * Specifies if the ready state should be checked on each call
  30629. */
  30630. checkReadyOnEveryCall: boolean;
  30631. /**
  30632. * Specifies if the ready state should be checked once
  30633. */
  30634. checkReadyOnlyOnce: boolean;
  30635. /**
  30636. * The state of the material
  30637. */
  30638. state: string;
  30639. /**
  30640. * If the material can be rendered to several textures with MRT extension
  30641. */
  30642. get canRenderToMRT(): boolean;
  30643. /**
  30644. * The alpha value of the material
  30645. */
  30646. protected _alpha: number;
  30647. /**
  30648. * List of inspectable custom properties (used by the Inspector)
  30649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30650. */
  30651. inspectableCustomProperties: IInspectable[];
  30652. /**
  30653. * Sets the alpha value of the material
  30654. */
  30655. set alpha(value: number);
  30656. /**
  30657. * Gets the alpha value of the material
  30658. */
  30659. get alpha(): number;
  30660. /**
  30661. * Specifies if back face culling is enabled
  30662. */
  30663. protected _backFaceCulling: boolean;
  30664. /**
  30665. * Sets the back-face culling state
  30666. */
  30667. set backFaceCulling(value: boolean);
  30668. /**
  30669. * Gets the back-face culling state
  30670. */
  30671. get backFaceCulling(): boolean;
  30672. /**
  30673. * Stores the value for side orientation
  30674. */
  30675. sideOrientation: number;
  30676. /**
  30677. * Callback triggered when the material is compiled
  30678. */
  30679. onCompiled: Nullable<(effect: Effect) => void>;
  30680. /**
  30681. * Callback triggered when an error occurs
  30682. */
  30683. onError: Nullable<(effect: Effect, errors: string) => void>;
  30684. /**
  30685. * Callback triggered to get the render target textures
  30686. */
  30687. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30688. /**
  30689. * Gets a boolean indicating that current material needs to register RTT
  30690. */
  30691. get hasRenderTargetTextures(): boolean;
  30692. /**
  30693. * Specifies if the material should be serialized
  30694. */
  30695. doNotSerialize: boolean;
  30696. /**
  30697. * @hidden
  30698. */
  30699. _storeEffectOnSubMeshes: boolean;
  30700. /**
  30701. * Stores the animations for the material
  30702. */
  30703. animations: Nullable<Array<Animation>>;
  30704. /**
  30705. * An event triggered when the material is disposed
  30706. */
  30707. onDisposeObservable: Observable<Material>;
  30708. /**
  30709. * An observer which watches for dispose events
  30710. */
  30711. private _onDisposeObserver;
  30712. private _onUnBindObservable;
  30713. /**
  30714. * Called during a dispose event
  30715. */
  30716. set onDispose(callback: () => void);
  30717. private _onBindObservable;
  30718. /**
  30719. * An event triggered when the material is bound
  30720. */
  30721. get onBindObservable(): Observable<AbstractMesh>;
  30722. /**
  30723. * An observer which watches for bind events
  30724. */
  30725. private _onBindObserver;
  30726. /**
  30727. * Called during a bind event
  30728. */
  30729. set onBind(callback: (Mesh: AbstractMesh) => void);
  30730. /**
  30731. * An event triggered when the material is unbound
  30732. */
  30733. get onUnBindObservable(): Observable<Material>;
  30734. protected _onEffectCreatedObservable: Nullable<Observable<{
  30735. effect: Effect;
  30736. subMesh: Nullable<SubMesh>;
  30737. }>>;
  30738. /**
  30739. * An event triggered when the effect is (re)created
  30740. */
  30741. get onEffectCreatedObservable(): Observable<{
  30742. effect: Effect;
  30743. subMesh: Nullable<SubMesh>;
  30744. }>;
  30745. /**
  30746. * Stores the value of the alpha mode
  30747. */
  30748. private _alphaMode;
  30749. /**
  30750. * Sets the value of the alpha mode.
  30751. *
  30752. * | Value | Type | Description |
  30753. * | --- | --- | --- |
  30754. * | 0 | ALPHA_DISABLE | |
  30755. * | 1 | ALPHA_ADD | |
  30756. * | 2 | ALPHA_COMBINE | |
  30757. * | 3 | ALPHA_SUBTRACT | |
  30758. * | 4 | ALPHA_MULTIPLY | |
  30759. * | 5 | ALPHA_MAXIMIZED | |
  30760. * | 6 | ALPHA_ONEONE | |
  30761. * | 7 | ALPHA_PREMULTIPLIED | |
  30762. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30763. * | 9 | ALPHA_INTERPOLATE | |
  30764. * | 10 | ALPHA_SCREENMODE | |
  30765. *
  30766. */
  30767. set alphaMode(value: number);
  30768. /**
  30769. * Gets the value of the alpha mode
  30770. */
  30771. get alphaMode(): number;
  30772. /**
  30773. * Stores the state of the need depth pre-pass value
  30774. */
  30775. private _needDepthPrePass;
  30776. /**
  30777. * Sets the need depth pre-pass value
  30778. */
  30779. set needDepthPrePass(value: boolean);
  30780. /**
  30781. * Gets the depth pre-pass value
  30782. */
  30783. get needDepthPrePass(): boolean;
  30784. /**
  30785. * Specifies if depth writing should be disabled
  30786. */
  30787. disableDepthWrite: boolean;
  30788. /**
  30789. * Specifies if color writing should be disabled
  30790. */
  30791. disableColorWrite: boolean;
  30792. /**
  30793. * Specifies if depth writing should be forced
  30794. */
  30795. forceDepthWrite: boolean;
  30796. /**
  30797. * Specifies the depth function that should be used. 0 means the default engine function
  30798. */
  30799. depthFunction: number;
  30800. /**
  30801. * Specifies if there should be a separate pass for culling
  30802. */
  30803. separateCullingPass: boolean;
  30804. /**
  30805. * Stores the state specifing if fog should be enabled
  30806. */
  30807. private _fogEnabled;
  30808. /**
  30809. * Sets the state for enabling fog
  30810. */
  30811. set fogEnabled(value: boolean);
  30812. /**
  30813. * Gets the value of the fog enabled state
  30814. */
  30815. get fogEnabled(): boolean;
  30816. /**
  30817. * Stores the size of points
  30818. */
  30819. pointSize: number;
  30820. /**
  30821. * Stores the z offset value
  30822. */
  30823. zOffset: number;
  30824. get wireframe(): boolean;
  30825. /**
  30826. * Sets the state of wireframe mode
  30827. */
  30828. set wireframe(value: boolean);
  30829. /**
  30830. * Gets the value specifying if point clouds are enabled
  30831. */
  30832. get pointsCloud(): boolean;
  30833. /**
  30834. * Sets the state of point cloud mode
  30835. */
  30836. set pointsCloud(value: boolean);
  30837. /**
  30838. * Gets the material fill mode
  30839. */
  30840. get fillMode(): number;
  30841. /**
  30842. * Sets the material fill mode
  30843. */
  30844. set fillMode(value: number);
  30845. /**
  30846. * @hidden
  30847. * Stores the effects for the material
  30848. */
  30849. _effect: Nullable<Effect>;
  30850. /**
  30851. * Specifies if uniform buffers should be used
  30852. */
  30853. private _useUBO;
  30854. /**
  30855. * Stores a reference to the scene
  30856. */
  30857. private _scene;
  30858. /**
  30859. * Stores the fill mode state
  30860. */
  30861. private _fillMode;
  30862. /**
  30863. * Specifies if the depth write state should be cached
  30864. */
  30865. private _cachedDepthWriteState;
  30866. /**
  30867. * Specifies if the color write state should be cached
  30868. */
  30869. private _cachedColorWriteState;
  30870. /**
  30871. * Specifies if the depth function state should be cached
  30872. */
  30873. private _cachedDepthFunctionState;
  30874. /**
  30875. * Stores the uniform buffer
  30876. */
  30877. protected _uniformBuffer: UniformBuffer;
  30878. /** @hidden */
  30879. _indexInSceneMaterialArray: number;
  30880. /** @hidden */
  30881. meshMap: Nullable<{
  30882. [id: string]: AbstractMesh | undefined;
  30883. }>;
  30884. /**
  30885. * Creates a material instance
  30886. * @param name defines the name of the material
  30887. * @param scene defines the scene to reference
  30888. * @param doNotAdd specifies if the material should be added to the scene
  30889. */
  30890. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30891. /**
  30892. * Returns a string representation of the current material
  30893. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30894. * @returns a string with material information
  30895. */
  30896. toString(fullDetails?: boolean): string;
  30897. /**
  30898. * Gets the class name of the material
  30899. * @returns a string with the class name of the material
  30900. */
  30901. getClassName(): string;
  30902. /**
  30903. * Specifies if updates for the material been locked
  30904. */
  30905. get isFrozen(): boolean;
  30906. /**
  30907. * Locks updates for the material
  30908. */
  30909. freeze(): void;
  30910. /**
  30911. * Unlocks updates for the material
  30912. */
  30913. unfreeze(): void;
  30914. /**
  30915. * Specifies if the material is ready to be used
  30916. * @param mesh defines the mesh to check
  30917. * @param useInstances specifies if instances should be used
  30918. * @returns a boolean indicating if the material is ready to be used
  30919. */
  30920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30921. /**
  30922. * Specifies that the submesh is ready to be used
  30923. * @param mesh defines the mesh to check
  30924. * @param subMesh defines which submesh to check
  30925. * @param useInstances specifies that instances should be used
  30926. * @returns a boolean indicating that the submesh is ready or not
  30927. */
  30928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30929. /**
  30930. * Returns the material effect
  30931. * @returns the effect associated with the material
  30932. */
  30933. getEffect(): Nullable<Effect>;
  30934. /**
  30935. * Returns the current scene
  30936. * @returns a Scene
  30937. */
  30938. getScene(): Scene;
  30939. /**
  30940. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30941. */
  30942. protected _forceAlphaTest: boolean;
  30943. /**
  30944. * The transparency mode of the material.
  30945. */
  30946. protected _transparencyMode: Nullable<number>;
  30947. /**
  30948. * Gets the current transparency mode.
  30949. */
  30950. get transparencyMode(): Nullable<number>;
  30951. /**
  30952. * Sets the transparency mode of the material.
  30953. *
  30954. * | Value | Type | Description |
  30955. * | ----- | ----------------------------------- | ----------- |
  30956. * | 0 | OPAQUE | |
  30957. * | 1 | ALPHATEST | |
  30958. * | 2 | ALPHABLEND | |
  30959. * | 3 | ALPHATESTANDBLEND | |
  30960. *
  30961. */
  30962. set transparencyMode(value: Nullable<number>);
  30963. /**
  30964. * Returns true if alpha blending should be disabled.
  30965. */
  30966. protected get _disableAlphaBlending(): boolean;
  30967. /**
  30968. * Specifies whether or not this material should be rendered in alpha blend mode.
  30969. * @returns a boolean specifying if alpha blending is needed
  30970. */
  30971. needAlphaBlending(): boolean;
  30972. /**
  30973. * Specifies if the mesh will require alpha blending
  30974. * @param mesh defines the mesh to check
  30975. * @returns a boolean specifying if alpha blending is needed for the mesh
  30976. */
  30977. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30978. /**
  30979. * Specifies whether or not this material should be rendered in alpha test mode.
  30980. * @returns a boolean specifying if an alpha test is needed.
  30981. */
  30982. needAlphaTesting(): boolean;
  30983. /**
  30984. * Specifies if material alpha testing should be turned on for the mesh
  30985. * @param mesh defines the mesh to check
  30986. */
  30987. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30988. /**
  30989. * Gets the texture used for the alpha test
  30990. * @returns the texture to use for alpha testing
  30991. */
  30992. getAlphaTestTexture(): Nullable<BaseTexture>;
  30993. /**
  30994. * Marks the material to indicate that it needs to be re-calculated
  30995. */
  30996. markDirty(): void;
  30997. /** @hidden */
  30998. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30999. /**
  31000. * Binds the material to the mesh
  31001. * @param world defines the world transformation matrix
  31002. * @param mesh defines the mesh to bind the material to
  31003. */
  31004. bind(world: Matrix, mesh?: Mesh): void;
  31005. /**
  31006. * Binds the submesh to the material
  31007. * @param world defines the world transformation matrix
  31008. * @param mesh defines the mesh containing the submesh
  31009. * @param subMesh defines the submesh to bind the material to
  31010. */
  31011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31012. /**
  31013. * Binds the world matrix to the material
  31014. * @param world defines the world transformation matrix
  31015. */
  31016. bindOnlyWorldMatrix(world: Matrix): void;
  31017. /**
  31018. * Binds the scene's uniform buffer to the effect.
  31019. * @param effect defines the effect to bind to the scene uniform buffer
  31020. * @param sceneUbo defines the uniform buffer storing scene data
  31021. */
  31022. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31023. /**
  31024. * Binds the view matrix to the effect
  31025. * @param effect defines the effect to bind the view matrix to
  31026. */
  31027. bindView(effect: Effect): void;
  31028. /**
  31029. * Binds the view projection matrix to the effect
  31030. * @param effect defines the effect to bind the view projection matrix to
  31031. */
  31032. bindViewProjection(effect: Effect): void;
  31033. /**
  31034. * Processes to execute after binding the material to a mesh
  31035. * @param mesh defines the rendered mesh
  31036. */
  31037. protected _afterBind(mesh?: Mesh): void;
  31038. /**
  31039. * Unbinds the material from the mesh
  31040. */
  31041. unbind(): void;
  31042. /**
  31043. * Gets the active textures from the material
  31044. * @returns an array of textures
  31045. */
  31046. getActiveTextures(): BaseTexture[];
  31047. /**
  31048. * Specifies if the material uses a texture
  31049. * @param texture defines the texture to check against the material
  31050. * @returns a boolean specifying if the material uses the texture
  31051. */
  31052. hasTexture(texture: BaseTexture): boolean;
  31053. /**
  31054. * Makes a duplicate of the material, and gives it a new name
  31055. * @param name defines the new name for the duplicated material
  31056. * @returns the cloned material
  31057. */
  31058. clone(name: string): Nullable<Material>;
  31059. /**
  31060. * Gets the meshes bound to the material
  31061. * @returns an array of meshes bound to the material
  31062. */
  31063. getBindedMeshes(): AbstractMesh[];
  31064. /**
  31065. * Force shader compilation
  31066. * @param mesh defines the mesh associated with this material
  31067. * @param onCompiled defines a function to execute once the material is compiled
  31068. * @param options defines the options to configure the compilation
  31069. * @param onError defines a function to execute if the material fails compiling
  31070. */
  31071. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31072. /**
  31073. * Force shader compilation
  31074. * @param mesh defines the mesh that will use this material
  31075. * @param options defines additional options for compiling the shaders
  31076. * @returns a promise that resolves when the compilation completes
  31077. */
  31078. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31079. private static readonly _AllDirtyCallBack;
  31080. private static readonly _ImageProcessingDirtyCallBack;
  31081. private static readonly _TextureDirtyCallBack;
  31082. private static readonly _FresnelDirtyCallBack;
  31083. private static readonly _MiscDirtyCallBack;
  31084. private static readonly _PrePassDirtyCallBack;
  31085. private static readonly _LightsDirtyCallBack;
  31086. private static readonly _AttributeDirtyCallBack;
  31087. private static _FresnelAndMiscDirtyCallBack;
  31088. private static _TextureAndMiscDirtyCallBack;
  31089. private static readonly _DirtyCallbackArray;
  31090. private static readonly _RunDirtyCallBacks;
  31091. /**
  31092. * Marks a define in the material to indicate that it needs to be re-computed
  31093. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31094. */
  31095. markAsDirty(flag: number): void;
  31096. /**
  31097. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31098. * @param func defines a function which checks material defines against the submeshes
  31099. */
  31100. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31101. /**
  31102. * Indicates that the scene should check if the rendering now needs a prepass
  31103. */
  31104. protected _markScenePrePassDirty(): void;
  31105. /**
  31106. * Indicates that we need to re-calculated for all submeshes
  31107. */
  31108. protected _markAllSubMeshesAsAllDirty(): void;
  31109. /**
  31110. * Indicates that image processing needs to be re-calculated for all submeshes
  31111. */
  31112. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31113. /**
  31114. * Indicates that textures need to be re-calculated for all submeshes
  31115. */
  31116. protected _markAllSubMeshesAsTexturesDirty(): void;
  31117. /**
  31118. * Indicates that fresnel needs to be re-calculated for all submeshes
  31119. */
  31120. protected _markAllSubMeshesAsFresnelDirty(): void;
  31121. /**
  31122. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31123. */
  31124. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31125. /**
  31126. * Indicates that lights need to be re-calculated for all submeshes
  31127. */
  31128. protected _markAllSubMeshesAsLightsDirty(): void;
  31129. /**
  31130. * Indicates that attributes need to be re-calculated for all submeshes
  31131. */
  31132. protected _markAllSubMeshesAsAttributesDirty(): void;
  31133. /**
  31134. * Indicates that misc needs to be re-calculated for all submeshes
  31135. */
  31136. protected _markAllSubMeshesAsMiscDirty(): void;
  31137. /**
  31138. * Indicates that prepass needs to be re-calculated for all submeshes
  31139. */
  31140. protected _markAllSubMeshesAsPrePassDirty(): void;
  31141. /**
  31142. * Indicates that textures and misc need to be re-calculated for all submeshes
  31143. */
  31144. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31145. /**
  31146. * Sets the required values to the prepass renderer.
  31147. * @param prePassRenderer defines the prepass renderer to setup.
  31148. * @returns true if the pre pass is needed.
  31149. */
  31150. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31151. /**
  31152. * Disposes the material
  31153. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31154. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31155. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31156. */
  31157. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31158. /** @hidden */
  31159. private releaseVertexArrayObject;
  31160. /**
  31161. * Serializes this material
  31162. * @returns the serialized material object
  31163. */
  31164. serialize(): any;
  31165. /**
  31166. * Creates a material from parsed material data
  31167. * @param parsedMaterial defines parsed material data
  31168. * @param scene defines the hosting scene
  31169. * @param rootUrl defines the root URL to use to load textures
  31170. * @returns a new material
  31171. */
  31172. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31173. }
  31174. }
  31175. declare module "babylonjs/Materials/multiMaterial" {
  31176. import { Nullable } from "babylonjs/types";
  31177. import { Scene } from "babylonjs/scene";
  31178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31179. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31181. import { Material } from "babylonjs/Materials/material";
  31182. /**
  31183. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31184. * separate meshes. This can be use to improve performances.
  31185. * @see https://doc.babylonjs.com/how_to/multi_materials
  31186. */
  31187. export class MultiMaterial extends Material {
  31188. private _subMaterials;
  31189. /**
  31190. * Gets or Sets the list of Materials used within the multi material.
  31191. * They need to be ordered according to the submeshes order in the associated mesh
  31192. */
  31193. get subMaterials(): Nullable<Material>[];
  31194. set subMaterials(value: Nullable<Material>[]);
  31195. /**
  31196. * Function used to align with Node.getChildren()
  31197. * @returns the list of Materials used within the multi material
  31198. */
  31199. getChildren(): Nullable<Material>[];
  31200. /**
  31201. * Instantiates a new Multi Material
  31202. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31203. * separate meshes. This can be use to improve performances.
  31204. * @see https://doc.babylonjs.com/how_to/multi_materials
  31205. * @param name Define the name in the scene
  31206. * @param scene Define the scene the material belongs to
  31207. */
  31208. constructor(name: string, scene: Scene);
  31209. private _hookArray;
  31210. /**
  31211. * Get one of the submaterial by its index in the submaterials array
  31212. * @param index The index to look the sub material at
  31213. * @returns The Material if the index has been defined
  31214. */
  31215. getSubMaterial(index: number): Nullable<Material>;
  31216. /**
  31217. * Get the list of active textures for the whole sub materials list.
  31218. * @returns All the textures that will be used during the rendering
  31219. */
  31220. getActiveTextures(): BaseTexture[];
  31221. /**
  31222. * Specifies if any sub-materials of this multi-material use a given texture.
  31223. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31224. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31225. */
  31226. hasTexture(texture: BaseTexture): boolean;
  31227. /**
  31228. * Gets the current class name of the material e.g. "MultiMaterial"
  31229. * Mainly use in serialization.
  31230. * @returns the class name
  31231. */
  31232. getClassName(): string;
  31233. /**
  31234. * Checks if the material is ready to render the requested sub mesh
  31235. * @param mesh Define the mesh the submesh belongs to
  31236. * @param subMesh Define the sub mesh to look readyness for
  31237. * @param useInstances Define whether or not the material is used with instances
  31238. * @returns true if ready, otherwise false
  31239. */
  31240. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31241. /**
  31242. * Clones the current material and its related sub materials
  31243. * @param name Define the name of the newly cloned material
  31244. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31245. * @returns the cloned material
  31246. */
  31247. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31248. /**
  31249. * Serializes the materials into a JSON representation.
  31250. * @returns the JSON representation
  31251. */
  31252. serialize(): any;
  31253. /**
  31254. * Dispose the material and release its associated resources
  31255. * @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)
  31256. * @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)
  31257. * @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)
  31258. */
  31259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31260. /**
  31261. * Creates a MultiMaterial from parsed MultiMaterial data.
  31262. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31263. * @param scene defines the hosting scene
  31264. * @returns a new MultiMaterial
  31265. */
  31266. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31267. }
  31268. }
  31269. declare module "babylonjs/Meshes/subMesh" {
  31270. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31271. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31272. import { Engine } from "babylonjs/Engines/engine";
  31273. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31274. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31275. import { Effect } from "babylonjs/Materials/effect";
  31276. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31277. import { Plane } from "babylonjs/Maths/math.plane";
  31278. import { Collider } from "babylonjs/Collisions/collider";
  31279. import { Material } from "babylonjs/Materials/material";
  31280. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31282. import { Mesh } from "babylonjs/Meshes/mesh";
  31283. import { Ray } from "babylonjs/Culling/ray";
  31284. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31285. /**
  31286. * Defines a subdivision inside a mesh
  31287. */
  31288. export class SubMesh implements ICullable {
  31289. /** the material index to use */
  31290. materialIndex: number;
  31291. /** vertex index start */
  31292. verticesStart: number;
  31293. /** vertices count */
  31294. verticesCount: number;
  31295. /** index start */
  31296. indexStart: number;
  31297. /** indices count */
  31298. indexCount: number;
  31299. /** @hidden */
  31300. _materialDefines: Nullable<MaterialDefines>;
  31301. /** @hidden */
  31302. _materialEffect: Nullable<Effect>;
  31303. /** @hidden */
  31304. _effectOverride: Nullable<Effect>;
  31305. /**
  31306. * Gets material defines used by the effect associated to the sub mesh
  31307. */
  31308. get materialDefines(): Nullable<MaterialDefines>;
  31309. /**
  31310. * Sets material defines used by the effect associated to the sub mesh
  31311. */
  31312. set materialDefines(defines: Nullable<MaterialDefines>);
  31313. /**
  31314. * Gets associated effect
  31315. */
  31316. get effect(): Nullable<Effect>;
  31317. /**
  31318. * Sets associated effect (effect used to render this submesh)
  31319. * @param effect defines the effect to associate with
  31320. * @param defines defines the set of defines used to compile this effect
  31321. */
  31322. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31323. /** @hidden */
  31324. _linesIndexCount: number;
  31325. private _mesh;
  31326. private _renderingMesh;
  31327. private _boundingInfo;
  31328. private _linesIndexBuffer;
  31329. /** @hidden */
  31330. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31331. /** @hidden */
  31332. _trianglePlanes: Plane[];
  31333. /** @hidden */
  31334. _lastColliderTransformMatrix: Nullable<Matrix>;
  31335. /** @hidden */
  31336. _renderId: number;
  31337. /** @hidden */
  31338. _alphaIndex: number;
  31339. /** @hidden */
  31340. _distanceToCamera: number;
  31341. /** @hidden */
  31342. _id: number;
  31343. private _currentMaterial;
  31344. /**
  31345. * Add a new submesh to a mesh
  31346. * @param materialIndex defines the material index to use
  31347. * @param verticesStart defines vertex index start
  31348. * @param verticesCount defines vertices count
  31349. * @param indexStart defines index start
  31350. * @param indexCount defines indices count
  31351. * @param mesh defines the parent mesh
  31352. * @param renderingMesh defines an optional rendering mesh
  31353. * @param createBoundingBox defines if bounding box should be created for this submesh
  31354. * @returns the new submesh
  31355. */
  31356. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31357. /**
  31358. * Creates a new submesh
  31359. * @param materialIndex defines the material index to use
  31360. * @param verticesStart defines vertex index start
  31361. * @param verticesCount defines vertices count
  31362. * @param indexStart defines index start
  31363. * @param indexCount defines indices count
  31364. * @param mesh defines the parent mesh
  31365. * @param renderingMesh defines an optional rendering mesh
  31366. * @param createBoundingBox defines if bounding box should be created for this submesh
  31367. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31368. */
  31369. constructor(
  31370. /** the material index to use */
  31371. materialIndex: number,
  31372. /** vertex index start */
  31373. verticesStart: number,
  31374. /** vertices count */
  31375. verticesCount: number,
  31376. /** index start */
  31377. indexStart: number,
  31378. /** indices count */
  31379. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31380. /**
  31381. * Returns true if this submesh covers the entire parent mesh
  31382. * @ignorenaming
  31383. */
  31384. get IsGlobal(): boolean;
  31385. /**
  31386. * Returns the submesh BoudingInfo object
  31387. * @returns current bounding info (or mesh's one if the submesh is global)
  31388. */
  31389. getBoundingInfo(): BoundingInfo;
  31390. /**
  31391. * Sets the submesh BoundingInfo
  31392. * @param boundingInfo defines the new bounding info to use
  31393. * @returns the SubMesh
  31394. */
  31395. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31396. /**
  31397. * Returns the mesh of the current submesh
  31398. * @return the parent mesh
  31399. */
  31400. getMesh(): AbstractMesh;
  31401. /**
  31402. * Returns the rendering mesh of the submesh
  31403. * @returns the rendering mesh (could be different from parent mesh)
  31404. */
  31405. getRenderingMesh(): Mesh;
  31406. /**
  31407. * Returns the replacement mesh of the submesh
  31408. * @returns the replacement mesh (could be different from parent mesh)
  31409. */
  31410. getReplacementMesh(): Nullable<AbstractMesh>;
  31411. /**
  31412. * Returns the effective mesh of the submesh
  31413. * @returns the effective mesh (could be different from parent mesh)
  31414. */
  31415. getEffectiveMesh(): AbstractMesh;
  31416. /**
  31417. * Returns the submesh material
  31418. * @returns null or the current material
  31419. */
  31420. getMaterial(): Nullable<Material>;
  31421. private _IsMultiMaterial;
  31422. /**
  31423. * Sets a new updated BoundingInfo object to the submesh
  31424. * @param data defines an optional position array to use to determine the bounding info
  31425. * @returns the SubMesh
  31426. */
  31427. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31428. /** @hidden */
  31429. _checkCollision(collider: Collider): boolean;
  31430. /**
  31431. * Updates the submesh BoundingInfo
  31432. * @param world defines the world matrix to use to update the bounding info
  31433. * @returns the submesh
  31434. */
  31435. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31436. /**
  31437. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31438. * @param frustumPlanes defines the frustum planes
  31439. * @returns true if the submesh is intersecting with the frustum
  31440. */
  31441. isInFrustum(frustumPlanes: Plane[]): boolean;
  31442. /**
  31443. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31444. * @param frustumPlanes defines the frustum planes
  31445. * @returns true if the submesh is inside the frustum
  31446. */
  31447. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31448. /**
  31449. * Renders the submesh
  31450. * @param enableAlphaMode defines if alpha needs to be used
  31451. * @returns the submesh
  31452. */
  31453. render(enableAlphaMode: boolean): SubMesh;
  31454. /**
  31455. * @hidden
  31456. */
  31457. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31458. /**
  31459. * Checks if the submesh intersects with a ray
  31460. * @param ray defines the ray to test
  31461. * @returns true is the passed ray intersects the submesh bounding box
  31462. */
  31463. canIntersects(ray: Ray): boolean;
  31464. /**
  31465. * Intersects current submesh with a ray
  31466. * @param ray defines the ray to test
  31467. * @param positions defines mesh's positions array
  31468. * @param indices defines mesh's indices array
  31469. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31471. * @returns intersection info or null if no intersection
  31472. */
  31473. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31474. /** @hidden */
  31475. private _intersectLines;
  31476. /** @hidden */
  31477. private _intersectUnIndexedLines;
  31478. /** @hidden */
  31479. private _intersectTriangles;
  31480. /** @hidden */
  31481. private _intersectUnIndexedTriangles;
  31482. /** @hidden */
  31483. _rebuild(): void;
  31484. /**
  31485. * Creates a new submesh from the passed mesh
  31486. * @param newMesh defines the new hosting mesh
  31487. * @param newRenderingMesh defines an optional rendering mesh
  31488. * @returns the new submesh
  31489. */
  31490. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31491. /**
  31492. * Release associated resources
  31493. */
  31494. dispose(): void;
  31495. /**
  31496. * Gets the class name
  31497. * @returns the string "SubMesh".
  31498. */
  31499. getClassName(): string;
  31500. /**
  31501. * Creates a new submesh from indices data
  31502. * @param materialIndex the index of the main mesh material
  31503. * @param startIndex the index where to start the copy in the mesh indices array
  31504. * @param indexCount the number of indices to copy then from the startIndex
  31505. * @param mesh the main mesh to create the submesh from
  31506. * @param renderingMesh the optional rendering mesh
  31507. * @returns a new submesh
  31508. */
  31509. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31510. }
  31511. }
  31512. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31513. /**
  31514. * Class used to represent data loading progression
  31515. */
  31516. export class SceneLoaderFlags {
  31517. private static _ForceFullSceneLoadingForIncremental;
  31518. private static _ShowLoadingScreen;
  31519. private static _CleanBoneMatrixWeights;
  31520. private static _loggingLevel;
  31521. /**
  31522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31523. */
  31524. static get ForceFullSceneLoadingForIncremental(): boolean;
  31525. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31526. /**
  31527. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31528. */
  31529. static get ShowLoadingScreen(): boolean;
  31530. static set ShowLoadingScreen(value: boolean);
  31531. /**
  31532. * Defines the current logging level (while loading the scene)
  31533. * @ignorenaming
  31534. */
  31535. static get loggingLevel(): number;
  31536. static set loggingLevel(value: number);
  31537. /**
  31538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31539. */
  31540. static get CleanBoneMatrixWeights(): boolean;
  31541. static set CleanBoneMatrixWeights(value: boolean);
  31542. }
  31543. }
  31544. declare module "babylonjs/Meshes/geometry" {
  31545. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31546. import { Scene } from "babylonjs/scene";
  31547. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31548. import { Engine } from "babylonjs/Engines/engine";
  31549. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31550. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31551. import { Effect } from "babylonjs/Materials/effect";
  31552. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31554. import { Mesh } from "babylonjs/Meshes/mesh";
  31555. /**
  31556. * Class used to store geometry data (vertex buffers + index buffer)
  31557. */
  31558. export class Geometry implements IGetSetVerticesData {
  31559. /**
  31560. * Gets or sets the ID of the geometry
  31561. */
  31562. id: string;
  31563. /**
  31564. * Gets or sets the unique ID of the geometry
  31565. */
  31566. uniqueId: number;
  31567. /**
  31568. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31569. */
  31570. delayLoadState: number;
  31571. /**
  31572. * Gets the file containing the data to load when running in delay load state
  31573. */
  31574. delayLoadingFile: Nullable<string>;
  31575. /**
  31576. * Callback called when the geometry is updated
  31577. */
  31578. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31579. private _scene;
  31580. private _engine;
  31581. private _meshes;
  31582. private _totalVertices;
  31583. /** @hidden */
  31584. _indices: IndicesArray;
  31585. /** @hidden */
  31586. _vertexBuffers: {
  31587. [key: string]: VertexBuffer;
  31588. };
  31589. private _isDisposed;
  31590. private _extend;
  31591. private _boundingBias;
  31592. /** @hidden */
  31593. _delayInfo: Array<string>;
  31594. private _indexBuffer;
  31595. private _indexBufferIsUpdatable;
  31596. /** @hidden */
  31597. _boundingInfo: Nullable<BoundingInfo>;
  31598. /** @hidden */
  31599. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31600. /** @hidden */
  31601. _softwareSkinningFrameId: number;
  31602. private _vertexArrayObjects;
  31603. private _updatable;
  31604. /** @hidden */
  31605. _positions: Nullable<Vector3[]>;
  31606. private _positionsCache;
  31607. /**
  31608. * 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
  31609. */
  31610. get boundingBias(): Vector2;
  31611. /**
  31612. * 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
  31613. */
  31614. set boundingBias(value: Vector2);
  31615. /**
  31616. * Static function used to attach a new empty geometry to a mesh
  31617. * @param mesh defines the mesh to attach the geometry to
  31618. * @returns the new Geometry
  31619. */
  31620. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31621. /** Get the list of meshes using this geometry */
  31622. get meshes(): Mesh[];
  31623. /**
  31624. * 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
  31625. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31626. */
  31627. useBoundingInfoFromGeometry: boolean;
  31628. /**
  31629. * Creates a new geometry
  31630. * @param id defines the unique ID
  31631. * @param scene defines the hosting scene
  31632. * @param vertexData defines the VertexData used to get geometry data
  31633. * @param updatable defines if geometry must be updatable (false by default)
  31634. * @param mesh defines the mesh that will be associated with the geometry
  31635. */
  31636. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31637. /**
  31638. * Gets the current extend of the geometry
  31639. */
  31640. get extend(): {
  31641. minimum: Vector3;
  31642. maximum: Vector3;
  31643. };
  31644. /**
  31645. * Gets the hosting scene
  31646. * @returns the hosting Scene
  31647. */
  31648. getScene(): Scene;
  31649. /**
  31650. * Gets the hosting engine
  31651. * @returns the hosting Engine
  31652. */
  31653. getEngine(): Engine;
  31654. /**
  31655. * Defines if the geometry is ready to use
  31656. * @returns true if the geometry is ready to be used
  31657. */
  31658. isReady(): boolean;
  31659. /**
  31660. * Gets a value indicating that the geometry should not be serialized
  31661. */
  31662. get doNotSerialize(): boolean;
  31663. /** @hidden */
  31664. _rebuild(): void;
  31665. /**
  31666. * Affects all geometry data in one call
  31667. * @param vertexData defines the geometry data
  31668. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31669. */
  31670. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31671. /**
  31672. * Set specific vertex data
  31673. * @param kind defines the data kind (Position, normal, etc...)
  31674. * @param data defines the vertex data to use
  31675. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31676. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31677. */
  31678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31679. /**
  31680. * Removes a specific vertex data
  31681. * @param kind defines the data kind (Position, normal, etc...)
  31682. */
  31683. removeVerticesData(kind: string): void;
  31684. /**
  31685. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31686. * @param buffer defines the vertex buffer to use
  31687. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31688. */
  31689. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31690. /**
  31691. * Update a specific vertex buffer
  31692. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31693. * It will do nothing if the buffer is not updatable
  31694. * @param kind defines the data kind (Position, normal, etc...)
  31695. * @param data defines the data to use
  31696. * @param offset defines the offset in the target buffer where to store the data
  31697. * @param useBytes set to true if the offset is in bytes
  31698. */
  31699. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31700. /**
  31701. * Update a specific vertex buffer
  31702. * This function will create a new buffer if the current one is not updatable
  31703. * @param kind defines the data kind (Position, normal, etc...)
  31704. * @param data defines the data to use
  31705. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31706. */
  31707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31708. private _updateBoundingInfo;
  31709. /** @hidden */
  31710. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31711. /**
  31712. * Gets total number of vertices
  31713. * @returns the total number of vertices
  31714. */
  31715. getTotalVertices(): number;
  31716. /**
  31717. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31718. * @param kind defines the data kind (Position, normal, etc...)
  31719. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31720. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31721. * @returns a float array containing vertex data
  31722. */
  31723. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31724. /**
  31725. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31726. * @param kind defines the data kind (Position, normal, etc...)
  31727. * @returns true if the vertex buffer with the specified kind is updatable
  31728. */
  31729. isVertexBufferUpdatable(kind: string): boolean;
  31730. /**
  31731. * Gets a specific vertex buffer
  31732. * @param kind defines the data kind (Position, normal, etc...)
  31733. * @returns a VertexBuffer
  31734. */
  31735. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31736. /**
  31737. * Returns all vertex buffers
  31738. * @return an object holding all vertex buffers indexed by kind
  31739. */
  31740. getVertexBuffers(): Nullable<{
  31741. [key: string]: VertexBuffer;
  31742. }>;
  31743. /**
  31744. * Gets a boolean indicating if specific vertex buffer is present
  31745. * @param kind defines the data kind (Position, normal, etc...)
  31746. * @returns true if data is present
  31747. */
  31748. isVerticesDataPresent(kind: string): boolean;
  31749. /**
  31750. * Gets a list of all attached data kinds (Position, normal, etc...)
  31751. * @returns a list of string containing all kinds
  31752. */
  31753. getVerticesDataKinds(): string[];
  31754. /**
  31755. * Update index buffer
  31756. * @param indices defines the indices to store in the index buffer
  31757. * @param offset defines the offset in the target buffer where to store the data
  31758. * @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)
  31759. */
  31760. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31761. /**
  31762. * Creates a new index buffer
  31763. * @param indices defines the indices to store in the index buffer
  31764. * @param totalVertices defines the total number of vertices (could be null)
  31765. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31766. */
  31767. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31768. /**
  31769. * Return the total number of indices
  31770. * @returns the total number of indices
  31771. */
  31772. getTotalIndices(): number;
  31773. /**
  31774. * Gets the index buffer array
  31775. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31777. * @returns the index buffer array
  31778. */
  31779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31780. /**
  31781. * Gets the index buffer
  31782. * @return the index buffer
  31783. */
  31784. getIndexBuffer(): Nullable<DataBuffer>;
  31785. /** @hidden */
  31786. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31787. /**
  31788. * Release the associated resources for a specific mesh
  31789. * @param mesh defines the source mesh
  31790. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31791. */
  31792. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31793. /**
  31794. * Apply current geometry to a given mesh
  31795. * @param mesh defines the mesh to apply geometry to
  31796. */
  31797. applyToMesh(mesh: Mesh): void;
  31798. private _updateExtend;
  31799. private _applyToMesh;
  31800. private notifyUpdate;
  31801. /**
  31802. * Load the geometry if it was flagged as delay loaded
  31803. * @param scene defines the hosting scene
  31804. * @param onLoaded defines a callback called when the geometry is loaded
  31805. */
  31806. load(scene: Scene, onLoaded?: () => void): void;
  31807. private _queueLoad;
  31808. /**
  31809. * Invert the geometry to move from a right handed system to a left handed one.
  31810. */
  31811. toLeftHanded(): void;
  31812. /** @hidden */
  31813. _resetPointsArrayCache(): void;
  31814. /** @hidden */
  31815. _generatePointsArray(): boolean;
  31816. /**
  31817. * Gets a value indicating if the geometry is disposed
  31818. * @returns true if the geometry was disposed
  31819. */
  31820. isDisposed(): boolean;
  31821. private _disposeVertexArrayObjects;
  31822. /**
  31823. * Free all associated resources
  31824. */
  31825. dispose(): void;
  31826. /**
  31827. * Clone the current geometry into a new geometry
  31828. * @param id defines the unique ID of the new geometry
  31829. * @returns a new geometry object
  31830. */
  31831. copy(id: string): Geometry;
  31832. /**
  31833. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31834. * @return a JSON representation of the current geometry data (without the vertices data)
  31835. */
  31836. serialize(): any;
  31837. private toNumberArray;
  31838. /**
  31839. * Serialize all vertices data into a JSON oject
  31840. * @returns a JSON representation of the current geometry data
  31841. */
  31842. serializeVerticeData(): any;
  31843. /**
  31844. * Extracts a clone of a mesh geometry
  31845. * @param mesh defines the source mesh
  31846. * @param id defines the unique ID of the new geometry object
  31847. * @returns the new geometry object
  31848. */
  31849. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31850. /**
  31851. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31853. * Be aware Math.random() could cause collisions, but:
  31854. * "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"
  31855. * @returns a string containing a new GUID
  31856. */
  31857. static RandomId(): string;
  31858. /** @hidden */
  31859. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31860. private static _CleanMatricesWeights;
  31861. /**
  31862. * Create a new geometry from persisted data (Using .babylon file format)
  31863. * @param parsedVertexData defines the persisted data
  31864. * @param scene defines the hosting scene
  31865. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31866. * @returns the new geometry object
  31867. */
  31868. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31869. }
  31870. }
  31871. declare module "babylonjs/Morph/morphTarget" {
  31872. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31873. import { Observable } from "babylonjs/Misc/observable";
  31874. import { Nullable, FloatArray } from "babylonjs/types";
  31875. import { Scene } from "babylonjs/scene";
  31876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31877. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31878. /**
  31879. * Defines a target to use with MorphTargetManager
  31880. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31881. */
  31882. export class MorphTarget implements IAnimatable {
  31883. /** defines the name of the target */
  31884. name: string;
  31885. /**
  31886. * Gets or sets the list of animations
  31887. */
  31888. animations: import("babylonjs/Animations/animation").Animation[];
  31889. private _scene;
  31890. private _positions;
  31891. private _normals;
  31892. private _tangents;
  31893. private _uvs;
  31894. private _influence;
  31895. private _uniqueId;
  31896. /**
  31897. * Observable raised when the influence changes
  31898. */
  31899. onInfluenceChanged: Observable<boolean>;
  31900. /** @hidden */
  31901. _onDataLayoutChanged: Observable<void>;
  31902. /**
  31903. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31904. */
  31905. get influence(): number;
  31906. set influence(influence: number);
  31907. /**
  31908. * Gets or sets the id of the morph Target
  31909. */
  31910. id: string;
  31911. private _animationPropertiesOverride;
  31912. /**
  31913. * Gets or sets the animation properties override
  31914. */
  31915. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31916. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31917. /**
  31918. * Creates a new MorphTarget
  31919. * @param name defines the name of the target
  31920. * @param influence defines the influence to use
  31921. * @param scene defines the scene the morphtarget belongs to
  31922. */
  31923. constructor(
  31924. /** defines the name of the target */
  31925. name: string, influence?: number, scene?: Nullable<Scene>);
  31926. /**
  31927. * Gets the unique ID of this manager
  31928. */
  31929. get uniqueId(): number;
  31930. /**
  31931. * Gets a boolean defining if the target contains position data
  31932. */
  31933. get hasPositions(): boolean;
  31934. /**
  31935. * Gets a boolean defining if the target contains normal data
  31936. */
  31937. get hasNormals(): boolean;
  31938. /**
  31939. * Gets a boolean defining if the target contains tangent data
  31940. */
  31941. get hasTangents(): boolean;
  31942. /**
  31943. * Gets a boolean defining if the target contains texture coordinates data
  31944. */
  31945. get hasUVs(): boolean;
  31946. /**
  31947. * Affects position data to this target
  31948. * @param data defines the position data to use
  31949. */
  31950. setPositions(data: Nullable<FloatArray>): void;
  31951. /**
  31952. * Gets the position data stored in this target
  31953. * @returns a FloatArray containing the position data (or null if not present)
  31954. */
  31955. getPositions(): Nullable<FloatArray>;
  31956. /**
  31957. * Affects normal data to this target
  31958. * @param data defines the normal data to use
  31959. */
  31960. setNormals(data: Nullable<FloatArray>): void;
  31961. /**
  31962. * Gets the normal data stored in this target
  31963. * @returns a FloatArray containing the normal data (or null if not present)
  31964. */
  31965. getNormals(): Nullable<FloatArray>;
  31966. /**
  31967. * Affects tangent data to this target
  31968. * @param data defines the tangent data to use
  31969. */
  31970. setTangents(data: Nullable<FloatArray>): void;
  31971. /**
  31972. * Gets the tangent data stored in this target
  31973. * @returns a FloatArray containing the tangent data (or null if not present)
  31974. */
  31975. getTangents(): Nullable<FloatArray>;
  31976. /**
  31977. * Affects texture coordinates data to this target
  31978. * @param data defines the texture coordinates data to use
  31979. */
  31980. setUVs(data: Nullable<FloatArray>): void;
  31981. /**
  31982. * Gets the texture coordinates data stored in this target
  31983. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31984. */
  31985. getUVs(): Nullable<FloatArray>;
  31986. /**
  31987. * Clone the current target
  31988. * @returns a new MorphTarget
  31989. */
  31990. clone(): MorphTarget;
  31991. /**
  31992. * Serializes the current target into a Serialization object
  31993. * @returns the serialized object
  31994. */
  31995. serialize(): any;
  31996. /**
  31997. * Returns the string "MorphTarget"
  31998. * @returns "MorphTarget"
  31999. */
  32000. getClassName(): string;
  32001. /**
  32002. * Creates a new target from serialized data
  32003. * @param serializationObject defines the serialized data to use
  32004. * @returns a new MorphTarget
  32005. */
  32006. static Parse(serializationObject: any): MorphTarget;
  32007. /**
  32008. * Creates a MorphTarget from mesh data
  32009. * @param mesh defines the source mesh
  32010. * @param name defines the name to use for the new target
  32011. * @param influence defines the influence to attach to the target
  32012. * @returns a new MorphTarget
  32013. */
  32014. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32015. }
  32016. }
  32017. declare module "babylonjs/Morph/morphTargetManager" {
  32018. import { Nullable } from "babylonjs/types";
  32019. import { Scene } from "babylonjs/scene";
  32020. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32021. /**
  32022. * This class is used to deform meshes using morphing between different targets
  32023. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32024. */
  32025. export class MorphTargetManager {
  32026. private _targets;
  32027. private _targetInfluenceChangedObservers;
  32028. private _targetDataLayoutChangedObservers;
  32029. private _activeTargets;
  32030. private _scene;
  32031. private _influences;
  32032. private _supportsNormals;
  32033. private _supportsTangents;
  32034. private _supportsUVs;
  32035. private _vertexCount;
  32036. private _uniqueId;
  32037. private _tempInfluences;
  32038. /**
  32039. * Gets or sets a boolean indicating if normals must be morphed
  32040. */
  32041. enableNormalMorphing: boolean;
  32042. /**
  32043. * Gets or sets a boolean indicating if tangents must be morphed
  32044. */
  32045. enableTangentMorphing: boolean;
  32046. /**
  32047. * Gets or sets a boolean indicating if UV must be morphed
  32048. */
  32049. enableUVMorphing: boolean;
  32050. /**
  32051. * Creates a new MorphTargetManager
  32052. * @param scene defines the current scene
  32053. */
  32054. constructor(scene?: Nullable<Scene>);
  32055. /**
  32056. * Gets the unique ID of this manager
  32057. */
  32058. get uniqueId(): number;
  32059. /**
  32060. * Gets the number of vertices handled by this manager
  32061. */
  32062. get vertexCount(): number;
  32063. /**
  32064. * Gets a boolean indicating if this manager supports morphing of normals
  32065. */
  32066. get supportsNormals(): boolean;
  32067. /**
  32068. * Gets a boolean indicating if this manager supports morphing of tangents
  32069. */
  32070. get supportsTangents(): boolean;
  32071. /**
  32072. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32073. */
  32074. get supportsUVs(): boolean;
  32075. /**
  32076. * Gets the number of targets stored in this manager
  32077. */
  32078. get numTargets(): number;
  32079. /**
  32080. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32081. */
  32082. get numInfluencers(): number;
  32083. /**
  32084. * Gets the list of influences (one per target)
  32085. */
  32086. get influences(): Float32Array;
  32087. /**
  32088. * Gets the active target at specified index. An active target is a target with an influence > 0
  32089. * @param index defines the index to check
  32090. * @returns the requested target
  32091. */
  32092. getActiveTarget(index: number): MorphTarget;
  32093. /**
  32094. * Gets the target at specified index
  32095. * @param index defines the index to check
  32096. * @returns the requested target
  32097. */
  32098. getTarget(index: number): MorphTarget;
  32099. /**
  32100. * Add a new target to this manager
  32101. * @param target defines the target to add
  32102. */
  32103. addTarget(target: MorphTarget): void;
  32104. /**
  32105. * Removes a target from the manager
  32106. * @param target defines the target to remove
  32107. */
  32108. removeTarget(target: MorphTarget): void;
  32109. /**
  32110. * Clone the current manager
  32111. * @returns a new MorphTargetManager
  32112. */
  32113. clone(): MorphTargetManager;
  32114. /**
  32115. * Serializes the current manager into a Serialization object
  32116. * @returns the serialized object
  32117. */
  32118. serialize(): any;
  32119. private _syncActiveTargets;
  32120. /**
  32121. * Syncrhonize the targets with all the meshes using this morph target manager
  32122. */
  32123. synchronize(): void;
  32124. /**
  32125. * Creates a new MorphTargetManager from serialized data
  32126. * @param serializationObject defines the serialized data
  32127. * @param scene defines the hosting scene
  32128. * @returns the new MorphTargetManager
  32129. */
  32130. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32131. }
  32132. }
  32133. declare module "babylonjs/Meshes/meshLODLevel" {
  32134. import { Mesh } from "babylonjs/Meshes/mesh";
  32135. import { Nullable } from "babylonjs/types";
  32136. /**
  32137. * Class used to represent a specific level of detail of a mesh
  32138. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32139. */
  32140. export class MeshLODLevel {
  32141. /** Defines the distance where this level should start being displayed */
  32142. distance: number;
  32143. /** Defines the mesh to use to render this level */
  32144. mesh: Nullable<Mesh>;
  32145. /**
  32146. * Creates a new LOD level
  32147. * @param distance defines the distance where this level should star being displayed
  32148. * @param mesh defines the mesh to use to render this level
  32149. */
  32150. constructor(
  32151. /** Defines the distance where this level should start being displayed */
  32152. distance: number,
  32153. /** Defines the mesh to use to render this level */
  32154. mesh: Nullable<Mesh>);
  32155. }
  32156. }
  32157. declare module "babylonjs/Misc/canvasGenerator" {
  32158. /**
  32159. * Helper class used to generate a canvas to manipulate images
  32160. */
  32161. export class CanvasGenerator {
  32162. /**
  32163. * Create a new canvas (or offscreen canvas depending on the context)
  32164. * @param width defines the expected width
  32165. * @param height defines the expected height
  32166. * @return a new canvas or offscreen canvas
  32167. */
  32168. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32169. }
  32170. }
  32171. declare module "babylonjs/Meshes/groundMesh" {
  32172. import { Scene } from "babylonjs/scene";
  32173. import { Vector3 } from "babylonjs/Maths/math.vector";
  32174. import { Mesh } from "babylonjs/Meshes/mesh";
  32175. /**
  32176. * Mesh representing the gorund
  32177. */
  32178. export class GroundMesh extends Mesh {
  32179. /** If octree should be generated */
  32180. generateOctree: boolean;
  32181. private _heightQuads;
  32182. /** @hidden */
  32183. _subdivisionsX: number;
  32184. /** @hidden */
  32185. _subdivisionsY: number;
  32186. /** @hidden */
  32187. _width: number;
  32188. /** @hidden */
  32189. _height: number;
  32190. /** @hidden */
  32191. _minX: number;
  32192. /** @hidden */
  32193. _maxX: number;
  32194. /** @hidden */
  32195. _minZ: number;
  32196. /** @hidden */
  32197. _maxZ: number;
  32198. constructor(name: string, scene: Scene);
  32199. /**
  32200. * "GroundMesh"
  32201. * @returns "GroundMesh"
  32202. */
  32203. getClassName(): string;
  32204. /**
  32205. * The minimum of x and y subdivisions
  32206. */
  32207. get subdivisions(): number;
  32208. /**
  32209. * X subdivisions
  32210. */
  32211. get subdivisionsX(): number;
  32212. /**
  32213. * Y subdivisions
  32214. */
  32215. get subdivisionsY(): number;
  32216. /**
  32217. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32219. * @param chunksCount the number of subdivisions for x and y
  32220. * @param octreeBlocksSize (Default: 32)
  32221. */
  32222. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32223. /**
  32224. * Returns a height (y) value in the Worl system :
  32225. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32226. * @param x x coordinate
  32227. * @param z z coordinate
  32228. * @returns the ground y position if (x, z) are outside the ground surface.
  32229. */
  32230. getHeightAtCoordinates(x: number, z: number): number;
  32231. /**
  32232. * Returns a normalized vector (Vector3) orthogonal to the ground
  32233. * at the ground coordinates (x, z) expressed in the World system.
  32234. * @param x x coordinate
  32235. * @param z z coordinate
  32236. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32237. */
  32238. getNormalAtCoordinates(x: number, z: number): Vector3;
  32239. /**
  32240. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32241. * at the ground coordinates (x, z) expressed in the World system.
  32242. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32243. * @param x x coordinate
  32244. * @param z z coordinate
  32245. * @param ref vector to store the result
  32246. * @returns the GroundMesh.
  32247. */
  32248. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32249. /**
  32250. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32251. * if the ground has been updated.
  32252. * This can be used in the render loop.
  32253. * @returns the GroundMesh.
  32254. */
  32255. updateCoordinateHeights(): GroundMesh;
  32256. private _getFacetAt;
  32257. private _initHeightQuads;
  32258. private _computeHeightQuads;
  32259. /**
  32260. * Serializes this ground mesh
  32261. * @param serializationObject object to write serialization to
  32262. */
  32263. serialize(serializationObject: any): void;
  32264. /**
  32265. * Parses a serialized ground mesh
  32266. * @param parsedMesh the serialized mesh
  32267. * @param scene the scene to create the ground mesh in
  32268. * @returns the created ground mesh
  32269. */
  32270. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32271. }
  32272. }
  32273. declare module "babylonjs/Physics/physicsJoint" {
  32274. import { Vector3 } from "babylonjs/Maths/math.vector";
  32275. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32276. /**
  32277. * Interface for Physics-Joint data
  32278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32279. */
  32280. export interface PhysicsJointData {
  32281. /**
  32282. * The main pivot of the joint
  32283. */
  32284. mainPivot?: Vector3;
  32285. /**
  32286. * The connected pivot of the joint
  32287. */
  32288. connectedPivot?: Vector3;
  32289. /**
  32290. * The main axis of the joint
  32291. */
  32292. mainAxis?: Vector3;
  32293. /**
  32294. * The connected axis of the joint
  32295. */
  32296. connectedAxis?: Vector3;
  32297. /**
  32298. * The collision of the joint
  32299. */
  32300. collision?: boolean;
  32301. /**
  32302. * Native Oimo/Cannon/Energy data
  32303. */
  32304. nativeParams?: any;
  32305. }
  32306. /**
  32307. * This is a holder class for the physics joint created by the physics plugin
  32308. * It holds a set of functions to control the underlying joint
  32309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32310. */
  32311. export class PhysicsJoint {
  32312. /**
  32313. * The type of the physics joint
  32314. */
  32315. type: number;
  32316. /**
  32317. * The data for the physics joint
  32318. */
  32319. jointData: PhysicsJointData;
  32320. private _physicsJoint;
  32321. protected _physicsPlugin: IPhysicsEnginePlugin;
  32322. /**
  32323. * Initializes the physics joint
  32324. * @param type The type of the physics joint
  32325. * @param jointData The data for the physics joint
  32326. */
  32327. constructor(
  32328. /**
  32329. * The type of the physics joint
  32330. */
  32331. type: number,
  32332. /**
  32333. * The data for the physics joint
  32334. */
  32335. jointData: PhysicsJointData);
  32336. /**
  32337. * Gets the physics joint
  32338. */
  32339. get physicsJoint(): any;
  32340. /**
  32341. * Sets the physics joint
  32342. */
  32343. set physicsJoint(newJoint: any);
  32344. /**
  32345. * Sets the physics plugin
  32346. */
  32347. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32348. /**
  32349. * Execute a function that is physics-plugin specific.
  32350. * @param {Function} func the function that will be executed.
  32351. * It accepts two parameters: the physics world and the physics joint
  32352. */
  32353. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32354. /**
  32355. * Distance-Joint type
  32356. */
  32357. static DistanceJoint: number;
  32358. /**
  32359. * Hinge-Joint type
  32360. */
  32361. static HingeJoint: number;
  32362. /**
  32363. * Ball-and-Socket joint type
  32364. */
  32365. static BallAndSocketJoint: number;
  32366. /**
  32367. * Wheel-Joint type
  32368. */
  32369. static WheelJoint: number;
  32370. /**
  32371. * Slider-Joint type
  32372. */
  32373. static SliderJoint: number;
  32374. /**
  32375. * Prismatic-Joint type
  32376. */
  32377. static PrismaticJoint: number;
  32378. /**
  32379. * Universal-Joint type
  32380. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32381. */
  32382. static UniversalJoint: number;
  32383. /**
  32384. * Hinge-Joint 2 type
  32385. */
  32386. static Hinge2Joint: number;
  32387. /**
  32388. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32389. */
  32390. static PointToPointJoint: number;
  32391. /**
  32392. * Spring-Joint type
  32393. */
  32394. static SpringJoint: number;
  32395. /**
  32396. * Lock-Joint type
  32397. */
  32398. static LockJoint: number;
  32399. }
  32400. /**
  32401. * A class representing a physics distance joint
  32402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32403. */
  32404. export class DistanceJoint extends PhysicsJoint {
  32405. /**
  32406. *
  32407. * @param jointData The data for the Distance-Joint
  32408. */
  32409. constructor(jointData: DistanceJointData);
  32410. /**
  32411. * Update the predefined distance.
  32412. * @param maxDistance The maximum preferred distance
  32413. * @param minDistance The minimum preferred distance
  32414. */
  32415. updateDistance(maxDistance: number, minDistance?: number): void;
  32416. }
  32417. /**
  32418. * Represents a Motor-Enabled Joint
  32419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32420. */
  32421. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32422. /**
  32423. * Initializes the Motor-Enabled Joint
  32424. * @param type The type of the joint
  32425. * @param jointData The physica joint data for the joint
  32426. */
  32427. constructor(type: number, jointData: PhysicsJointData);
  32428. /**
  32429. * Set the motor values.
  32430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32431. * @param force the force to apply
  32432. * @param maxForce max force for this motor.
  32433. */
  32434. setMotor(force?: number, maxForce?: number): void;
  32435. /**
  32436. * Set the motor's limits.
  32437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32438. * @param upperLimit The upper limit of the motor
  32439. * @param lowerLimit The lower limit of the motor
  32440. */
  32441. setLimit(upperLimit: number, lowerLimit?: number): void;
  32442. }
  32443. /**
  32444. * This class represents a single physics Hinge-Joint
  32445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32446. */
  32447. export class HingeJoint extends MotorEnabledJoint {
  32448. /**
  32449. * Initializes the Hinge-Joint
  32450. * @param jointData The joint data for the Hinge-Joint
  32451. */
  32452. constructor(jointData: PhysicsJointData);
  32453. /**
  32454. * Set the motor values.
  32455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32456. * @param {number} force the force to apply
  32457. * @param {number} maxForce max force for this motor.
  32458. */
  32459. setMotor(force?: number, maxForce?: number): void;
  32460. /**
  32461. * Set the motor's limits.
  32462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32463. * @param upperLimit The upper limit of the motor
  32464. * @param lowerLimit The lower limit of the motor
  32465. */
  32466. setLimit(upperLimit: number, lowerLimit?: number): void;
  32467. }
  32468. /**
  32469. * This class represents a dual hinge physics joint (same as wheel joint)
  32470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32471. */
  32472. export class Hinge2Joint extends MotorEnabledJoint {
  32473. /**
  32474. * Initializes the Hinge2-Joint
  32475. * @param jointData The joint data for the Hinge2-Joint
  32476. */
  32477. constructor(jointData: PhysicsJointData);
  32478. /**
  32479. * Set the motor values.
  32480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32481. * @param {number} targetSpeed the speed the motor is to reach
  32482. * @param {number} maxForce max force for this motor.
  32483. * @param {motorIndex} the motor's index, 0 or 1.
  32484. */
  32485. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32486. /**
  32487. * Set the motor limits.
  32488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32489. * @param {number} upperLimit the upper limit
  32490. * @param {number} lowerLimit lower limit
  32491. * @param {motorIndex} the motor's index, 0 or 1.
  32492. */
  32493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32494. }
  32495. /**
  32496. * Interface for a motor enabled joint
  32497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32498. */
  32499. export interface IMotorEnabledJoint {
  32500. /**
  32501. * Physics joint
  32502. */
  32503. physicsJoint: any;
  32504. /**
  32505. * Sets the motor of the motor-enabled joint
  32506. * @param force The force of the motor
  32507. * @param maxForce The maximum force of the motor
  32508. * @param motorIndex The index of the motor
  32509. */
  32510. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32511. /**
  32512. * Sets the limit of the motor
  32513. * @param upperLimit The upper limit of the motor
  32514. * @param lowerLimit The lower limit of the motor
  32515. * @param motorIndex The index of the motor
  32516. */
  32517. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32518. }
  32519. /**
  32520. * Joint data for a Distance-Joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export interface DistanceJointData extends PhysicsJointData {
  32524. /**
  32525. * Max distance the 2 joint objects can be apart
  32526. */
  32527. maxDistance: number;
  32528. }
  32529. /**
  32530. * Joint data from a spring joint
  32531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32532. */
  32533. export interface SpringJointData extends PhysicsJointData {
  32534. /**
  32535. * Length of the spring
  32536. */
  32537. length: number;
  32538. /**
  32539. * Stiffness of the spring
  32540. */
  32541. stiffness: number;
  32542. /**
  32543. * Damping of the spring
  32544. */
  32545. damping: number;
  32546. /** this callback will be called when applying the force to the impostors. */
  32547. forceApplicationCallback: () => void;
  32548. }
  32549. }
  32550. declare module "babylonjs/Physics/physicsRaycastResult" {
  32551. import { Vector3 } from "babylonjs/Maths/math.vector";
  32552. /**
  32553. * Holds the data for the raycast result
  32554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32555. */
  32556. export class PhysicsRaycastResult {
  32557. private _hasHit;
  32558. private _hitDistance;
  32559. private _hitNormalWorld;
  32560. private _hitPointWorld;
  32561. private _rayFromWorld;
  32562. private _rayToWorld;
  32563. /**
  32564. * Gets if there was a hit
  32565. */
  32566. get hasHit(): boolean;
  32567. /**
  32568. * Gets the distance from the hit
  32569. */
  32570. get hitDistance(): number;
  32571. /**
  32572. * Gets the hit normal/direction in the world
  32573. */
  32574. get hitNormalWorld(): Vector3;
  32575. /**
  32576. * Gets the hit point in the world
  32577. */
  32578. get hitPointWorld(): Vector3;
  32579. /**
  32580. * Gets the ray "start point" of the ray in the world
  32581. */
  32582. get rayFromWorld(): Vector3;
  32583. /**
  32584. * Gets the ray "end point" of the ray in the world
  32585. */
  32586. get rayToWorld(): Vector3;
  32587. /**
  32588. * Sets the hit data (normal & point in world space)
  32589. * @param hitNormalWorld defines the normal in world space
  32590. * @param hitPointWorld defines the point in world space
  32591. */
  32592. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32593. /**
  32594. * Sets the distance from the start point to the hit point
  32595. * @param distance
  32596. */
  32597. setHitDistance(distance: number): void;
  32598. /**
  32599. * Calculates the distance manually
  32600. */
  32601. calculateHitDistance(): void;
  32602. /**
  32603. * Resets all the values to default
  32604. * @param from The from point on world space
  32605. * @param to The to point on world space
  32606. */
  32607. reset(from?: Vector3, to?: Vector3): void;
  32608. }
  32609. /**
  32610. * Interface for the size containing width and height
  32611. */
  32612. interface IXYZ {
  32613. /**
  32614. * X
  32615. */
  32616. x: number;
  32617. /**
  32618. * Y
  32619. */
  32620. y: number;
  32621. /**
  32622. * Z
  32623. */
  32624. z: number;
  32625. }
  32626. }
  32627. declare module "babylonjs/Physics/IPhysicsEngine" {
  32628. import { Nullable } from "babylonjs/types";
  32629. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32631. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32632. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32633. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32634. /**
  32635. * Interface used to describe a physics joint
  32636. */
  32637. export interface PhysicsImpostorJoint {
  32638. /** Defines the main impostor to which the joint is linked */
  32639. mainImpostor: PhysicsImpostor;
  32640. /** Defines the impostor that is connected to the main impostor using this joint */
  32641. connectedImpostor: PhysicsImpostor;
  32642. /** Defines the joint itself */
  32643. joint: PhysicsJoint;
  32644. }
  32645. /** @hidden */
  32646. export interface IPhysicsEnginePlugin {
  32647. world: any;
  32648. name: string;
  32649. setGravity(gravity: Vector3): void;
  32650. setTimeStep(timeStep: number): void;
  32651. getTimeStep(): number;
  32652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32656. removePhysicsBody(impostor: PhysicsImpostor): void;
  32657. generateJoint(joint: PhysicsImpostorJoint): void;
  32658. removeJoint(joint: PhysicsImpostorJoint): void;
  32659. isSupported(): boolean;
  32660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32667. getBodyMass(impostor: PhysicsImpostor): number;
  32668. getBodyFriction(impostor: PhysicsImpostor): number;
  32669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32670. getBodyRestitution(impostor: PhysicsImpostor): number;
  32671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32672. getBodyPressure?(impostor: PhysicsImpostor): number;
  32673. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32674. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32675. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32676. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32677. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32678. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32679. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32680. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32681. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32682. sleepBody(impostor: PhysicsImpostor): void;
  32683. wakeUpBody(impostor: PhysicsImpostor): void;
  32684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32688. getRadius(impostor: PhysicsImpostor): number;
  32689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32691. dispose(): void;
  32692. }
  32693. /**
  32694. * Interface used to define a physics engine
  32695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32696. */
  32697. export interface IPhysicsEngine {
  32698. /**
  32699. * Gets the gravity vector used by the simulation
  32700. */
  32701. gravity: Vector3;
  32702. /**
  32703. * Sets the gravity vector used by the simulation
  32704. * @param gravity defines the gravity vector to use
  32705. */
  32706. setGravity(gravity: Vector3): void;
  32707. /**
  32708. * Set the time step of the physics engine.
  32709. * Default is 1/60.
  32710. * To slow it down, enter 1/600 for example.
  32711. * To speed it up, 1/30
  32712. * @param newTimeStep the new timestep to apply to this world.
  32713. */
  32714. setTimeStep(newTimeStep: number): void;
  32715. /**
  32716. * Get the time step of the physics engine.
  32717. * @returns the current time step
  32718. */
  32719. getTimeStep(): number;
  32720. /**
  32721. * Set the sub time step of the physics engine.
  32722. * Default is 0 meaning there is no sub steps
  32723. * To increase physics resolution precision, set a small value (like 1 ms)
  32724. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32725. */
  32726. setSubTimeStep(subTimeStep: number): void;
  32727. /**
  32728. * Get the sub time step of the physics engine.
  32729. * @returns the current sub time step
  32730. */
  32731. getSubTimeStep(): number;
  32732. /**
  32733. * Release all resources
  32734. */
  32735. dispose(): void;
  32736. /**
  32737. * Gets the name of the current physics plugin
  32738. * @returns the name of the plugin
  32739. */
  32740. getPhysicsPluginName(): string;
  32741. /**
  32742. * Adding a new impostor for the impostor tracking.
  32743. * This will be done by the impostor itself.
  32744. * @param impostor the impostor to add
  32745. */
  32746. addImpostor(impostor: PhysicsImpostor): void;
  32747. /**
  32748. * Remove an impostor from the engine.
  32749. * This impostor and its mesh will not longer be updated by the physics engine.
  32750. * @param impostor the impostor to remove
  32751. */
  32752. removeImpostor(impostor: PhysicsImpostor): void;
  32753. /**
  32754. * Add a joint to the physics engine
  32755. * @param mainImpostor defines the main impostor to which the joint is added.
  32756. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32757. * @param joint defines the joint that will connect both impostors.
  32758. */
  32759. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32760. /**
  32761. * Removes a joint from the simulation
  32762. * @param mainImpostor defines the impostor used with the joint
  32763. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32764. * @param joint defines the joint to remove
  32765. */
  32766. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32767. /**
  32768. * Gets the current plugin used to run the simulation
  32769. * @returns current plugin
  32770. */
  32771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32772. /**
  32773. * Gets the list of physic impostors
  32774. * @returns an array of PhysicsImpostor
  32775. */
  32776. getImpostors(): Array<PhysicsImpostor>;
  32777. /**
  32778. * Gets the impostor for a physics enabled object
  32779. * @param object defines the object impersonated by the impostor
  32780. * @returns the PhysicsImpostor or null if not found
  32781. */
  32782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32783. /**
  32784. * Gets the impostor for a physics body object
  32785. * @param body defines physics body used by the impostor
  32786. * @returns the PhysicsImpostor or null if not found
  32787. */
  32788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32789. /**
  32790. * Does a raycast in the physics world
  32791. * @param from when should the ray start?
  32792. * @param to when should the ray end?
  32793. * @returns PhysicsRaycastResult
  32794. */
  32795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32796. /**
  32797. * Called by the scene. No need to call it.
  32798. * @param delta defines the timespam between frames
  32799. */
  32800. _step(delta: number): void;
  32801. }
  32802. }
  32803. declare module "babylonjs/Physics/physicsImpostor" {
  32804. import { Nullable, IndicesArray } from "babylonjs/types";
  32805. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32806. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32808. import { Scene } from "babylonjs/scene";
  32809. import { Bone } from "babylonjs/Bones/bone";
  32810. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32811. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32812. import { Space } from "babylonjs/Maths/math.axis";
  32813. /**
  32814. * The interface for the physics imposter parameters
  32815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32816. */
  32817. export interface PhysicsImpostorParameters {
  32818. /**
  32819. * The mass of the physics imposter
  32820. */
  32821. mass: number;
  32822. /**
  32823. * The friction of the physics imposter
  32824. */
  32825. friction?: number;
  32826. /**
  32827. * The coefficient of restitution of the physics imposter
  32828. */
  32829. restitution?: number;
  32830. /**
  32831. * The native options of the physics imposter
  32832. */
  32833. nativeOptions?: any;
  32834. /**
  32835. * Specifies if the parent should be ignored
  32836. */
  32837. ignoreParent?: boolean;
  32838. /**
  32839. * Specifies if bi-directional transformations should be disabled
  32840. */
  32841. disableBidirectionalTransformation?: boolean;
  32842. /**
  32843. * The pressure inside the physics imposter, soft object only
  32844. */
  32845. pressure?: number;
  32846. /**
  32847. * The stiffness the physics imposter, soft object only
  32848. */
  32849. stiffness?: number;
  32850. /**
  32851. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32852. */
  32853. velocityIterations?: number;
  32854. /**
  32855. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32856. */
  32857. positionIterations?: number;
  32858. /**
  32859. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32860. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32861. * Add to fix multiple points
  32862. */
  32863. fixedPoints?: number;
  32864. /**
  32865. * The collision margin around a soft object
  32866. */
  32867. margin?: number;
  32868. /**
  32869. * The collision margin around a soft object
  32870. */
  32871. damping?: number;
  32872. /**
  32873. * The path for a rope based on an extrusion
  32874. */
  32875. path?: any;
  32876. /**
  32877. * The shape of an extrusion used for a rope based on an extrusion
  32878. */
  32879. shape?: any;
  32880. }
  32881. /**
  32882. * Interface for a physics-enabled object
  32883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32884. */
  32885. export interface IPhysicsEnabledObject {
  32886. /**
  32887. * The position of the physics-enabled object
  32888. */
  32889. position: Vector3;
  32890. /**
  32891. * The rotation of the physics-enabled object
  32892. */
  32893. rotationQuaternion: Nullable<Quaternion>;
  32894. /**
  32895. * The scale of the physics-enabled object
  32896. */
  32897. scaling: Vector3;
  32898. /**
  32899. * The rotation of the physics-enabled object
  32900. */
  32901. rotation?: Vector3;
  32902. /**
  32903. * The parent of the physics-enabled object
  32904. */
  32905. parent?: any;
  32906. /**
  32907. * The bounding info of the physics-enabled object
  32908. * @returns The bounding info of the physics-enabled object
  32909. */
  32910. getBoundingInfo(): BoundingInfo;
  32911. /**
  32912. * Computes the world matrix
  32913. * @param force Specifies if the world matrix should be computed by force
  32914. * @returns A world matrix
  32915. */
  32916. computeWorldMatrix(force: boolean): Matrix;
  32917. /**
  32918. * Gets the world matrix
  32919. * @returns A world matrix
  32920. */
  32921. getWorldMatrix?(): Matrix;
  32922. /**
  32923. * Gets the child meshes
  32924. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32925. * @returns An array of abstract meshes
  32926. */
  32927. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32928. /**
  32929. * Gets the vertex data
  32930. * @param kind The type of vertex data
  32931. * @returns A nullable array of numbers, or a float32 array
  32932. */
  32933. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32934. /**
  32935. * Gets the indices from the mesh
  32936. * @returns A nullable array of index arrays
  32937. */
  32938. getIndices?(): Nullable<IndicesArray>;
  32939. /**
  32940. * Gets the scene from the mesh
  32941. * @returns the indices array or null
  32942. */
  32943. getScene?(): Scene;
  32944. /**
  32945. * Gets the absolute position from the mesh
  32946. * @returns the absolute position
  32947. */
  32948. getAbsolutePosition(): Vector3;
  32949. /**
  32950. * Gets the absolute pivot point from the mesh
  32951. * @returns the absolute pivot point
  32952. */
  32953. getAbsolutePivotPoint(): Vector3;
  32954. /**
  32955. * Rotates the mesh
  32956. * @param axis The axis of rotation
  32957. * @param amount The amount of rotation
  32958. * @param space The space of the rotation
  32959. * @returns The rotation transform node
  32960. */
  32961. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32962. /**
  32963. * Translates the mesh
  32964. * @param axis The axis of translation
  32965. * @param distance The distance of translation
  32966. * @param space The space of the translation
  32967. * @returns The transform node
  32968. */
  32969. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32970. /**
  32971. * Sets the absolute position of the mesh
  32972. * @param absolutePosition The absolute position of the mesh
  32973. * @returns The transform node
  32974. */
  32975. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32976. /**
  32977. * Gets the class name of the mesh
  32978. * @returns The class name
  32979. */
  32980. getClassName(): string;
  32981. }
  32982. /**
  32983. * Represents a physics imposter
  32984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32985. */
  32986. export class PhysicsImpostor {
  32987. /**
  32988. * The physics-enabled object used as the physics imposter
  32989. */
  32990. object: IPhysicsEnabledObject;
  32991. /**
  32992. * The type of the physics imposter
  32993. */
  32994. type: number;
  32995. private _options;
  32996. private _scene?;
  32997. /**
  32998. * The default object size of the imposter
  32999. */
  33000. static DEFAULT_OBJECT_SIZE: Vector3;
  33001. /**
  33002. * The identity quaternion of the imposter
  33003. */
  33004. static IDENTITY_QUATERNION: Quaternion;
  33005. /** @hidden */
  33006. _pluginData: any;
  33007. private _physicsEngine;
  33008. private _physicsBody;
  33009. private _bodyUpdateRequired;
  33010. private _onBeforePhysicsStepCallbacks;
  33011. private _onAfterPhysicsStepCallbacks;
  33012. /** @hidden */
  33013. _onPhysicsCollideCallbacks: Array<{
  33014. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33015. otherImpostors: Array<PhysicsImpostor>;
  33016. }>;
  33017. private _deltaPosition;
  33018. private _deltaRotation;
  33019. private _deltaRotationConjugated;
  33020. /** @hidden */
  33021. _isFromLine: boolean;
  33022. private _parent;
  33023. private _isDisposed;
  33024. private static _tmpVecs;
  33025. private static _tmpQuat;
  33026. /**
  33027. * Specifies if the physics imposter is disposed
  33028. */
  33029. get isDisposed(): boolean;
  33030. /**
  33031. * Gets the mass of the physics imposter
  33032. */
  33033. get mass(): number;
  33034. set mass(value: number);
  33035. /**
  33036. * Gets the coefficient of friction
  33037. */
  33038. get friction(): number;
  33039. /**
  33040. * Sets the coefficient of friction
  33041. */
  33042. set friction(value: number);
  33043. /**
  33044. * Gets the coefficient of restitution
  33045. */
  33046. get restitution(): number;
  33047. /**
  33048. * Sets the coefficient of restitution
  33049. */
  33050. set restitution(value: number);
  33051. /**
  33052. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33053. */
  33054. get pressure(): number;
  33055. /**
  33056. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33057. */
  33058. set pressure(value: number);
  33059. /**
  33060. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33061. */
  33062. get stiffness(): number;
  33063. /**
  33064. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33065. */
  33066. set stiffness(value: number);
  33067. /**
  33068. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33069. */
  33070. get velocityIterations(): number;
  33071. /**
  33072. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33073. */
  33074. set velocityIterations(value: number);
  33075. /**
  33076. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33077. */
  33078. get positionIterations(): number;
  33079. /**
  33080. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33081. */
  33082. set positionIterations(value: number);
  33083. /**
  33084. * The unique id of the physics imposter
  33085. * set by the physics engine when adding this impostor to the array
  33086. */
  33087. uniqueId: number;
  33088. /**
  33089. * @hidden
  33090. */
  33091. soft: boolean;
  33092. /**
  33093. * @hidden
  33094. */
  33095. segments: number;
  33096. private _joints;
  33097. /**
  33098. * Initializes the physics imposter
  33099. * @param object The physics-enabled object used as the physics imposter
  33100. * @param type The type of the physics imposter
  33101. * @param _options The options for the physics imposter
  33102. * @param _scene The Babylon scene
  33103. */
  33104. constructor(
  33105. /**
  33106. * The physics-enabled object used as the physics imposter
  33107. */
  33108. object: IPhysicsEnabledObject,
  33109. /**
  33110. * The type of the physics imposter
  33111. */
  33112. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33113. /**
  33114. * This function will completly initialize this impostor.
  33115. * It will create a new body - but only if this mesh has no parent.
  33116. * If it has, this impostor will not be used other than to define the impostor
  33117. * of the child mesh.
  33118. * @hidden
  33119. */
  33120. _init(): void;
  33121. private _getPhysicsParent;
  33122. /**
  33123. * Should a new body be generated.
  33124. * @returns boolean specifying if body initialization is required
  33125. */
  33126. isBodyInitRequired(): boolean;
  33127. /**
  33128. * Sets the updated scaling
  33129. * @param updated Specifies if the scaling is updated
  33130. */
  33131. setScalingUpdated(): void;
  33132. /**
  33133. * Force a regeneration of this or the parent's impostor's body.
  33134. * Use under cautious - This will remove all joints already implemented.
  33135. */
  33136. forceUpdate(): void;
  33137. /**
  33138. * Gets the body that holds this impostor. Either its own, or its parent.
  33139. */
  33140. get physicsBody(): any;
  33141. /**
  33142. * Get the parent of the physics imposter
  33143. * @returns Physics imposter or null
  33144. */
  33145. get parent(): Nullable<PhysicsImpostor>;
  33146. /**
  33147. * Sets the parent of the physics imposter
  33148. */
  33149. set parent(value: Nullable<PhysicsImpostor>);
  33150. /**
  33151. * Set the physics body. Used mainly by the physics engine/plugin
  33152. */
  33153. set physicsBody(physicsBody: any);
  33154. /**
  33155. * Resets the update flags
  33156. */
  33157. resetUpdateFlags(): void;
  33158. /**
  33159. * Gets the object extend size
  33160. * @returns the object extend size
  33161. */
  33162. getObjectExtendSize(): Vector3;
  33163. /**
  33164. * Gets the object center
  33165. * @returns The object center
  33166. */
  33167. getObjectCenter(): Vector3;
  33168. /**
  33169. * Get a specific parameter from the options parameters
  33170. * @param paramName The object parameter name
  33171. * @returns The object parameter
  33172. */
  33173. getParam(paramName: string): any;
  33174. /**
  33175. * Sets a specific parameter in the options given to the physics plugin
  33176. * @param paramName The parameter name
  33177. * @param value The value of the parameter
  33178. */
  33179. setParam(paramName: string, value: number): void;
  33180. /**
  33181. * Specifically change the body's mass option. Won't recreate the physics body object
  33182. * @param mass The mass of the physics imposter
  33183. */
  33184. setMass(mass: number): void;
  33185. /**
  33186. * Gets the linear velocity
  33187. * @returns linear velocity or null
  33188. */
  33189. getLinearVelocity(): Nullable<Vector3>;
  33190. /**
  33191. * Sets the linear velocity
  33192. * @param velocity linear velocity or null
  33193. */
  33194. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33195. /**
  33196. * Gets the angular velocity
  33197. * @returns angular velocity or null
  33198. */
  33199. getAngularVelocity(): Nullable<Vector3>;
  33200. /**
  33201. * Sets the angular velocity
  33202. * @param velocity The velocity or null
  33203. */
  33204. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33205. /**
  33206. * Execute a function with the physics plugin native code
  33207. * Provide a function the will have two variables - the world object and the physics body object
  33208. * @param func The function to execute with the physics plugin native code
  33209. */
  33210. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33211. /**
  33212. * Register a function that will be executed before the physics world is stepping forward
  33213. * @param func The function to execute before the physics world is stepped forward
  33214. */
  33215. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33216. /**
  33217. * Unregister a function that will be executed before the physics world is stepping forward
  33218. * @param func The function to execute before the physics world is stepped forward
  33219. */
  33220. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33221. /**
  33222. * Register a function that will be executed after the physics step
  33223. * @param func The function to execute after physics step
  33224. */
  33225. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33226. /**
  33227. * Unregisters a function that will be executed after the physics step
  33228. * @param func The function to execute after physics step
  33229. */
  33230. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33231. /**
  33232. * register a function that will be executed when this impostor collides against a different body
  33233. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33234. * @param func Callback that is executed on collision
  33235. */
  33236. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33237. /**
  33238. * Unregisters the physics imposter on contact
  33239. * @param collideAgainst The physics object to collide against
  33240. * @param func Callback to execute on collision
  33241. */
  33242. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33243. private _tmpQuat;
  33244. private _tmpQuat2;
  33245. /**
  33246. * Get the parent rotation
  33247. * @returns The parent rotation
  33248. */
  33249. getParentsRotation(): Quaternion;
  33250. /**
  33251. * this function is executed by the physics engine.
  33252. */
  33253. beforeStep: () => void;
  33254. /**
  33255. * this function is executed by the physics engine
  33256. */
  33257. afterStep: () => void;
  33258. /**
  33259. * Legacy collision detection event support
  33260. */
  33261. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33262. /**
  33263. * event and body object due to cannon's event-based architecture.
  33264. */
  33265. onCollide: (e: {
  33266. body: any;
  33267. point: Nullable<Vector3>;
  33268. }) => void;
  33269. /**
  33270. * Apply a force
  33271. * @param force The force to apply
  33272. * @param contactPoint The contact point for the force
  33273. * @returns The physics imposter
  33274. */
  33275. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33276. /**
  33277. * Apply an impulse
  33278. * @param force The impulse force
  33279. * @param contactPoint The contact point for the impulse force
  33280. * @returns The physics imposter
  33281. */
  33282. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33283. /**
  33284. * A help function to create a joint
  33285. * @param otherImpostor A physics imposter used to create a joint
  33286. * @param jointType The type of joint
  33287. * @param jointData The data for the joint
  33288. * @returns The physics imposter
  33289. */
  33290. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33291. /**
  33292. * Add a joint to this impostor with a different impostor
  33293. * @param otherImpostor A physics imposter used to add a joint
  33294. * @param joint The joint to add
  33295. * @returns The physics imposter
  33296. */
  33297. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33298. /**
  33299. * Add an anchor to a cloth impostor
  33300. * @param otherImpostor rigid impostor to anchor to
  33301. * @param width ratio across width from 0 to 1
  33302. * @param height ratio up height from 0 to 1
  33303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33304. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33305. * @returns impostor the soft imposter
  33306. */
  33307. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33308. /**
  33309. * Add a hook to a rope impostor
  33310. * @param otherImpostor rigid impostor to anchor to
  33311. * @param length ratio across rope from 0 to 1
  33312. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33314. * @returns impostor the rope imposter
  33315. */
  33316. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33317. /**
  33318. * Will keep this body still, in a sleep mode.
  33319. * @returns the physics imposter
  33320. */
  33321. sleep(): PhysicsImpostor;
  33322. /**
  33323. * Wake the body up.
  33324. * @returns The physics imposter
  33325. */
  33326. wakeUp(): PhysicsImpostor;
  33327. /**
  33328. * Clones the physics imposter
  33329. * @param newObject The physics imposter clones to this physics-enabled object
  33330. * @returns A nullable physics imposter
  33331. */
  33332. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33333. /**
  33334. * Disposes the physics imposter
  33335. */
  33336. dispose(): void;
  33337. /**
  33338. * Sets the delta position
  33339. * @param position The delta position amount
  33340. */
  33341. setDeltaPosition(position: Vector3): void;
  33342. /**
  33343. * Sets the delta rotation
  33344. * @param rotation The delta rotation amount
  33345. */
  33346. setDeltaRotation(rotation: Quaternion): void;
  33347. /**
  33348. * Gets the box size of the physics imposter and stores the result in the input parameter
  33349. * @param result Stores the box size
  33350. * @returns The physics imposter
  33351. */
  33352. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33353. /**
  33354. * Gets the radius of the physics imposter
  33355. * @returns Radius of the physics imposter
  33356. */
  33357. getRadius(): number;
  33358. /**
  33359. * Sync a bone with this impostor
  33360. * @param bone The bone to sync to the impostor.
  33361. * @param boneMesh The mesh that the bone is influencing.
  33362. * @param jointPivot The pivot of the joint / bone in local space.
  33363. * @param distToJoint Optional distance from the impostor to the joint.
  33364. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33365. */
  33366. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33367. /**
  33368. * Sync impostor to a bone
  33369. * @param bone The bone that the impostor will be synced to.
  33370. * @param boneMesh The mesh that the bone is influencing.
  33371. * @param jointPivot The pivot of the joint / bone in local space.
  33372. * @param distToJoint Optional distance from the impostor to the joint.
  33373. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33374. * @param boneAxis Optional vector3 axis the bone is aligned with
  33375. */
  33376. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33377. /**
  33378. * No-Imposter type
  33379. */
  33380. static NoImpostor: number;
  33381. /**
  33382. * Sphere-Imposter type
  33383. */
  33384. static SphereImpostor: number;
  33385. /**
  33386. * Box-Imposter type
  33387. */
  33388. static BoxImpostor: number;
  33389. /**
  33390. * Plane-Imposter type
  33391. */
  33392. static PlaneImpostor: number;
  33393. /**
  33394. * Mesh-imposter type
  33395. */
  33396. static MeshImpostor: number;
  33397. /**
  33398. * Capsule-Impostor type (Ammo.js plugin only)
  33399. */
  33400. static CapsuleImpostor: number;
  33401. /**
  33402. * Cylinder-Imposter type
  33403. */
  33404. static CylinderImpostor: number;
  33405. /**
  33406. * Particle-Imposter type
  33407. */
  33408. static ParticleImpostor: number;
  33409. /**
  33410. * Heightmap-Imposter type
  33411. */
  33412. static HeightmapImpostor: number;
  33413. /**
  33414. * ConvexHull-Impostor type (Ammo.js plugin only)
  33415. */
  33416. static ConvexHullImpostor: number;
  33417. /**
  33418. * Custom-Imposter type (Ammo.js plugin only)
  33419. */
  33420. static CustomImpostor: number;
  33421. /**
  33422. * Rope-Imposter type
  33423. */
  33424. static RopeImpostor: number;
  33425. /**
  33426. * Cloth-Imposter type
  33427. */
  33428. static ClothImpostor: number;
  33429. /**
  33430. * Softbody-Imposter type
  33431. */
  33432. static SoftbodyImpostor: number;
  33433. }
  33434. }
  33435. declare module "babylonjs/Meshes/mesh" {
  33436. import { Observable } from "babylonjs/Misc/observable";
  33437. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33438. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33439. import { Camera } from "babylonjs/Cameras/camera";
  33440. import { Scene } from "babylonjs/scene";
  33441. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33442. import { Color4 } from "babylonjs/Maths/math.color";
  33443. import { Engine } from "babylonjs/Engines/engine";
  33444. import { Node } from "babylonjs/node";
  33445. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33446. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33447. import { Buffer } from "babylonjs/Meshes/buffer";
  33448. import { Geometry } from "babylonjs/Meshes/geometry";
  33449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33451. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33452. import { Effect } from "babylonjs/Materials/effect";
  33453. import { Material } from "babylonjs/Materials/material";
  33454. import { Skeleton } from "babylonjs/Bones/skeleton";
  33455. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33456. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33457. import { Path3D } from "babylonjs/Maths/math.path";
  33458. import { Plane } from "babylonjs/Maths/math.plane";
  33459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33460. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33461. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33462. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33463. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33464. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33465. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33466. /**
  33467. * @hidden
  33468. **/
  33469. export class _CreationDataStorage {
  33470. closePath?: boolean;
  33471. closeArray?: boolean;
  33472. idx: number[];
  33473. dashSize: number;
  33474. gapSize: number;
  33475. path3D: Path3D;
  33476. pathArray: Vector3[][];
  33477. arc: number;
  33478. radius: number;
  33479. cap: number;
  33480. tessellation: number;
  33481. }
  33482. /**
  33483. * @hidden
  33484. **/
  33485. class _InstanceDataStorage {
  33486. visibleInstances: any;
  33487. batchCache: _InstancesBatch;
  33488. instancesBufferSize: number;
  33489. instancesBuffer: Nullable<Buffer>;
  33490. instancesData: Float32Array;
  33491. overridenInstanceCount: number;
  33492. isFrozen: boolean;
  33493. previousBatch: Nullable<_InstancesBatch>;
  33494. hardwareInstancedRendering: boolean;
  33495. sideOrientation: number;
  33496. manualUpdate: boolean;
  33497. previousRenderId: number;
  33498. }
  33499. /**
  33500. * @hidden
  33501. **/
  33502. export class _InstancesBatch {
  33503. mustReturn: boolean;
  33504. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33505. renderSelf: boolean[];
  33506. hardwareInstancedRendering: boolean[];
  33507. }
  33508. /**
  33509. * @hidden
  33510. **/
  33511. class _ThinInstanceDataStorage {
  33512. instancesCount: number;
  33513. matrixBuffer: Nullable<Buffer>;
  33514. matrixBufferSize: number;
  33515. matrixData: Nullable<Float32Array>;
  33516. boundingVectors: Array<Vector3>;
  33517. worldMatrices: Nullable<Matrix[]>;
  33518. }
  33519. /**
  33520. * Class used to represent renderable models
  33521. */
  33522. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33523. /**
  33524. * Mesh side orientation : usually the external or front surface
  33525. */
  33526. static readonly FRONTSIDE: number;
  33527. /**
  33528. * Mesh side orientation : usually the internal or back surface
  33529. */
  33530. static readonly BACKSIDE: number;
  33531. /**
  33532. * Mesh side orientation : both internal and external or front and back surfaces
  33533. */
  33534. static readonly DOUBLESIDE: number;
  33535. /**
  33536. * Mesh side orientation : by default, `FRONTSIDE`
  33537. */
  33538. static readonly DEFAULTSIDE: number;
  33539. /**
  33540. * Mesh cap setting : no cap
  33541. */
  33542. static readonly NO_CAP: number;
  33543. /**
  33544. * Mesh cap setting : one cap at the beginning of the mesh
  33545. */
  33546. static readonly CAP_START: number;
  33547. /**
  33548. * Mesh cap setting : one cap at the end of the mesh
  33549. */
  33550. static readonly CAP_END: number;
  33551. /**
  33552. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33553. */
  33554. static readonly CAP_ALL: number;
  33555. /**
  33556. * Mesh pattern setting : no flip or rotate
  33557. */
  33558. static readonly NO_FLIP: number;
  33559. /**
  33560. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33561. */
  33562. static readonly FLIP_TILE: number;
  33563. /**
  33564. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33565. */
  33566. static readonly ROTATE_TILE: number;
  33567. /**
  33568. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33569. */
  33570. static readonly FLIP_ROW: number;
  33571. /**
  33572. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33573. */
  33574. static readonly ROTATE_ROW: number;
  33575. /**
  33576. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33577. */
  33578. static readonly FLIP_N_ROTATE_TILE: number;
  33579. /**
  33580. * Mesh pattern setting : rotate pattern and rotate
  33581. */
  33582. static readonly FLIP_N_ROTATE_ROW: number;
  33583. /**
  33584. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33585. */
  33586. static readonly CENTER: number;
  33587. /**
  33588. * Mesh tile positioning : part tiles on left
  33589. */
  33590. static readonly LEFT: number;
  33591. /**
  33592. * Mesh tile positioning : part tiles on right
  33593. */
  33594. static readonly RIGHT: number;
  33595. /**
  33596. * Mesh tile positioning : part tiles on top
  33597. */
  33598. static readonly TOP: number;
  33599. /**
  33600. * Mesh tile positioning : part tiles on bottom
  33601. */
  33602. static readonly BOTTOM: number;
  33603. /**
  33604. * Gets the default side orientation.
  33605. * @param orientation the orientation to value to attempt to get
  33606. * @returns the default orientation
  33607. * @hidden
  33608. */
  33609. static _GetDefaultSideOrientation(orientation?: number): number;
  33610. private _internalMeshDataInfo;
  33611. get computeBonesUsingShaders(): boolean;
  33612. set computeBonesUsingShaders(value: boolean);
  33613. /**
  33614. * An event triggered before rendering the mesh
  33615. */
  33616. get onBeforeRenderObservable(): Observable<Mesh>;
  33617. /**
  33618. * An event triggered before binding the mesh
  33619. */
  33620. get onBeforeBindObservable(): Observable<Mesh>;
  33621. /**
  33622. * An event triggered after rendering the mesh
  33623. */
  33624. get onAfterRenderObservable(): Observable<Mesh>;
  33625. /**
  33626. * An event triggered before drawing the mesh
  33627. */
  33628. get onBeforeDrawObservable(): Observable<Mesh>;
  33629. private _onBeforeDrawObserver;
  33630. /**
  33631. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33632. */
  33633. set onBeforeDraw(callback: () => void);
  33634. get hasInstances(): boolean;
  33635. get hasThinInstances(): boolean;
  33636. /**
  33637. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33638. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33639. */
  33640. delayLoadState: number;
  33641. /**
  33642. * Gets the list of instances created from this mesh
  33643. * it is not supposed to be modified manually.
  33644. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33645. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33646. */
  33647. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33648. /**
  33649. * Gets the file containing delay loading data for this mesh
  33650. */
  33651. delayLoadingFile: string;
  33652. /** @hidden */
  33653. _binaryInfo: any;
  33654. /**
  33655. * User defined function used to change how LOD level selection is done
  33656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33657. */
  33658. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33659. /**
  33660. * Gets or sets the morph target manager
  33661. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33662. */
  33663. get morphTargetManager(): Nullable<MorphTargetManager>;
  33664. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33665. /** @hidden */
  33666. _creationDataStorage: Nullable<_CreationDataStorage>;
  33667. /** @hidden */
  33668. _geometry: Nullable<Geometry>;
  33669. /** @hidden */
  33670. _delayInfo: Array<string>;
  33671. /** @hidden */
  33672. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33673. /** @hidden */
  33674. _instanceDataStorage: _InstanceDataStorage;
  33675. /** @hidden */
  33676. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33677. private _effectiveMaterial;
  33678. /** @hidden */
  33679. _shouldGenerateFlatShading: boolean;
  33680. /** @hidden */
  33681. _originalBuilderSideOrientation: number;
  33682. /**
  33683. * Use this property to change the original side orientation defined at construction time
  33684. */
  33685. overrideMaterialSideOrientation: Nullable<number>;
  33686. /**
  33687. * Gets the source mesh (the one used to clone this one from)
  33688. */
  33689. get source(): Nullable<Mesh>;
  33690. /**
  33691. * Gets the list of clones of this mesh
  33692. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33693. * Note that useClonedMeshMap=true is the default setting
  33694. */
  33695. get cloneMeshMap(): Nullable<{
  33696. [id: string]: Mesh | undefined;
  33697. }>;
  33698. /**
  33699. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33700. */
  33701. get isUnIndexed(): boolean;
  33702. set isUnIndexed(value: boolean);
  33703. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33704. get worldMatrixInstancedBuffer(): Float32Array;
  33705. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33706. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33707. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33708. /**
  33709. * @constructor
  33710. * @param name The value used by scene.getMeshByName() to do a lookup.
  33711. * @param scene The scene to add this mesh to.
  33712. * @param parent The parent of this mesh, if it has one
  33713. * @param source An optional Mesh from which geometry is shared, cloned.
  33714. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33715. * When false, achieved by calling a clone(), also passing False.
  33716. * This will make creation of children, recursive.
  33717. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33718. */
  33719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33720. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33721. doNotInstantiate: boolean;
  33722. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33723. /**
  33724. * Gets the class name
  33725. * @returns the string "Mesh".
  33726. */
  33727. getClassName(): string;
  33728. /** @hidden */
  33729. get _isMesh(): boolean;
  33730. /**
  33731. * Returns a description of this mesh
  33732. * @param fullDetails define if full details about this mesh must be used
  33733. * @returns a descriptive string representing this mesh
  33734. */
  33735. toString(fullDetails?: boolean): string;
  33736. /** @hidden */
  33737. _unBindEffect(): void;
  33738. /**
  33739. * Gets a boolean indicating if this mesh has LOD
  33740. */
  33741. get hasLODLevels(): boolean;
  33742. /**
  33743. * Gets the list of MeshLODLevel associated with the current mesh
  33744. * @returns an array of MeshLODLevel
  33745. */
  33746. getLODLevels(): MeshLODLevel[];
  33747. private _sortLODLevels;
  33748. /**
  33749. * Add a mesh as LOD level triggered at the given distance.
  33750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33751. * @param distance The distance from the center of the object to show this level
  33752. * @param mesh The mesh to be added as LOD level (can be null)
  33753. * @return This mesh (for chaining)
  33754. */
  33755. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33756. /**
  33757. * Returns the LOD level mesh at the passed distance or null if not found.
  33758. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33759. * @param distance The distance from the center of the object to show this level
  33760. * @returns a Mesh or `null`
  33761. */
  33762. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33763. /**
  33764. * Remove a mesh from the LOD array
  33765. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33766. * @param mesh defines the mesh to be removed
  33767. * @return This mesh (for chaining)
  33768. */
  33769. removeLODLevel(mesh: Mesh): Mesh;
  33770. /**
  33771. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33773. * @param camera defines the camera to use to compute distance
  33774. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33775. * @return This mesh (for chaining)
  33776. */
  33777. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33778. /**
  33779. * Gets the mesh internal Geometry object
  33780. */
  33781. get geometry(): Nullable<Geometry>;
  33782. /**
  33783. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33784. * @returns the total number of vertices
  33785. */
  33786. getTotalVertices(): number;
  33787. /**
  33788. * Returns the content of an associated vertex buffer
  33789. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33790. * - VertexBuffer.PositionKind
  33791. * - VertexBuffer.UVKind
  33792. * - VertexBuffer.UV2Kind
  33793. * - VertexBuffer.UV3Kind
  33794. * - VertexBuffer.UV4Kind
  33795. * - VertexBuffer.UV5Kind
  33796. * - VertexBuffer.UV6Kind
  33797. * - VertexBuffer.ColorKind
  33798. * - VertexBuffer.MatricesIndicesKind
  33799. * - VertexBuffer.MatricesIndicesExtraKind
  33800. * - VertexBuffer.MatricesWeightsKind
  33801. * - VertexBuffer.MatricesWeightsExtraKind
  33802. * @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
  33803. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33804. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33805. */
  33806. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33807. /**
  33808. * Returns the mesh VertexBuffer object from the requested `kind`
  33809. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33810. * - VertexBuffer.PositionKind
  33811. * - VertexBuffer.NormalKind
  33812. * - VertexBuffer.UVKind
  33813. * - VertexBuffer.UV2Kind
  33814. * - VertexBuffer.UV3Kind
  33815. * - VertexBuffer.UV4Kind
  33816. * - VertexBuffer.UV5Kind
  33817. * - VertexBuffer.UV6Kind
  33818. * - VertexBuffer.ColorKind
  33819. * - VertexBuffer.MatricesIndicesKind
  33820. * - VertexBuffer.MatricesIndicesExtraKind
  33821. * - VertexBuffer.MatricesWeightsKind
  33822. * - VertexBuffer.MatricesWeightsExtraKind
  33823. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33824. */
  33825. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33826. /**
  33827. * Tests if a specific vertex buffer is associated with this mesh
  33828. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33829. * - VertexBuffer.PositionKind
  33830. * - VertexBuffer.NormalKind
  33831. * - VertexBuffer.UVKind
  33832. * - VertexBuffer.UV2Kind
  33833. * - VertexBuffer.UV3Kind
  33834. * - VertexBuffer.UV4Kind
  33835. * - VertexBuffer.UV5Kind
  33836. * - VertexBuffer.UV6Kind
  33837. * - VertexBuffer.ColorKind
  33838. * - VertexBuffer.MatricesIndicesKind
  33839. * - VertexBuffer.MatricesIndicesExtraKind
  33840. * - VertexBuffer.MatricesWeightsKind
  33841. * - VertexBuffer.MatricesWeightsExtraKind
  33842. * @returns a boolean
  33843. */
  33844. isVerticesDataPresent(kind: string): boolean;
  33845. /**
  33846. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33847. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33848. * - VertexBuffer.PositionKind
  33849. * - VertexBuffer.UVKind
  33850. * - VertexBuffer.UV2Kind
  33851. * - VertexBuffer.UV3Kind
  33852. * - VertexBuffer.UV4Kind
  33853. * - VertexBuffer.UV5Kind
  33854. * - VertexBuffer.UV6Kind
  33855. * - VertexBuffer.ColorKind
  33856. * - VertexBuffer.MatricesIndicesKind
  33857. * - VertexBuffer.MatricesIndicesExtraKind
  33858. * - VertexBuffer.MatricesWeightsKind
  33859. * - VertexBuffer.MatricesWeightsExtraKind
  33860. * @returns a boolean
  33861. */
  33862. isVertexBufferUpdatable(kind: string): boolean;
  33863. /**
  33864. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33865. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33866. * - VertexBuffer.PositionKind
  33867. * - VertexBuffer.NormalKind
  33868. * - VertexBuffer.UVKind
  33869. * - VertexBuffer.UV2Kind
  33870. * - VertexBuffer.UV3Kind
  33871. * - VertexBuffer.UV4Kind
  33872. * - VertexBuffer.UV5Kind
  33873. * - VertexBuffer.UV6Kind
  33874. * - VertexBuffer.ColorKind
  33875. * - VertexBuffer.MatricesIndicesKind
  33876. * - VertexBuffer.MatricesIndicesExtraKind
  33877. * - VertexBuffer.MatricesWeightsKind
  33878. * - VertexBuffer.MatricesWeightsExtraKind
  33879. * @returns an array of strings
  33880. */
  33881. getVerticesDataKinds(): string[];
  33882. /**
  33883. * Returns a positive integer : the total number of indices in this mesh geometry.
  33884. * @returns the numner of indices or zero if the mesh has no geometry.
  33885. */
  33886. getTotalIndices(): number;
  33887. /**
  33888. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33889. * @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.
  33890. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33891. * @returns the indices array or an empty array if the mesh has no geometry
  33892. */
  33893. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33894. get isBlocked(): boolean;
  33895. /**
  33896. * Determine if the current mesh is ready to be rendered
  33897. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33898. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33899. * @returns true if all associated assets are ready (material, textures, shaders)
  33900. */
  33901. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33902. /**
  33903. * 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.
  33904. */
  33905. get areNormalsFrozen(): boolean;
  33906. /**
  33907. * 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.
  33908. * @returns the current mesh
  33909. */
  33910. freezeNormals(): Mesh;
  33911. /**
  33912. * 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
  33913. * @returns the current mesh
  33914. */
  33915. unfreezeNormals(): Mesh;
  33916. /**
  33917. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33918. */
  33919. set overridenInstanceCount(count: number);
  33920. /** @hidden */
  33921. _preActivate(): Mesh;
  33922. /** @hidden */
  33923. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33924. /** @hidden */
  33925. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33926. protected _afterComputeWorldMatrix(): void;
  33927. /** @hidden */
  33928. _postActivate(): void;
  33929. /**
  33930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33931. * This means the mesh underlying bounding box and sphere are recomputed.
  33932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33933. * @returns the current mesh
  33934. */
  33935. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33936. /** @hidden */
  33937. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33938. /**
  33939. * This function will subdivide the mesh into multiple submeshes
  33940. * @param count defines the expected number of submeshes
  33941. */
  33942. subdivide(count: number): void;
  33943. /**
  33944. * Copy a FloatArray into a specific associated vertex buffer
  33945. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33946. * - VertexBuffer.PositionKind
  33947. * - VertexBuffer.UVKind
  33948. * - VertexBuffer.UV2Kind
  33949. * - VertexBuffer.UV3Kind
  33950. * - VertexBuffer.UV4Kind
  33951. * - VertexBuffer.UV5Kind
  33952. * - VertexBuffer.UV6Kind
  33953. * - VertexBuffer.ColorKind
  33954. * - VertexBuffer.MatricesIndicesKind
  33955. * - VertexBuffer.MatricesIndicesExtraKind
  33956. * - VertexBuffer.MatricesWeightsKind
  33957. * - VertexBuffer.MatricesWeightsExtraKind
  33958. * @param data defines the data source
  33959. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33960. * @param stride defines the data stride size (can be null)
  33961. * @returns the current mesh
  33962. */
  33963. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33964. /**
  33965. * Delete a vertex buffer associated with this mesh
  33966. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33967. * - VertexBuffer.PositionKind
  33968. * - VertexBuffer.UVKind
  33969. * - VertexBuffer.UV2Kind
  33970. * - VertexBuffer.UV3Kind
  33971. * - VertexBuffer.UV4Kind
  33972. * - VertexBuffer.UV5Kind
  33973. * - VertexBuffer.UV6Kind
  33974. * - VertexBuffer.ColorKind
  33975. * - VertexBuffer.MatricesIndicesKind
  33976. * - VertexBuffer.MatricesIndicesExtraKind
  33977. * - VertexBuffer.MatricesWeightsKind
  33978. * - VertexBuffer.MatricesWeightsExtraKind
  33979. */
  33980. removeVerticesData(kind: string): void;
  33981. /**
  33982. * Flags an associated vertex buffer as updatable
  33983. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33984. * - VertexBuffer.PositionKind
  33985. * - VertexBuffer.UVKind
  33986. * - VertexBuffer.UV2Kind
  33987. * - VertexBuffer.UV3Kind
  33988. * - VertexBuffer.UV4Kind
  33989. * - VertexBuffer.UV5Kind
  33990. * - VertexBuffer.UV6Kind
  33991. * - VertexBuffer.ColorKind
  33992. * - VertexBuffer.MatricesIndicesKind
  33993. * - VertexBuffer.MatricesIndicesExtraKind
  33994. * - VertexBuffer.MatricesWeightsKind
  33995. * - VertexBuffer.MatricesWeightsExtraKind
  33996. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33997. */
  33998. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33999. /**
  34000. * Sets the mesh global Vertex Buffer
  34001. * @param buffer defines the buffer to use
  34002. * @returns the current mesh
  34003. */
  34004. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34005. /**
  34006. * Update a specific associated vertex buffer
  34007. * @param kind defines which buffer to write to (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 data defines the data source
  34021. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34022. * @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)
  34023. * @returns the current mesh
  34024. */
  34025. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34026. /**
  34027. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34028. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34029. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34030. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34031. * @returns the current mesh
  34032. */
  34033. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34034. /**
  34035. * Creates a un-shared specific occurence of the geometry for the mesh.
  34036. * @returns the current mesh
  34037. */
  34038. makeGeometryUnique(): Mesh;
  34039. /**
  34040. * Set the index buffer of this mesh
  34041. * @param indices defines the source data
  34042. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34043. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34044. * @returns the current mesh
  34045. */
  34046. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34047. /**
  34048. * Update the current index buffer
  34049. * @param indices defines the source data
  34050. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34051. * @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)
  34052. * @returns the current mesh
  34053. */
  34054. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34055. /**
  34056. * Invert the geometry to move from a right handed system to a left handed one.
  34057. * @returns the current mesh
  34058. */
  34059. toLeftHanded(): Mesh;
  34060. /** @hidden */
  34061. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34062. /** @hidden */
  34063. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34064. /**
  34065. * Registers for this mesh a javascript function called just before the rendering process
  34066. * @param func defines the function to call before rendering this mesh
  34067. * @returns the current mesh
  34068. */
  34069. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34070. /**
  34071. * Disposes a previously registered javascript function called before the rendering
  34072. * @param func defines the function to remove
  34073. * @returns the current mesh
  34074. */
  34075. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34076. /**
  34077. * Registers for this mesh a javascript function called just after the rendering is complete
  34078. * @param func defines the function to call after rendering this mesh
  34079. * @returns the current mesh
  34080. */
  34081. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34082. /**
  34083. * Disposes a previously registered javascript function called after the rendering.
  34084. * @param func defines the function to remove
  34085. * @returns the current mesh
  34086. */
  34087. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34088. /** @hidden */
  34089. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34090. /** @hidden */
  34091. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34092. /** @hidden */
  34093. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34094. /** @hidden */
  34095. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34096. /** @hidden */
  34097. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34098. /** @hidden */
  34099. _rebuild(): void;
  34100. /** @hidden */
  34101. _freeze(): void;
  34102. /** @hidden */
  34103. _unFreeze(): void;
  34104. /**
  34105. * 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
  34106. * @param subMesh defines the subMesh to render
  34107. * @param enableAlphaMode defines if alpha mode can be changed
  34108. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34109. * @returns the current mesh
  34110. */
  34111. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34112. private _onBeforeDraw;
  34113. /**
  34114. * Renormalize the mesh and patch it up if there are no weights
  34115. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34116. * However in the case of zero weights then we set just a single influence to 1.
  34117. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34118. */
  34119. cleanMatrixWeights(): void;
  34120. private normalizeSkinFourWeights;
  34121. private normalizeSkinWeightsAndExtra;
  34122. /**
  34123. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34124. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34125. * the user know there was an issue with importing the mesh
  34126. * @returns a validation object with skinned, valid and report string
  34127. */
  34128. validateSkinning(): {
  34129. skinned: boolean;
  34130. valid: boolean;
  34131. report: string;
  34132. };
  34133. /** @hidden */
  34134. _checkDelayState(): Mesh;
  34135. private _queueLoad;
  34136. /**
  34137. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34138. * A mesh is in the frustum if its bounding box intersects the frustum
  34139. * @param frustumPlanes defines the frustum to test
  34140. * @returns true if the mesh is in the frustum planes
  34141. */
  34142. isInFrustum(frustumPlanes: Plane[]): boolean;
  34143. /**
  34144. * Sets the mesh material by the material or multiMaterial `id` property
  34145. * @param id is a string identifying the material or the multiMaterial
  34146. * @returns the current mesh
  34147. */
  34148. setMaterialByID(id: string): Mesh;
  34149. /**
  34150. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34151. * @returns an array of IAnimatable
  34152. */
  34153. getAnimatables(): IAnimatable[];
  34154. /**
  34155. * Modifies the mesh geometry according to the passed transformation matrix.
  34156. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34157. * The mesh normals are modified using the same transformation.
  34158. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34159. * @param transform defines the transform matrix to use
  34160. * @see https://doc.babylonjs.com/resources/baking_transformations
  34161. * @returns the current mesh
  34162. */
  34163. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34164. /**
  34165. * Modifies the mesh geometry according to its own current World Matrix.
  34166. * The mesh World Matrix is then reset.
  34167. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34169. * @see https://doc.babylonjs.com/resources/baking_transformations
  34170. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34171. * @returns the current mesh
  34172. */
  34173. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34174. /** @hidden */
  34175. get _positions(): Nullable<Vector3[]>;
  34176. /** @hidden */
  34177. _resetPointsArrayCache(): Mesh;
  34178. /** @hidden */
  34179. _generatePointsArray(): boolean;
  34180. /**
  34181. * Returns a new Mesh object generated from the current mesh properties.
  34182. * This method must not get confused with createInstance()
  34183. * @param name is a string, the name given to the new mesh
  34184. * @param newParent can be any Node object (default `null`)
  34185. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34186. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34187. * @returns a new mesh
  34188. */
  34189. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34190. /**
  34191. * Releases resources associated with this mesh.
  34192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34194. */
  34195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34196. /** @hidden */
  34197. _disposeInstanceSpecificData(): void;
  34198. /** @hidden */
  34199. _disposeThinInstanceSpecificData(): void;
  34200. /**
  34201. * Modifies the mesh geometry according to a displacement map.
  34202. * 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.
  34203. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34204. * @param url is a string, the URL from the image file is to be downloaded.
  34205. * @param minHeight is the lower limit of the displacement.
  34206. * @param maxHeight is the upper limit of the displacement.
  34207. * @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.
  34208. * @param uvOffset is an optional vector2 used to offset UV.
  34209. * @param uvScale is an optional vector2 used to scale UV.
  34210. * @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.
  34211. * @returns the Mesh.
  34212. */
  34213. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34214. /**
  34215. * Modifies the mesh geometry according to a displacementMap buffer.
  34216. * 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.
  34217. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34218. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34219. * @param heightMapWidth is the width of the buffer image.
  34220. * @param heightMapHeight is the height of the buffer image.
  34221. * @param minHeight is the lower limit of the displacement.
  34222. * @param maxHeight is the upper limit of the displacement.
  34223. * @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.
  34224. * @param uvOffset is an optional vector2 used to offset UV.
  34225. * @param uvScale is an optional vector2 used to scale UV.
  34226. * @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.
  34227. * @returns the Mesh.
  34228. */
  34229. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34230. /**
  34231. * Modify the mesh to get a flat shading rendering.
  34232. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34233. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34234. * @returns current mesh
  34235. */
  34236. convertToFlatShadedMesh(): Mesh;
  34237. /**
  34238. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34239. * In other words, more vertices, no more indices and a single bigger VBO.
  34240. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34241. * @returns current mesh
  34242. */
  34243. convertToUnIndexedMesh(): Mesh;
  34244. /**
  34245. * Inverses facet orientations.
  34246. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34247. * @param flipNormals will also inverts the normals
  34248. * @returns current mesh
  34249. */
  34250. flipFaces(flipNormals?: boolean): Mesh;
  34251. /**
  34252. * Increase the number of facets and hence vertices in a mesh
  34253. * Vertex normals are interpolated from existing vertex normals
  34254. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34255. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34256. */
  34257. increaseVertices(numberPerEdge: number): void;
  34258. /**
  34259. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34260. * This will undo any application of covertToFlatShadedMesh
  34261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34262. */
  34263. forceSharedVertices(): void;
  34264. /** @hidden */
  34265. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34266. /** @hidden */
  34267. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34268. /**
  34269. * Creates a new InstancedMesh object from the mesh model.
  34270. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34271. * @param name defines the name of the new instance
  34272. * @returns a new InstancedMesh
  34273. */
  34274. createInstance(name: string): InstancedMesh;
  34275. /**
  34276. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34277. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34278. * @returns the current mesh
  34279. */
  34280. synchronizeInstances(): Mesh;
  34281. /**
  34282. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34283. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34284. * This should be used together with the simplification to avoid disappearing triangles.
  34285. * @param successCallback an optional success callback to be called after the optimization finished.
  34286. * @returns the current mesh
  34287. */
  34288. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34289. /**
  34290. * Serialize current mesh
  34291. * @param serializationObject defines the object which will receive the serialization data
  34292. */
  34293. serialize(serializationObject: any): void;
  34294. /** @hidden */
  34295. _syncGeometryWithMorphTargetManager(): void;
  34296. /** @hidden */
  34297. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34298. /**
  34299. * Returns a new Mesh object parsed from the source provided.
  34300. * @param parsedMesh is the source
  34301. * @param scene defines the hosting scene
  34302. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34303. * @returns a new Mesh
  34304. */
  34305. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34306. /**
  34307. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34309. * @param name defines the name of the mesh to create
  34310. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34311. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34312. * @param closePath creates a seam between the first and the last points of each path of the path array
  34313. * @param offset is taken in account only if the `pathArray` is containing a single path
  34314. * @param scene defines the hosting scene
  34315. * @param updatable defines if the mesh must be flagged as updatable
  34316. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34317. * @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)
  34318. * @returns a new Mesh
  34319. */
  34320. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34321. /**
  34322. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34323. * @param name defines the name of the mesh to create
  34324. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34325. * @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
  34326. * @param scene defines the hosting scene
  34327. * @param updatable defines if the mesh must be flagged as updatable
  34328. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34329. * @returns a new Mesh
  34330. */
  34331. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34332. /**
  34333. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34334. * @param name defines the name of the mesh to create
  34335. * @param size sets the size (float) of each box side (default 1)
  34336. * @param scene defines the hosting scene
  34337. * @param updatable defines if the mesh must be flagged as updatable
  34338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34339. * @returns a new Mesh
  34340. */
  34341. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34342. /**
  34343. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34344. * @param name defines the name of the mesh to create
  34345. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34346. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34347. * @param scene defines the hosting scene
  34348. * @param updatable defines if the mesh must be flagged as updatable
  34349. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34350. * @returns a new Mesh
  34351. */
  34352. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34353. /**
  34354. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34355. * @param name defines the name of the mesh to create
  34356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34358. * @param scene defines the hosting scene
  34359. * @returns a new Mesh
  34360. */
  34361. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34362. /**
  34363. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34364. * @param name defines the name of the mesh to create
  34365. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34366. * @param diameterTop set the top cap diameter (floats, default 1)
  34367. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34368. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34369. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34370. * @param scene defines the hosting scene
  34371. * @param updatable defines if the mesh must be flagged as updatable
  34372. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34373. * @returns a new Mesh
  34374. */
  34375. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34376. /**
  34377. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34378. * @param name defines the name of the mesh to create
  34379. * @param diameter sets the diameter size (float) of the torus (default 1)
  34380. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34381. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34382. * @param scene defines the hosting scene
  34383. * @param updatable defines if the mesh must be flagged as updatable
  34384. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34385. * @returns a new Mesh
  34386. */
  34387. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34388. /**
  34389. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34390. * @param name defines the name of the mesh to create
  34391. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34392. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34393. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34394. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34395. * @param p the number of windings on X axis (positive integers, default 2)
  34396. * @param q the number of windings on Y axis (positive integers, default 3)
  34397. * @param scene defines the hosting scene
  34398. * @param updatable defines if the mesh must be flagged as updatable
  34399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34400. * @returns a new Mesh
  34401. */
  34402. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34403. /**
  34404. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34405. * @param name defines the name of the mesh to create
  34406. * @param points is an array successive Vector3
  34407. * @param scene defines the hosting scene
  34408. * @param updatable defines if the mesh must be flagged as updatable
  34409. * @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).
  34410. * @returns a new Mesh
  34411. */
  34412. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34413. /**
  34414. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34415. * @param name defines the name of the mesh to create
  34416. * @param points is an array successive Vector3
  34417. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34418. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34419. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34420. * @param scene defines the hosting scene
  34421. * @param updatable defines if the mesh must be flagged as updatable
  34422. * @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)
  34423. * @returns a new Mesh
  34424. */
  34425. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34426. /**
  34427. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34429. * 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.
  34430. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34431. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34432. * Remember you can only change the shape positions, not their number when updating a polygon.
  34433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34434. * @param name defines the name of the mesh to create
  34435. * @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
  34436. * @param scene defines the hosting scene
  34437. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34438. * @param updatable defines if the mesh must be flagged as updatable
  34439. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34440. * @param earcutInjection can be used to inject your own earcut reference
  34441. * @returns a new Mesh
  34442. */
  34443. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34444. /**
  34445. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34447. * @param name defines the name of the mesh to create
  34448. * @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
  34449. * @param depth defines the height of extrusion
  34450. * @param scene defines the hosting scene
  34451. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34452. * @param updatable defines if the mesh must be flagged as updatable
  34453. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34454. * @param earcutInjection can be used to inject your own earcut reference
  34455. * @returns a new Mesh
  34456. */
  34457. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34458. /**
  34459. * Creates an extruded shape mesh.
  34460. * 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
  34461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34463. * @param name defines the name of the mesh to create
  34464. * @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
  34465. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34466. * @param scale is the value to scale the shape
  34467. * @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
  34468. * @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
  34469. * @param scene defines the hosting scene
  34470. * @param updatable defines if the mesh must be flagged as updatable
  34471. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34472. * @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)
  34473. * @returns a new Mesh
  34474. */
  34475. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34476. /**
  34477. * Creates an custom extruded shape mesh.
  34478. * The custom extrusion is a parametric shape.
  34479. * It has no predefined shape. Its final shape will depend on the input parameters.
  34480. * Please consider using the same method from the MeshBuilder class instead
  34481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34482. * @param name defines the name of the mesh to create
  34483. * @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
  34484. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34485. * @param scaleFunction is a custom Javascript function called on each path point
  34486. * @param rotationFunction is a custom Javascript function called on each path point
  34487. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34488. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34489. * @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
  34490. * @param scene defines the hosting scene
  34491. * @param updatable defines if the mesh must be flagged as updatable
  34492. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34493. * @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)
  34494. * @returns a new Mesh
  34495. */
  34496. 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;
  34497. /**
  34498. * Creates lathe mesh.
  34499. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34500. * Please consider using the same method from the MeshBuilder class instead
  34501. * @param name defines the name of the mesh to create
  34502. * @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
  34503. * @param radius is the radius value of the lathe
  34504. * @param tessellation is the side number of the lathe.
  34505. * @param scene defines the hosting scene
  34506. * @param updatable defines if the mesh must be flagged as updatable
  34507. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34508. * @returns a new Mesh
  34509. */
  34510. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34511. /**
  34512. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34513. * @param name defines the name of the mesh to create
  34514. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34515. * @param scene defines the hosting scene
  34516. * @param updatable defines if the mesh must be flagged as updatable
  34517. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34518. * @returns a new Mesh
  34519. */
  34520. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34521. /**
  34522. * Creates a ground mesh.
  34523. * Please consider using the same method from the MeshBuilder class instead
  34524. * @param name defines the name of the mesh to create
  34525. * @param width set the width of the ground
  34526. * @param height set the height of the ground
  34527. * @param subdivisions sets the number of subdivisions per side
  34528. * @param scene defines the hosting scene
  34529. * @param updatable defines if the mesh must be flagged as updatable
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34533. /**
  34534. * Creates a tiled ground mesh.
  34535. * Please consider using the same method from the MeshBuilder class instead
  34536. * @param name defines the name of the mesh to create
  34537. * @param xmin set the ground minimum X coordinate
  34538. * @param zmin set the ground minimum Y coordinate
  34539. * @param xmax set the ground maximum X coordinate
  34540. * @param zmax set the ground maximum Z coordinate
  34541. * @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
  34542. * @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
  34543. * @param scene defines the hosting scene
  34544. * @param updatable defines if the mesh must be flagged as updatable
  34545. * @returns a new Mesh
  34546. */
  34547. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34548. w: number;
  34549. h: number;
  34550. }, precision: {
  34551. w: number;
  34552. h: number;
  34553. }, scene: Scene, updatable?: boolean): Mesh;
  34554. /**
  34555. * Creates a ground mesh from a height map.
  34556. * Please consider using the same method from the MeshBuilder class instead
  34557. * @see https://doc.babylonjs.com/babylon101/height_map
  34558. * @param name defines the name of the mesh to create
  34559. * @param url sets the URL of the height map image resource
  34560. * @param width set the ground width size
  34561. * @param height set the ground height size
  34562. * @param subdivisions sets the number of subdivision per side
  34563. * @param minHeight is the minimum altitude on the ground
  34564. * @param maxHeight is the maximum altitude on the ground
  34565. * @param scene defines the hosting scene
  34566. * @param updatable defines if the mesh must be flagged as updatable
  34567. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34568. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34569. * @returns a new Mesh
  34570. */
  34571. 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;
  34572. /**
  34573. * Creates a tube mesh.
  34574. * The tube is a parametric shape.
  34575. * It has no predefined shape. Its final shape will depend on the input parameters.
  34576. * Please consider using the same method from the MeshBuilder class instead
  34577. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34578. * @param name defines the name of the mesh to create
  34579. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34580. * @param radius sets the tube radius size
  34581. * @param tessellation is the number of sides on the tubular surface
  34582. * @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
  34583. * @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
  34584. * @param scene defines the hosting scene
  34585. * @param updatable defines if the mesh must be flagged as updatable
  34586. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34587. * @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)
  34588. * @returns a new Mesh
  34589. */
  34590. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34591. (i: number, distance: number): number;
  34592. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34593. /**
  34594. * Creates a polyhedron mesh.
  34595. * Please consider using the same method from the MeshBuilder class instead.
  34596. * * 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
  34597. * * The parameter `size` (positive float, default 1) sets the polygon size
  34598. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34599. * * 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`
  34600. * * 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
  34601. * * 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)`)
  34602. * * 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
  34603. * * 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
  34604. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34607. * @param name defines the name of the mesh to create
  34608. * @param options defines the options used to create the mesh
  34609. * @param scene defines the hosting scene
  34610. * @returns a new Mesh
  34611. */
  34612. static CreatePolyhedron(name: string, options: {
  34613. type?: number;
  34614. size?: number;
  34615. sizeX?: number;
  34616. sizeY?: number;
  34617. sizeZ?: number;
  34618. custom?: any;
  34619. faceUV?: Vector4[];
  34620. faceColors?: Color4[];
  34621. updatable?: boolean;
  34622. sideOrientation?: number;
  34623. }, scene: Scene): Mesh;
  34624. /**
  34625. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34626. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34627. * * 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`)
  34628. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34629. * * 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
  34630. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34633. * @param name defines the name of the mesh
  34634. * @param options defines the options used to create the mesh
  34635. * @param scene defines the hosting scene
  34636. * @returns a new Mesh
  34637. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34638. */
  34639. static CreateIcoSphere(name: string, options: {
  34640. radius?: number;
  34641. flat?: boolean;
  34642. subdivisions?: number;
  34643. sideOrientation?: number;
  34644. updatable?: boolean;
  34645. }, scene: Scene): Mesh;
  34646. /**
  34647. * Creates a decal mesh.
  34648. * Please consider using the same method from the MeshBuilder class instead.
  34649. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34650. * @param name defines the name of the mesh
  34651. * @param sourceMesh defines the mesh receiving the decal
  34652. * @param position sets the position of the decal in world coordinates
  34653. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34654. * @param size sets the decal scaling
  34655. * @param angle sets the angle to rotate the decal
  34656. * @returns a new Mesh
  34657. */
  34658. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34659. /** Creates a Capsule Mesh
  34660. * @param name defines the name of the mesh.
  34661. * @param options the constructors options used to shape the mesh.
  34662. * @param scene defines the scene the mesh is scoped to.
  34663. * @returns the capsule mesh
  34664. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34665. */
  34666. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34667. /**
  34668. * Prepare internal position array for software CPU skinning
  34669. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34670. */
  34671. setPositionsForCPUSkinning(): Float32Array;
  34672. /**
  34673. * Prepare internal normal array for software CPU skinning
  34674. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34675. */
  34676. setNormalsForCPUSkinning(): Float32Array;
  34677. /**
  34678. * Updates the vertex buffer by applying transformation from the bones
  34679. * @param skeleton defines the skeleton to apply to current mesh
  34680. * @returns the current mesh
  34681. */
  34682. applySkeleton(skeleton: Skeleton): Mesh;
  34683. /**
  34684. * 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
  34685. * @param meshes defines the list of meshes to scan
  34686. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34687. */
  34688. static MinMax(meshes: AbstractMesh[]): {
  34689. min: Vector3;
  34690. max: Vector3;
  34691. };
  34692. /**
  34693. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34694. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34695. * @returns a vector3
  34696. */
  34697. static Center(meshesOrMinMaxVector: {
  34698. min: Vector3;
  34699. max: Vector3;
  34700. } | AbstractMesh[]): Vector3;
  34701. /**
  34702. * Merge the array of meshes into a single mesh for performance reasons.
  34703. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34704. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34705. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34706. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34707. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34708. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34709. * @returns a new mesh
  34710. */
  34711. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34712. /** @hidden */
  34713. addInstance(instance: InstancedMesh): void;
  34714. /** @hidden */
  34715. removeInstance(instance: InstancedMesh): void;
  34716. }
  34717. }
  34718. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34719. import { Vector3 } from "babylonjs/Maths/math.vector";
  34720. import { Mesh } from "babylonjs/Meshes/mesh";
  34721. /**
  34722. * The options Interface for creating a Capsule Mesh
  34723. */
  34724. export interface ICreateCapsuleOptions {
  34725. /** The Orientation of the capsule. Default : Vector3.Up() */
  34726. orientation?: Vector3;
  34727. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34728. subdivisions: number;
  34729. /** Number of cylindrical segments on the capsule. */
  34730. tessellation: number;
  34731. /** Height or Length of the capsule. */
  34732. height: number;
  34733. /** Radius of the capsule. */
  34734. radius: number;
  34735. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34736. capSubdivisions: number;
  34737. /** Overwrite for the top radius. */
  34738. radiusTop?: number;
  34739. /** Overwrite for the bottom radius. */
  34740. radiusBottom?: number;
  34741. /** Overwrite for the top capSubdivisions. */
  34742. topCapSubdivisions?: number;
  34743. /** Overwrite for the bottom capSubdivisions. */
  34744. bottomCapSubdivisions?: number;
  34745. }
  34746. /**
  34747. * Class containing static functions to help procedurally build meshes
  34748. */
  34749. export class CapsuleBuilder {
  34750. /**
  34751. * Creates a capsule or a pill mesh
  34752. * @param name defines the name of the mesh
  34753. * @param options The constructors options.
  34754. * @param scene The scene the mesh is scoped to.
  34755. * @returns Capsule Mesh
  34756. */
  34757. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34758. }
  34759. }
  34760. declare module "babylonjs/Meshes/mesh.vertexData" {
  34761. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34762. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34763. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34764. import { Geometry } from "babylonjs/Meshes/geometry";
  34765. import { Mesh } from "babylonjs/Meshes/mesh";
  34766. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34767. /**
  34768. * Define an interface for all classes that will get and set the data on vertices
  34769. */
  34770. export interface IGetSetVerticesData {
  34771. /**
  34772. * Gets a boolean indicating if specific vertex data is present
  34773. * @param kind defines the vertex data kind to use
  34774. * @returns true is data kind is present
  34775. */
  34776. isVerticesDataPresent(kind: string): boolean;
  34777. /**
  34778. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34779. * @param kind defines the data kind (Position, normal, etc...)
  34780. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34782. * @returns a float array containing vertex data
  34783. */
  34784. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34785. /**
  34786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34787. * @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.
  34788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34789. * @returns the indices array or an empty array if the mesh has no geometry
  34790. */
  34791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34792. /**
  34793. * Set specific vertex data
  34794. * @param kind defines the data kind (Position, normal, etc...)
  34795. * @param data defines the vertex data to use
  34796. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34797. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34798. */
  34799. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34800. /**
  34801. * Update a specific associated vertex buffer
  34802. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34803. * - VertexBuffer.PositionKind
  34804. * - VertexBuffer.UVKind
  34805. * - VertexBuffer.UV2Kind
  34806. * - VertexBuffer.UV3Kind
  34807. * - VertexBuffer.UV4Kind
  34808. * - VertexBuffer.UV5Kind
  34809. * - VertexBuffer.UV6Kind
  34810. * - VertexBuffer.ColorKind
  34811. * - VertexBuffer.MatricesIndicesKind
  34812. * - VertexBuffer.MatricesIndicesExtraKind
  34813. * - VertexBuffer.MatricesWeightsKind
  34814. * - VertexBuffer.MatricesWeightsExtraKind
  34815. * @param data defines the data source
  34816. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34817. * @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)
  34818. */
  34819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34820. /**
  34821. * Creates a new index buffer
  34822. * @param indices defines the indices to store in the index buffer
  34823. * @param totalVertices defines the total number of vertices (could be null)
  34824. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34825. */
  34826. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34827. }
  34828. /**
  34829. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34830. */
  34831. export class VertexData {
  34832. /**
  34833. * Mesh side orientation : usually the external or front surface
  34834. */
  34835. static readonly FRONTSIDE: number;
  34836. /**
  34837. * Mesh side orientation : usually the internal or back surface
  34838. */
  34839. static readonly BACKSIDE: number;
  34840. /**
  34841. * Mesh side orientation : both internal and external or front and back surfaces
  34842. */
  34843. static readonly DOUBLESIDE: number;
  34844. /**
  34845. * Mesh side orientation : by default, `FRONTSIDE`
  34846. */
  34847. static readonly DEFAULTSIDE: number;
  34848. /**
  34849. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34850. */
  34851. positions: Nullable<FloatArray>;
  34852. /**
  34853. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34854. */
  34855. normals: Nullable<FloatArray>;
  34856. /**
  34857. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34858. */
  34859. tangents: Nullable<FloatArray>;
  34860. /**
  34861. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34862. */
  34863. uvs: Nullable<FloatArray>;
  34864. /**
  34865. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34866. */
  34867. uvs2: Nullable<FloatArray>;
  34868. /**
  34869. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34870. */
  34871. uvs3: Nullable<FloatArray>;
  34872. /**
  34873. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34874. */
  34875. uvs4: Nullable<FloatArray>;
  34876. /**
  34877. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34878. */
  34879. uvs5: Nullable<FloatArray>;
  34880. /**
  34881. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34882. */
  34883. uvs6: Nullable<FloatArray>;
  34884. /**
  34885. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34886. */
  34887. colors: Nullable<FloatArray>;
  34888. /**
  34889. * 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).
  34890. */
  34891. matricesIndices: Nullable<FloatArray>;
  34892. /**
  34893. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34894. */
  34895. matricesWeights: Nullable<FloatArray>;
  34896. /**
  34897. * An array extending the number of possible indices
  34898. */
  34899. matricesIndicesExtra: Nullable<FloatArray>;
  34900. /**
  34901. * An array extending the number of possible weights when the number of indices is extended
  34902. */
  34903. matricesWeightsExtra: Nullable<FloatArray>;
  34904. /**
  34905. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34906. */
  34907. indices: Nullable<IndicesArray>;
  34908. /**
  34909. * Uses the passed data array to set the set the values for the specified kind of data
  34910. * @param data a linear array of floating numbers
  34911. * @param kind the type of data that is being set, eg positions, colors etc
  34912. */
  34913. set(data: FloatArray, kind: string): void;
  34914. /**
  34915. * Associates the vertexData to the passed Mesh.
  34916. * Sets it as updatable or not (default `false`)
  34917. * @param mesh the mesh the vertexData is applied to
  34918. * @param updatable when used and having the value true allows new data to update the vertexData
  34919. * @returns the VertexData
  34920. */
  34921. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34922. /**
  34923. * Associates the vertexData to the passed Geometry.
  34924. * Sets it as updatable or not (default `false`)
  34925. * @param geometry the geometry the vertexData is applied to
  34926. * @param updatable when used and having the value true allows new data to update the vertexData
  34927. * @returns VertexData
  34928. */
  34929. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34930. /**
  34931. * Updates the associated mesh
  34932. * @param mesh the mesh to be updated
  34933. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34934. * @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
  34935. * @returns VertexData
  34936. */
  34937. updateMesh(mesh: Mesh): VertexData;
  34938. /**
  34939. * Updates the associated geometry
  34940. * @param geometry the geometry to be updated
  34941. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34942. * @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
  34943. * @returns VertexData.
  34944. */
  34945. updateGeometry(geometry: Geometry): VertexData;
  34946. private _applyTo;
  34947. private _update;
  34948. /**
  34949. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34950. * @param matrix the transforming matrix
  34951. * @returns the VertexData
  34952. */
  34953. transform(matrix: Matrix): VertexData;
  34954. /**
  34955. * Merges the passed VertexData into the current one
  34956. * @param other the VertexData to be merged into the current one
  34957. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34958. * @returns the modified VertexData
  34959. */
  34960. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34961. private _mergeElement;
  34962. private _validate;
  34963. /**
  34964. * Serializes the VertexData
  34965. * @returns a serialized object
  34966. */
  34967. serialize(): any;
  34968. /**
  34969. * Extracts the vertexData from a mesh
  34970. * @param mesh the mesh from which to extract the VertexData
  34971. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34972. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34973. * @returns the object VertexData associated to the passed mesh
  34974. */
  34975. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34976. /**
  34977. * Extracts the vertexData from the geometry
  34978. * @param geometry the geometry from which to extract the VertexData
  34979. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34980. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34981. * @returns the object VertexData associated to the passed mesh
  34982. */
  34983. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34984. private static _ExtractFrom;
  34985. /**
  34986. * Creates the VertexData for a Ribbon
  34987. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34988. * * pathArray array of paths, each of which an array of successive Vector3
  34989. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34990. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34991. * * 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
  34992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34993. * * 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)
  34994. * * 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)
  34995. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34996. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34997. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34998. * @returns the VertexData of the ribbon
  34999. */
  35000. static CreateRibbon(options: {
  35001. pathArray: Vector3[][];
  35002. closeArray?: boolean;
  35003. closePath?: boolean;
  35004. offset?: number;
  35005. sideOrientation?: number;
  35006. frontUVs?: Vector4;
  35007. backUVs?: Vector4;
  35008. invertUV?: boolean;
  35009. uvs?: Vector2[];
  35010. colors?: Color4[];
  35011. }): VertexData;
  35012. /**
  35013. * Creates the VertexData for a box
  35014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35015. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35016. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35017. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35018. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35022. * * 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)
  35023. * * 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)
  35024. * @returns the VertexData of the box
  35025. */
  35026. static CreateBox(options: {
  35027. size?: number;
  35028. width?: number;
  35029. height?: number;
  35030. depth?: number;
  35031. faceUV?: Vector4[];
  35032. faceColors?: Color4[];
  35033. sideOrientation?: number;
  35034. frontUVs?: Vector4;
  35035. backUVs?: Vector4;
  35036. }): VertexData;
  35037. /**
  35038. * Creates the VertexData for a tiled box
  35039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35040. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35041. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35042. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35044. * @returns the VertexData of the box
  35045. */
  35046. static CreateTiledBox(options: {
  35047. pattern?: number;
  35048. width?: number;
  35049. height?: number;
  35050. depth?: number;
  35051. tileSize?: number;
  35052. tileWidth?: number;
  35053. tileHeight?: number;
  35054. alignHorizontal?: number;
  35055. alignVertical?: number;
  35056. faceUV?: Vector4[];
  35057. faceColors?: Color4[];
  35058. sideOrientation?: number;
  35059. }): VertexData;
  35060. /**
  35061. * Creates the VertexData for a tiled plane
  35062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35063. * * pattern a limited pattern arrangement depending on the number
  35064. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35065. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35066. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35068. * * 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)
  35069. * * 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)
  35070. * @returns the VertexData of the tiled plane
  35071. */
  35072. static CreateTiledPlane(options: {
  35073. pattern?: number;
  35074. tileSize?: number;
  35075. tileWidth?: number;
  35076. tileHeight?: number;
  35077. size?: number;
  35078. width?: number;
  35079. height?: number;
  35080. alignHorizontal?: number;
  35081. alignVertical?: number;
  35082. sideOrientation?: number;
  35083. frontUVs?: Vector4;
  35084. backUVs?: Vector4;
  35085. }): VertexData;
  35086. /**
  35087. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35089. * * segments sets the number of horizontal strips optional, default 32
  35090. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35091. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35092. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35093. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35094. * * 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
  35095. * * 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
  35096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35097. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35098. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35099. * @returns the VertexData of the ellipsoid
  35100. */
  35101. static CreateSphere(options: {
  35102. segments?: number;
  35103. diameter?: number;
  35104. diameterX?: number;
  35105. diameterY?: number;
  35106. diameterZ?: number;
  35107. arc?: number;
  35108. slice?: number;
  35109. sideOrientation?: number;
  35110. frontUVs?: Vector4;
  35111. backUVs?: Vector4;
  35112. }): VertexData;
  35113. /**
  35114. * Creates the VertexData for a cylinder, cone or prism
  35115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35116. * * height sets the height (y direction) of the cylinder, optional, default 2
  35117. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35118. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35119. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35120. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35121. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35122. * * 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
  35123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35125. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35126. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35128. * * 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)
  35129. * * 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)
  35130. * @returns the VertexData of the cylinder, cone or prism
  35131. */
  35132. static CreateCylinder(options: {
  35133. height?: number;
  35134. diameterTop?: number;
  35135. diameterBottom?: number;
  35136. diameter?: number;
  35137. tessellation?: number;
  35138. subdivisions?: number;
  35139. arc?: number;
  35140. faceColors?: Color4[];
  35141. faceUV?: Vector4[];
  35142. hasRings?: boolean;
  35143. enclose?: boolean;
  35144. sideOrientation?: number;
  35145. frontUVs?: Vector4;
  35146. backUVs?: Vector4;
  35147. }): VertexData;
  35148. /**
  35149. * Creates the VertexData for a torus
  35150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35151. * * diameter the diameter of the torus, optional default 1
  35152. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35153. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35155. * * 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)
  35156. * * 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)
  35157. * @returns the VertexData of the torus
  35158. */
  35159. static CreateTorus(options: {
  35160. diameter?: number;
  35161. thickness?: number;
  35162. tessellation?: number;
  35163. sideOrientation?: number;
  35164. frontUVs?: Vector4;
  35165. backUVs?: Vector4;
  35166. }): VertexData;
  35167. /**
  35168. * Creates the VertexData of the LineSystem
  35169. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35170. * - lines an array of lines, each line being an array of successive Vector3
  35171. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35172. * @returns the VertexData of the LineSystem
  35173. */
  35174. static CreateLineSystem(options: {
  35175. lines: Vector3[][];
  35176. colors?: Nullable<Color4[][]>;
  35177. }): VertexData;
  35178. /**
  35179. * Create the VertexData for a DashedLines
  35180. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35181. * - points an array successive Vector3
  35182. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35183. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35184. * - dashNb the intended total number of dashes, optional, default 200
  35185. * @returns the VertexData for the DashedLines
  35186. */
  35187. static CreateDashedLines(options: {
  35188. points: Vector3[];
  35189. dashSize?: number;
  35190. gapSize?: number;
  35191. dashNb?: number;
  35192. }): VertexData;
  35193. /**
  35194. * Creates the VertexData for a Ground
  35195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35196. * - width the width (x direction) of the ground, optional, default 1
  35197. * - height the height (z direction) of the ground, optional, default 1
  35198. * - subdivisions the number of subdivisions per side, optional, default 1
  35199. * @returns the VertexData of the Ground
  35200. */
  35201. static CreateGround(options: {
  35202. width?: number;
  35203. height?: number;
  35204. subdivisions?: number;
  35205. subdivisionsX?: number;
  35206. subdivisionsY?: number;
  35207. }): VertexData;
  35208. /**
  35209. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35210. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35211. * * xmin the ground minimum X coordinate, optional, default -1
  35212. * * zmin the ground minimum Z coordinate, optional, default -1
  35213. * * xmax the ground maximum X coordinate, optional, default 1
  35214. * * zmax the ground maximum Z coordinate, optional, default 1
  35215. * * 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}
  35216. * * 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}
  35217. * @returns the VertexData of the TiledGround
  35218. */
  35219. static CreateTiledGround(options: {
  35220. xmin: number;
  35221. zmin: number;
  35222. xmax: number;
  35223. zmax: number;
  35224. subdivisions?: {
  35225. w: number;
  35226. h: number;
  35227. };
  35228. precision?: {
  35229. w: number;
  35230. h: number;
  35231. };
  35232. }): VertexData;
  35233. /**
  35234. * Creates the VertexData of the Ground designed from a heightmap
  35235. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35236. * * width the width (x direction) of the ground
  35237. * * height the height (z direction) of the ground
  35238. * * subdivisions the number of subdivisions per side
  35239. * * minHeight the minimum altitude on the ground, optional, default 0
  35240. * * maxHeight the maximum altitude on the ground, optional default 1
  35241. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35242. * * buffer the array holding the image color data
  35243. * * bufferWidth the width of image
  35244. * * bufferHeight the height of image
  35245. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35246. * @returns the VertexData of the Ground designed from a heightmap
  35247. */
  35248. static CreateGroundFromHeightMap(options: {
  35249. width: number;
  35250. height: number;
  35251. subdivisions: number;
  35252. minHeight: number;
  35253. maxHeight: number;
  35254. colorFilter: Color3;
  35255. buffer: Uint8Array;
  35256. bufferWidth: number;
  35257. bufferHeight: number;
  35258. alphaFilter: number;
  35259. }): VertexData;
  35260. /**
  35261. * Creates the VertexData for a Plane
  35262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35263. * * size sets the width and height of the plane to the value of size, optional default 1
  35264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35267. * * 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)
  35268. * * 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)
  35269. * @returns the VertexData of the box
  35270. */
  35271. static CreatePlane(options: {
  35272. size?: number;
  35273. width?: number;
  35274. height?: number;
  35275. sideOrientation?: number;
  35276. frontUVs?: Vector4;
  35277. backUVs?: Vector4;
  35278. }): VertexData;
  35279. /**
  35280. * Creates the VertexData of the Disc or regular Polygon
  35281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35282. * * radius the radius of the disc, optional default 0.5
  35283. * * tessellation the number of polygon sides, optional, default 64
  35284. * * 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
  35285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35286. * * 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)
  35287. * * 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)
  35288. * @returns the VertexData of the box
  35289. */
  35290. static CreateDisc(options: {
  35291. radius?: number;
  35292. tessellation?: number;
  35293. arc?: number;
  35294. sideOrientation?: number;
  35295. frontUVs?: Vector4;
  35296. backUVs?: Vector4;
  35297. }): VertexData;
  35298. /**
  35299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35301. * @param polygon a mesh built from polygonTriangulation.build()
  35302. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35305. * @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)
  35306. * @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)
  35307. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35308. * @returns the VertexData of the Polygon
  35309. */
  35310. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35311. /**
  35312. * Creates the VertexData of the IcoSphere
  35313. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35314. * * radius the radius of the IcoSphere, optional default 1
  35315. * * radiusX allows stretching in the x direction, optional, default radius
  35316. * * radiusY allows stretching in the y direction, optional, default radius
  35317. * * radiusZ allows stretching in the z direction, optional, default radius
  35318. * * flat when true creates a flat shaded mesh, optional, default true
  35319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35321. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35322. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35323. * @returns the VertexData of the IcoSphere
  35324. */
  35325. static CreateIcoSphere(options: {
  35326. radius?: number;
  35327. radiusX?: number;
  35328. radiusY?: number;
  35329. radiusZ?: number;
  35330. flat?: boolean;
  35331. subdivisions?: number;
  35332. sideOrientation?: number;
  35333. frontUVs?: Vector4;
  35334. backUVs?: Vector4;
  35335. }): VertexData;
  35336. /**
  35337. * Creates the VertexData for a Polyhedron
  35338. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35339. * * type provided types are:
  35340. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35341. * * 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)
  35342. * * size the size of the IcoSphere, optional default 1
  35343. * * sizeX allows stretching in the x direction, optional, default size
  35344. * * sizeY allows stretching in the y direction, optional, default size
  35345. * * sizeZ allows stretching in the z direction, optional, default size
  35346. * * 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
  35347. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35348. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35349. * * flat when true creates a flat shaded mesh, optional, default true
  35350. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35352. * * 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)
  35353. * * 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)
  35354. * @returns the VertexData of the Polyhedron
  35355. */
  35356. static CreatePolyhedron(options: {
  35357. type?: number;
  35358. size?: number;
  35359. sizeX?: number;
  35360. sizeY?: number;
  35361. sizeZ?: number;
  35362. custom?: any;
  35363. faceUV?: Vector4[];
  35364. faceColors?: Color4[];
  35365. flat?: boolean;
  35366. sideOrientation?: number;
  35367. frontUVs?: Vector4;
  35368. backUVs?: Vector4;
  35369. }): VertexData;
  35370. /**
  35371. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35372. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35373. * @returns the VertexData of the Capsule
  35374. */
  35375. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35376. /**
  35377. * Creates the VertexData for a TorusKnot
  35378. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35379. * * radius the radius of the torus knot, optional, default 2
  35380. * * tube the thickness of the tube, optional, default 0.5
  35381. * * radialSegments the number of sides on each tube segments, optional, default 32
  35382. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35383. * * p the number of windings around the z axis, optional, default 2
  35384. * * q the number of windings around the x axis, optional, default 3
  35385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35386. * * 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)
  35387. * * 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)
  35388. * @returns the VertexData of the Torus Knot
  35389. */
  35390. static CreateTorusKnot(options: {
  35391. radius?: number;
  35392. tube?: number;
  35393. radialSegments?: number;
  35394. tubularSegments?: number;
  35395. p?: number;
  35396. q?: number;
  35397. sideOrientation?: number;
  35398. frontUVs?: Vector4;
  35399. backUVs?: Vector4;
  35400. }): VertexData;
  35401. /**
  35402. * Compute normals for given positions and indices
  35403. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35404. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35405. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35406. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35407. * * facetNormals : optional array of facet normals (vector3)
  35408. * * facetPositions : optional array of facet positions (vector3)
  35409. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35410. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35411. * * bInfo : optional bounding info, required for facetPartitioning computation
  35412. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35413. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35414. * * useRightHandedSystem: optional boolean to for right handed system computation
  35415. * * depthSort : optional boolean to enable the facet depth sort computation
  35416. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35417. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35418. */
  35419. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35420. facetNormals?: any;
  35421. facetPositions?: any;
  35422. facetPartitioning?: any;
  35423. ratio?: number;
  35424. bInfo?: any;
  35425. bbSize?: Vector3;
  35426. subDiv?: any;
  35427. useRightHandedSystem?: boolean;
  35428. depthSort?: boolean;
  35429. distanceTo?: Vector3;
  35430. depthSortedFacets?: any;
  35431. }): void;
  35432. /** @hidden */
  35433. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35434. /**
  35435. * Applies VertexData created from the imported parameters to the geometry
  35436. * @param parsedVertexData the parsed data from an imported file
  35437. * @param geometry the geometry to apply the VertexData to
  35438. */
  35439. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35440. }
  35441. }
  35442. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35443. import { Nullable } from "babylonjs/types";
  35444. import { Scene } from "babylonjs/scene";
  35445. import { Vector4 } from "babylonjs/Maths/math.vector";
  35446. import { Mesh } from "babylonjs/Meshes/mesh";
  35447. /**
  35448. * Class containing static functions to help procedurally build meshes
  35449. */
  35450. export class DiscBuilder {
  35451. /**
  35452. * Creates a plane polygonal mesh. By default, this is a disc
  35453. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35454. * * 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
  35455. * * 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
  35456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35459. * @param name defines the name of the mesh
  35460. * @param options defines the options used to create the mesh
  35461. * @param scene defines the hosting scene
  35462. * @returns the plane polygonal mesh
  35463. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35464. */
  35465. static CreateDisc(name: string, options: {
  35466. radius?: number;
  35467. tessellation?: number;
  35468. arc?: number;
  35469. updatable?: boolean;
  35470. sideOrientation?: number;
  35471. frontUVs?: Vector4;
  35472. backUVs?: Vector4;
  35473. }, scene?: Nullable<Scene>): Mesh;
  35474. }
  35475. }
  35476. declare module "babylonjs/Particles/solidParticleSystem" {
  35477. import { Nullable } from "babylonjs/types";
  35478. import { Mesh } from "babylonjs/Meshes/mesh";
  35479. import { Scene, IDisposable } from "babylonjs/scene";
  35480. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35481. import { Material } from "babylonjs/Materials/material";
  35482. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35483. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35484. /**
  35485. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35486. *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.
  35487. * The SPS is also a particle system. It provides some methods to manage the particles.
  35488. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35489. *
  35490. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35491. */
  35492. export class SolidParticleSystem implements IDisposable {
  35493. /**
  35494. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35495. * Example : var p = SPS.particles[i];
  35496. */
  35497. particles: SolidParticle[];
  35498. /**
  35499. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35500. */
  35501. nbParticles: number;
  35502. /**
  35503. * If the particles must ever face the camera (default false). Useful for planar particles.
  35504. */
  35505. billboard: boolean;
  35506. /**
  35507. * Recompute normals when adding a shape
  35508. */
  35509. recomputeNormals: boolean;
  35510. /**
  35511. * This a counter ofr your own usage. It's not set by any SPS functions.
  35512. */
  35513. counter: number;
  35514. /**
  35515. * The SPS name. This name is also given to the underlying mesh.
  35516. */
  35517. name: string;
  35518. /**
  35519. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35520. */
  35521. mesh: Mesh;
  35522. /**
  35523. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35524. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35525. */
  35526. vars: any;
  35527. /**
  35528. * This array is populated when the SPS is set as 'pickable'.
  35529. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35530. * Each element of this array is an object `{idx: int, faceId: int}`.
  35531. * `idx` is the picked particle index in the `SPS.particles` array
  35532. * `faceId` is the picked face index counted within this particle.
  35533. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35534. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35535. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35536. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35537. */
  35538. pickedParticles: {
  35539. idx: number;
  35540. faceId: number;
  35541. }[];
  35542. /**
  35543. * This array is populated when the SPS is set as 'pickable'
  35544. * Each key of this array is a submesh index.
  35545. * Each element of this array is a second array defined like this :
  35546. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35547. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35548. * `idx` is the picked particle index in the `SPS.particles` array
  35549. * `faceId` is the picked face index counted within this particle.
  35550. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35551. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35552. */
  35553. pickedBySubMesh: {
  35554. idx: number;
  35555. faceId: number;
  35556. }[][];
  35557. /**
  35558. * This array is populated when `enableDepthSort` is set to true.
  35559. * Each element of this array is an instance of the class DepthSortedParticle.
  35560. */
  35561. depthSortedParticles: DepthSortedParticle[];
  35562. /**
  35563. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35564. * @hidden
  35565. */
  35566. _bSphereOnly: boolean;
  35567. /**
  35568. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35569. * @hidden
  35570. */
  35571. _bSphereRadiusFactor: number;
  35572. private _scene;
  35573. private _positions;
  35574. private _indices;
  35575. private _normals;
  35576. private _colors;
  35577. private _uvs;
  35578. private _indices32;
  35579. private _positions32;
  35580. private _normals32;
  35581. private _fixedNormal32;
  35582. private _colors32;
  35583. private _uvs32;
  35584. private _index;
  35585. private _updatable;
  35586. private _pickable;
  35587. private _isVisibilityBoxLocked;
  35588. private _alwaysVisible;
  35589. private _depthSort;
  35590. private _expandable;
  35591. private _shapeCounter;
  35592. private _copy;
  35593. private _color;
  35594. private _computeParticleColor;
  35595. private _computeParticleTexture;
  35596. private _computeParticleRotation;
  35597. private _computeParticleVertex;
  35598. private _computeBoundingBox;
  35599. private _depthSortParticles;
  35600. private _camera;
  35601. private _mustUnrotateFixedNormals;
  35602. private _particlesIntersect;
  35603. private _needs32Bits;
  35604. private _isNotBuilt;
  35605. private _lastParticleId;
  35606. private _idxOfId;
  35607. private _multimaterialEnabled;
  35608. private _useModelMaterial;
  35609. private _indicesByMaterial;
  35610. private _materialIndexes;
  35611. private _depthSortFunction;
  35612. private _materialSortFunction;
  35613. private _materials;
  35614. private _multimaterial;
  35615. private _materialIndexesById;
  35616. private _defaultMaterial;
  35617. private _autoUpdateSubMeshes;
  35618. private _tmpVertex;
  35619. /**
  35620. * Creates a SPS (Solid Particle System) object.
  35621. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35622. * @param scene (Scene) is the scene in which the SPS is added.
  35623. * @param options defines the options of the sps e.g.
  35624. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35625. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35626. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35627. * * 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.
  35628. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35629. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35630. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35631. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35632. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35633. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35634. */
  35635. constructor(name: string, scene: Scene, options?: {
  35636. updatable?: boolean;
  35637. isPickable?: boolean;
  35638. enableDepthSort?: boolean;
  35639. particleIntersection?: boolean;
  35640. boundingSphereOnly?: boolean;
  35641. bSphereRadiusFactor?: number;
  35642. expandable?: boolean;
  35643. useModelMaterial?: boolean;
  35644. enableMultiMaterial?: boolean;
  35645. });
  35646. /**
  35647. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35648. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35649. * @returns the created mesh
  35650. */
  35651. buildMesh(): Mesh;
  35652. /**
  35653. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35654. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35655. * Thus the particles generated from `digest()` have their property `position` set yet.
  35656. * @param mesh ( Mesh ) is the mesh to be digested
  35657. * @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
  35658. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35659. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35660. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35661. * @returns the current SPS
  35662. */
  35663. digest(mesh: Mesh, options?: {
  35664. facetNb?: number;
  35665. number?: number;
  35666. delta?: number;
  35667. storage?: [];
  35668. }): SolidParticleSystem;
  35669. /**
  35670. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35671. * @hidden
  35672. */
  35673. private _unrotateFixedNormals;
  35674. /**
  35675. * Resets the temporary working copy particle
  35676. * @hidden
  35677. */
  35678. private _resetCopy;
  35679. /**
  35680. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35681. * @param p the current index in the positions array to be updated
  35682. * @param ind the current index in the indices array
  35683. * @param shape a Vector3 array, the shape geometry
  35684. * @param positions the positions array to be updated
  35685. * @param meshInd the shape indices array
  35686. * @param indices the indices array to be updated
  35687. * @param meshUV the shape uv array
  35688. * @param uvs the uv array to be updated
  35689. * @param meshCol the shape color array
  35690. * @param colors the color array to be updated
  35691. * @param meshNor the shape normals array
  35692. * @param normals the normals array to be updated
  35693. * @param idx the particle index
  35694. * @param idxInShape the particle index in its shape
  35695. * @param options the addShape() method passed options
  35696. * @model the particle model
  35697. * @hidden
  35698. */
  35699. private _meshBuilder;
  35700. /**
  35701. * Returns a shape Vector3 array from positions float array
  35702. * @param positions float array
  35703. * @returns a vector3 array
  35704. * @hidden
  35705. */
  35706. private _posToShape;
  35707. /**
  35708. * Returns a shapeUV array from a float uvs (array deep copy)
  35709. * @param uvs as a float array
  35710. * @returns a shapeUV array
  35711. * @hidden
  35712. */
  35713. private _uvsToShapeUV;
  35714. /**
  35715. * Adds a new particle object in the particles array
  35716. * @param idx particle index in particles array
  35717. * @param id particle id
  35718. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35719. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35720. * @param model particle ModelShape object
  35721. * @param shapeId model shape identifier
  35722. * @param idxInShape index of the particle in the current model
  35723. * @param bInfo model bounding info object
  35724. * @param storage target storage array, if any
  35725. * @hidden
  35726. */
  35727. private _addParticle;
  35728. /**
  35729. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35730. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35731. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35732. * @param nb (positive integer) the number of particles to be created from this model
  35733. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35734. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35735. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35736. * @returns the number of shapes in the system
  35737. */
  35738. addShape(mesh: Mesh, nb: number, options?: {
  35739. positionFunction?: any;
  35740. vertexFunction?: any;
  35741. storage?: [];
  35742. }): number;
  35743. /**
  35744. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35745. * @hidden
  35746. */
  35747. private _rebuildParticle;
  35748. /**
  35749. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35750. * @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.
  35751. * @returns the SPS.
  35752. */
  35753. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35754. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35755. * Returns an array with the removed particles.
  35756. * 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.
  35757. * The SPS can't be empty so at least one particle needs to remain in place.
  35758. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35759. * @param start index of the first particle to remove
  35760. * @param end index of the last particle to remove (included)
  35761. * @returns an array populated with the removed particles
  35762. */
  35763. removeParticles(start: number, end: number): SolidParticle[];
  35764. /**
  35765. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35766. * @param solidParticleArray an array populated with Solid Particles objects
  35767. * @returns the SPS
  35768. */
  35769. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35770. /**
  35771. * Creates a new particle and modifies the SPS mesh geometry :
  35772. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35773. * - calls _addParticle() to populate the particle array
  35774. * factorized code from addShape() and insertParticlesFromArray()
  35775. * @param idx particle index in the particles array
  35776. * @param i particle index in its shape
  35777. * @param modelShape particle ModelShape object
  35778. * @param shape shape vertex array
  35779. * @param meshInd shape indices array
  35780. * @param meshUV shape uv array
  35781. * @param meshCol shape color array
  35782. * @param meshNor shape normals array
  35783. * @param bbInfo shape bounding info
  35784. * @param storage target particle storage
  35785. * @options addShape() passed options
  35786. * @hidden
  35787. */
  35788. private _insertNewParticle;
  35789. /**
  35790. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35791. * This method calls `updateParticle()` for each particle of the SPS.
  35792. * For an animated SPS, it is usually called within the render loop.
  35793. * 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.
  35794. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35795. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35796. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35797. * @returns the SPS.
  35798. */
  35799. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35800. /**
  35801. * Disposes the SPS.
  35802. */
  35803. dispose(): void;
  35804. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35805. * idx is the particle index in the SPS
  35806. * faceId is the picked face index counted within this particle.
  35807. * Returns null if the pickInfo can't identify a picked particle.
  35808. * @param pickingInfo (PickingInfo object)
  35809. * @returns {idx: number, faceId: number} or null
  35810. */
  35811. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35812. idx: number;
  35813. faceId: number;
  35814. }>;
  35815. /**
  35816. * Returns a SolidParticle object from its identifier : particle.id
  35817. * @param id (integer) the particle Id
  35818. * @returns the searched particle or null if not found in the SPS.
  35819. */
  35820. getParticleById(id: number): Nullable<SolidParticle>;
  35821. /**
  35822. * Returns a new array populated with the particles having the passed shapeId.
  35823. * @param shapeId (integer) the shape identifier
  35824. * @returns a new solid particle array
  35825. */
  35826. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35827. /**
  35828. * Populates the passed array "ref" with the particles having the passed shapeId.
  35829. * @param shapeId the shape identifier
  35830. * @returns the SPS
  35831. * @param ref
  35832. */
  35833. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35834. /**
  35835. * Computes the required SubMeshes according the materials assigned to the particles.
  35836. * @returns the solid particle system.
  35837. * Does nothing if called before the SPS mesh is built.
  35838. */
  35839. computeSubMeshes(): SolidParticleSystem;
  35840. /**
  35841. * Sorts the solid particles by material when MultiMaterial is enabled.
  35842. * Updates the indices32 array.
  35843. * Updates the indicesByMaterial array.
  35844. * Updates the mesh indices array.
  35845. * @returns the SPS
  35846. * @hidden
  35847. */
  35848. private _sortParticlesByMaterial;
  35849. /**
  35850. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35851. * @hidden
  35852. */
  35853. private _setMaterialIndexesById;
  35854. /**
  35855. * Returns an array with unique values of Materials from the passed array
  35856. * @param array the material array to be checked and filtered
  35857. * @hidden
  35858. */
  35859. private _filterUniqueMaterialId;
  35860. /**
  35861. * Sets a new Standard Material as _defaultMaterial if not already set.
  35862. * @hidden
  35863. */
  35864. private _setDefaultMaterial;
  35865. /**
  35866. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35867. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35868. * @returns the SPS.
  35869. */
  35870. refreshVisibleSize(): SolidParticleSystem;
  35871. /**
  35872. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35873. * @param size the size (float) of the visibility box
  35874. * note : this doesn't lock the SPS mesh bounding box.
  35875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35876. */
  35877. setVisibilityBox(size: number): void;
  35878. /**
  35879. * Gets whether the SPS as always visible or not
  35880. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35881. */
  35882. get isAlwaysVisible(): boolean;
  35883. /**
  35884. * Sets the SPS as always visible or not
  35885. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35886. */
  35887. set isAlwaysVisible(val: boolean);
  35888. /**
  35889. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35890. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35891. */
  35892. set isVisibilityBoxLocked(val: boolean);
  35893. /**
  35894. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35895. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35896. */
  35897. get isVisibilityBoxLocked(): boolean;
  35898. /**
  35899. * Tells to `setParticles()` to compute the particle rotations or not.
  35900. * Default value : true. The SPS is faster when it's set to false.
  35901. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35902. */
  35903. set computeParticleRotation(val: boolean);
  35904. /**
  35905. * Tells to `setParticles()` to compute the particle colors or not.
  35906. * Default value : true. The SPS is faster when it's set to false.
  35907. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35908. */
  35909. set computeParticleColor(val: boolean);
  35910. set computeParticleTexture(val: boolean);
  35911. /**
  35912. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35913. * Default value : false. The SPS is faster when it's set to false.
  35914. * Note : the particle custom vertex positions aren't stored values.
  35915. */
  35916. set computeParticleVertex(val: boolean);
  35917. /**
  35918. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35919. */
  35920. set computeBoundingBox(val: boolean);
  35921. /**
  35922. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35923. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35924. * Default : `true`
  35925. */
  35926. set depthSortParticles(val: boolean);
  35927. /**
  35928. * Gets if `setParticles()` computes the particle rotations or not.
  35929. * Default value : true. The SPS is faster when it's set to false.
  35930. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35931. */
  35932. get computeParticleRotation(): boolean;
  35933. /**
  35934. * Gets if `setParticles()` computes the particle colors or not.
  35935. * Default value : true. The SPS is faster when it's set to false.
  35936. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35937. */
  35938. get computeParticleColor(): boolean;
  35939. /**
  35940. * Gets if `setParticles()` computes the particle textures or not.
  35941. * Default value : true. The SPS is faster when it's set to false.
  35942. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35943. */
  35944. get computeParticleTexture(): boolean;
  35945. /**
  35946. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35947. * Default value : false. The SPS is faster when it's set to false.
  35948. * Note : the particle custom vertex positions aren't stored values.
  35949. */
  35950. get computeParticleVertex(): boolean;
  35951. /**
  35952. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35953. */
  35954. get computeBoundingBox(): boolean;
  35955. /**
  35956. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35957. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35958. * Default : `true`
  35959. */
  35960. get depthSortParticles(): boolean;
  35961. /**
  35962. * Gets if the SPS is created as expandable at construction time.
  35963. * Default : `false`
  35964. */
  35965. get expandable(): boolean;
  35966. /**
  35967. * Gets if the SPS supports the Multi Materials
  35968. */
  35969. get multimaterialEnabled(): boolean;
  35970. /**
  35971. * Gets if the SPS uses the model materials for its own multimaterial.
  35972. */
  35973. get useModelMaterial(): boolean;
  35974. /**
  35975. * The SPS used material array.
  35976. */
  35977. get materials(): Material[];
  35978. /**
  35979. * Sets the SPS MultiMaterial from the passed materials.
  35980. * Note : the passed array is internally copied and not used then by reference.
  35981. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35982. */
  35983. setMultiMaterial(materials: Material[]): void;
  35984. /**
  35985. * The SPS computed multimaterial object
  35986. */
  35987. get multimaterial(): MultiMaterial;
  35988. set multimaterial(mm: MultiMaterial);
  35989. /**
  35990. * If the subMeshes must be updated on the next call to setParticles()
  35991. */
  35992. get autoUpdateSubMeshes(): boolean;
  35993. set autoUpdateSubMeshes(val: boolean);
  35994. /**
  35995. * This function does nothing. It may be overwritten to set all the particle first values.
  35996. * The SPS doesn't call this function, you may have to call it by your own.
  35997. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35998. */
  35999. initParticles(): void;
  36000. /**
  36001. * This function does nothing. It may be overwritten to recycle a particle.
  36002. * The SPS doesn't call this function, you may have to call it by your own.
  36003. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36004. * @param particle The particle to recycle
  36005. * @returns the recycled particle
  36006. */
  36007. recycleParticle(particle: SolidParticle): SolidParticle;
  36008. /**
  36009. * Updates a particle : this function should be overwritten by the user.
  36010. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36011. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36012. * @example : just set a particle position or velocity and recycle conditions
  36013. * @param particle The particle to update
  36014. * @returns the updated particle
  36015. */
  36016. updateParticle(particle: SolidParticle): SolidParticle;
  36017. /**
  36018. * Updates a vertex of a particle : it can be overwritten by the user.
  36019. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36020. * @param particle the current particle
  36021. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36022. * @param pt the index of the current vertex in the particle shape
  36023. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36024. * @example : just set a vertex particle position or color
  36025. * @returns the sps
  36026. */
  36027. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36028. /**
  36029. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36030. * This does nothing and may be overwritten by the user.
  36031. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36032. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36033. * @param update the boolean update value actually passed to setParticles()
  36034. */
  36035. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36036. /**
  36037. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36038. * This will be passed three parameters.
  36039. * This does nothing and may be overwritten by the user.
  36040. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36041. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36042. * @param update the boolean update value actually passed to setParticles()
  36043. */
  36044. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36045. }
  36046. }
  36047. declare module "babylonjs/Particles/solidParticle" {
  36048. import { Nullable } from "babylonjs/types";
  36049. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36050. import { Color4 } from "babylonjs/Maths/math.color";
  36051. import { Mesh } from "babylonjs/Meshes/mesh";
  36052. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36053. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36054. import { Plane } from "babylonjs/Maths/math.plane";
  36055. import { Material } from "babylonjs/Materials/material";
  36056. /**
  36057. * Represents one particle of a solid particle system.
  36058. */
  36059. export class SolidParticle {
  36060. /**
  36061. * particle global index
  36062. */
  36063. idx: number;
  36064. /**
  36065. * particle identifier
  36066. */
  36067. id: number;
  36068. /**
  36069. * The color of the particle
  36070. */
  36071. color: Nullable<Color4>;
  36072. /**
  36073. * The world space position of the particle.
  36074. */
  36075. position: Vector3;
  36076. /**
  36077. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36078. */
  36079. rotation: Vector3;
  36080. /**
  36081. * The world space rotation quaternion of the particle.
  36082. */
  36083. rotationQuaternion: Nullable<Quaternion>;
  36084. /**
  36085. * The scaling of the particle.
  36086. */
  36087. scaling: Vector3;
  36088. /**
  36089. * The uvs of the particle.
  36090. */
  36091. uvs: Vector4;
  36092. /**
  36093. * The current speed of the particle.
  36094. */
  36095. velocity: Vector3;
  36096. /**
  36097. * The pivot point in the particle local space.
  36098. */
  36099. pivot: Vector3;
  36100. /**
  36101. * Must the particle be translated from its pivot point in its local space ?
  36102. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36103. * Default : false
  36104. */
  36105. translateFromPivot: boolean;
  36106. /**
  36107. * Is the particle active or not ?
  36108. */
  36109. alive: boolean;
  36110. /**
  36111. * Is the particle visible or not ?
  36112. */
  36113. isVisible: boolean;
  36114. /**
  36115. * Index of this particle in the global "positions" array (Internal use)
  36116. * @hidden
  36117. */
  36118. _pos: number;
  36119. /**
  36120. * @hidden Index of this particle in the global "indices" array (Internal use)
  36121. */
  36122. _ind: number;
  36123. /**
  36124. * @hidden ModelShape of this particle (Internal use)
  36125. */
  36126. _model: ModelShape;
  36127. /**
  36128. * ModelShape id of this particle
  36129. */
  36130. shapeId: number;
  36131. /**
  36132. * Index of the particle in its shape id
  36133. */
  36134. idxInShape: number;
  36135. /**
  36136. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36137. */
  36138. _modelBoundingInfo: BoundingInfo;
  36139. /**
  36140. * @hidden Particle BoundingInfo object (Internal use)
  36141. */
  36142. _boundingInfo: BoundingInfo;
  36143. /**
  36144. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36145. */
  36146. _sps: SolidParticleSystem;
  36147. /**
  36148. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36149. */
  36150. _stillInvisible: boolean;
  36151. /**
  36152. * @hidden Last computed particle rotation matrix
  36153. */
  36154. _rotationMatrix: number[];
  36155. /**
  36156. * Parent particle Id, if any.
  36157. * Default null.
  36158. */
  36159. parentId: Nullable<number>;
  36160. /**
  36161. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36162. */
  36163. materialIndex: Nullable<number>;
  36164. /**
  36165. * Custom object or properties.
  36166. */
  36167. props: Nullable<any>;
  36168. /**
  36169. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36170. * The possible values are :
  36171. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36172. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36173. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36174. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36175. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36176. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36177. * */
  36178. cullingStrategy: number;
  36179. /**
  36180. * @hidden Internal global position in the SPS.
  36181. */
  36182. _globalPosition: Vector3;
  36183. /**
  36184. * Creates a Solid Particle object.
  36185. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36186. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36187. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36188. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36189. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36190. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36191. * @param shapeId (integer) is the model shape identifier in the SPS.
  36192. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36193. * @param sps defines the sps it is associated to
  36194. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36195. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36196. */
  36197. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36198. /**
  36199. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36200. * @param target the particle target
  36201. * @returns the current particle
  36202. */
  36203. copyToRef(target: SolidParticle): SolidParticle;
  36204. /**
  36205. * Legacy support, changed scale to scaling
  36206. */
  36207. get scale(): Vector3;
  36208. /**
  36209. * Legacy support, changed scale to scaling
  36210. */
  36211. set scale(scale: Vector3);
  36212. /**
  36213. * Legacy support, changed quaternion to rotationQuaternion
  36214. */
  36215. get quaternion(): Nullable<Quaternion>;
  36216. /**
  36217. * Legacy support, changed quaternion to rotationQuaternion
  36218. */
  36219. set quaternion(q: Nullable<Quaternion>);
  36220. /**
  36221. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36222. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36223. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36224. * @returns true if it intersects
  36225. */
  36226. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36227. /**
  36228. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36229. * A particle is in the frustum if its bounding box intersects the frustum
  36230. * @param frustumPlanes defines the frustum to test
  36231. * @returns true if the particle is in the frustum planes
  36232. */
  36233. isInFrustum(frustumPlanes: Plane[]): boolean;
  36234. /**
  36235. * get the rotation matrix of the particle
  36236. * @hidden
  36237. */
  36238. getRotationMatrix(m: Matrix): void;
  36239. }
  36240. /**
  36241. * Represents the shape of the model used by one particle of a solid particle system.
  36242. * SPS internal tool, don't use it manually.
  36243. */
  36244. export class ModelShape {
  36245. /**
  36246. * The shape id
  36247. * @hidden
  36248. */
  36249. shapeID: number;
  36250. /**
  36251. * flat array of model positions (internal use)
  36252. * @hidden
  36253. */
  36254. _shape: Vector3[];
  36255. /**
  36256. * flat array of model UVs (internal use)
  36257. * @hidden
  36258. */
  36259. _shapeUV: number[];
  36260. /**
  36261. * color array of the model
  36262. * @hidden
  36263. */
  36264. _shapeColors: number[];
  36265. /**
  36266. * indices array of the model
  36267. * @hidden
  36268. */
  36269. _indices: number[];
  36270. /**
  36271. * normals array of the model
  36272. * @hidden
  36273. */
  36274. _normals: number[];
  36275. /**
  36276. * length of the shape in the model indices array (internal use)
  36277. * @hidden
  36278. */
  36279. _indicesLength: number;
  36280. /**
  36281. * Custom position function (internal use)
  36282. * @hidden
  36283. */
  36284. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36285. /**
  36286. * Custom vertex function (internal use)
  36287. * @hidden
  36288. */
  36289. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36290. /**
  36291. * Model material (internal use)
  36292. * @hidden
  36293. */
  36294. _material: Nullable<Material>;
  36295. /**
  36296. * 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.
  36297. * SPS internal tool, don't use it manually.
  36298. * @hidden
  36299. */
  36300. 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>);
  36301. }
  36302. /**
  36303. * Represents a Depth Sorted Particle in the solid particle system.
  36304. * @hidden
  36305. */
  36306. export class DepthSortedParticle {
  36307. /**
  36308. * Particle index
  36309. */
  36310. idx: number;
  36311. /**
  36312. * Index of the particle in the "indices" array
  36313. */
  36314. ind: number;
  36315. /**
  36316. * Length of the particle shape in the "indices" array
  36317. */
  36318. indicesLength: number;
  36319. /**
  36320. * Squared distance from the particle to the camera
  36321. */
  36322. sqDistance: number;
  36323. /**
  36324. * Material index when used with MultiMaterials
  36325. */
  36326. materialIndex: number;
  36327. /**
  36328. * Creates a new sorted particle
  36329. * @param materialIndex
  36330. */
  36331. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36332. }
  36333. /**
  36334. * Represents a solid particle vertex
  36335. */
  36336. export class SolidParticleVertex {
  36337. /**
  36338. * Vertex position
  36339. */
  36340. position: Vector3;
  36341. /**
  36342. * Vertex color
  36343. */
  36344. color: Color4;
  36345. /**
  36346. * Vertex UV
  36347. */
  36348. uv: Vector2;
  36349. /**
  36350. * Creates a new solid particle vertex
  36351. */
  36352. constructor();
  36353. /** Vertex x coordinate */
  36354. get x(): number;
  36355. set x(val: number);
  36356. /** Vertex y coordinate */
  36357. get y(): number;
  36358. set y(val: number);
  36359. /** Vertex z coordinate */
  36360. get z(): number;
  36361. set z(val: number);
  36362. }
  36363. }
  36364. declare module "babylonjs/Collisions/meshCollisionData" {
  36365. import { Collider } from "babylonjs/Collisions/collider";
  36366. import { Vector3 } from "babylonjs/Maths/math.vector";
  36367. import { Nullable } from "babylonjs/types";
  36368. import { Observer } from "babylonjs/Misc/observable";
  36369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36370. /**
  36371. * @hidden
  36372. */
  36373. export class _MeshCollisionData {
  36374. _checkCollisions: boolean;
  36375. _collisionMask: number;
  36376. _collisionGroup: number;
  36377. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36378. _collider: Nullable<Collider>;
  36379. _oldPositionForCollisions: Vector3;
  36380. _diffPositionForCollisions: Vector3;
  36381. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36382. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36383. _collisionResponse: boolean;
  36384. }
  36385. }
  36386. declare module "babylonjs/Meshes/abstractMesh" {
  36387. import { Observable } from "babylonjs/Misc/observable";
  36388. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36389. import { Camera } from "babylonjs/Cameras/camera";
  36390. import { Scene, IDisposable } from "babylonjs/scene";
  36391. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36392. import { Node } from "babylonjs/node";
  36393. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36397. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36398. import { Material } from "babylonjs/Materials/material";
  36399. import { Light } from "babylonjs/Lights/light";
  36400. import { Skeleton } from "babylonjs/Bones/skeleton";
  36401. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36402. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36403. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36404. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36406. import { Plane } from "babylonjs/Maths/math.plane";
  36407. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36408. import { Ray } from "babylonjs/Culling/ray";
  36409. import { Collider } from "babylonjs/Collisions/collider";
  36410. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36411. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36412. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36413. /** @hidden */
  36414. class _FacetDataStorage {
  36415. facetPositions: Vector3[];
  36416. facetNormals: Vector3[];
  36417. facetPartitioning: number[][];
  36418. facetNb: number;
  36419. partitioningSubdivisions: number;
  36420. partitioningBBoxRatio: number;
  36421. facetDataEnabled: boolean;
  36422. facetParameters: any;
  36423. bbSize: Vector3;
  36424. subDiv: {
  36425. max: number;
  36426. X: number;
  36427. Y: number;
  36428. Z: number;
  36429. };
  36430. facetDepthSort: boolean;
  36431. facetDepthSortEnabled: boolean;
  36432. depthSortedIndices: IndicesArray;
  36433. depthSortedFacets: {
  36434. ind: number;
  36435. sqDistance: number;
  36436. }[];
  36437. facetDepthSortFunction: (f1: {
  36438. ind: number;
  36439. sqDistance: number;
  36440. }, f2: {
  36441. ind: number;
  36442. sqDistance: number;
  36443. }) => number;
  36444. facetDepthSortFrom: Vector3;
  36445. facetDepthSortOrigin: Vector3;
  36446. invertedMatrix: Matrix;
  36447. }
  36448. /**
  36449. * @hidden
  36450. **/
  36451. class _InternalAbstractMeshDataInfo {
  36452. _hasVertexAlpha: boolean;
  36453. _useVertexColors: boolean;
  36454. _numBoneInfluencers: number;
  36455. _applyFog: boolean;
  36456. _receiveShadows: boolean;
  36457. _facetData: _FacetDataStorage;
  36458. _visibility: number;
  36459. _skeleton: Nullable<Skeleton>;
  36460. _layerMask: number;
  36461. _computeBonesUsingShaders: boolean;
  36462. _isActive: boolean;
  36463. _onlyForInstances: boolean;
  36464. _isActiveIntermediate: boolean;
  36465. _onlyForInstancesIntermediate: boolean;
  36466. _actAsRegularMesh: boolean;
  36467. _currentLOD: Nullable<AbstractMesh>;
  36468. _currentLODIsUpToDate: boolean;
  36469. }
  36470. /**
  36471. * Class used to store all common mesh properties
  36472. */
  36473. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36474. /** No occlusion */
  36475. static OCCLUSION_TYPE_NONE: number;
  36476. /** Occlusion set to optimisitic */
  36477. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36478. /** Occlusion set to strict */
  36479. static OCCLUSION_TYPE_STRICT: number;
  36480. /** Use an accurante occlusion algorithm */
  36481. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36482. /** Use a conservative occlusion algorithm */
  36483. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36484. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36485. * Test order :
  36486. * Is the bounding sphere outside the frustum ?
  36487. * If not, are the bounding box vertices outside the frustum ?
  36488. * It not, then the cullable object is in the frustum.
  36489. */
  36490. static readonly CULLINGSTRATEGY_STANDARD: number;
  36491. /** Culling strategy : Bounding Sphere Only.
  36492. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36493. * It's also less accurate than the standard because some not visible objects can still be selected.
  36494. * Test : is the bounding sphere outside the frustum ?
  36495. * If not, then the cullable object is in the frustum.
  36496. */
  36497. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36498. /** Culling strategy : Optimistic Inclusion.
  36499. * This in an inclusion test first, then the standard exclusion test.
  36500. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36501. * 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.
  36502. * Anyway, it's as accurate as the standard strategy.
  36503. * Test :
  36504. * Is the cullable object bounding sphere center in the frustum ?
  36505. * If not, apply the default culling strategy.
  36506. */
  36507. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36508. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36509. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36510. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36511. * 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.
  36512. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36513. * Test :
  36514. * Is the cullable object bounding sphere center in the frustum ?
  36515. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36516. */
  36517. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36518. /**
  36519. * No billboard
  36520. */
  36521. static get BILLBOARDMODE_NONE(): number;
  36522. /** Billboard on X axis */
  36523. static get BILLBOARDMODE_X(): number;
  36524. /** Billboard on Y axis */
  36525. static get BILLBOARDMODE_Y(): number;
  36526. /** Billboard on Z axis */
  36527. static get BILLBOARDMODE_Z(): number;
  36528. /** Billboard on all axes */
  36529. static get BILLBOARDMODE_ALL(): number;
  36530. /** Billboard on using position instead of orientation */
  36531. static get BILLBOARDMODE_USE_POSITION(): number;
  36532. /** @hidden */
  36533. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36534. /**
  36535. * The culling strategy to use to check whether the mesh must be rendered or not.
  36536. * This value can be changed at any time and will be used on the next render mesh selection.
  36537. * The possible values are :
  36538. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36539. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36540. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36541. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36542. * Please read each static variable documentation to get details about the culling process.
  36543. * */
  36544. cullingStrategy: number;
  36545. /**
  36546. * Gets the number of facets in the mesh
  36547. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36548. */
  36549. get facetNb(): number;
  36550. /**
  36551. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36552. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36553. */
  36554. get partitioningSubdivisions(): number;
  36555. set partitioningSubdivisions(nb: number);
  36556. /**
  36557. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36558. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36559. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36560. */
  36561. get partitioningBBoxRatio(): number;
  36562. set partitioningBBoxRatio(ratio: number);
  36563. /**
  36564. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36565. * Works only for updatable meshes.
  36566. * Doesn't work with multi-materials
  36567. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36568. */
  36569. get mustDepthSortFacets(): boolean;
  36570. set mustDepthSortFacets(sort: boolean);
  36571. /**
  36572. * The location (Vector3) where the facet depth sort must be computed from.
  36573. * By default, the active camera position.
  36574. * Used only when facet depth sort is enabled
  36575. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36576. */
  36577. get facetDepthSortFrom(): Vector3;
  36578. set facetDepthSortFrom(location: Vector3);
  36579. /**
  36580. * gets a boolean indicating if facetData is enabled
  36581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36582. */
  36583. get isFacetDataEnabled(): boolean;
  36584. /** @hidden */
  36585. _updateNonUniformScalingState(value: boolean): boolean;
  36586. /**
  36587. * An event triggered when this mesh collides with another one
  36588. */
  36589. onCollideObservable: Observable<AbstractMesh>;
  36590. /** Set a function to call when this mesh collides with another one */
  36591. set onCollide(callback: () => void);
  36592. /**
  36593. * An event triggered when the collision's position changes
  36594. */
  36595. onCollisionPositionChangeObservable: Observable<Vector3>;
  36596. /** Set a function to call when the collision's position changes */
  36597. set onCollisionPositionChange(callback: () => void);
  36598. /**
  36599. * An event triggered when material is changed
  36600. */
  36601. onMaterialChangedObservable: Observable<AbstractMesh>;
  36602. /**
  36603. * Gets or sets the orientation for POV movement & rotation
  36604. */
  36605. definedFacingForward: boolean;
  36606. /** @hidden */
  36607. _occlusionQuery: Nullable<WebGLQuery>;
  36608. /** @hidden */
  36609. _renderingGroup: Nullable<RenderingGroup>;
  36610. /**
  36611. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36612. */
  36613. get visibility(): number;
  36614. /**
  36615. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36616. */
  36617. set visibility(value: number);
  36618. /** Gets or sets the alpha index used to sort transparent meshes
  36619. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36620. */
  36621. alphaIndex: number;
  36622. /**
  36623. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36624. */
  36625. isVisible: boolean;
  36626. /**
  36627. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36628. */
  36629. isPickable: boolean;
  36630. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36631. showSubMeshesBoundingBox: boolean;
  36632. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36633. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36634. */
  36635. isBlocker: boolean;
  36636. /**
  36637. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36638. */
  36639. enablePointerMoveEvents: boolean;
  36640. private _renderingGroupId;
  36641. /**
  36642. * Specifies the rendering group id for this mesh (0 by default)
  36643. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36644. */
  36645. get renderingGroupId(): number;
  36646. set renderingGroupId(value: number);
  36647. private _material;
  36648. /** Gets or sets current material */
  36649. get material(): Nullable<Material>;
  36650. set material(value: Nullable<Material>);
  36651. /**
  36652. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36653. * @see https://doc.babylonjs.com/babylon101/shadows
  36654. */
  36655. get receiveShadows(): boolean;
  36656. set receiveShadows(value: boolean);
  36657. /** Defines color to use when rendering outline */
  36658. outlineColor: Color3;
  36659. /** Define width to use when rendering outline */
  36660. outlineWidth: number;
  36661. /** Defines color to use when rendering overlay */
  36662. overlayColor: Color3;
  36663. /** Defines alpha to use when rendering overlay */
  36664. overlayAlpha: number;
  36665. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36666. get hasVertexAlpha(): boolean;
  36667. set hasVertexAlpha(value: boolean);
  36668. /** 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) */
  36669. get useVertexColors(): boolean;
  36670. set useVertexColors(value: boolean);
  36671. /**
  36672. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36673. */
  36674. get computeBonesUsingShaders(): boolean;
  36675. set computeBonesUsingShaders(value: boolean);
  36676. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36677. get numBoneInfluencers(): number;
  36678. set numBoneInfluencers(value: number);
  36679. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36680. get applyFog(): boolean;
  36681. set applyFog(value: boolean);
  36682. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36683. useOctreeForRenderingSelection: boolean;
  36684. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36685. useOctreeForPicking: boolean;
  36686. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36687. useOctreeForCollisions: boolean;
  36688. /**
  36689. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36690. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36691. */
  36692. get layerMask(): number;
  36693. set layerMask(value: number);
  36694. /**
  36695. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36696. */
  36697. alwaysSelectAsActiveMesh: boolean;
  36698. /**
  36699. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36700. */
  36701. doNotSyncBoundingInfo: boolean;
  36702. /**
  36703. * Gets or sets the current action manager
  36704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36705. */
  36706. actionManager: Nullable<AbstractActionManager>;
  36707. private _meshCollisionData;
  36708. /**
  36709. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36711. */
  36712. ellipsoid: Vector3;
  36713. /**
  36714. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36715. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36716. */
  36717. ellipsoidOffset: Vector3;
  36718. /**
  36719. * Gets or sets a collision mask used to mask collisions (default is -1).
  36720. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36721. */
  36722. get collisionMask(): number;
  36723. set collisionMask(mask: number);
  36724. /**
  36725. * Gets or sets a collision response flag (default is true).
  36726. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36727. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36728. * to respond to the collision.
  36729. */
  36730. get collisionResponse(): boolean;
  36731. set collisionResponse(response: boolean);
  36732. /**
  36733. * Gets or sets the current collision group mask (-1 by default).
  36734. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36735. */
  36736. get collisionGroup(): number;
  36737. set collisionGroup(mask: number);
  36738. /**
  36739. * Gets or sets current surrounding meshes (null by default).
  36740. *
  36741. * By default collision detection is tested against every mesh in the scene.
  36742. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36743. * meshes will be tested for the collision.
  36744. *
  36745. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36746. */
  36747. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36748. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36749. /**
  36750. * Defines edge width used when edgesRenderer is enabled
  36751. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36752. */
  36753. edgesWidth: number;
  36754. /**
  36755. * Defines edge color used when edgesRenderer is enabled
  36756. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36757. */
  36758. edgesColor: Color4;
  36759. /** @hidden */
  36760. _edgesRenderer: Nullable<IEdgesRenderer>;
  36761. /** @hidden */
  36762. _masterMesh: Nullable<AbstractMesh>;
  36763. /** @hidden */
  36764. _boundingInfo: Nullable<BoundingInfo>;
  36765. /** @hidden */
  36766. _renderId: number;
  36767. /**
  36768. * Gets or sets the list of subMeshes
  36769. * @see https://doc.babylonjs.com/how_to/multi_materials
  36770. */
  36771. subMeshes: SubMesh[];
  36772. /** @hidden */
  36773. _intersectionsInProgress: AbstractMesh[];
  36774. /** @hidden */
  36775. _unIndexed: boolean;
  36776. /** @hidden */
  36777. _lightSources: Light[];
  36778. /** Gets the list of lights affecting that mesh */
  36779. get lightSources(): Light[];
  36780. /** @hidden */
  36781. get _positions(): Nullable<Vector3[]>;
  36782. /** @hidden */
  36783. _waitingData: {
  36784. lods: Nullable<any>;
  36785. actions: Nullable<any>;
  36786. freezeWorldMatrix: Nullable<boolean>;
  36787. };
  36788. /** @hidden */
  36789. _bonesTransformMatrices: Nullable<Float32Array>;
  36790. /** @hidden */
  36791. _transformMatrixTexture: Nullable<RawTexture>;
  36792. /**
  36793. * Gets or sets a skeleton to apply skining transformations
  36794. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36795. */
  36796. set skeleton(value: Nullable<Skeleton>);
  36797. get skeleton(): Nullable<Skeleton>;
  36798. /**
  36799. * An event triggered when the mesh is rebuilt.
  36800. */
  36801. onRebuildObservable: Observable<AbstractMesh>;
  36802. /**
  36803. * Creates a new AbstractMesh
  36804. * @param name defines the name of the mesh
  36805. * @param scene defines the hosting scene
  36806. */
  36807. constructor(name: string, scene?: Nullable<Scene>);
  36808. /**
  36809. * Returns the string "AbstractMesh"
  36810. * @returns "AbstractMesh"
  36811. */
  36812. getClassName(): string;
  36813. /**
  36814. * Gets a string representation of the current mesh
  36815. * @param fullDetails defines a boolean indicating if full details must be included
  36816. * @returns a string representation of the current mesh
  36817. */
  36818. toString(fullDetails?: boolean): string;
  36819. /**
  36820. * @hidden
  36821. */
  36822. protected _getEffectiveParent(): Nullable<Node>;
  36823. /** @hidden */
  36824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36825. /** @hidden */
  36826. _rebuild(): void;
  36827. /** @hidden */
  36828. _resyncLightSources(): void;
  36829. /** @hidden */
  36830. _resyncLightSource(light: Light): void;
  36831. /** @hidden */
  36832. _unBindEffect(): void;
  36833. /** @hidden */
  36834. _removeLightSource(light: Light, dispose: boolean): void;
  36835. private _markSubMeshesAsDirty;
  36836. /** @hidden */
  36837. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36838. /** @hidden */
  36839. _markSubMeshesAsAttributesDirty(): void;
  36840. /** @hidden */
  36841. _markSubMeshesAsMiscDirty(): void;
  36842. /**
  36843. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36844. */
  36845. get scaling(): Vector3;
  36846. set scaling(newScaling: Vector3);
  36847. /**
  36848. * Returns true if the mesh is blocked. Implemented by child classes
  36849. */
  36850. get isBlocked(): boolean;
  36851. /**
  36852. * Returns the mesh itself by default. Implemented by child classes
  36853. * @param camera defines the camera to use to pick the right LOD level
  36854. * @returns the currentAbstractMesh
  36855. */
  36856. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36857. /**
  36858. * Returns 0 by default. Implemented by child classes
  36859. * @returns an integer
  36860. */
  36861. getTotalVertices(): number;
  36862. /**
  36863. * Returns a positive integer : the total number of indices in this mesh geometry.
  36864. * @returns the numner of indices or zero if the mesh has no geometry.
  36865. */
  36866. getTotalIndices(): number;
  36867. /**
  36868. * Returns null by default. Implemented by child classes
  36869. * @returns null
  36870. */
  36871. getIndices(): Nullable<IndicesArray>;
  36872. /**
  36873. * Returns the array of the requested vertex data kind. Implemented by child classes
  36874. * @param kind defines the vertex data kind to use
  36875. * @returns null
  36876. */
  36877. getVerticesData(kind: string): Nullable<FloatArray>;
  36878. /**
  36879. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36880. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36881. * Note that a new underlying VertexBuffer object is created each call.
  36882. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36883. * @param kind defines vertex data kind:
  36884. * * VertexBuffer.PositionKind
  36885. * * VertexBuffer.UVKind
  36886. * * VertexBuffer.UV2Kind
  36887. * * VertexBuffer.UV3Kind
  36888. * * VertexBuffer.UV4Kind
  36889. * * VertexBuffer.UV5Kind
  36890. * * VertexBuffer.UV6Kind
  36891. * * VertexBuffer.ColorKind
  36892. * * VertexBuffer.MatricesIndicesKind
  36893. * * VertexBuffer.MatricesIndicesExtraKind
  36894. * * VertexBuffer.MatricesWeightsKind
  36895. * * VertexBuffer.MatricesWeightsExtraKind
  36896. * @param data defines the data source
  36897. * @param updatable defines if the data must be flagged as updatable (or static)
  36898. * @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
  36899. * @returns the current mesh
  36900. */
  36901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36902. /**
  36903. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36904. * If the mesh has no geometry, it is simply returned as it is.
  36905. * @param kind defines vertex data kind:
  36906. * * VertexBuffer.PositionKind
  36907. * * VertexBuffer.UVKind
  36908. * * VertexBuffer.UV2Kind
  36909. * * VertexBuffer.UV3Kind
  36910. * * VertexBuffer.UV4Kind
  36911. * * VertexBuffer.UV5Kind
  36912. * * VertexBuffer.UV6Kind
  36913. * * VertexBuffer.ColorKind
  36914. * * VertexBuffer.MatricesIndicesKind
  36915. * * VertexBuffer.MatricesIndicesExtraKind
  36916. * * VertexBuffer.MatricesWeightsKind
  36917. * * VertexBuffer.MatricesWeightsExtraKind
  36918. * @param data defines the data source
  36919. * @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
  36920. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36921. * @returns the current mesh
  36922. */
  36923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36924. /**
  36925. * Sets the mesh indices,
  36926. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36927. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36928. * @param totalVertices Defines the total number of vertices
  36929. * @returns the current mesh
  36930. */
  36931. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36932. /**
  36933. * Gets a boolean indicating if specific vertex data is present
  36934. * @param kind defines the vertex data kind to use
  36935. * @returns true is data kind is present
  36936. */
  36937. isVerticesDataPresent(kind: string): boolean;
  36938. /**
  36939. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36940. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36941. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36942. * @returns a BoundingInfo
  36943. */
  36944. getBoundingInfo(): BoundingInfo;
  36945. /**
  36946. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36947. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36948. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36949. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36950. * @returns the current mesh
  36951. */
  36952. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36953. /**
  36954. * Overwrite the current bounding info
  36955. * @param boundingInfo defines the new bounding info
  36956. * @returns the current mesh
  36957. */
  36958. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36959. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36960. get useBones(): boolean;
  36961. /** @hidden */
  36962. _preActivate(): void;
  36963. /** @hidden */
  36964. _preActivateForIntermediateRendering(renderId: number): void;
  36965. /** @hidden */
  36966. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36967. /** @hidden */
  36968. _postActivate(): void;
  36969. /** @hidden */
  36970. _freeze(): void;
  36971. /** @hidden */
  36972. _unFreeze(): void;
  36973. /**
  36974. * Gets the current world matrix
  36975. * @returns a Matrix
  36976. */
  36977. getWorldMatrix(): Matrix;
  36978. /** @hidden */
  36979. _getWorldMatrixDeterminant(): number;
  36980. /**
  36981. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36982. */
  36983. get isAnInstance(): boolean;
  36984. /**
  36985. * Gets a boolean indicating if this mesh has instances
  36986. */
  36987. get hasInstances(): boolean;
  36988. /**
  36989. * Gets a boolean indicating if this mesh has thin instances
  36990. */
  36991. get hasThinInstances(): boolean;
  36992. /**
  36993. * Perform relative position change from the point of view of behind the front of the mesh.
  36994. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36995. * Supports definition of mesh facing forward or backward
  36996. * @param amountRight defines the distance on the right axis
  36997. * @param amountUp defines the distance on the up axis
  36998. * @param amountForward defines the distance on the forward axis
  36999. * @returns the current mesh
  37000. */
  37001. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37002. /**
  37003. * Calculate relative position change from the point of view of behind the front of the mesh.
  37004. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37005. * Supports definition of mesh facing forward or backward
  37006. * @param amountRight defines the distance on the right axis
  37007. * @param amountUp defines the distance on the up axis
  37008. * @param amountForward defines the distance on the forward axis
  37009. * @returns the new displacement vector
  37010. */
  37011. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37012. /**
  37013. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37014. * Supports definition of mesh facing forward or backward
  37015. * @param flipBack defines the flip
  37016. * @param twirlClockwise defines the twirl
  37017. * @param tiltRight defines the tilt
  37018. * @returns the current mesh
  37019. */
  37020. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37021. /**
  37022. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37023. * Supports definition of mesh facing forward or backward.
  37024. * @param flipBack defines the flip
  37025. * @param twirlClockwise defines the twirl
  37026. * @param tiltRight defines the tilt
  37027. * @returns the new rotation vector
  37028. */
  37029. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37030. /**
  37031. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37032. * This means the mesh underlying bounding box and sphere are recomputed.
  37033. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37034. * @returns the current mesh
  37035. */
  37036. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37037. /** @hidden */
  37038. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37039. /** @hidden */
  37040. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37041. /** @hidden */
  37042. _updateBoundingInfo(): AbstractMesh;
  37043. /** @hidden */
  37044. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37045. /** @hidden */
  37046. protected _afterComputeWorldMatrix(): void;
  37047. /** @hidden */
  37048. get _effectiveMesh(): AbstractMesh;
  37049. /**
  37050. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37051. * A mesh is in the frustum if its bounding box intersects the frustum
  37052. * @param frustumPlanes defines the frustum to test
  37053. * @returns true if the mesh is in the frustum planes
  37054. */
  37055. isInFrustum(frustumPlanes: Plane[]): boolean;
  37056. /**
  37057. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37058. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37059. * @param frustumPlanes defines the frustum to test
  37060. * @returns true if the mesh is completely in the frustum planes
  37061. */
  37062. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37063. /**
  37064. * True if the mesh intersects another mesh or a SolidParticle object
  37065. * @param mesh defines a target mesh or SolidParticle to test
  37066. * @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)
  37067. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37068. * @returns true if there is an intersection
  37069. */
  37070. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37071. /**
  37072. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37073. * @param point defines the point to test
  37074. * @returns true if there is an intersection
  37075. */
  37076. intersectsPoint(point: Vector3): boolean;
  37077. /**
  37078. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37079. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37080. */
  37081. get checkCollisions(): boolean;
  37082. set checkCollisions(collisionEnabled: boolean);
  37083. /**
  37084. * Gets Collider object used to compute collisions (not physics)
  37085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37086. */
  37087. get collider(): Nullable<Collider>;
  37088. /**
  37089. * Move the mesh using collision engine
  37090. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37091. * @param displacement defines the requested displacement vector
  37092. * @returns the current mesh
  37093. */
  37094. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37095. private _onCollisionPositionChange;
  37096. /** @hidden */
  37097. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37098. /** @hidden */
  37099. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37100. /** @hidden */
  37101. _checkCollision(collider: Collider): AbstractMesh;
  37102. /** @hidden */
  37103. _generatePointsArray(): boolean;
  37104. /**
  37105. * Checks if the passed Ray intersects with the mesh
  37106. * @param ray defines the ray to use
  37107. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37109. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37110. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37111. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37112. * @returns the picking info
  37113. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37114. */
  37115. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37116. /**
  37117. * Clones the current mesh
  37118. * @param name defines the mesh name
  37119. * @param newParent defines the new mesh parent
  37120. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37121. * @returns the new mesh
  37122. */
  37123. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37124. /**
  37125. * Disposes all the submeshes of the current meshnp
  37126. * @returns the current mesh
  37127. */
  37128. releaseSubMeshes(): AbstractMesh;
  37129. /**
  37130. * Releases resources associated with this abstract mesh.
  37131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37133. */
  37134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37135. /**
  37136. * Adds the passed mesh as a child to the current mesh
  37137. * @param mesh defines the child mesh
  37138. * @returns the current mesh
  37139. */
  37140. addChild(mesh: AbstractMesh): AbstractMesh;
  37141. /**
  37142. * Removes the passed mesh from the current mesh children list
  37143. * @param mesh defines the child mesh
  37144. * @returns the current mesh
  37145. */
  37146. removeChild(mesh: AbstractMesh): AbstractMesh;
  37147. /** @hidden */
  37148. private _initFacetData;
  37149. /**
  37150. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37151. * This method can be called within the render loop.
  37152. * 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
  37153. * @returns the current mesh
  37154. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37155. */
  37156. updateFacetData(): AbstractMesh;
  37157. /**
  37158. * Returns the facetLocalNormals array.
  37159. * The normals are expressed in the mesh local spac
  37160. * @returns an array of Vector3
  37161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37162. */
  37163. getFacetLocalNormals(): Vector3[];
  37164. /**
  37165. * Returns the facetLocalPositions array.
  37166. * The facet positions are expressed in the mesh local space
  37167. * @returns an array of Vector3
  37168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37169. */
  37170. getFacetLocalPositions(): Vector3[];
  37171. /**
  37172. * Returns the facetLocalPartioning array
  37173. * @returns an array of array of numbers
  37174. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37175. */
  37176. getFacetLocalPartitioning(): number[][];
  37177. /**
  37178. * Returns the i-th facet position in the world system.
  37179. * This method allocates a new Vector3 per call
  37180. * @param i defines the facet index
  37181. * @returns a new Vector3
  37182. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37183. */
  37184. getFacetPosition(i: number): Vector3;
  37185. /**
  37186. * Sets the reference Vector3 with the i-th facet position in the world system
  37187. * @param i defines the facet index
  37188. * @param ref defines the target vector
  37189. * @returns the current mesh
  37190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37191. */
  37192. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37193. /**
  37194. * Returns the i-th facet normal in the world system.
  37195. * This method allocates a new Vector3 per call
  37196. * @param i defines the facet index
  37197. * @returns a new Vector3
  37198. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37199. */
  37200. getFacetNormal(i: number): Vector3;
  37201. /**
  37202. * Sets the reference Vector3 with the i-th facet normal in the world system
  37203. * @param i defines the facet index
  37204. * @param ref defines the target vector
  37205. * @returns the current mesh
  37206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37207. */
  37208. getFacetNormalToRef(i: number, ref: Vector3): this;
  37209. /**
  37210. * 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)
  37211. * @param x defines x coordinate
  37212. * @param y defines y coordinate
  37213. * @param z defines z coordinate
  37214. * @returns the array of facet indexes
  37215. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37216. */
  37217. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37218. /**
  37219. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37220. * @param projected sets as the (x,y,z) world projection on the facet
  37221. * @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
  37222. * @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
  37223. * @param x defines x coordinate
  37224. * @param y defines y coordinate
  37225. * @param z defines z coordinate
  37226. * @returns the face index if found (or null instead)
  37227. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37228. */
  37229. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37230. /**
  37231. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37232. * @param projected sets as the (x,y,z) local projection on the facet
  37233. * @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
  37234. * @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
  37235. * @param x defines x coordinate
  37236. * @param y defines y coordinate
  37237. * @param z defines z coordinate
  37238. * @returns the face index if found (or null instead)
  37239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37240. */
  37241. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37242. /**
  37243. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37244. * @returns the parameters
  37245. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37246. */
  37247. getFacetDataParameters(): any;
  37248. /**
  37249. * Disables the feature FacetData and frees the related memory
  37250. * @returns the current mesh
  37251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37252. */
  37253. disableFacetData(): AbstractMesh;
  37254. /**
  37255. * Updates the AbstractMesh indices array
  37256. * @param indices defines the data source
  37257. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37258. * @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)
  37259. * @returns the current mesh
  37260. */
  37261. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37262. /**
  37263. * Creates new normals data for the mesh
  37264. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37265. * @returns the current mesh
  37266. */
  37267. createNormals(updatable: boolean): AbstractMesh;
  37268. /**
  37269. * Align the mesh with a normal
  37270. * @param normal defines the normal to use
  37271. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37272. * @returns the current mesh
  37273. */
  37274. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37275. /** @hidden */
  37276. _checkOcclusionQuery(): boolean;
  37277. /**
  37278. * Disables the mesh edge rendering mode
  37279. * @returns the currentAbstractMesh
  37280. */
  37281. disableEdgesRendering(): AbstractMesh;
  37282. /**
  37283. * Enables the edge rendering mode on the mesh.
  37284. * This mode makes the mesh edges visible
  37285. * @param epsilon defines the maximal distance between two angles to detect a face
  37286. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37287. * @param options options to the edge renderer
  37288. * @returns the currentAbstractMesh
  37289. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37290. */
  37291. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37292. /**
  37293. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37294. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37295. */
  37296. getConnectedParticleSystems(): IParticleSystem[];
  37297. }
  37298. }
  37299. declare module "babylonjs/Actions/actionEvent" {
  37300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37301. import { Nullable } from "babylonjs/types";
  37302. import { Sprite } from "babylonjs/Sprites/sprite";
  37303. import { Scene } from "babylonjs/scene";
  37304. import { Vector2 } from "babylonjs/Maths/math.vector";
  37305. /**
  37306. * Interface used to define ActionEvent
  37307. */
  37308. export interface IActionEvent {
  37309. /** The mesh or sprite that triggered the action */
  37310. source: any;
  37311. /** The X mouse cursor position at the time of the event */
  37312. pointerX: number;
  37313. /** The Y mouse cursor position at the time of the event */
  37314. pointerY: number;
  37315. /** The mesh that is currently pointed at (can be null) */
  37316. meshUnderPointer: Nullable<AbstractMesh>;
  37317. /** the original (browser) event that triggered the ActionEvent */
  37318. sourceEvent?: any;
  37319. /** additional data for the event */
  37320. additionalData?: any;
  37321. }
  37322. /**
  37323. * ActionEvent is the event being sent when an action is triggered.
  37324. */
  37325. export class ActionEvent implements IActionEvent {
  37326. /** The mesh or sprite that triggered the action */
  37327. source: any;
  37328. /** The X mouse cursor position at the time of the event */
  37329. pointerX: number;
  37330. /** The Y mouse cursor position at the time of the event */
  37331. pointerY: number;
  37332. /** The mesh that is currently pointed at (can be null) */
  37333. meshUnderPointer: Nullable<AbstractMesh>;
  37334. /** the original (browser) event that triggered the ActionEvent */
  37335. sourceEvent?: any;
  37336. /** additional data for the event */
  37337. additionalData?: any;
  37338. /**
  37339. * Creates a new ActionEvent
  37340. * @param source The mesh or sprite that triggered the action
  37341. * @param pointerX The X mouse cursor position at the time of the event
  37342. * @param pointerY The Y mouse cursor position at the time of the event
  37343. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37344. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37345. * @param additionalData additional data for the event
  37346. */
  37347. constructor(
  37348. /** The mesh or sprite that triggered the action */
  37349. source: any,
  37350. /** The X mouse cursor position at the time of the event */
  37351. pointerX: number,
  37352. /** The Y mouse cursor position at the time of the event */
  37353. pointerY: number,
  37354. /** The mesh that is currently pointed at (can be null) */
  37355. meshUnderPointer: Nullable<AbstractMesh>,
  37356. /** the original (browser) event that triggered the ActionEvent */
  37357. sourceEvent?: any,
  37358. /** additional data for the event */
  37359. additionalData?: any);
  37360. /**
  37361. * Helper function to auto-create an ActionEvent from a source mesh.
  37362. * @param source The source mesh that triggered the event
  37363. * @param evt The original (browser) event
  37364. * @param additionalData additional data for the event
  37365. * @returns the new ActionEvent
  37366. */
  37367. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37368. /**
  37369. * Helper function to auto-create an ActionEvent from a source sprite
  37370. * @param source The source sprite that triggered the event
  37371. * @param scene Scene associated with the sprite
  37372. * @param evt The original (browser) event
  37373. * @param additionalData additional data for the event
  37374. * @returns the new ActionEvent
  37375. */
  37376. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37377. /**
  37378. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37379. * @param scene the scene where the event occurred
  37380. * @param evt The original (browser) event
  37381. * @returns the new ActionEvent
  37382. */
  37383. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37384. /**
  37385. * Helper function to auto-create an ActionEvent from a primitive
  37386. * @param prim defines the target primitive
  37387. * @param pointerPos defines the pointer position
  37388. * @param evt The original (browser) event
  37389. * @param additionalData additional data for the event
  37390. * @returns the new ActionEvent
  37391. */
  37392. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37393. }
  37394. }
  37395. declare module "babylonjs/Actions/abstractActionManager" {
  37396. import { IDisposable } from "babylonjs/scene";
  37397. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37398. import { IAction } from "babylonjs/Actions/action";
  37399. import { Nullable } from "babylonjs/types";
  37400. /**
  37401. * Abstract class used to decouple action Manager from scene and meshes.
  37402. * Do not instantiate.
  37403. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37404. */
  37405. export abstract class AbstractActionManager implements IDisposable {
  37406. /** Gets the list of active triggers */
  37407. static Triggers: {
  37408. [key: string]: number;
  37409. };
  37410. /** Gets the cursor to use when hovering items */
  37411. hoverCursor: string;
  37412. /** Gets the list of actions */
  37413. actions: IAction[];
  37414. /**
  37415. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37416. */
  37417. isRecursive: boolean;
  37418. /**
  37419. * Releases all associated resources
  37420. */
  37421. abstract dispose(): void;
  37422. /**
  37423. * Does this action manager has pointer triggers
  37424. */
  37425. abstract get hasPointerTriggers(): boolean;
  37426. /**
  37427. * Does this action manager has pick triggers
  37428. */
  37429. abstract get hasPickTriggers(): boolean;
  37430. /**
  37431. * Process a specific trigger
  37432. * @param trigger defines the trigger to process
  37433. * @param evt defines the event details to be processed
  37434. */
  37435. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37436. /**
  37437. * Does this action manager handles actions of any of the given triggers
  37438. * @param triggers defines the triggers to be tested
  37439. * @return a boolean indicating whether one (or more) of the triggers is handled
  37440. */
  37441. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37442. /**
  37443. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37444. * speed.
  37445. * @param triggerA defines the trigger to be tested
  37446. * @param triggerB defines the trigger to be tested
  37447. * @return a boolean indicating whether one (or more) of the triggers is handled
  37448. */
  37449. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37450. /**
  37451. * Does this action manager handles actions of a given trigger
  37452. * @param trigger defines the trigger to be tested
  37453. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37454. * @return whether the trigger is handled
  37455. */
  37456. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37457. /**
  37458. * Serialize this manager to a JSON object
  37459. * @param name defines the property name to store this manager
  37460. * @returns a JSON representation of this manager
  37461. */
  37462. abstract serialize(name: string): any;
  37463. /**
  37464. * Registers an action to this action manager
  37465. * @param action defines the action to be registered
  37466. * @return the action amended (prepared) after registration
  37467. */
  37468. abstract registerAction(action: IAction): Nullable<IAction>;
  37469. /**
  37470. * Unregisters an action to this action manager
  37471. * @param action defines the action to be unregistered
  37472. * @return a boolean indicating whether the action has been unregistered
  37473. */
  37474. abstract unregisterAction(action: IAction): Boolean;
  37475. /**
  37476. * Does exist one action manager with at least one trigger
  37477. **/
  37478. static get HasTriggers(): boolean;
  37479. /**
  37480. * Does exist one action manager with at least one pick trigger
  37481. **/
  37482. static get HasPickTriggers(): boolean;
  37483. /**
  37484. * Does exist one action manager that handles actions of a given trigger
  37485. * @param trigger defines the trigger to be tested
  37486. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37487. **/
  37488. static HasSpecificTrigger(trigger: number): boolean;
  37489. }
  37490. }
  37491. declare module "babylonjs/node" {
  37492. import { Scene } from "babylonjs/scene";
  37493. import { Nullable } from "babylonjs/types";
  37494. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37495. import { Engine } from "babylonjs/Engines/engine";
  37496. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37497. import { Observable } from "babylonjs/Misc/observable";
  37498. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37500. import { Animatable } from "babylonjs/Animations/animatable";
  37501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37502. import { Animation } from "babylonjs/Animations/animation";
  37503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37505. /**
  37506. * Defines how a node can be built from a string name.
  37507. */
  37508. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37509. /**
  37510. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37511. */
  37512. export class Node implements IBehaviorAware<Node> {
  37513. /** @hidden */
  37514. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37515. private static _NodeConstructors;
  37516. /**
  37517. * Add a new node constructor
  37518. * @param type defines the type name of the node to construct
  37519. * @param constructorFunc defines the constructor function
  37520. */
  37521. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37522. /**
  37523. * Returns a node constructor based on type name
  37524. * @param type defines the type name
  37525. * @param name defines the new node name
  37526. * @param scene defines the hosting scene
  37527. * @param options defines optional options to transmit to constructors
  37528. * @returns the new constructor or null
  37529. */
  37530. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37531. /**
  37532. * Gets or sets the name of the node
  37533. */
  37534. name: string;
  37535. /**
  37536. * Gets or sets the id of the node
  37537. */
  37538. id: string;
  37539. /**
  37540. * Gets or sets the unique id of the node
  37541. */
  37542. uniqueId: number;
  37543. /**
  37544. * Gets or sets a string used to store user defined state for the node
  37545. */
  37546. state: string;
  37547. /**
  37548. * Gets or sets an object used to store user defined information for the node
  37549. */
  37550. metadata: any;
  37551. /**
  37552. * For internal use only. Please do not use.
  37553. */
  37554. reservedDataStore: any;
  37555. /**
  37556. * List of inspectable custom properties (used by the Inspector)
  37557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37558. */
  37559. inspectableCustomProperties: IInspectable[];
  37560. private _doNotSerialize;
  37561. /**
  37562. * Gets or sets a boolean used to define if the node must be serialized
  37563. */
  37564. get doNotSerialize(): boolean;
  37565. set doNotSerialize(value: boolean);
  37566. /** @hidden */
  37567. _isDisposed: boolean;
  37568. /**
  37569. * Gets a list of Animations associated with the node
  37570. */
  37571. animations: import("babylonjs/Animations/animation").Animation[];
  37572. protected _ranges: {
  37573. [name: string]: Nullable<AnimationRange>;
  37574. };
  37575. /**
  37576. * Callback raised when the node is ready to be used
  37577. */
  37578. onReady: Nullable<(node: Node) => void>;
  37579. private _isEnabled;
  37580. private _isParentEnabled;
  37581. private _isReady;
  37582. /** @hidden */
  37583. _currentRenderId: number;
  37584. private _parentUpdateId;
  37585. /** @hidden */
  37586. _childUpdateId: number;
  37587. /** @hidden */
  37588. _waitingParentId: Nullable<string>;
  37589. /** @hidden */
  37590. _scene: Scene;
  37591. /** @hidden */
  37592. _cache: any;
  37593. private _parentNode;
  37594. private _children;
  37595. /** @hidden */
  37596. _worldMatrix: Matrix;
  37597. /** @hidden */
  37598. _worldMatrixDeterminant: number;
  37599. /** @hidden */
  37600. _worldMatrixDeterminantIsDirty: boolean;
  37601. /** @hidden */
  37602. private _sceneRootNodesIndex;
  37603. /**
  37604. * Gets a boolean indicating if the node has been disposed
  37605. * @returns true if the node was disposed
  37606. */
  37607. isDisposed(): boolean;
  37608. /**
  37609. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37610. * @see https://doc.babylonjs.com/how_to/parenting
  37611. */
  37612. set parent(parent: Nullable<Node>);
  37613. get parent(): Nullable<Node>;
  37614. /** @hidden */
  37615. _addToSceneRootNodes(): void;
  37616. /** @hidden */
  37617. _removeFromSceneRootNodes(): void;
  37618. private _animationPropertiesOverride;
  37619. /**
  37620. * Gets or sets the animation properties override
  37621. */
  37622. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37623. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37624. /**
  37625. * Gets a string identifying the name of the class
  37626. * @returns "Node" string
  37627. */
  37628. getClassName(): string;
  37629. /** @hidden */
  37630. readonly _isNode: boolean;
  37631. /**
  37632. * An event triggered when the mesh is disposed
  37633. */
  37634. onDisposeObservable: Observable<Node>;
  37635. private _onDisposeObserver;
  37636. /**
  37637. * Sets a callback that will be raised when the node will be disposed
  37638. */
  37639. set onDispose(callback: () => void);
  37640. /**
  37641. * Creates a new Node
  37642. * @param name the name and id to be given to this node
  37643. * @param scene the scene this node will be added to
  37644. */
  37645. constructor(name: string, scene?: Nullable<Scene>);
  37646. /**
  37647. * Gets the scene of the node
  37648. * @returns a scene
  37649. */
  37650. getScene(): Scene;
  37651. /**
  37652. * Gets the engine of the node
  37653. * @returns a Engine
  37654. */
  37655. getEngine(): Engine;
  37656. private _behaviors;
  37657. /**
  37658. * Attach a behavior to the node
  37659. * @see https://doc.babylonjs.com/features/behaviour
  37660. * @param behavior defines the behavior to attach
  37661. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37662. * @returns the current Node
  37663. */
  37664. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37665. /**
  37666. * Remove an attached behavior
  37667. * @see https://doc.babylonjs.com/features/behaviour
  37668. * @param behavior defines the behavior to attach
  37669. * @returns the current Node
  37670. */
  37671. removeBehavior(behavior: Behavior<Node>): Node;
  37672. /**
  37673. * Gets the list of attached behaviors
  37674. * @see https://doc.babylonjs.com/features/behaviour
  37675. */
  37676. get behaviors(): Behavior<Node>[];
  37677. /**
  37678. * Gets an attached behavior by name
  37679. * @param name defines the name of the behavior to look for
  37680. * @see https://doc.babylonjs.com/features/behaviour
  37681. * @returns null if behavior was not found else the requested behavior
  37682. */
  37683. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37684. /**
  37685. * Returns the latest update of the World matrix
  37686. * @returns a Matrix
  37687. */
  37688. getWorldMatrix(): Matrix;
  37689. /** @hidden */
  37690. _getWorldMatrixDeterminant(): number;
  37691. /**
  37692. * Returns directly the latest state of the mesh World matrix.
  37693. * A Matrix is returned.
  37694. */
  37695. get worldMatrixFromCache(): Matrix;
  37696. /** @hidden */
  37697. _initCache(): void;
  37698. /** @hidden */
  37699. updateCache(force?: boolean): void;
  37700. /** @hidden */
  37701. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37702. /** @hidden */
  37703. _updateCache(ignoreParentClass?: boolean): void;
  37704. /** @hidden */
  37705. _isSynchronized(): boolean;
  37706. /** @hidden */
  37707. _markSyncedWithParent(): void;
  37708. /** @hidden */
  37709. isSynchronizedWithParent(): boolean;
  37710. /** @hidden */
  37711. isSynchronized(): boolean;
  37712. /**
  37713. * Is this node ready to be used/rendered
  37714. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37715. * @return true if the node is ready
  37716. */
  37717. isReady(completeCheck?: boolean): boolean;
  37718. /**
  37719. * Is this node enabled?
  37720. * 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
  37721. * @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
  37722. * @return whether this node (and its parent) is enabled
  37723. */
  37724. isEnabled(checkAncestors?: boolean): boolean;
  37725. /** @hidden */
  37726. protected _syncParentEnabledState(): void;
  37727. /**
  37728. * Set the enabled state of this node
  37729. * @param value defines the new enabled state
  37730. */
  37731. setEnabled(value: boolean): void;
  37732. /**
  37733. * Is this node a descendant of the given node?
  37734. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37735. * @param ancestor defines the parent node to inspect
  37736. * @returns a boolean indicating if this node is a descendant of the given node
  37737. */
  37738. isDescendantOf(ancestor: Node): boolean;
  37739. /** @hidden */
  37740. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37741. /**
  37742. * Will return all nodes that have this node as ascendant
  37743. * @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
  37744. * @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
  37745. * @return all children nodes of all types
  37746. */
  37747. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37748. /**
  37749. * Get all child-meshes of this node
  37750. * @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)
  37751. * @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
  37752. * @returns an array of AbstractMesh
  37753. */
  37754. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37755. /**
  37756. * Get all direct children of this node
  37757. * @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
  37758. * @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)
  37759. * @returns an array of Node
  37760. */
  37761. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37762. /** @hidden */
  37763. _setReady(state: boolean): void;
  37764. /**
  37765. * Get an animation by name
  37766. * @param name defines the name of the animation to look for
  37767. * @returns null if not found else the requested animation
  37768. */
  37769. getAnimationByName(name: string): Nullable<Animation>;
  37770. /**
  37771. * Creates an animation range for this node
  37772. * @param name defines the name of the range
  37773. * @param from defines the starting key
  37774. * @param to defines the end key
  37775. */
  37776. createAnimationRange(name: string, from: number, to: number): void;
  37777. /**
  37778. * Delete a specific animation range
  37779. * @param name defines the name of the range to delete
  37780. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37781. */
  37782. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37783. /**
  37784. * Get an animation range by name
  37785. * @param name defines the name of the animation range to look for
  37786. * @returns null if not found else the requested animation range
  37787. */
  37788. getAnimationRange(name: string): Nullable<AnimationRange>;
  37789. /**
  37790. * Gets the list of all animation ranges defined on this node
  37791. * @returns an array
  37792. */
  37793. getAnimationRanges(): Nullable<AnimationRange>[];
  37794. /**
  37795. * Will start the animation sequence
  37796. * @param name defines the range frames for animation sequence
  37797. * @param loop defines if the animation should loop (false by default)
  37798. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37799. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37800. * @returns the object created for this animation. If range does not exist, it will return null
  37801. */
  37802. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37803. /**
  37804. * Serialize animation ranges into a JSON compatible object
  37805. * @returns serialization object
  37806. */
  37807. serializeAnimationRanges(): any;
  37808. /**
  37809. * Computes the world matrix of the node
  37810. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37811. * @returns the world matrix
  37812. */
  37813. computeWorldMatrix(force?: boolean): Matrix;
  37814. /**
  37815. * Releases resources associated with this node.
  37816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37818. */
  37819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37820. /**
  37821. * Parse animation range data from a serialization object and store them into a given node
  37822. * @param node defines where to store the animation ranges
  37823. * @param parsedNode defines the serialization object to read data from
  37824. * @param scene defines the hosting scene
  37825. */
  37826. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37827. /**
  37828. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37829. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37830. * @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
  37831. * @returns the new bounding vectors
  37832. */
  37833. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37834. min: Vector3;
  37835. max: Vector3;
  37836. };
  37837. }
  37838. }
  37839. declare module "babylonjs/Animations/animation" {
  37840. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37841. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37842. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37843. import { Nullable } from "babylonjs/types";
  37844. import { Scene } from "babylonjs/scene";
  37845. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37846. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37847. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37848. import { Node } from "babylonjs/node";
  37849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37850. import { Size } from "babylonjs/Maths/math.size";
  37851. import { Animatable } from "babylonjs/Animations/animatable";
  37852. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37853. /**
  37854. * @hidden
  37855. */
  37856. export class _IAnimationState {
  37857. key: number;
  37858. repeatCount: number;
  37859. workValue?: any;
  37860. loopMode?: number;
  37861. offsetValue?: any;
  37862. highLimitValue?: any;
  37863. }
  37864. /**
  37865. * Class used to store any kind of animation
  37866. */
  37867. export class Animation {
  37868. /**Name of the animation */
  37869. name: string;
  37870. /**Property to animate */
  37871. targetProperty: string;
  37872. /**The frames per second of the animation */
  37873. framePerSecond: number;
  37874. /**The data type of the animation */
  37875. dataType: number;
  37876. /**The loop mode of the animation */
  37877. loopMode?: number | undefined;
  37878. /**Specifies if blending should be enabled */
  37879. enableBlending?: boolean | undefined;
  37880. /**
  37881. * Use matrix interpolation instead of using direct key value when animating matrices
  37882. */
  37883. static AllowMatricesInterpolation: boolean;
  37884. /**
  37885. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37886. */
  37887. static AllowMatrixDecomposeForInterpolation: boolean;
  37888. /** Define the Url to load snippets */
  37889. static SnippetUrl: string;
  37890. /** Snippet ID if the animation was created from the snippet server */
  37891. snippetId: string;
  37892. /**
  37893. * Stores the key frames of the animation
  37894. */
  37895. private _keys;
  37896. /**
  37897. * Stores the easing function of the animation
  37898. */
  37899. private _easingFunction;
  37900. /**
  37901. * @hidden Internal use only
  37902. */
  37903. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37904. /**
  37905. * The set of event that will be linked to this animation
  37906. */
  37907. private _events;
  37908. /**
  37909. * Stores an array of target property paths
  37910. */
  37911. targetPropertyPath: string[];
  37912. /**
  37913. * Stores the blending speed of the animation
  37914. */
  37915. blendingSpeed: number;
  37916. /**
  37917. * Stores the animation ranges for the animation
  37918. */
  37919. private _ranges;
  37920. /**
  37921. * @hidden Internal use
  37922. */
  37923. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37924. /**
  37925. * Sets up an animation
  37926. * @param property The property to animate
  37927. * @param animationType The animation type to apply
  37928. * @param framePerSecond The frames per second of the animation
  37929. * @param easingFunction The easing function used in the animation
  37930. * @returns The created animation
  37931. */
  37932. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37933. /**
  37934. * Create and start an animation on a node
  37935. * @param name defines the name of the global animation that will be run on all nodes
  37936. * @param node defines the root node where the animation will take place
  37937. * @param targetProperty defines property to animate
  37938. * @param framePerSecond defines the number of frame per second yo use
  37939. * @param totalFrame defines the number of frames in total
  37940. * @param from defines the initial value
  37941. * @param to defines the final value
  37942. * @param loopMode defines which loop mode you want to use (off by default)
  37943. * @param easingFunction defines the easing function to use (linear by default)
  37944. * @param onAnimationEnd defines the callback to call when animation end
  37945. * @returns the animatable created for this animation
  37946. */
  37947. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37948. /**
  37949. * Create and start an animation on a node and its descendants
  37950. * @param name defines the name of the global animation that will be run on all nodes
  37951. * @param node defines the root node where the animation will take place
  37952. * @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
  37953. * @param targetProperty defines property to animate
  37954. * @param framePerSecond defines the number of frame per second to use
  37955. * @param totalFrame defines the number of frames in total
  37956. * @param from defines the initial value
  37957. * @param to defines the final value
  37958. * @param loopMode defines which loop mode you want to use (off by default)
  37959. * @param easingFunction defines the easing function to use (linear by default)
  37960. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37961. * @returns the list of animatables created for all nodes
  37962. * @example https://www.babylonjs-playground.com/#MH0VLI
  37963. */
  37964. 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[]>;
  37965. /**
  37966. * Creates a new animation, merges it with the existing animations and starts it
  37967. * @param name Name of the animation
  37968. * @param node Node which contains the scene that begins the animations
  37969. * @param targetProperty Specifies which property to animate
  37970. * @param framePerSecond The frames per second of the animation
  37971. * @param totalFrame The total number of frames
  37972. * @param from The frame at the beginning of the animation
  37973. * @param to The frame at the end of the animation
  37974. * @param loopMode Specifies the loop mode of the animation
  37975. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37976. * @param onAnimationEnd Callback to run once the animation is complete
  37977. * @returns Nullable animation
  37978. */
  37979. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37980. /**
  37981. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37982. * @param sourceAnimation defines the Animation containing keyframes to convert
  37983. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37984. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37985. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37986. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37987. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37988. */
  37989. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37990. /**
  37991. * Transition property of an host to the target Value
  37992. * @param property The property to transition
  37993. * @param targetValue The target Value of the property
  37994. * @param host The object where the property to animate belongs
  37995. * @param scene Scene used to run the animation
  37996. * @param frameRate Framerate (in frame/s) to use
  37997. * @param transition The transition type we want to use
  37998. * @param duration The duration of the animation, in milliseconds
  37999. * @param onAnimationEnd Callback trigger at the end of the animation
  38000. * @returns Nullable animation
  38001. */
  38002. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38003. /**
  38004. * Return the array of runtime animations currently using this animation
  38005. */
  38006. get runtimeAnimations(): RuntimeAnimation[];
  38007. /**
  38008. * Specifies if any of the runtime animations are currently running
  38009. */
  38010. get hasRunningRuntimeAnimations(): boolean;
  38011. /**
  38012. * Initializes the animation
  38013. * @param name Name of the animation
  38014. * @param targetProperty Property to animate
  38015. * @param framePerSecond The frames per second of the animation
  38016. * @param dataType The data type of the animation
  38017. * @param loopMode The loop mode of the animation
  38018. * @param enableBlending Specifies if blending should be enabled
  38019. */
  38020. constructor(
  38021. /**Name of the animation */
  38022. name: string,
  38023. /**Property to animate */
  38024. targetProperty: string,
  38025. /**The frames per second of the animation */
  38026. framePerSecond: number,
  38027. /**The data type of the animation */
  38028. dataType: number,
  38029. /**The loop mode of the animation */
  38030. loopMode?: number | undefined,
  38031. /**Specifies if blending should be enabled */
  38032. enableBlending?: boolean | undefined);
  38033. /**
  38034. * Converts the animation to a string
  38035. * @param fullDetails support for multiple levels of logging within scene loading
  38036. * @returns String form of the animation
  38037. */
  38038. toString(fullDetails?: boolean): string;
  38039. /**
  38040. * Add an event to this animation
  38041. * @param event Event to add
  38042. */
  38043. addEvent(event: AnimationEvent): void;
  38044. /**
  38045. * Remove all events found at the given frame
  38046. * @param frame The frame to remove events from
  38047. */
  38048. removeEvents(frame: number): void;
  38049. /**
  38050. * Retrieves all the events from the animation
  38051. * @returns Events from the animation
  38052. */
  38053. getEvents(): AnimationEvent[];
  38054. /**
  38055. * Creates an animation range
  38056. * @param name Name of the animation range
  38057. * @param from Starting frame of the animation range
  38058. * @param to Ending frame of the animation
  38059. */
  38060. createRange(name: string, from: number, to: number): void;
  38061. /**
  38062. * Deletes an animation range by name
  38063. * @param name Name of the animation range to delete
  38064. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38065. */
  38066. deleteRange(name: string, deleteFrames?: boolean): void;
  38067. /**
  38068. * Gets the animation range by name, or null if not defined
  38069. * @param name Name of the animation range
  38070. * @returns Nullable animation range
  38071. */
  38072. getRange(name: string): Nullable<AnimationRange>;
  38073. /**
  38074. * Gets the key frames from the animation
  38075. * @returns The key frames of the animation
  38076. */
  38077. getKeys(): Array<IAnimationKey>;
  38078. /**
  38079. * Gets the highest frame rate of the animation
  38080. * @returns Highest frame rate of the animation
  38081. */
  38082. getHighestFrame(): number;
  38083. /**
  38084. * Gets the easing function of the animation
  38085. * @returns Easing function of the animation
  38086. */
  38087. getEasingFunction(): IEasingFunction;
  38088. /**
  38089. * Sets the easing function of the animation
  38090. * @param easingFunction A custom mathematical formula for animation
  38091. */
  38092. setEasingFunction(easingFunction: EasingFunction): void;
  38093. /**
  38094. * Interpolates a scalar linearly
  38095. * @param startValue Start value of the animation curve
  38096. * @param endValue End value of the animation curve
  38097. * @param gradient Scalar amount to interpolate
  38098. * @returns Interpolated scalar value
  38099. */
  38100. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38101. /**
  38102. * Interpolates a scalar cubically
  38103. * @param startValue Start value of the animation curve
  38104. * @param outTangent End tangent of the animation
  38105. * @param endValue End value of the animation curve
  38106. * @param inTangent Start tangent of the animation curve
  38107. * @param gradient Scalar amount to interpolate
  38108. * @returns Interpolated scalar value
  38109. */
  38110. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38111. /**
  38112. * Interpolates a quaternion using a spherical linear interpolation
  38113. * @param startValue Start value of the animation curve
  38114. * @param endValue End value of the animation curve
  38115. * @param gradient Scalar amount to interpolate
  38116. * @returns Interpolated quaternion value
  38117. */
  38118. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38119. /**
  38120. * Interpolates a quaternion cubically
  38121. * @param startValue Start value of the animation curve
  38122. * @param outTangent End tangent of the animation curve
  38123. * @param endValue End value of the animation curve
  38124. * @param inTangent Start tangent of the animation curve
  38125. * @param gradient Scalar amount to interpolate
  38126. * @returns Interpolated quaternion value
  38127. */
  38128. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38129. /**
  38130. * Interpolates a Vector3 linearl
  38131. * @param startValue Start value of the animation curve
  38132. * @param endValue End value of the animation curve
  38133. * @param gradient Scalar amount to interpolate
  38134. * @returns Interpolated scalar value
  38135. */
  38136. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38137. /**
  38138. * Interpolates a Vector3 cubically
  38139. * @param startValue Start value of the animation curve
  38140. * @param outTangent End tangent of the animation
  38141. * @param endValue End value of the animation curve
  38142. * @param inTangent Start tangent of the animation curve
  38143. * @param gradient Scalar amount to interpolate
  38144. * @returns InterpolatedVector3 value
  38145. */
  38146. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38147. /**
  38148. * Interpolates a Vector2 linearly
  38149. * @param startValue Start value of the animation curve
  38150. * @param endValue End value of the animation curve
  38151. * @param gradient Scalar amount to interpolate
  38152. * @returns Interpolated Vector2 value
  38153. */
  38154. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38155. /**
  38156. * Interpolates a Vector2 cubically
  38157. * @param startValue Start value of the animation curve
  38158. * @param outTangent End tangent of the animation
  38159. * @param endValue End value of the animation curve
  38160. * @param inTangent Start tangent of the animation curve
  38161. * @param gradient Scalar amount to interpolate
  38162. * @returns Interpolated Vector2 value
  38163. */
  38164. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38165. /**
  38166. * Interpolates a size linearly
  38167. * @param startValue Start value of the animation curve
  38168. * @param endValue End value of the animation curve
  38169. * @param gradient Scalar amount to interpolate
  38170. * @returns Interpolated Size value
  38171. */
  38172. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38173. /**
  38174. * Interpolates a Color3 linearly
  38175. * @param startValue Start value of the animation curve
  38176. * @param endValue End value of the animation curve
  38177. * @param gradient Scalar amount to interpolate
  38178. * @returns Interpolated Color3 value
  38179. */
  38180. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38181. /**
  38182. * Interpolates a Color4 linearly
  38183. * @param startValue Start value of the animation curve
  38184. * @param endValue End value of the animation curve
  38185. * @param gradient Scalar amount to interpolate
  38186. * @returns Interpolated Color3 value
  38187. */
  38188. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38189. /**
  38190. * @hidden Internal use only
  38191. */
  38192. _getKeyValue(value: any): any;
  38193. /**
  38194. * @hidden Internal use only
  38195. */
  38196. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38197. /**
  38198. * Defines the function to use to interpolate matrices
  38199. * @param startValue defines the start matrix
  38200. * @param endValue defines the end matrix
  38201. * @param gradient defines the gradient between both matrices
  38202. * @param result defines an optional target matrix where to store the interpolation
  38203. * @returns the interpolated matrix
  38204. */
  38205. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38206. /**
  38207. * Makes a copy of the animation
  38208. * @returns Cloned animation
  38209. */
  38210. clone(): Animation;
  38211. /**
  38212. * Sets the key frames of the animation
  38213. * @param values The animation key frames to set
  38214. */
  38215. setKeys(values: Array<IAnimationKey>): void;
  38216. /**
  38217. * Serializes the animation to an object
  38218. * @returns Serialized object
  38219. */
  38220. serialize(): any;
  38221. /**
  38222. * Float animation type
  38223. */
  38224. static readonly ANIMATIONTYPE_FLOAT: number;
  38225. /**
  38226. * Vector3 animation type
  38227. */
  38228. static readonly ANIMATIONTYPE_VECTOR3: number;
  38229. /**
  38230. * Quaternion animation type
  38231. */
  38232. static readonly ANIMATIONTYPE_QUATERNION: number;
  38233. /**
  38234. * Matrix animation type
  38235. */
  38236. static readonly ANIMATIONTYPE_MATRIX: number;
  38237. /**
  38238. * Color3 animation type
  38239. */
  38240. static readonly ANIMATIONTYPE_COLOR3: number;
  38241. /**
  38242. * Color3 animation type
  38243. */
  38244. static readonly ANIMATIONTYPE_COLOR4: number;
  38245. /**
  38246. * Vector2 animation type
  38247. */
  38248. static readonly ANIMATIONTYPE_VECTOR2: number;
  38249. /**
  38250. * Size animation type
  38251. */
  38252. static readonly ANIMATIONTYPE_SIZE: number;
  38253. /**
  38254. * Relative Loop Mode
  38255. */
  38256. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38257. /**
  38258. * Cycle Loop Mode
  38259. */
  38260. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38261. /**
  38262. * Constant Loop Mode
  38263. */
  38264. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38265. /** @hidden */
  38266. static _UniversalLerp(left: any, right: any, amount: number): any;
  38267. /**
  38268. * Parses an animation object and creates an animation
  38269. * @param parsedAnimation Parsed animation object
  38270. * @returns Animation object
  38271. */
  38272. static Parse(parsedAnimation: any): Animation;
  38273. /**
  38274. * Appends the serialized animations from the source animations
  38275. * @param source Source containing the animations
  38276. * @param destination Target to store the animations
  38277. */
  38278. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38279. /**
  38280. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38281. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38282. * @param url defines the url to load from
  38283. * @returns a promise that will resolve to the new animation or an array of animations
  38284. */
  38285. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38286. /**
  38287. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38288. * @param snippetId defines the snippet to load
  38289. * @returns a promise that will resolve to the new animation or a new array of animations
  38290. */
  38291. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38292. }
  38293. }
  38294. declare module "babylonjs/Animations/animatable.interface" {
  38295. import { Nullable } from "babylonjs/types";
  38296. import { Animation } from "babylonjs/Animations/animation";
  38297. /**
  38298. * Interface containing an array of animations
  38299. */
  38300. export interface IAnimatable {
  38301. /**
  38302. * Array of animations
  38303. */
  38304. animations: Nullable<Array<Animation>>;
  38305. }
  38306. }
  38307. declare module "babylonjs/Misc/decorators" {
  38308. import { Nullable } from "babylonjs/types";
  38309. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38310. import { Scene } from "babylonjs/scene";
  38311. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38312. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38315. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38316. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38317. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38318. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38319. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38320. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38321. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38322. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38323. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38324. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38325. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38326. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38327. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38328. /**
  38329. * Decorator used to define property that can be serialized as reference to a camera
  38330. * @param sourceName defines the name of the property to decorate
  38331. */
  38332. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38333. /**
  38334. * Class used to help serialization objects
  38335. */
  38336. export class SerializationHelper {
  38337. /** @hidden */
  38338. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38339. /** @hidden */
  38340. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38341. /** @hidden */
  38342. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38343. /** @hidden */
  38344. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38345. /**
  38346. * Appends the serialized animations from the source animations
  38347. * @param source Source containing the animations
  38348. * @param destination Target to store the animations
  38349. */
  38350. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38351. /**
  38352. * Static function used to serialized a specific entity
  38353. * @param entity defines the entity to serialize
  38354. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38355. * @returns a JSON compatible object representing the serialization of the entity
  38356. */
  38357. static Serialize<T>(entity: T, serializationObject?: any): any;
  38358. /**
  38359. * Creates a new entity from a serialization data object
  38360. * @param creationFunction defines a function used to instanciated the new entity
  38361. * @param source defines the source serialization data
  38362. * @param scene defines the hosting scene
  38363. * @param rootUrl defines the root url for resources
  38364. * @returns a new entity
  38365. */
  38366. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38367. /**
  38368. * Clones an object
  38369. * @param creationFunction defines the function used to instanciate the new object
  38370. * @param source defines the source object
  38371. * @returns the cloned object
  38372. */
  38373. static Clone<T>(creationFunction: () => T, source: T): T;
  38374. /**
  38375. * Instanciates a new object based on a source one (some data will be shared between both object)
  38376. * @param creationFunction defines the function used to instanciate the new object
  38377. * @param source defines the source object
  38378. * @returns the new object
  38379. */
  38380. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38381. }
  38382. }
  38383. declare module "babylonjs/Cameras/camera" {
  38384. import { SmartArray } from "babylonjs/Misc/smartArray";
  38385. import { Observable } from "babylonjs/Misc/observable";
  38386. import { Nullable } from "babylonjs/types";
  38387. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38388. import { Scene } from "babylonjs/scene";
  38389. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38390. import { Node } from "babylonjs/node";
  38391. import { Mesh } from "babylonjs/Meshes/mesh";
  38392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38393. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38394. import { Viewport } from "babylonjs/Maths/math.viewport";
  38395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38398. import { Ray } from "babylonjs/Culling/ray";
  38399. /**
  38400. * This is the base class of all the camera used in the application.
  38401. * @see https://doc.babylonjs.com/features/cameras
  38402. */
  38403. export class Camera extends Node {
  38404. /** @hidden */
  38405. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38406. /**
  38407. * This is the default projection mode used by the cameras.
  38408. * It helps recreating a feeling of perspective and better appreciate depth.
  38409. * This is the best way to simulate real life cameras.
  38410. */
  38411. static readonly PERSPECTIVE_CAMERA: number;
  38412. /**
  38413. * This helps creating camera with an orthographic mode.
  38414. * 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.
  38415. */
  38416. static readonly ORTHOGRAPHIC_CAMERA: number;
  38417. /**
  38418. * This is the default FOV mode for perspective cameras.
  38419. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38420. */
  38421. static readonly FOVMODE_VERTICAL_FIXED: number;
  38422. /**
  38423. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38424. */
  38425. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38426. /**
  38427. * This specifies ther is no need for a camera rig.
  38428. * Basically only one eye is rendered corresponding to the camera.
  38429. */
  38430. static readonly RIG_MODE_NONE: number;
  38431. /**
  38432. * Simulates a camera Rig with one blue eye and one red eye.
  38433. * This can be use with 3d blue and red glasses.
  38434. */
  38435. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38436. /**
  38437. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38438. */
  38439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38440. /**
  38441. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38442. */
  38443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38444. /**
  38445. * Defines that both eyes of the camera will be rendered over under each other.
  38446. */
  38447. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38448. /**
  38449. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38450. */
  38451. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38452. /**
  38453. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38454. */
  38455. static readonly RIG_MODE_VR: number;
  38456. /**
  38457. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38458. */
  38459. static readonly RIG_MODE_WEBVR: number;
  38460. /**
  38461. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38462. */
  38463. static readonly RIG_MODE_CUSTOM: number;
  38464. /**
  38465. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38466. */
  38467. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38468. /**
  38469. * Define the input manager associated with the camera.
  38470. */
  38471. inputs: CameraInputsManager<Camera>;
  38472. /** @hidden */
  38473. _position: Vector3;
  38474. /**
  38475. * Define the current local position of the camera in the scene
  38476. */
  38477. get position(): Vector3;
  38478. set position(newPosition: Vector3);
  38479. protected _upVector: Vector3;
  38480. /**
  38481. * The vector the camera should consider as up.
  38482. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38483. */
  38484. set upVector(vec: Vector3);
  38485. get upVector(): Vector3;
  38486. /**
  38487. * Define the current limit on the left side for an orthographic camera
  38488. * In scene unit
  38489. */
  38490. orthoLeft: Nullable<number>;
  38491. /**
  38492. * Define the current limit on the right side for an orthographic camera
  38493. * In scene unit
  38494. */
  38495. orthoRight: Nullable<number>;
  38496. /**
  38497. * Define the current limit on the bottom side for an orthographic camera
  38498. * In scene unit
  38499. */
  38500. orthoBottom: Nullable<number>;
  38501. /**
  38502. * Define the current limit on the top side for an orthographic camera
  38503. * In scene unit
  38504. */
  38505. orthoTop: Nullable<number>;
  38506. /**
  38507. * Field Of View is set in Radians. (default is 0.8)
  38508. */
  38509. fov: number;
  38510. /**
  38511. * Define the minimum distance the camera can see from.
  38512. * This is important to note that the depth buffer are not infinite and the closer it starts
  38513. * the more your scene might encounter depth fighting issue.
  38514. */
  38515. minZ: number;
  38516. /**
  38517. * Define the maximum distance the camera can see to.
  38518. * This is important to note that the depth buffer are not infinite and the further it end
  38519. * the more your scene might encounter depth fighting issue.
  38520. */
  38521. maxZ: number;
  38522. /**
  38523. * Define the default inertia of the camera.
  38524. * This helps giving a smooth feeling to the camera movement.
  38525. */
  38526. inertia: number;
  38527. /**
  38528. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38529. */
  38530. mode: number;
  38531. /**
  38532. * Define whether the camera is intermediate.
  38533. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38534. */
  38535. isIntermediate: boolean;
  38536. /**
  38537. * Define the viewport of the camera.
  38538. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38539. */
  38540. viewport: Viewport;
  38541. /**
  38542. * Restricts the camera to viewing objects with the same layerMask.
  38543. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38544. */
  38545. layerMask: number;
  38546. /**
  38547. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38548. */
  38549. fovMode: number;
  38550. /**
  38551. * Rig mode of the camera.
  38552. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38553. * This is normally controlled byt the camera themselves as internal use.
  38554. */
  38555. cameraRigMode: number;
  38556. /**
  38557. * Defines the distance between both "eyes" in case of a RIG
  38558. */
  38559. interaxialDistance: number;
  38560. /**
  38561. * Defines if stereoscopic rendering is done side by side or over under.
  38562. */
  38563. isStereoscopicSideBySide: boolean;
  38564. /**
  38565. * 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
  38566. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38567. * else in the scene. (Eg. security camera)
  38568. *
  38569. * 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)
  38570. */
  38571. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38572. /**
  38573. * When set, the camera will render to this render target instead of the default canvas
  38574. *
  38575. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38576. */
  38577. outputRenderTarget: Nullable<RenderTargetTexture>;
  38578. /**
  38579. * Observable triggered when the camera view matrix has changed.
  38580. */
  38581. onViewMatrixChangedObservable: Observable<Camera>;
  38582. /**
  38583. * Observable triggered when the camera Projection matrix has changed.
  38584. */
  38585. onProjectionMatrixChangedObservable: Observable<Camera>;
  38586. /**
  38587. * Observable triggered when the inputs have been processed.
  38588. */
  38589. onAfterCheckInputsObservable: Observable<Camera>;
  38590. /**
  38591. * Observable triggered when reset has been called and applied to the camera.
  38592. */
  38593. onRestoreStateObservable: Observable<Camera>;
  38594. /**
  38595. * Is this camera a part of a rig system?
  38596. */
  38597. isRigCamera: boolean;
  38598. /**
  38599. * If isRigCamera set to true this will be set with the parent camera.
  38600. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38601. */
  38602. rigParent?: Camera;
  38603. /** @hidden */
  38604. _cameraRigParams: any;
  38605. /** @hidden */
  38606. _rigCameras: Camera[];
  38607. /** @hidden */
  38608. _rigPostProcess: Nullable<PostProcess>;
  38609. protected _webvrViewMatrix: Matrix;
  38610. /** @hidden */
  38611. _skipRendering: boolean;
  38612. /** @hidden */
  38613. _projectionMatrix: Matrix;
  38614. /** @hidden */
  38615. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38616. /** @hidden */
  38617. _activeMeshes: SmartArray<AbstractMesh>;
  38618. protected _globalPosition: Vector3;
  38619. /** @hidden */
  38620. _computedViewMatrix: Matrix;
  38621. private _doNotComputeProjectionMatrix;
  38622. private _transformMatrix;
  38623. private _frustumPlanes;
  38624. private _refreshFrustumPlanes;
  38625. private _storedFov;
  38626. private _stateStored;
  38627. /**
  38628. * Instantiates a new camera object.
  38629. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38630. * @see https://doc.babylonjs.com/features/cameras
  38631. * @param name Defines the name of the camera in the scene
  38632. * @param position Defines the position of the camera
  38633. * @param scene Defines the scene the camera belongs too
  38634. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38635. */
  38636. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38637. /**
  38638. * Store current camera state (fov, position, etc..)
  38639. * @returns the camera
  38640. */
  38641. storeState(): Camera;
  38642. /**
  38643. * Restores the camera state values if it has been stored. You must call storeState() first
  38644. */
  38645. protected _restoreStateValues(): boolean;
  38646. /**
  38647. * Restored camera state. You must call storeState() first.
  38648. * @returns true if restored and false otherwise
  38649. */
  38650. restoreState(): boolean;
  38651. /**
  38652. * Gets the class name of the camera.
  38653. * @returns the class name
  38654. */
  38655. getClassName(): string;
  38656. /** @hidden */
  38657. readonly _isCamera: boolean;
  38658. /**
  38659. * Gets a string representation of the camera useful for debug purpose.
  38660. * @param fullDetails Defines that a more verboe level of logging is required
  38661. * @returns the string representation
  38662. */
  38663. toString(fullDetails?: boolean): string;
  38664. /**
  38665. * Gets the current world space position of the camera.
  38666. */
  38667. get globalPosition(): Vector3;
  38668. /**
  38669. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38670. * @returns the active meshe list
  38671. */
  38672. getActiveMeshes(): SmartArray<AbstractMesh>;
  38673. /**
  38674. * Check whether a mesh is part of the current active mesh list of the camera
  38675. * @param mesh Defines the mesh to check
  38676. * @returns true if active, false otherwise
  38677. */
  38678. isActiveMesh(mesh: Mesh): boolean;
  38679. /**
  38680. * Is this camera ready to be used/rendered
  38681. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38682. * @return true if the camera is ready
  38683. */
  38684. isReady(completeCheck?: boolean): boolean;
  38685. /** @hidden */
  38686. _initCache(): void;
  38687. /** @hidden */
  38688. _updateCache(ignoreParentClass?: boolean): void;
  38689. /** @hidden */
  38690. _isSynchronized(): boolean;
  38691. /** @hidden */
  38692. _isSynchronizedViewMatrix(): boolean;
  38693. /** @hidden */
  38694. _isSynchronizedProjectionMatrix(): boolean;
  38695. /**
  38696. * Attach the input controls to a specific dom element to get the input from.
  38697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38698. */
  38699. attachControl(noPreventDefault?: boolean): void;
  38700. /**
  38701. * Attach the input controls to a specific dom element to get the input from.
  38702. * @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
  38703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38704. * BACK COMPAT SIGNATURE ONLY.
  38705. */
  38706. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38707. /**
  38708. * Detach the current controls from the specified dom element.
  38709. */
  38710. detachControl(): void;
  38711. /**
  38712. * Detach the current controls from the specified dom element.
  38713. * @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
  38714. */
  38715. detachControl(ignored: any): void;
  38716. /**
  38717. * Update the camera state according to the different inputs gathered during the frame.
  38718. */
  38719. update(): void;
  38720. /** @hidden */
  38721. _checkInputs(): void;
  38722. /** @hidden */
  38723. get rigCameras(): Camera[];
  38724. /**
  38725. * Gets the post process used by the rig cameras
  38726. */
  38727. get rigPostProcess(): Nullable<PostProcess>;
  38728. /**
  38729. * Internal, gets the first post proces.
  38730. * @returns the first post process to be run on this camera.
  38731. */
  38732. _getFirstPostProcess(): Nullable<PostProcess>;
  38733. private _cascadePostProcessesToRigCams;
  38734. /**
  38735. * Attach a post process to the camera.
  38736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38737. * @param postProcess The post process to attach to the camera
  38738. * @param insertAt The position of the post process in case several of them are in use in the scene
  38739. * @returns the position the post process has been inserted at
  38740. */
  38741. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38742. /**
  38743. * Detach a post process to the camera.
  38744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38745. * @param postProcess The post process to detach from the camera
  38746. */
  38747. detachPostProcess(postProcess: PostProcess): void;
  38748. /**
  38749. * Gets the current world matrix of the camera
  38750. */
  38751. getWorldMatrix(): Matrix;
  38752. /** @hidden */
  38753. _getViewMatrix(): Matrix;
  38754. /**
  38755. * Gets the current view matrix of the camera.
  38756. * @param force forces the camera to recompute the matrix without looking at the cached state
  38757. * @returns the view matrix
  38758. */
  38759. getViewMatrix(force?: boolean): Matrix;
  38760. /**
  38761. * Freeze the projection matrix.
  38762. * It will prevent the cache check of the camera projection compute and can speed up perf
  38763. * if no parameter of the camera are meant to change
  38764. * @param projection Defines manually a projection if necessary
  38765. */
  38766. freezeProjectionMatrix(projection?: Matrix): void;
  38767. /**
  38768. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38769. */
  38770. unfreezeProjectionMatrix(): void;
  38771. /**
  38772. * Gets the current projection matrix of the camera.
  38773. * @param force forces the camera to recompute the matrix without looking at the cached state
  38774. * @returns the projection matrix
  38775. */
  38776. getProjectionMatrix(force?: boolean): Matrix;
  38777. /**
  38778. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38779. * @returns a Matrix
  38780. */
  38781. getTransformationMatrix(): Matrix;
  38782. private _updateFrustumPlanes;
  38783. /**
  38784. * Checks if a cullable object (mesh...) is in the camera frustum
  38785. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38786. * @param target The object to check
  38787. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38788. * @returns true if the object is in frustum otherwise false
  38789. */
  38790. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38791. /**
  38792. * Checks if a cullable object (mesh...) is in the camera frustum
  38793. * Unlike isInFrustum this cheks the full bounding box
  38794. * @param target The object to check
  38795. * @returns true if the object is in frustum otherwise false
  38796. */
  38797. isCompletelyInFrustum(target: ICullable): boolean;
  38798. /**
  38799. * Gets a ray in the forward direction from the camera.
  38800. * @param length Defines the length of the ray to create
  38801. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38802. * @param origin Defines the start point of the ray which defaults to the camera position
  38803. * @returns the forward ray
  38804. */
  38805. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38806. /**
  38807. * Gets a ray in the forward direction from the camera.
  38808. * @param refRay the ray to (re)use when setting the values
  38809. * @param length Defines the length of the ray to create
  38810. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38811. * @param origin Defines the start point of the ray which defaults to the camera position
  38812. * @returns the forward ray
  38813. */
  38814. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38815. /**
  38816. * Releases resources associated with this node.
  38817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38819. */
  38820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38821. /** @hidden */
  38822. _isLeftCamera: boolean;
  38823. /**
  38824. * Gets the left camera of a rig setup in case of Rigged Camera
  38825. */
  38826. get isLeftCamera(): boolean;
  38827. /** @hidden */
  38828. _isRightCamera: boolean;
  38829. /**
  38830. * Gets the right camera of a rig setup in case of Rigged Camera
  38831. */
  38832. get isRightCamera(): boolean;
  38833. /**
  38834. * Gets the left camera of a rig setup in case of Rigged Camera
  38835. */
  38836. get leftCamera(): Nullable<FreeCamera>;
  38837. /**
  38838. * Gets the right camera of a rig setup in case of Rigged Camera
  38839. */
  38840. get rightCamera(): Nullable<FreeCamera>;
  38841. /**
  38842. * Gets the left camera target of a rig setup in case of Rigged Camera
  38843. * @returns the target position
  38844. */
  38845. getLeftTarget(): Nullable<Vector3>;
  38846. /**
  38847. * Gets the right camera target of a rig setup in case of Rigged Camera
  38848. * @returns the target position
  38849. */
  38850. getRightTarget(): Nullable<Vector3>;
  38851. /**
  38852. * @hidden
  38853. */
  38854. setCameraRigMode(mode: number, rigParams: any): void;
  38855. /** @hidden */
  38856. static _setStereoscopicRigMode(camera: Camera): void;
  38857. /** @hidden */
  38858. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38859. /** @hidden */
  38860. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38861. /** @hidden */
  38862. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38863. /** @hidden */
  38864. _getVRProjectionMatrix(): Matrix;
  38865. protected _updateCameraRotationMatrix(): void;
  38866. protected _updateWebVRCameraRotationMatrix(): void;
  38867. /**
  38868. * This function MUST be overwritten by the different WebVR cameras available.
  38869. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38870. * @hidden
  38871. */
  38872. _getWebVRProjectionMatrix(): Matrix;
  38873. /**
  38874. * This function MUST be overwritten by the different WebVR cameras available.
  38875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38876. * @hidden
  38877. */
  38878. _getWebVRViewMatrix(): Matrix;
  38879. /** @hidden */
  38880. setCameraRigParameter(name: string, value: any): void;
  38881. /**
  38882. * needs to be overridden by children so sub has required properties to be copied
  38883. * @hidden
  38884. */
  38885. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38886. /**
  38887. * May need to be overridden by children
  38888. * @hidden
  38889. */
  38890. _updateRigCameras(): void;
  38891. /** @hidden */
  38892. _setupInputs(): void;
  38893. /**
  38894. * Serialiaze the camera setup to a json represention
  38895. * @returns the JSON representation
  38896. */
  38897. serialize(): any;
  38898. /**
  38899. * Clones the current camera.
  38900. * @param name The cloned camera name
  38901. * @returns the cloned camera
  38902. */
  38903. clone(name: string): Camera;
  38904. /**
  38905. * Gets the direction of the camera relative to a given local axis.
  38906. * @param localAxis Defines the reference axis to provide a relative direction.
  38907. * @return the direction
  38908. */
  38909. getDirection(localAxis: Vector3): Vector3;
  38910. /**
  38911. * Returns the current camera absolute rotation
  38912. */
  38913. get absoluteRotation(): Quaternion;
  38914. /**
  38915. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38916. * @param localAxis Defines the reference axis to provide a relative direction.
  38917. * @param result Defines the vector to store the result in
  38918. */
  38919. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38920. /**
  38921. * Gets a camera constructor for a given camera type
  38922. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38923. * @param name The name of the camera the result will be able to instantiate
  38924. * @param scene The scene the result will construct the camera in
  38925. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38926. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38927. * @returns a factory method to construc the camera
  38928. */
  38929. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38930. /**
  38931. * Compute the world matrix of the camera.
  38932. * @returns the camera world matrix
  38933. */
  38934. computeWorldMatrix(): Matrix;
  38935. /**
  38936. * Parse a JSON and creates the camera from the parsed information
  38937. * @param parsedCamera The JSON to parse
  38938. * @param scene The scene to instantiate the camera in
  38939. * @returns the newly constructed camera
  38940. */
  38941. static Parse(parsedCamera: any, scene: Scene): Camera;
  38942. }
  38943. }
  38944. declare module "babylonjs/PostProcesses/postProcessManager" {
  38945. import { Nullable } from "babylonjs/types";
  38946. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38948. import { Scene } from "babylonjs/scene";
  38949. /**
  38950. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38951. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38952. */
  38953. export class PostProcessManager {
  38954. private _scene;
  38955. private _indexBuffer;
  38956. private _vertexBuffers;
  38957. /**
  38958. * Creates a new instance PostProcess
  38959. * @param scene The scene that the post process is associated with.
  38960. */
  38961. constructor(scene: Scene);
  38962. private _prepareBuffers;
  38963. private _buildIndexBuffer;
  38964. /**
  38965. * Rebuilds the vertex buffers of the manager.
  38966. * @hidden
  38967. */
  38968. _rebuild(): void;
  38969. /**
  38970. * Prepares a frame to be run through a post process.
  38971. * @param sourceTexture The input texture to the post procesess. (default: null)
  38972. * @param postProcesses An array of post processes to be run. (default: null)
  38973. * @returns True if the post processes were able to be run.
  38974. * @hidden
  38975. */
  38976. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38977. /**
  38978. * Manually render a set of post processes to a texture.
  38979. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38980. * @param postProcesses An array of post processes to be run.
  38981. * @param targetTexture The target texture to render to.
  38982. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38983. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38984. * @param lodLevel defines which lod of the texture to render to
  38985. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38986. */
  38987. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38988. /**
  38989. * Finalize the result of the output of the postprocesses.
  38990. * @param doNotPresent If true the result will not be displayed to the screen.
  38991. * @param targetTexture The target texture to render to.
  38992. * @param faceIndex The index of the face to bind the target texture to.
  38993. * @param postProcesses The array of post processes to render.
  38994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38995. * @hidden
  38996. */
  38997. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38998. /**
  38999. * Disposes of the post process manager.
  39000. */
  39001. dispose(): void;
  39002. }
  39003. }
  39004. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39005. import { Observable } from "babylonjs/Misc/observable";
  39006. import { SmartArray } from "babylonjs/Misc/smartArray";
  39007. import { Nullable, Immutable } from "babylonjs/types";
  39008. import { Camera } from "babylonjs/Cameras/camera";
  39009. import { Scene } from "babylonjs/scene";
  39010. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39011. import { Color4 } from "babylonjs/Maths/math.color";
  39012. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39016. import { Texture } from "babylonjs/Materials/Textures/texture";
  39017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39018. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39019. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39020. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39021. import { Engine } from "babylonjs/Engines/engine";
  39022. /**
  39023. * This Helps creating a texture that will be created from a camera in your scene.
  39024. * It is basically a dynamic texture that could be used to create special effects for instance.
  39025. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39026. */
  39027. export class RenderTargetTexture extends Texture {
  39028. /**
  39029. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39030. */
  39031. static readonly REFRESHRATE_RENDER_ONCE: number;
  39032. /**
  39033. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39034. */
  39035. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39036. /**
  39037. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39038. * the central point of your effect and can save a lot of performances.
  39039. */
  39040. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39041. /**
  39042. * Use this predicate to dynamically define the list of mesh you want to render.
  39043. * If set, the renderList property will be overwritten.
  39044. */
  39045. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39046. private _renderList;
  39047. /**
  39048. * Use this list to define the list of mesh you want to render.
  39049. */
  39050. get renderList(): Nullable<Array<AbstractMesh>>;
  39051. set renderList(value: Nullable<Array<AbstractMesh>>);
  39052. /**
  39053. * Use this function to overload the renderList array at rendering time.
  39054. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39055. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39056. * the cube (if the RTT is a cube, else layerOrFace=0).
  39057. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39058. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39059. * hold dummy elements!
  39060. */
  39061. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39062. private _hookArray;
  39063. /**
  39064. * Define if particles should be rendered in your texture.
  39065. */
  39066. renderParticles: boolean;
  39067. /**
  39068. * Define if sprites should be rendered in your texture.
  39069. */
  39070. renderSprites: boolean;
  39071. /**
  39072. * Define the camera used to render the texture.
  39073. */
  39074. activeCamera: Nullable<Camera>;
  39075. /**
  39076. * Override the mesh isReady function with your own one.
  39077. */
  39078. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39079. /**
  39080. * Override the render function of the texture with your own one.
  39081. */
  39082. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39083. /**
  39084. * Define if camera post processes should be use while rendering the texture.
  39085. */
  39086. useCameraPostProcesses: boolean;
  39087. /**
  39088. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39089. */
  39090. ignoreCameraViewport: boolean;
  39091. private _postProcessManager;
  39092. private _postProcesses;
  39093. private _resizeObserver;
  39094. /**
  39095. * An event triggered when the texture is unbind.
  39096. */
  39097. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39098. /**
  39099. * An event triggered when the texture is unbind.
  39100. */
  39101. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39102. private _onAfterUnbindObserver;
  39103. /**
  39104. * Set a after unbind callback in the texture.
  39105. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39106. */
  39107. set onAfterUnbind(callback: () => void);
  39108. /**
  39109. * An event triggered before rendering the texture
  39110. */
  39111. onBeforeRenderObservable: Observable<number>;
  39112. private _onBeforeRenderObserver;
  39113. /**
  39114. * Set a before render callback in the texture.
  39115. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39116. */
  39117. set onBeforeRender(callback: (faceIndex: number) => void);
  39118. /**
  39119. * An event triggered after rendering the texture
  39120. */
  39121. onAfterRenderObservable: Observable<number>;
  39122. private _onAfterRenderObserver;
  39123. /**
  39124. * Set a after render callback in the texture.
  39125. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39126. */
  39127. set onAfterRender(callback: (faceIndex: number) => void);
  39128. /**
  39129. * An event triggered after the texture clear
  39130. */
  39131. onClearObservable: Observable<Engine>;
  39132. private _onClearObserver;
  39133. /**
  39134. * Set a clear callback in the texture.
  39135. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39136. */
  39137. set onClear(callback: (Engine: Engine) => void);
  39138. /**
  39139. * An event triggered when the texture is resized.
  39140. */
  39141. onResizeObservable: Observable<RenderTargetTexture>;
  39142. /**
  39143. * Define the clear color of the Render Target if it should be different from the scene.
  39144. */
  39145. clearColor: Color4;
  39146. protected _size: number | {
  39147. width: number;
  39148. height: number;
  39149. layers?: number;
  39150. };
  39151. protected _initialSizeParameter: number | {
  39152. width: number;
  39153. height: number;
  39154. } | {
  39155. ratio: number;
  39156. };
  39157. protected _sizeRatio: Nullable<number>;
  39158. /** @hidden */
  39159. _generateMipMaps: boolean;
  39160. protected _renderingManager: RenderingManager;
  39161. /** @hidden */
  39162. _waitingRenderList?: string[];
  39163. protected _doNotChangeAspectRatio: boolean;
  39164. protected _currentRefreshId: number;
  39165. protected _refreshRate: number;
  39166. protected _textureMatrix: Matrix;
  39167. protected _samples: number;
  39168. protected _renderTargetOptions: RenderTargetCreationOptions;
  39169. /**
  39170. * Gets render target creation options that were used.
  39171. */
  39172. get renderTargetOptions(): RenderTargetCreationOptions;
  39173. protected _onRatioRescale(): void;
  39174. /**
  39175. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39176. * It must define where the camera used to render the texture is set
  39177. */
  39178. boundingBoxPosition: Vector3;
  39179. private _boundingBoxSize;
  39180. /**
  39181. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39182. * When defined, the cubemap will switch to local mode
  39183. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39184. * @example https://www.babylonjs-playground.com/#RNASML
  39185. */
  39186. set boundingBoxSize(value: Vector3);
  39187. get boundingBoxSize(): Vector3;
  39188. /**
  39189. * In case the RTT has been created with a depth texture, get the associated
  39190. * depth texture.
  39191. * Otherwise, return null.
  39192. */
  39193. get depthStencilTexture(): Nullable<InternalTexture>;
  39194. /**
  39195. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39196. * or used a shadow, depth texture...
  39197. * @param name The friendly name of the texture
  39198. * @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)
  39199. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39200. * @param generateMipMaps True if mip maps need to be generated after render.
  39201. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39202. * @param type The type of the buffer in the RTT (int, half float, float...)
  39203. * @param isCube True if a cube texture needs to be created
  39204. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39205. * @param generateDepthBuffer True to generate a depth buffer
  39206. * @param generateStencilBuffer True to generate a stencil buffer
  39207. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39208. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39209. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39210. */
  39211. constructor(name: string, size: number | {
  39212. width: number;
  39213. height: number;
  39214. layers?: number;
  39215. } | {
  39216. ratio: number;
  39217. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39218. /**
  39219. * Creates a depth stencil texture.
  39220. * This is only available in WebGL 2 or with the depth texture extension available.
  39221. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39222. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39223. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39224. */
  39225. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39226. private _processSizeParameter;
  39227. /**
  39228. * Define the number of samples to use in case of MSAA.
  39229. * It defaults to one meaning no MSAA has been enabled.
  39230. */
  39231. get samples(): number;
  39232. set samples(value: number);
  39233. /**
  39234. * Resets the refresh counter of the texture and start bak from scratch.
  39235. * Could be useful to regenerate the texture if it is setup to render only once.
  39236. */
  39237. resetRefreshCounter(): void;
  39238. /**
  39239. * Define the refresh rate of the texture or the rendering frequency.
  39240. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39241. */
  39242. get refreshRate(): number;
  39243. set refreshRate(value: number);
  39244. /**
  39245. * Adds a post process to the render target rendering passes.
  39246. * @param postProcess define the post process to add
  39247. */
  39248. addPostProcess(postProcess: PostProcess): void;
  39249. /**
  39250. * Clear all the post processes attached to the render target
  39251. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39252. */
  39253. clearPostProcesses(dispose?: boolean): void;
  39254. /**
  39255. * Remove one of the post process from the list of attached post processes to the texture
  39256. * @param postProcess define the post process to remove from the list
  39257. */
  39258. removePostProcess(postProcess: PostProcess): void;
  39259. /** @hidden */
  39260. _shouldRender(): boolean;
  39261. /**
  39262. * Gets the actual render size of the texture.
  39263. * @returns the width of the render size
  39264. */
  39265. getRenderSize(): number;
  39266. /**
  39267. * Gets the actual render width of the texture.
  39268. * @returns the width of the render size
  39269. */
  39270. getRenderWidth(): number;
  39271. /**
  39272. * Gets the actual render height of the texture.
  39273. * @returns the height of the render size
  39274. */
  39275. getRenderHeight(): number;
  39276. /**
  39277. * Gets the actual number of layers of the texture.
  39278. * @returns the number of layers
  39279. */
  39280. getRenderLayers(): number;
  39281. /**
  39282. * Get if the texture can be rescaled or not.
  39283. */
  39284. get canRescale(): boolean;
  39285. /**
  39286. * Resize the texture using a ratio.
  39287. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39288. */
  39289. scale(ratio: number): void;
  39290. /**
  39291. * Get the texture reflection matrix used to rotate/transform the reflection.
  39292. * @returns the reflection matrix
  39293. */
  39294. getReflectionTextureMatrix(): Matrix;
  39295. /**
  39296. * Resize the texture to a new desired size.
  39297. * Be carrefull as it will recreate all the data in the new texture.
  39298. * @param size Define the new size. It can be:
  39299. * - a number for squared texture,
  39300. * - an object containing { width: number, height: number }
  39301. * - or an object containing a ratio { ratio: number }
  39302. */
  39303. resize(size: number | {
  39304. width: number;
  39305. height: number;
  39306. } | {
  39307. ratio: number;
  39308. }): void;
  39309. private _defaultRenderListPrepared;
  39310. /**
  39311. * Renders all the objects from the render list into the texture.
  39312. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39313. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39314. */
  39315. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39316. private _bestReflectionRenderTargetDimension;
  39317. private _prepareRenderingManager;
  39318. /**
  39319. * @hidden
  39320. * @param faceIndex face index to bind to if this is a cubetexture
  39321. * @param layer defines the index of the texture to bind in the array
  39322. */
  39323. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39324. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39325. private renderToTarget;
  39326. /**
  39327. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39328. * This allowed control for front to back rendering or reversly depending of the special needs.
  39329. *
  39330. * @param renderingGroupId The rendering group id corresponding to its index
  39331. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39332. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39333. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39334. */
  39335. 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;
  39336. /**
  39337. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39338. *
  39339. * @param renderingGroupId The rendering group id corresponding to its index
  39340. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39341. */
  39342. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39343. /**
  39344. * Clones the texture.
  39345. * @returns the cloned texture
  39346. */
  39347. clone(): RenderTargetTexture;
  39348. /**
  39349. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39350. * @returns The JSON representation of the texture
  39351. */
  39352. serialize(): any;
  39353. /**
  39354. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39355. */
  39356. disposeFramebufferObjects(): void;
  39357. /**
  39358. * Dispose the texture and release its associated resources.
  39359. */
  39360. dispose(): void;
  39361. /** @hidden */
  39362. _rebuild(): void;
  39363. /**
  39364. * Clear the info related to rendering groups preventing retention point in material dispose.
  39365. */
  39366. freeRenderingGroups(): void;
  39367. /**
  39368. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39369. * @returns the view count
  39370. */
  39371. getViewCount(): number;
  39372. }
  39373. }
  39374. declare module "babylonjs/Materials/effect" {
  39375. import { Observable } from "babylonjs/Misc/observable";
  39376. import { Nullable } from "babylonjs/types";
  39377. import { IDisposable } from "babylonjs/scene";
  39378. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39379. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39380. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39381. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39382. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39383. import { Engine } from "babylonjs/Engines/engine";
  39384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39385. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39386. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39387. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39388. /**
  39389. * Options to be used when creating an effect.
  39390. */
  39391. export interface IEffectCreationOptions {
  39392. /**
  39393. * Atrributes that will be used in the shader.
  39394. */
  39395. attributes: string[];
  39396. /**
  39397. * Uniform varible names that will be set in the shader.
  39398. */
  39399. uniformsNames: string[];
  39400. /**
  39401. * Uniform buffer variable names that will be set in the shader.
  39402. */
  39403. uniformBuffersNames: string[];
  39404. /**
  39405. * Sampler texture variable names that will be set in the shader.
  39406. */
  39407. samplers: string[];
  39408. /**
  39409. * Define statements that will be set in the shader.
  39410. */
  39411. defines: any;
  39412. /**
  39413. * Possible fallbacks for this effect to improve performance when needed.
  39414. */
  39415. fallbacks: Nullable<IEffectFallbacks>;
  39416. /**
  39417. * Callback that will be called when the shader is compiled.
  39418. */
  39419. onCompiled: Nullable<(effect: Effect) => void>;
  39420. /**
  39421. * Callback that will be called if an error occurs during shader compilation.
  39422. */
  39423. onError: Nullable<(effect: Effect, errors: string) => void>;
  39424. /**
  39425. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39426. */
  39427. indexParameters?: any;
  39428. /**
  39429. * Max number of lights that can be used in the shader.
  39430. */
  39431. maxSimultaneousLights?: number;
  39432. /**
  39433. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39434. */
  39435. transformFeedbackVaryings?: Nullable<string[]>;
  39436. /**
  39437. * 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
  39438. */
  39439. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39440. /**
  39441. * Is this effect rendering to several color attachments ?
  39442. */
  39443. multiTarget?: boolean;
  39444. }
  39445. /**
  39446. * Effect containing vertex and fragment shader that can be executed on an object.
  39447. */
  39448. export class Effect implements IDisposable {
  39449. /**
  39450. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39451. */
  39452. static ShadersRepository: string;
  39453. /**
  39454. * Enable logging of the shader code when a compilation error occurs
  39455. */
  39456. static LogShaderCodeOnCompilationError: boolean;
  39457. /**
  39458. * Name of the effect.
  39459. */
  39460. name: any;
  39461. /**
  39462. * String container all the define statements that should be set on the shader.
  39463. */
  39464. defines: string;
  39465. /**
  39466. * Callback that will be called when the shader is compiled.
  39467. */
  39468. onCompiled: Nullable<(effect: Effect) => void>;
  39469. /**
  39470. * Callback that will be called if an error occurs during shader compilation.
  39471. */
  39472. onError: Nullable<(effect: Effect, errors: string) => void>;
  39473. /**
  39474. * Callback that will be called when effect is bound.
  39475. */
  39476. onBind: Nullable<(effect: Effect) => void>;
  39477. /**
  39478. * Unique ID of the effect.
  39479. */
  39480. uniqueId: number;
  39481. /**
  39482. * Observable that will be called when the shader is compiled.
  39483. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39484. */
  39485. onCompileObservable: Observable<Effect>;
  39486. /**
  39487. * Observable that will be called if an error occurs during shader compilation.
  39488. */
  39489. onErrorObservable: Observable<Effect>;
  39490. /** @hidden */
  39491. _onBindObservable: Nullable<Observable<Effect>>;
  39492. /**
  39493. * @hidden
  39494. * Specifies if the effect was previously ready
  39495. */
  39496. _wasPreviouslyReady: boolean;
  39497. /**
  39498. * Observable that will be called when effect is bound.
  39499. */
  39500. get onBindObservable(): Observable<Effect>;
  39501. /** @hidden */
  39502. _bonesComputationForcedToCPU: boolean;
  39503. /** @hidden */
  39504. _multiTarget: boolean;
  39505. private static _uniqueIdSeed;
  39506. private _engine;
  39507. private _uniformBuffersNames;
  39508. private _uniformBuffersNamesList;
  39509. private _uniformsNames;
  39510. private _samplerList;
  39511. private _samplers;
  39512. private _isReady;
  39513. private _compilationError;
  39514. private _allFallbacksProcessed;
  39515. private _attributesNames;
  39516. private _attributes;
  39517. private _attributeLocationByName;
  39518. private _uniforms;
  39519. /**
  39520. * Key for the effect.
  39521. * @hidden
  39522. */
  39523. _key: string;
  39524. private _indexParameters;
  39525. private _fallbacks;
  39526. private _vertexSourceCode;
  39527. private _fragmentSourceCode;
  39528. private _vertexSourceCodeOverride;
  39529. private _fragmentSourceCodeOverride;
  39530. private _transformFeedbackVaryings;
  39531. private _rawVertexSourceCode;
  39532. private _rawFragmentSourceCode;
  39533. /**
  39534. * Compiled shader to webGL program.
  39535. * @hidden
  39536. */
  39537. _pipelineContext: Nullable<IPipelineContext>;
  39538. private _valueCache;
  39539. private static _baseCache;
  39540. /**
  39541. * Instantiates an effect.
  39542. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39543. * @param baseName Name of the effect.
  39544. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39545. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39546. * @param samplers List of sampler variables that will be passed to the shader.
  39547. * @param engine Engine to be used to render the effect
  39548. * @param defines Define statements to be added to the shader.
  39549. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39550. * @param onCompiled Callback that will be called when the shader is compiled.
  39551. * @param onError Callback that will be called if an error occurs during shader compilation.
  39552. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39553. */
  39554. 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);
  39555. private _useFinalCode;
  39556. /**
  39557. * Unique key for this effect
  39558. */
  39559. get key(): string;
  39560. /**
  39561. * If the effect has been compiled and prepared.
  39562. * @returns if the effect is compiled and prepared.
  39563. */
  39564. isReady(): boolean;
  39565. private _isReadyInternal;
  39566. /**
  39567. * The engine the effect was initialized with.
  39568. * @returns the engine.
  39569. */
  39570. getEngine(): Engine;
  39571. /**
  39572. * The pipeline context for this effect
  39573. * @returns the associated pipeline context
  39574. */
  39575. getPipelineContext(): Nullable<IPipelineContext>;
  39576. /**
  39577. * The set of names of attribute variables for the shader.
  39578. * @returns An array of attribute names.
  39579. */
  39580. getAttributesNames(): string[];
  39581. /**
  39582. * Returns the attribute at the given index.
  39583. * @param index The index of the attribute.
  39584. * @returns The location of the attribute.
  39585. */
  39586. getAttributeLocation(index: number): number;
  39587. /**
  39588. * Returns the attribute based on the name of the variable.
  39589. * @param name of the attribute to look up.
  39590. * @returns the attribute location.
  39591. */
  39592. getAttributeLocationByName(name: string): number;
  39593. /**
  39594. * The number of attributes.
  39595. * @returns the numnber of attributes.
  39596. */
  39597. getAttributesCount(): number;
  39598. /**
  39599. * Gets the index of a uniform variable.
  39600. * @param uniformName of the uniform to look up.
  39601. * @returns the index.
  39602. */
  39603. getUniformIndex(uniformName: string): number;
  39604. /**
  39605. * Returns the attribute based on the name of the variable.
  39606. * @param uniformName of the uniform to look up.
  39607. * @returns the location of the uniform.
  39608. */
  39609. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39610. /**
  39611. * Returns an array of sampler variable names
  39612. * @returns The array of sampler variable names.
  39613. */
  39614. getSamplers(): string[];
  39615. /**
  39616. * Returns an array of uniform variable names
  39617. * @returns The array of uniform variable names.
  39618. */
  39619. getUniformNames(): string[];
  39620. /**
  39621. * Returns an array of uniform buffer variable names
  39622. * @returns The array of uniform buffer variable names.
  39623. */
  39624. getUniformBuffersNames(): string[];
  39625. /**
  39626. * Returns the index parameters used to create the effect
  39627. * @returns The index parameters object
  39628. */
  39629. getIndexParameters(): any;
  39630. /**
  39631. * The error from the last compilation.
  39632. * @returns the error string.
  39633. */
  39634. getCompilationError(): string;
  39635. /**
  39636. * Gets a boolean indicating that all fallbacks were used during compilation
  39637. * @returns true if all fallbacks were used
  39638. */
  39639. allFallbacksProcessed(): boolean;
  39640. /**
  39641. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39642. * @param func The callback to be used.
  39643. */
  39644. executeWhenCompiled(func: (effect: Effect) => void): void;
  39645. private _checkIsReady;
  39646. private _loadShader;
  39647. /**
  39648. * Gets the vertex shader source code of this effect
  39649. */
  39650. get vertexSourceCode(): string;
  39651. /**
  39652. * Gets the fragment shader source code of this effect
  39653. */
  39654. get fragmentSourceCode(): string;
  39655. /**
  39656. * Gets the vertex shader source code before it has been processed by the preprocessor
  39657. */
  39658. get rawVertexSourceCode(): string;
  39659. /**
  39660. * Gets the fragment shader source code before it has been processed by the preprocessor
  39661. */
  39662. get rawFragmentSourceCode(): string;
  39663. /**
  39664. * Recompiles the webGL program
  39665. * @param vertexSourceCode The source code for the vertex shader.
  39666. * @param fragmentSourceCode The source code for the fragment shader.
  39667. * @param onCompiled Callback called when completed.
  39668. * @param onError Callback called on error.
  39669. * @hidden
  39670. */
  39671. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39672. /**
  39673. * Prepares the effect
  39674. * @hidden
  39675. */
  39676. _prepareEffect(): void;
  39677. private _getShaderCodeAndErrorLine;
  39678. private _processCompilationErrors;
  39679. /**
  39680. * Checks if the effect is supported. (Must be called after compilation)
  39681. */
  39682. get isSupported(): boolean;
  39683. /**
  39684. * Binds a texture to the engine to be used as output of the shader.
  39685. * @param channel Name of the output variable.
  39686. * @param texture Texture to bind.
  39687. * @hidden
  39688. */
  39689. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39690. /**
  39691. * Sets a texture on the engine to be used in the shader.
  39692. * @param channel Name of the sampler variable.
  39693. * @param texture Texture to set.
  39694. */
  39695. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39696. /**
  39697. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39698. * @param channel Name of the sampler variable.
  39699. * @param texture Texture to set.
  39700. */
  39701. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39702. /**
  39703. * Sets an array of textures on the engine to be used in the shader.
  39704. * @param channel Name of the variable.
  39705. * @param textures Textures to set.
  39706. */
  39707. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39708. /**
  39709. * 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)
  39710. * @param channel Name of the sampler variable.
  39711. * @param postProcess Post process to get the input texture from.
  39712. */
  39713. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39714. /**
  39715. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39716. * 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)
  39717. * @param channel Name of the sampler variable.
  39718. * @param postProcess Post process to get the output texture from.
  39719. */
  39720. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39721. /** @hidden */
  39722. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39723. /** @hidden */
  39724. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39725. /** @hidden */
  39726. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39727. /** @hidden */
  39728. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39729. /**
  39730. * Binds a buffer to a uniform.
  39731. * @param buffer Buffer to bind.
  39732. * @param name Name of the uniform variable to bind to.
  39733. */
  39734. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39735. /**
  39736. * Binds block to a uniform.
  39737. * @param blockName Name of the block to bind.
  39738. * @param index Index to bind.
  39739. */
  39740. bindUniformBlock(blockName: string, index: number): void;
  39741. /**
  39742. * Sets an interger value on a uniform variable.
  39743. * @param uniformName Name of the variable.
  39744. * @param value Value to be set.
  39745. * @returns this effect.
  39746. */
  39747. setInt(uniformName: string, value: number): Effect;
  39748. /**
  39749. * Sets an int array on a uniform variable.
  39750. * @param uniformName Name of the variable.
  39751. * @param array array to be set.
  39752. * @returns this effect.
  39753. */
  39754. setIntArray(uniformName: string, array: Int32Array): Effect;
  39755. /**
  39756. * 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)
  39757. * @param uniformName Name of the variable.
  39758. * @param array array to be set.
  39759. * @returns this effect.
  39760. */
  39761. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39762. /**
  39763. * 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)
  39764. * @param uniformName Name of the variable.
  39765. * @param array array to be set.
  39766. * @returns this effect.
  39767. */
  39768. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39769. /**
  39770. * 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)
  39771. * @param uniformName Name of the variable.
  39772. * @param array array to be set.
  39773. * @returns this effect.
  39774. */
  39775. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39776. /**
  39777. * Sets an float array on a uniform variable.
  39778. * @param uniformName Name of the variable.
  39779. * @param array array to be set.
  39780. * @returns this effect.
  39781. */
  39782. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39783. /**
  39784. * 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)
  39785. * @param uniformName Name of the variable.
  39786. * @param array array to be set.
  39787. * @returns this effect.
  39788. */
  39789. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39790. /**
  39791. * 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)
  39792. * @param uniformName Name of the variable.
  39793. * @param array array to be set.
  39794. * @returns this effect.
  39795. */
  39796. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39797. /**
  39798. * 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)
  39799. * @param uniformName Name of the variable.
  39800. * @param array array to be set.
  39801. * @returns this effect.
  39802. */
  39803. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39804. /**
  39805. * Sets an array on a uniform variable.
  39806. * @param uniformName Name of the variable.
  39807. * @param array array to be set.
  39808. * @returns this effect.
  39809. */
  39810. setArray(uniformName: string, array: number[]): Effect;
  39811. /**
  39812. * 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)
  39813. * @param uniformName Name of the variable.
  39814. * @param array array to be set.
  39815. * @returns this effect.
  39816. */
  39817. setArray2(uniformName: string, array: number[]): Effect;
  39818. /**
  39819. * 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)
  39820. * @param uniformName Name of the variable.
  39821. * @param array array to be set.
  39822. * @returns this effect.
  39823. */
  39824. setArray3(uniformName: string, array: number[]): Effect;
  39825. /**
  39826. * 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)
  39827. * @param uniformName Name of the variable.
  39828. * @param array array to be set.
  39829. * @returns this effect.
  39830. */
  39831. setArray4(uniformName: string, array: number[]): Effect;
  39832. /**
  39833. * Sets matrices on a uniform variable.
  39834. * @param uniformName Name of the variable.
  39835. * @param matrices matrices to be set.
  39836. * @returns this effect.
  39837. */
  39838. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39839. /**
  39840. * Sets matrix on a uniform variable.
  39841. * @param uniformName Name of the variable.
  39842. * @param matrix matrix to be set.
  39843. * @returns this effect.
  39844. */
  39845. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39846. /**
  39847. * 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)
  39848. * @param uniformName Name of the variable.
  39849. * @param matrix matrix to be set.
  39850. * @returns this effect.
  39851. */
  39852. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39853. /**
  39854. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39855. * @param uniformName Name of the variable.
  39856. * @param matrix matrix to be set.
  39857. * @returns this effect.
  39858. */
  39859. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39860. /**
  39861. * Sets a float on a uniform variable.
  39862. * @param uniformName Name of the variable.
  39863. * @param value value to be set.
  39864. * @returns this effect.
  39865. */
  39866. setFloat(uniformName: string, value: number): Effect;
  39867. /**
  39868. * Sets a boolean on a uniform variable.
  39869. * @param uniformName Name of the variable.
  39870. * @param bool value to be set.
  39871. * @returns this effect.
  39872. */
  39873. setBool(uniformName: string, bool: boolean): Effect;
  39874. /**
  39875. * Sets a Vector2 on a uniform variable.
  39876. * @param uniformName Name of the variable.
  39877. * @param vector2 vector2 to be set.
  39878. * @returns this effect.
  39879. */
  39880. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39881. /**
  39882. * Sets a float2 on a uniform variable.
  39883. * @param uniformName Name of the variable.
  39884. * @param x First float in float2.
  39885. * @param y Second float in float2.
  39886. * @returns this effect.
  39887. */
  39888. setFloat2(uniformName: string, x: number, y: number): Effect;
  39889. /**
  39890. * Sets a Vector3 on a uniform variable.
  39891. * @param uniformName Name of the variable.
  39892. * @param vector3 Value to be set.
  39893. * @returns this effect.
  39894. */
  39895. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39896. /**
  39897. * Sets a float3 on a uniform variable.
  39898. * @param uniformName Name of the variable.
  39899. * @param x First float in float3.
  39900. * @param y Second float in float3.
  39901. * @param z Third float in float3.
  39902. * @returns this effect.
  39903. */
  39904. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39905. /**
  39906. * Sets a Vector4 on a uniform variable.
  39907. * @param uniformName Name of the variable.
  39908. * @param vector4 Value to be set.
  39909. * @returns this effect.
  39910. */
  39911. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39912. /**
  39913. * Sets a float4 on a uniform variable.
  39914. * @param uniformName Name of the variable.
  39915. * @param x First float in float4.
  39916. * @param y Second float in float4.
  39917. * @param z Third float in float4.
  39918. * @param w Fourth float in float4.
  39919. * @returns this effect.
  39920. */
  39921. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39922. /**
  39923. * Sets a Color3 on a uniform variable.
  39924. * @param uniformName Name of the variable.
  39925. * @param color3 Value to be set.
  39926. * @returns this effect.
  39927. */
  39928. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39929. /**
  39930. * Sets a Color4 on a uniform variable.
  39931. * @param uniformName Name of the variable.
  39932. * @param color3 Value to be set.
  39933. * @param alpha Alpha value to be set.
  39934. * @returns this effect.
  39935. */
  39936. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39937. /**
  39938. * Sets a Color4 on a uniform variable
  39939. * @param uniformName defines the name of the variable
  39940. * @param color4 defines the value to be set
  39941. * @returns this effect.
  39942. */
  39943. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39944. /** Release all associated resources */
  39945. dispose(): void;
  39946. /**
  39947. * This function will add a new shader to the shader store
  39948. * @param name the name of the shader
  39949. * @param pixelShader optional pixel shader content
  39950. * @param vertexShader optional vertex shader content
  39951. */
  39952. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39953. /**
  39954. * Store of each shader (The can be looked up using effect.key)
  39955. */
  39956. static ShadersStore: {
  39957. [key: string]: string;
  39958. };
  39959. /**
  39960. * Store of each included file for a shader (The can be looked up using effect.key)
  39961. */
  39962. static IncludesShadersStore: {
  39963. [key: string]: string;
  39964. };
  39965. /**
  39966. * Resets the cache of effects.
  39967. */
  39968. static ResetCache(): void;
  39969. }
  39970. }
  39971. declare module "babylonjs/Engines/engineCapabilities" {
  39972. /**
  39973. * Interface used to describe the capabilities of the engine relatively to the current browser
  39974. */
  39975. export interface EngineCapabilities {
  39976. /** Maximum textures units per fragment shader */
  39977. maxTexturesImageUnits: number;
  39978. /** Maximum texture units per vertex shader */
  39979. maxVertexTextureImageUnits: number;
  39980. /** Maximum textures units in the entire pipeline */
  39981. maxCombinedTexturesImageUnits: number;
  39982. /** Maximum texture size */
  39983. maxTextureSize: number;
  39984. /** Maximum texture samples */
  39985. maxSamples?: number;
  39986. /** Maximum cube texture size */
  39987. maxCubemapTextureSize: number;
  39988. /** Maximum render texture size */
  39989. maxRenderTextureSize: number;
  39990. /** Maximum number of vertex attributes */
  39991. maxVertexAttribs: number;
  39992. /** Maximum number of varyings */
  39993. maxVaryingVectors: number;
  39994. /** Maximum number of uniforms per vertex shader */
  39995. maxVertexUniformVectors: number;
  39996. /** Maximum number of uniforms per fragment shader */
  39997. maxFragmentUniformVectors: number;
  39998. /** Defines if standard derivates (dx/dy) are supported */
  39999. standardDerivatives: boolean;
  40000. /** Defines if s3tc texture compression is supported */
  40001. s3tc?: WEBGL_compressed_texture_s3tc;
  40002. /** Defines if pvrtc texture compression is supported */
  40003. pvrtc: any;
  40004. /** Defines if etc1 texture compression is supported */
  40005. etc1: any;
  40006. /** Defines if etc2 texture compression is supported */
  40007. etc2: any;
  40008. /** Defines if astc texture compression is supported */
  40009. astc: any;
  40010. /** Defines if bptc texture compression is supported */
  40011. bptc: any;
  40012. /** Defines if float textures are supported */
  40013. textureFloat: boolean;
  40014. /** Defines if vertex array objects are supported */
  40015. vertexArrayObject: boolean;
  40016. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40017. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40018. /** Gets the maximum level of anisotropy supported */
  40019. maxAnisotropy: number;
  40020. /** Defines if instancing is supported */
  40021. instancedArrays: boolean;
  40022. /** Defines if 32 bits indices are supported */
  40023. uintIndices: boolean;
  40024. /** Defines if high precision shaders are supported */
  40025. highPrecisionShaderSupported: boolean;
  40026. /** Defines if depth reading in the fragment shader is supported */
  40027. fragmentDepthSupported: boolean;
  40028. /** Defines if float texture linear filtering is supported*/
  40029. textureFloatLinearFiltering: boolean;
  40030. /** Defines if rendering to float textures is supported */
  40031. textureFloatRender: boolean;
  40032. /** Defines if half float textures are supported*/
  40033. textureHalfFloat: boolean;
  40034. /** Defines if half float texture linear filtering is supported*/
  40035. textureHalfFloatLinearFiltering: boolean;
  40036. /** Defines if rendering to half float textures is supported */
  40037. textureHalfFloatRender: boolean;
  40038. /** Defines if textureLOD shader command is supported */
  40039. textureLOD: boolean;
  40040. /** Defines if draw buffers extension is supported */
  40041. drawBuffersExtension: boolean;
  40042. /** Defines if depth textures are supported */
  40043. depthTextureExtension: boolean;
  40044. /** Defines if float color buffer are supported */
  40045. colorBufferFloat: boolean;
  40046. /** Gets disjoint timer query extension (null if not supported) */
  40047. timerQuery?: EXT_disjoint_timer_query;
  40048. /** Defines if timestamp can be used with timer query */
  40049. canUseTimestampForTimerQuery: boolean;
  40050. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40051. multiview?: any;
  40052. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40053. oculusMultiview?: any;
  40054. /** Function used to let the system compiles shaders in background */
  40055. parallelShaderCompile?: {
  40056. COMPLETION_STATUS_KHR: number;
  40057. };
  40058. /** Max number of texture samples for MSAA */
  40059. maxMSAASamples: number;
  40060. /** Defines if the blend min max extension is supported */
  40061. blendMinMax: boolean;
  40062. }
  40063. }
  40064. declare module "babylonjs/States/depthCullingState" {
  40065. import { Nullable } from "babylonjs/types";
  40066. /**
  40067. * @hidden
  40068. **/
  40069. export class DepthCullingState {
  40070. private _isDepthTestDirty;
  40071. private _isDepthMaskDirty;
  40072. private _isDepthFuncDirty;
  40073. private _isCullFaceDirty;
  40074. private _isCullDirty;
  40075. private _isZOffsetDirty;
  40076. private _isFrontFaceDirty;
  40077. private _depthTest;
  40078. private _depthMask;
  40079. private _depthFunc;
  40080. private _cull;
  40081. private _cullFace;
  40082. private _zOffset;
  40083. private _frontFace;
  40084. /**
  40085. * Initializes the state.
  40086. */
  40087. constructor();
  40088. get isDirty(): boolean;
  40089. get zOffset(): number;
  40090. set zOffset(value: number);
  40091. get cullFace(): Nullable<number>;
  40092. set cullFace(value: Nullable<number>);
  40093. get cull(): Nullable<boolean>;
  40094. set cull(value: Nullable<boolean>);
  40095. get depthFunc(): Nullable<number>;
  40096. set depthFunc(value: Nullable<number>);
  40097. get depthMask(): boolean;
  40098. set depthMask(value: boolean);
  40099. get depthTest(): boolean;
  40100. set depthTest(value: boolean);
  40101. get frontFace(): Nullable<number>;
  40102. set frontFace(value: Nullable<number>);
  40103. reset(): void;
  40104. apply(gl: WebGLRenderingContext): void;
  40105. }
  40106. }
  40107. declare module "babylonjs/States/stencilState" {
  40108. /**
  40109. * @hidden
  40110. **/
  40111. export class StencilState {
  40112. /** 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 */
  40113. static readonly ALWAYS: number;
  40114. /** Passed to stencilOperation to specify that stencil value must be kept */
  40115. static readonly KEEP: number;
  40116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40117. static readonly REPLACE: number;
  40118. private _isStencilTestDirty;
  40119. private _isStencilMaskDirty;
  40120. private _isStencilFuncDirty;
  40121. private _isStencilOpDirty;
  40122. private _stencilTest;
  40123. private _stencilMask;
  40124. private _stencilFunc;
  40125. private _stencilFuncRef;
  40126. private _stencilFuncMask;
  40127. private _stencilOpStencilFail;
  40128. private _stencilOpDepthFail;
  40129. private _stencilOpStencilDepthPass;
  40130. get isDirty(): boolean;
  40131. get stencilFunc(): number;
  40132. set stencilFunc(value: number);
  40133. get stencilFuncRef(): number;
  40134. set stencilFuncRef(value: number);
  40135. get stencilFuncMask(): number;
  40136. set stencilFuncMask(value: number);
  40137. get stencilOpStencilFail(): number;
  40138. set stencilOpStencilFail(value: number);
  40139. get stencilOpDepthFail(): number;
  40140. set stencilOpDepthFail(value: number);
  40141. get stencilOpStencilDepthPass(): number;
  40142. set stencilOpStencilDepthPass(value: number);
  40143. get stencilMask(): number;
  40144. set stencilMask(value: number);
  40145. get stencilTest(): boolean;
  40146. set stencilTest(value: boolean);
  40147. constructor();
  40148. reset(): void;
  40149. apply(gl: WebGLRenderingContext): void;
  40150. }
  40151. }
  40152. declare module "babylonjs/States/alphaCullingState" {
  40153. /**
  40154. * @hidden
  40155. **/
  40156. export class AlphaState {
  40157. private _isAlphaBlendDirty;
  40158. private _isBlendFunctionParametersDirty;
  40159. private _isBlendEquationParametersDirty;
  40160. private _isBlendConstantsDirty;
  40161. private _alphaBlend;
  40162. private _blendFunctionParameters;
  40163. private _blendEquationParameters;
  40164. private _blendConstants;
  40165. /**
  40166. * Initializes the state.
  40167. */
  40168. constructor();
  40169. get isDirty(): boolean;
  40170. get alphaBlend(): boolean;
  40171. set alphaBlend(value: boolean);
  40172. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40173. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40174. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40175. reset(): void;
  40176. apply(gl: WebGLRenderingContext): void;
  40177. }
  40178. }
  40179. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40180. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40181. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40182. /** @hidden */
  40183. export class WebGLShaderProcessor implements IShaderProcessor {
  40184. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40185. }
  40186. }
  40187. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40188. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40189. /** @hidden */
  40190. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40191. attributeProcessor(attribute: string): string;
  40192. varyingProcessor(varying: string, isFragment: boolean): string;
  40193. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40194. }
  40195. }
  40196. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40197. /**
  40198. * Interface for attribute information associated with buffer instanciation
  40199. */
  40200. export interface InstancingAttributeInfo {
  40201. /**
  40202. * Name of the GLSL attribute
  40203. * if attribute index is not specified, this is used to retrieve the index from the effect
  40204. */
  40205. attributeName: string;
  40206. /**
  40207. * Index/offset of the attribute in the vertex shader
  40208. * if not specified, this will be computes from the name.
  40209. */
  40210. index?: number;
  40211. /**
  40212. * size of the attribute, 1, 2, 3 or 4
  40213. */
  40214. attributeSize: number;
  40215. /**
  40216. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40217. */
  40218. offset: number;
  40219. /**
  40220. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40221. * default to 1
  40222. */
  40223. divisor?: number;
  40224. /**
  40225. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40226. * default is FLOAT
  40227. */
  40228. attributeType?: number;
  40229. /**
  40230. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40231. */
  40232. normalized?: boolean;
  40233. }
  40234. }
  40235. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40237. import { Nullable } from "babylonjs/types";
  40238. module "babylonjs/Engines/thinEngine" {
  40239. interface ThinEngine {
  40240. /**
  40241. * Update a video texture
  40242. * @param texture defines the texture to update
  40243. * @param video defines the video element to use
  40244. * @param invertY defines if data must be stored with Y axis inverted
  40245. */
  40246. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40247. }
  40248. }
  40249. }
  40250. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40251. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40252. import { Nullable } from "babylonjs/types";
  40253. module "babylonjs/Engines/thinEngine" {
  40254. interface ThinEngine {
  40255. /**
  40256. * Creates a dynamic texture
  40257. * @param width defines the width of the texture
  40258. * @param height defines the height of the texture
  40259. * @param generateMipMaps defines if the engine should generate the mip levels
  40260. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40261. * @returns the dynamic texture inside an InternalTexture
  40262. */
  40263. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40264. /**
  40265. * Update the content of a dynamic texture
  40266. * @param texture defines the texture to update
  40267. * @param source defines the source containing the data
  40268. * @param invertY defines if data must be stored with Y axis inverted
  40269. * @param premulAlpha defines if alpha is stored as premultiplied
  40270. * @param format defines the format of the data
  40271. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40272. */
  40273. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40274. }
  40275. }
  40276. }
  40277. declare module "babylonjs/Materials/Textures/videoTexture" {
  40278. import { Observable } from "babylonjs/Misc/observable";
  40279. import { Nullable } from "babylonjs/types";
  40280. import { Scene } from "babylonjs/scene";
  40281. import { Texture } from "babylonjs/Materials/Textures/texture";
  40282. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40283. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40284. /**
  40285. * Settings for finer control over video usage
  40286. */
  40287. export interface VideoTextureSettings {
  40288. /**
  40289. * Applies `autoplay` to video, if specified
  40290. */
  40291. autoPlay?: boolean;
  40292. /**
  40293. * Applies `muted` to video, if specified
  40294. */
  40295. muted?: boolean;
  40296. /**
  40297. * Applies `loop` to video, if specified
  40298. */
  40299. loop?: boolean;
  40300. /**
  40301. * Automatically updates internal texture from video at every frame in the render loop
  40302. */
  40303. autoUpdateTexture: boolean;
  40304. /**
  40305. * Image src displayed during the video loading or until the user interacts with the video.
  40306. */
  40307. poster?: string;
  40308. }
  40309. /**
  40310. * If you want to display a video in your scene, this is the special texture for that.
  40311. * This special texture works similar to other textures, with the exception of a few parameters.
  40312. * @see https://doc.babylonjs.com/how_to/video_texture
  40313. */
  40314. export class VideoTexture extends Texture {
  40315. /**
  40316. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40317. */
  40318. readonly autoUpdateTexture: boolean;
  40319. /**
  40320. * The video instance used by the texture internally
  40321. */
  40322. readonly video: HTMLVideoElement;
  40323. private _onUserActionRequestedObservable;
  40324. /**
  40325. * Event triggerd when a dom action is required by the user to play the video.
  40326. * This happens due to recent changes in browser policies preventing video to auto start.
  40327. */
  40328. get onUserActionRequestedObservable(): Observable<Texture>;
  40329. private _generateMipMaps;
  40330. private _stillImageCaptured;
  40331. private _displayingPosterTexture;
  40332. private _settings;
  40333. private _createInternalTextureOnEvent;
  40334. private _frameId;
  40335. private _currentSrc;
  40336. /**
  40337. * Creates a video texture.
  40338. * If you want to display a video in your scene, this is the special texture for that.
  40339. * This special texture works similar to other textures, with the exception of a few parameters.
  40340. * @see https://doc.babylonjs.com/how_to/video_texture
  40341. * @param name optional name, will detect from video source, if not defined
  40342. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40343. * @param scene is obviously the current scene.
  40344. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40345. * @param invertY is false by default but can be used to invert video on Y axis
  40346. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40347. * @param settings allows finer control over video usage
  40348. */
  40349. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40350. private _getName;
  40351. private _getVideo;
  40352. private _createInternalTexture;
  40353. private reset;
  40354. /**
  40355. * @hidden Internal method to initiate `update`.
  40356. */
  40357. _rebuild(): void;
  40358. /**
  40359. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40360. */
  40361. update(): void;
  40362. /**
  40363. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40364. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40365. */
  40366. updateTexture(isVisible: boolean): void;
  40367. protected _updateInternalTexture: () => void;
  40368. /**
  40369. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40370. * @param url New url.
  40371. */
  40372. updateURL(url: string): void;
  40373. /**
  40374. * Clones the texture.
  40375. * @returns the cloned texture
  40376. */
  40377. clone(): VideoTexture;
  40378. /**
  40379. * Dispose the texture and release its associated resources.
  40380. */
  40381. dispose(): void;
  40382. /**
  40383. * Creates a video texture straight from a stream.
  40384. * @param scene Define the scene the texture should be created in
  40385. * @param stream Define the stream the texture should be created from
  40386. * @returns The created video texture as a promise
  40387. */
  40388. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40389. /**
  40390. * Creates a video texture straight from your WebCam video feed.
  40391. * @param scene Define the scene the texture should be created in
  40392. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40393. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40394. * @returns The created video texture as a promise
  40395. */
  40396. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40397. minWidth: number;
  40398. maxWidth: number;
  40399. minHeight: number;
  40400. maxHeight: number;
  40401. deviceId: string;
  40402. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40403. /**
  40404. * Creates a video texture straight from your WebCam video feed.
  40405. * @param scene Define the scene the texture should be created in
  40406. * @param onReady Define a callback to triggered once the texture will be ready
  40407. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40408. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40409. */
  40410. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40411. minWidth: number;
  40412. maxWidth: number;
  40413. minHeight: number;
  40414. maxHeight: number;
  40415. deviceId: string;
  40416. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40417. }
  40418. }
  40419. declare module "babylonjs/Engines/thinEngine" {
  40420. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40421. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40422. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40423. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40424. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40425. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40426. import { Observable } from "babylonjs/Misc/observable";
  40427. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40428. import { StencilState } from "babylonjs/States/stencilState";
  40429. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40431. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40432. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40433. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40435. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40436. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40437. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40438. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40439. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40440. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40441. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40442. import { WebRequest } from "babylonjs/Misc/webRequest";
  40443. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40444. /**
  40445. * Defines the interface used by objects working like Scene
  40446. * @hidden
  40447. */
  40448. export interface ISceneLike {
  40449. _addPendingData(data: any): void;
  40450. _removePendingData(data: any): void;
  40451. offlineProvider: IOfflineProvider;
  40452. }
  40453. /**
  40454. * Information about the current host
  40455. */
  40456. export interface HostInformation {
  40457. /**
  40458. * Defines if the current host is a mobile
  40459. */
  40460. isMobile: boolean;
  40461. }
  40462. /** Interface defining initialization parameters for Engine class */
  40463. export interface EngineOptions extends WebGLContextAttributes {
  40464. /**
  40465. * Defines if the engine should no exceed a specified device ratio
  40466. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40467. */
  40468. limitDeviceRatio?: number;
  40469. /**
  40470. * Defines if webvr should be enabled automatically
  40471. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40472. */
  40473. autoEnableWebVR?: boolean;
  40474. /**
  40475. * Defines if webgl2 should be turned off even if supported
  40476. * @see https://doc.babylonjs.com/features/webgl2
  40477. */
  40478. disableWebGL2Support?: boolean;
  40479. /**
  40480. * Defines if webaudio should be initialized as well
  40481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40482. */
  40483. audioEngine?: boolean;
  40484. /**
  40485. * Defines if animations should run using a deterministic lock step
  40486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40487. */
  40488. deterministicLockstep?: boolean;
  40489. /** Defines the maximum steps to use with deterministic lock step mode */
  40490. lockstepMaxSteps?: number;
  40491. /** Defines the seconds between each deterministic lock step */
  40492. timeStep?: number;
  40493. /**
  40494. * Defines that engine should ignore context lost events
  40495. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40496. */
  40497. doNotHandleContextLost?: boolean;
  40498. /**
  40499. * Defines that engine should ignore modifying touch action attribute and style
  40500. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40501. */
  40502. doNotHandleTouchAction?: boolean;
  40503. /**
  40504. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40505. */
  40506. useHighPrecisionFloats?: boolean;
  40507. /**
  40508. * Make the canvas XR Compatible for XR sessions
  40509. */
  40510. xrCompatible?: boolean;
  40511. /**
  40512. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40513. */
  40514. useHighPrecisionMatrix?: boolean;
  40515. /**
  40516. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40517. */
  40518. failIfMajorPerformanceCaveat?: boolean;
  40519. }
  40520. /**
  40521. * The base engine class (root of all engines)
  40522. */
  40523. export class ThinEngine {
  40524. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40525. static ExceptionList: ({
  40526. key: string;
  40527. capture: string;
  40528. captureConstraint: number;
  40529. targets: string[];
  40530. } | {
  40531. key: string;
  40532. capture: null;
  40533. captureConstraint: null;
  40534. targets: string[];
  40535. })[];
  40536. /** @hidden */
  40537. static _TextureLoaders: IInternalTextureLoader[];
  40538. /**
  40539. * Returns the current npm package of the sdk
  40540. */
  40541. static get NpmPackage(): string;
  40542. /**
  40543. * Returns the current version of the framework
  40544. */
  40545. static get Version(): string;
  40546. /**
  40547. * Returns a string describing the current engine
  40548. */
  40549. get description(): string;
  40550. /**
  40551. * Gets or sets the epsilon value used by collision engine
  40552. */
  40553. static CollisionsEpsilon: number;
  40554. /**
  40555. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40556. */
  40557. static get ShadersRepository(): string;
  40558. static set ShadersRepository(value: string);
  40559. /** @hidden */
  40560. _shaderProcessor: IShaderProcessor;
  40561. /**
  40562. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40563. */
  40564. forcePOTTextures: boolean;
  40565. /**
  40566. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40567. */
  40568. isFullscreen: boolean;
  40569. /**
  40570. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40571. */
  40572. cullBackFaces: boolean;
  40573. /**
  40574. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40575. */
  40576. renderEvenInBackground: boolean;
  40577. /**
  40578. * Gets or sets a boolean indicating that cache can be kept between frames
  40579. */
  40580. preventCacheWipeBetweenFrames: boolean;
  40581. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40582. validateShaderPrograms: boolean;
  40583. /**
  40584. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40585. * This can provide greater z depth for distant objects.
  40586. */
  40587. useReverseDepthBuffer: boolean;
  40588. /**
  40589. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40590. */
  40591. disableUniformBuffers: boolean;
  40592. /** @hidden */
  40593. _uniformBuffers: UniformBuffer[];
  40594. /**
  40595. * Gets a boolean indicating that the engine supports uniform buffers
  40596. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40597. */
  40598. get supportsUniformBuffers(): boolean;
  40599. /** @hidden */
  40600. _gl: WebGLRenderingContext;
  40601. /** @hidden */
  40602. _webGLVersion: number;
  40603. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40604. protected _windowIsBackground: boolean;
  40605. protected _creationOptions: EngineOptions;
  40606. protected _highPrecisionShadersAllowed: boolean;
  40607. /** @hidden */
  40608. get _shouldUseHighPrecisionShader(): boolean;
  40609. /**
  40610. * Gets a boolean indicating that only power of 2 textures are supported
  40611. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40612. */
  40613. get needPOTTextures(): boolean;
  40614. /** @hidden */
  40615. _badOS: boolean;
  40616. /** @hidden */
  40617. _badDesktopOS: boolean;
  40618. private _hardwareScalingLevel;
  40619. /** @hidden */
  40620. _caps: EngineCapabilities;
  40621. private _isStencilEnable;
  40622. private _glVersion;
  40623. private _glRenderer;
  40624. private _glVendor;
  40625. /** @hidden */
  40626. _videoTextureSupported: boolean;
  40627. protected _renderingQueueLaunched: boolean;
  40628. protected _activeRenderLoops: (() => void)[];
  40629. /**
  40630. * Observable signaled when a context lost event is raised
  40631. */
  40632. onContextLostObservable: Observable<ThinEngine>;
  40633. /**
  40634. * Observable signaled when a context restored event is raised
  40635. */
  40636. onContextRestoredObservable: Observable<ThinEngine>;
  40637. private _onContextLost;
  40638. private _onContextRestored;
  40639. protected _contextWasLost: boolean;
  40640. /** @hidden */
  40641. _doNotHandleContextLost: boolean;
  40642. /**
  40643. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40645. */
  40646. get doNotHandleContextLost(): boolean;
  40647. set doNotHandleContextLost(value: boolean);
  40648. /**
  40649. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40650. */
  40651. disableVertexArrayObjects: boolean;
  40652. /** @hidden */
  40653. protected _colorWrite: boolean;
  40654. /** @hidden */
  40655. protected _colorWriteChanged: boolean;
  40656. /** @hidden */
  40657. protected _depthCullingState: DepthCullingState;
  40658. /** @hidden */
  40659. protected _stencilState: StencilState;
  40660. /** @hidden */
  40661. _alphaState: AlphaState;
  40662. /** @hidden */
  40663. _alphaMode: number;
  40664. /** @hidden */
  40665. _alphaEquation: number;
  40666. /** @hidden */
  40667. _internalTexturesCache: InternalTexture[];
  40668. /** @hidden */
  40669. protected _activeChannel: number;
  40670. private _currentTextureChannel;
  40671. /** @hidden */
  40672. protected _boundTexturesCache: {
  40673. [key: string]: Nullable<InternalTexture>;
  40674. };
  40675. /** @hidden */
  40676. protected _currentEffect: Nullable<Effect>;
  40677. /** @hidden */
  40678. protected _currentProgram: Nullable<WebGLProgram>;
  40679. private _compiledEffects;
  40680. private _vertexAttribArraysEnabled;
  40681. /** @hidden */
  40682. protected _cachedViewport: Nullable<IViewportLike>;
  40683. private _cachedVertexArrayObject;
  40684. /** @hidden */
  40685. protected _cachedVertexBuffers: any;
  40686. /** @hidden */
  40687. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40688. /** @hidden */
  40689. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40690. /** @hidden */
  40691. _currentRenderTarget: Nullable<InternalTexture>;
  40692. private _uintIndicesCurrentlySet;
  40693. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40694. /** @hidden */
  40695. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40696. /** @hidden */
  40697. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40698. private _currentBufferPointers;
  40699. private _currentInstanceLocations;
  40700. private _currentInstanceBuffers;
  40701. private _textureUnits;
  40702. /** @hidden */
  40703. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40704. /** @hidden */
  40705. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40706. /** @hidden */
  40707. _boundRenderFunction: any;
  40708. private _vaoRecordInProgress;
  40709. private _mustWipeVertexAttributes;
  40710. private _emptyTexture;
  40711. private _emptyCubeTexture;
  40712. private _emptyTexture3D;
  40713. private _emptyTexture2DArray;
  40714. /** @hidden */
  40715. _frameHandler: number;
  40716. private _nextFreeTextureSlots;
  40717. private _maxSimultaneousTextures;
  40718. private _activeRequests;
  40719. /** @hidden */
  40720. _transformTextureUrl: Nullable<(url: string) => string>;
  40721. /**
  40722. * Gets information about the current host
  40723. */
  40724. hostInformation: HostInformation;
  40725. protected get _supportsHardwareTextureRescaling(): boolean;
  40726. private _framebufferDimensionsObject;
  40727. /**
  40728. * sets the object from which width and height will be taken from when getting render width and height
  40729. * Will fallback to the gl object
  40730. * @param dimensions the framebuffer width and height that will be used.
  40731. */
  40732. set framebufferDimensionsObject(dimensions: Nullable<{
  40733. framebufferWidth: number;
  40734. framebufferHeight: number;
  40735. }>);
  40736. /**
  40737. * Gets the current viewport
  40738. */
  40739. get currentViewport(): Nullable<IViewportLike>;
  40740. /**
  40741. * Gets the default empty texture
  40742. */
  40743. get emptyTexture(): InternalTexture;
  40744. /**
  40745. * Gets the default empty 3D texture
  40746. */
  40747. get emptyTexture3D(): InternalTexture;
  40748. /**
  40749. * Gets the default empty 2D array texture
  40750. */
  40751. get emptyTexture2DArray(): InternalTexture;
  40752. /**
  40753. * Gets the default empty cube texture
  40754. */
  40755. get emptyCubeTexture(): InternalTexture;
  40756. /**
  40757. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40758. */
  40759. readonly premultipliedAlpha: boolean;
  40760. /**
  40761. * Observable event triggered before each texture is initialized
  40762. */
  40763. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40764. /**
  40765. * Creates a new engine
  40766. * @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
  40767. * @param antialias defines enable antialiasing (default: false)
  40768. * @param options defines further options to be sent to the getContext() function
  40769. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40770. */
  40771. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40772. private _rebuildInternalTextures;
  40773. private _rebuildEffects;
  40774. /**
  40775. * Gets a boolean indicating if all created effects are ready
  40776. * @returns true if all effects are ready
  40777. */
  40778. areAllEffectsReady(): boolean;
  40779. protected _rebuildBuffers(): void;
  40780. protected _initGLContext(): void;
  40781. /**
  40782. * Gets version of the current webGL context
  40783. */
  40784. get webGLVersion(): number;
  40785. /**
  40786. * Gets a string identifying the name of the class
  40787. * @returns "Engine" string
  40788. */
  40789. getClassName(): string;
  40790. /**
  40791. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40792. */
  40793. get isStencilEnable(): boolean;
  40794. /** @hidden */
  40795. _prepareWorkingCanvas(): void;
  40796. /**
  40797. * Reset the texture cache to empty state
  40798. */
  40799. resetTextureCache(): void;
  40800. /**
  40801. * Gets an object containing information about the current webGL context
  40802. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40803. */
  40804. getGlInfo(): {
  40805. vendor: string;
  40806. renderer: string;
  40807. version: string;
  40808. };
  40809. /**
  40810. * Defines the hardware scaling level.
  40811. * By default the hardware scaling level is computed from the window device ratio.
  40812. * 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.
  40813. * @param level defines the level to use
  40814. */
  40815. setHardwareScalingLevel(level: number): void;
  40816. /**
  40817. * Gets the current hardware scaling level.
  40818. * By default the hardware scaling level is computed from the window device ratio.
  40819. * 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.
  40820. * @returns a number indicating the current hardware scaling level
  40821. */
  40822. getHardwareScalingLevel(): number;
  40823. /**
  40824. * Gets the list of loaded textures
  40825. * @returns an array containing all loaded textures
  40826. */
  40827. getLoadedTexturesCache(): InternalTexture[];
  40828. /**
  40829. * Gets the object containing all engine capabilities
  40830. * @returns the EngineCapabilities object
  40831. */
  40832. getCaps(): EngineCapabilities;
  40833. /**
  40834. * stop executing a render loop function and remove it from the execution array
  40835. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40836. */
  40837. stopRenderLoop(renderFunction?: () => void): void;
  40838. /** @hidden */
  40839. _renderLoop(): void;
  40840. /**
  40841. * Gets the HTML canvas attached with the current webGL context
  40842. * @returns a HTML canvas
  40843. */
  40844. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40845. /**
  40846. * Gets host window
  40847. * @returns the host window object
  40848. */
  40849. getHostWindow(): Nullable<Window>;
  40850. /**
  40851. * Gets the current render width
  40852. * @param useScreen defines if screen size must be used (or the current render target if any)
  40853. * @returns a number defining the current render width
  40854. */
  40855. getRenderWidth(useScreen?: boolean): number;
  40856. /**
  40857. * Gets the current render height
  40858. * @param useScreen defines if screen size must be used (or the current render target if any)
  40859. * @returns a number defining the current render height
  40860. */
  40861. getRenderHeight(useScreen?: boolean): number;
  40862. /**
  40863. * Can be used to override the current requestAnimationFrame requester.
  40864. * @hidden
  40865. */
  40866. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40867. /**
  40868. * Register and execute a render loop. The engine can have more than one render function
  40869. * @param renderFunction defines the function to continuously execute
  40870. */
  40871. runRenderLoop(renderFunction: () => void): void;
  40872. /**
  40873. * Clear the current render buffer or the current render target (if any is set up)
  40874. * @param color defines the color to use
  40875. * @param backBuffer defines if the back buffer must be cleared
  40876. * @param depth defines if the depth buffer must be cleared
  40877. * @param stencil defines if the stencil buffer must be cleared
  40878. */
  40879. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40880. private _viewportCached;
  40881. /** @hidden */
  40882. _viewport(x: number, y: number, width: number, height: number): void;
  40883. /**
  40884. * Set the WebGL's viewport
  40885. * @param viewport defines the viewport element to be used
  40886. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40887. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40888. */
  40889. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40890. /**
  40891. * Begin a new frame
  40892. */
  40893. beginFrame(): void;
  40894. /**
  40895. * Enf the current frame
  40896. */
  40897. endFrame(): void;
  40898. /**
  40899. * Resize the view according to the canvas' size
  40900. */
  40901. resize(): void;
  40902. /**
  40903. * Force a specific size of the canvas
  40904. * @param width defines the new canvas' width
  40905. * @param height defines the new canvas' height
  40906. * @returns true if the size was changed
  40907. */
  40908. setSize(width: number, height: number): boolean;
  40909. /**
  40910. * Binds the frame buffer to the specified texture.
  40911. * @param texture The texture to render to or null for the default canvas
  40912. * @param faceIndex The face of the texture to render to in case of cube texture
  40913. * @param requiredWidth The width of the target to render to
  40914. * @param requiredHeight The height of the target to render to
  40915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40916. * @param lodLevel defines the lod level to bind to the frame buffer
  40917. * @param layer defines the 2d array index to bind to frame buffer to
  40918. */
  40919. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40920. /** @hidden */
  40921. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40922. /**
  40923. * Unbind the current render target texture from the webGL context
  40924. * @param texture defines the render target texture to unbind
  40925. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40926. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40927. */
  40928. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40929. /**
  40930. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40931. */
  40932. flushFramebuffer(): void;
  40933. /**
  40934. * Unbind the current render target and bind the default framebuffer
  40935. */
  40936. restoreDefaultFramebuffer(): void;
  40937. /** @hidden */
  40938. protected _resetVertexBufferBinding(): void;
  40939. /**
  40940. * Creates a vertex buffer
  40941. * @param data the data for the vertex buffer
  40942. * @returns the new WebGL static buffer
  40943. */
  40944. createVertexBuffer(data: DataArray): DataBuffer;
  40945. private _createVertexBuffer;
  40946. /**
  40947. * Creates a dynamic vertex buffer
  40948. * @param data the data for the dynamic vertex buffer
  40949. * @returns the new WebGL dynamic buffer
  40950. */
  40951. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40952. protected _resetIndexBufferBinding(): void;
  40953. /**
  40954. * Creates a new index buffer
  40955. * @param indices defines the content of the index buffer
  40956. * @param updatable defines if the index buffer must be updatable
  40957. * @returns a new webGL buffer
  40958. */
  40959. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40960. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40961. /**
  40962. * Bind a webGL buffer to the webGL context
  40963. * @param buffer defines the buffer to bind
  40964. */
  40965. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40966. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40967. private bindBuffer;
  40968. /**
  40969. * update the bound buffer with the given data
  40970. * @param data defines the data to update
  40971. */
  40972. updateArrayBuffer(data: Float32Array): void;
  40973. private _vertexAttribPointer;
  40974. /** @hidden */
  40975. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40976. private _bindVertexBuffersAttributes;
  40977. /**
  40978. * Records a vertex array object
  40979. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40980. * @param vertexBuffers defines the list of vertex buffers to store
  40981. * @param indexBuffer defines the index buffer to store
  40982. * @param effect defines the effect to store
  40983. * @returns the new vertex array object
  40984. */
  40985. recordVertexArrayObject(vertexBuffers: {
  40986. [key: string]: VertexBuffer;
  40987. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40988. /**
  40989. * Bind a specific vertex array object
  40990. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40991. * @param vertexArrayObject defines the vertex array object to bind
  40992. * @param indexBuffer defines the index buffer to bind
  40993. */
  40994. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40995. /**
  40996. * Bind webGl buffers directly to the webGL context
  40997. * @param vertexBuffer defines the vertex buffer to bind
  40998. * @param indexBuffer defines the index buffer to bind
  40999. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41000. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41001. * @param effect defines the effect associated with the vertex buffer
  41002. */
  41003. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41004. private _unbindVertexArrayObject;
  41005. /**
  41006. * Bind a list of vertex buffers to the webGL context
  41007. * @param vertexBuffers defines the list of vertex buffers to bind
  41008. * @param indexBuffer defines the index buffer to bind
  41009. * @param effect defines the effect associated with the vertex buffers
  41010. */
  41011. bindBuffers(vertexBuffers: {
  41012. [key: string]: Nullable<VertexBuffer>;
  41013. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41014. /**
  41015. * Unbind all instance attributes
  41016. */
  41017. unbindInstanceAttributes(): void;
  41018. /**
  41019. * Release and free the memory of a vertex array object
  41020. * @param vao defines the vertex array object to delete
  41021. */
  41022. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41023. /** @hidden */
  41024. _releaseBuffer(buffer: DataBuffer): boolean;
  41025. protected _deleteBuffer(buffer: DataBuffer): void;
  41026. /**
  41027. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41028. * @param instancesBuffer defines the webGL buffer to update and bind
  41029. * @param data defines the data to store in the buffer
  41030. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41031. */
  41032. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41033. /**
  41034. * Bind the content of a webGL buffer used with instantiation
  41035. * @param instancesBuffer defines the webGL buffer to bind
  41036. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41037. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41038. */
  41039. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41040. /**
  41041. * Disable the instance attribute corresponding to the name in parameter
  41042. * @param name defines the name of the attribute to disable
  41043. */
  41044. disableInstanceAttributeByName(name: string): void;
  41045. /**
  41046. * Disable the instance attribute corresponding to the location in parameter
  41047. * @param attributeLocation defines the attribute location of the attribute to disable
  41048. */
  41049. disableInstanceAttribute(attributeLocation: number): void;
  41050. /**
  41051. * Disable the attribute corresponding to the location in parameter
  41052. * @param attributeLocation defines the attribute location of the attribute to disable
  41053. */
  41054. disableAttributeByIndex(attributeLocation: number): void;
  41055. /**
  41056. * Send a draw order
  41057. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41058. * @param indexStart defines the starting index
  41059. * @param indexCount defines the number of index to draw
  41060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41061. */
  41062. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41063. /**
  41064. * Draw a list of points
  41065. * @param verticesStart defines the index of first vertex to draw
  41066. * @param verticesCount defines the count of vertices to draw
  41067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41068. */
  41069. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41070. /**
  41071. * Draw a list of unindexed primitives
  41072. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41073. * @param verticesStart defines the index of first vertex to draw
  41074. * @param verticesCount defines the count of vertices to draw
  41075. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41076. */
  41077. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41078. /**
  41079. * Draw a list of indexed primitives
  41080. * @param fillMode defines the primitive to use
  41081. * @param indexStart defines the starting index
  41082. * @param indexCount defines the number of index to draw
  41083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41084. */
  41085. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41086. /**
  41087. * Draw a list of unindexed primitives
  41088. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41094. private _drawMode;
  41095. /** @hidden */
  41096. protected _reportDrawCall(): void;
  41097. /** @hidden */
  41098. _releaseEffect(effect: Effect): void;
  41099. /** @hidden */
  41100. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41101. /**
  41102. * Create a new effect (used to store vertex/fragment shaders)
  41103. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41104. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41105. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41106. * @param samplers defines an array of string used to represent textures
  41107. * @param defines defines the string containing the defines to use to compile the shaders
  41108. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41109. * @param onCompiled defines a function to call when the effect creation is successful
  41110. * @param onError defines a function to call when the effect creation has failed
  41111. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41112. * @returns the new Effect
  41113. */
  41114. 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;
  41115. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41116. private _compileShader;
  41117. private _compileRawShader;
  41118. /** @hidden */
  41119. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41120. /**
  41121. * Directly creates a webGL program
  41122. * @param pipelineContext defines the pipeline context to attach to
  41123. * @param vertexCode defines the vertex shader code to use
  41124. * @param fragmentCode defines the fragment shader code to use
  41125. * @param context defines the webGL context to use (if not set, the current one will be used)
  41126. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41127. * @returns the new webGL program
  41128. */
  41129. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41130. /**
  41131. * Creates a webGL program
  41132. * @param pipelineContext defines the pipeline context to attach to
  41133. * @param vertexCode defines the vertex shader code to use
  41134. * @param fragmentCode defines the fragment shader code to use
  41135. * @param defines defines the string containing the defines to use to compile the shaders
  41136. * @param context defines the webGL context to use (if not set, the current one will be used)
  41137. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41138. * @returns the new webGL program
  41139. */
  41140. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41141. /**
  41142. * Creates a new pipeline context
  41143. * @returns the new pipeline
  41144. */
  41145. createPipelineContext(): IPipelineContext;
  41146. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41147. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41148. /** @hidden */
  41149. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41150. /** @hidden */
  41151. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41152. /** @hidden */
  41153. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41154. /**
  41155. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41156. * @param pipelineContext defines the pipeline context to use
  41157. * @param uniformsNames defines the list of uniform names
  41158. * @returns an array of webGL uniform locations
  41159. */
  41160. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41161. /**
  41162. * Gets the lsit of active attributes for a given webGL program
  41163. * @param pipelineContext defines the pipeline context to use
  41164. * @param attributesNames defines the list of attribute names to get
  41165. * @returns an array of indices indicating the offset of each attribute
  41166. */
  41167. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41168. /**
  41169. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41170. * @param effect defines the effect to activate
  41171. */
  41172. enableEffect(effect: Nullable<Effect>): void;
  41173. /**
  41174. * Set the value of an uniform to a number (int)
  41175. * @param uniform defines the webGL uniform location where to store the value
  41176. * @param value defines the int number to store
  41177. * @returns true if the value was set
  41178. */
  41179. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41180. /**
  41181. * Set the value of an uniform to an array of int32
  41182. * @param uniform defines the webGL uniform location where to store the value
  41183. * @param array defines the array of int32 to store
  41184. * @returns true if the value was set
  41185. */
  41186. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41187. /**
  41188. * Set the value of an uniform to an array of int32 (stored as vec2)
  41189. * @param uniform defines the webGL uniform location where to store the value
  41190. * @param array defines the array of int32 to store
  41191. * @returns true if the value was set
  41192. */
  41193. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41194. /**
  41195. * Set the value of an uniform to an array of int32 (stored as vec3)
  41196. * @param uniform defines the webGL uniform location where to store the value
  41197. * @param array defines the array of int32 to store
  41198. * @returns true if the value was set
  41199. */
  41200. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41201. /**
  41202. * Set the value of an uniform to an array of int32 (stored as vec4)
  41203. * @param uniform defines the webGL uniform location where to store the value
  41204. * @param array defines the array of int32 to store
  41205. * @returns true if the value was set
  41206. */
  41207. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41208. /**
  41209. * Set the value of an uniform to an array of number
  41210. * @param uniform defines the webGL uniform location where to store the value
  41211. * @param array defines the array of number to store
  41212. * @returns true if the value was set
  41213. */
  41214. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41215. /**
  41216. * Set the value of an uniform to an array of number (stored as vec2)
  41217. * @param uniform defines the webGL uniform location where to store the value
  41218. * @param array defines the array of number to store
  41219. * @returns true if the value was set
  41220. */
  41221. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41222. /**
  41223. * Set the value of an uniform to an array of number (stored as vec3)
  41224. * @param uniform defines the webGL uniform location where to store the value
  41225. * @param array defines the array of number to store
  41226. * @returns true if the value was set
  41227. */
  41228. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41229. /**
  41230. * Set the value of an uniform to an array of number (stored as vec4)
  41231. * @param uniform defines the webGL uniform location where to store the value
  41232. * @param array defines the array of number to store
  41233. * @returns true if the value was set
  41234. */
  41235. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41236. /**
  41237. * Set the value of an uniform to an array of float32 (stored as matrices)
  41238. * @param uniform defines the webGL uniform location where to store the value
  41239. * @param matrices defines the array of float32 to store
  41240. * @returns true if the value was set
  41241. */
  41242. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41243. /**
  41244. * Set the value of an uniform to a matrix (3x3)
  41245. * @param uniform defines the webGL uniform location where to store the value
  41246. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41247. * @returns true if the value was set
  41248. */
  41249. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41250. /**
  41251. * Set the value of an uniform to a matrix (2x2)
  41252. * @param uniform defines the webGL uniform location where to store the value
  41253. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41254. * @returns true if the value was set
  41255. */
  41256. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41257. /**
  41258. * Set the value of an uniform to a number (float)
  41259. * @param uniform defines the webGL uniform location where to store the value
  41260. * @param value defines the float number to store
  41261. * @returns true if the value was transfered
  41262. */
  41263. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41264. /**
  41265. * Set the value of an uniform to a vec2
  41266. * @param uniform defines the webGL uniform location where to store the value
  41267. * @param x defines the 1st component of the value
  41268. * @param y defines the 2nd component of the value
  41269. * @returns true if the value was set
  41270. */
  41271. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41272. /**
  41273. * Set the value of an uniform to a vec3
  41274. * @param uniform defines the webGL uniform location where to store the value
  41275. * @param x defines the 1st component of the value
  41276. * @param y defines the 2nd component of the value
  41277. * @param z defines the 3rd component of the value
  41278. * @returns true if the value was set
  41279. */
  41280. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41281. /**
  41282. * Set the value of an uniform to a vec4
  41283. * @param uniform defines the webGL uniform location where to store the value
  41284. * @param x defines the 1st component of the value
  41285. * @param y defines the 2nd component of the value
  41286. * @param z defines the 3rd component of the value
  41287. * @param w defines the 4th component of the value
  41288. * @returns true if the value was set
  41289. */
  41290. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41291. /**
  41292. * Apply all cached states (depth, culling, stencil and alpha)
  41293. */
  41294. applyStates(): void;
  41295. /**
  41296. * Enable or disable color writing
  41297. * @param enable defines the state to set
  41298. */
  41299. setColorWrite(enable: boolean): void;
  41300. /**
  41301. * Gets a boolean indicating if color writing is enabled
  41302. * @returns the current color writing state
  41303. */
  41304. getColorWrite(): boolean;
  41305. /**
  41306. * Gets the depth culling state manager
  41307. */
  41308. get depthCullingState(): DepthCullingState;
  41309. /**
  41310. * Gets the alpha state manager
  41311. */
  41312. get alphaState(): AlphaState;
  41313. /**
  41314. * Gets the stencil state manager
  41315. */
  41316. get stencilState(): StencilState;
  41317. /**
  41318. * Clears the list of texture accessible through engine.
  41319. * This can help preventing texture load conflict due to name collision.
  41320. */
  41321. clearInternalTexturesCache(): void;
  41322. /**
  41323. * Force the entire cache to be cleared
  41324. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41325. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41326. */
  41327. wipeCaches(bruteForce?: boolean): void;
  41328. /** @hidden */
  41329. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41330. min: number;
  41331. mag: number;
  41332. };
  41333. /** @hidden */
  41334. _createTexture(): WebGLTexture;
  41335. /**
  41336. * Usually called from Texture.ts.
  41337. * Passed information to create a WebGLTexture
  41338. * @param url defines a value which contains one of the following:
  41339. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41340. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41341. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41343. * @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)
  41344. * @param scene needed for loading to the correct scene
  41345. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41346. * @param onLoad optional callback to be called upon successful completion
  41347. * @param onError optional callback to be called upon failure
  41348. * @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
  41349. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41350. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41351. * @param forcedExtension defines the extension to use to pick the right loader
  41352. * @param mimeType defines an optional mime type
  41353. * @param loaderOptions options to be passed to the loader
  41354. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41355. */
  41356. 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;
  41357. /**
  41358. * Loads an image as an HTMLImageElement.
  41359. * @param input url string, ArrayBuffer, or Blob to load
  41360. * @param onLoad callback called when the image successfully loads
  41361. * @param onError callback called when the image fails to load
  41362. * @param offlineProvider offline provider for caching
  41363. * @param mimeType optional mime type
  41364. * @returns the HTMLImageElement of the loaded image
  41365. * @hidden
  41366. */
  41367. 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>;
  41368. /**
  41369. * @hidden
  41370. */
  41371. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41372. private _unpackFlipYCached;
  41373. /**
  41374. * In case you are sharing the context with other applications, it might
  41375. * be interested to not cache the unpack flip y state to ensure a consistent
  41376. * value would be set.
  41377. */
  41378. enableUnpackFlipYCached: boolean;
  41379. /** @hidden */
  41380. _unpackFlipY(value: boolean): void;
  41381. /** @hidden */
  41382. _getUnpackAlignement(): number;
  41383. private _getTextureTarget;
  41384. /**
  41385. * Update the sampling mode of a given texture
  41386. * @param samplingMode defines the required sampling mode
  41387. * @param texture defines the texture to update
  41388. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41389. */
  41390. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41391. /**
  41392. * Update the sampling mode of a given texture
  41393. * @param texture defines the texture to update
  41394. * @param wrapU defines the texture wrap mode of the u coordinates
  41395. * @param wrapV defines the texture wrap mode of the v coordinates
  41396. * @param wrapR defines the texture wrap mode of the r coordinates
  41397. */
  41398. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41399. /** @hidden */
  41400. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41401. width: number;
  41402. height: number;
  41403. layers?: number;
  41404. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41405. /** @hidden */
  41406. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41407. /** @hidden */
  41408. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41409. /**
  41410. * Update a portion of an internal texture
  41411. * @param texture defines the texture to update
  41412. * @param imageData defines the data to store into the texture
  41413. * @param xOffset defines the x coordinates of the update rectangle
  41414. * @param yOffset defines the y coordinates of the update rectangle
  41415. * @param width defines the width of the update rectangle
  41416. * @param height defines the height of the update rectangle
  41417. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41418. * @param lod defines the lod level to update (0 by default)
  41419. */
  41420. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41421. /** @hidden */
  41422. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41423. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41424. private _prepareWebGLTexture;
  41425. /** @hidden */
  41426. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41427. private _getDepthStencilBuffer;
  41428. /** @hidden */
  41429. _releaseFramebufferObjects(texture: InternalTexture): void;
  41430. /** @hidden */
  41431. _releaseTexture(texture: InternalTexture): void;
  41432. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41433. protected _setProgram(program: WebGLProgram): void;
  41434. protected _boundUniforms: {
  41435. [key: number]: WebGLUniformLocation;
  41436. };
  41437. /**
  41438. * Binds an effect to the webGL context
  41439. * @param effect defines the effect to bind
  41440. */
  41441. bindSamplers(effect: Effect): void;
  41442. private _activateCurrentTexture;
  41443. /** @hidden */
  41444. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41445. /** @hidden */
  41446. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41447. /**
  41448. * Unbind all textures from the webGL context
  41449. */
  41450. unbindAllTextures(): void;
  41451. /**
  41452. * Sets a texture to the according uniform.
  41453. * @param channel The texture channel
  41454. * @param uniform The uniform to set
  41455. * @param texture The texture to apply
  41456. */
  41457. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41458. private _bindSamplerUniformToChannel;
  41459. private _getTextureWrapMode;
  41460. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41461. /**
  41462. * Sets an array of texture to the webGL context
  41463. * @param channel defines the channel where the texture array must be set
  41464. * @param uniform defines the associated uniform location
  41465. * @param textures defines the array of textures to bind
  41466. */
  41467. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41468. /** @hidden */
  41469. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41470. private _setTextureParameterFloat;
  41471. private _setTextureParameterInteger;
  41472. /**
  41473. * Unbind all vertex attributes from the webGL context
  41474. */
  41475. unbindAllAttributes(): void;
  41476. /**
  41477. * 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
  41478. */
  41479. releaseEffects(): void;
  41480. /**
  41481. * Dispose and release all associated resources
  41482. */
  41483. dispose(): void;
  41484. /**
  41485. * Attach a new callback raised when context lost event is fired
  41486. * @param callback defines the callback to call
  41487. */
  41488. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41489. /**
  41490. * Attach a new callback raised when context restored event is fired
  41491. * @param callback defines the callback to call
  41492. */
  41493. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41494. /**
  41495. * Get the current error code of the webGL context
  41496. * @returns the error code
  41497. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41498. */
  41499. getError(): number;
  41500. private _canRenderToFloatFramebuffer;
  41501. private _canRenderToHalfFloatFramebuffer;
  41502. private _canRenderToFramebuffer;
  41503. /** @hidden */
  41504. _getWebGLTextureType(type: number): number;
  41505. /** @hidden */
  41506. _getInternalFormat(format: number): number;
  41507. /** @hidden */
  41508. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41509. /** @hidden */
  41510. _getRGBAMultiSampleBufferFormat(type: number): number;
  41511. /** @hidden */
  41512. _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;
  41513. /**
  41514. * Loads a file from a url
  41515. * @param url url to load
  41516. * @param onSuccess callback called when the file successfully loads
  41517. * @param onProgress callback called while file is loading (if the server supports this mode)
  41518. * @param offlineProvider defines the offline provider for caching
  41519. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41520. * @param onError callback called when the file fails to load
  41521. * @returns a file request object
  41522. * @hidden
  41523. */
  41524. 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;
  41525. /**
  41526. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41527. * @param x defines the x coordinate of the rectangle where pixels must be read
  41528. * @param y defines the y coordinate of the rectangle where pixels must be read
  41529. * @param width defines the width of the rectangle where pixels must be read
  41530. * @param height defines the height of the rectangle where pixels must be read
  41531. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41532. * @returns a Uint8Array containing RGBA colors
  41533. */
  41534. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41535. private static _IsSupported;
  41536. private static _HasMajorPerformanceCaveat;
  41537. /**
  41538. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41539. */
  41540. static get IsSupported(): boolean;
  41541. /**
  41542. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41543. * @returns true if the engine can be created
  41544. * @ignorenaming
  41545. */
  41546. static isSupported(): boolean;
  41547. /**
  41548. * 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)
  41549. */
  41550. static get HasMajorPerformanceCaveat(): boolean;
  41551. /**
  41552. * Find the next highest power of two.
  41553. * @param x Number to start search from.
  41554. * @return Next highest power of two.
  41555. */
  41556. static CeilingPOT(x: number): number;
  41557. /**
  41558. * Find the next lowest power of two.
  41559. * @param x Number to start search from.
  41560. * @return Next lowest power of two.
  41561. */
  41562. static FloorPOT(x: number): number;
  41563. /**
  41564. * Find the nearest power of two.
  41565. * @param x Number to start search from.
  41566. * @return Next nearest power of two.
  41567. */
  41568. static NearestPOT(x: number): number;
  41569. /**
  41570. * Get the closest exponent of two
  41571. * @param value defines the value to approximate
  41572. * @param max defines the maximum value to return
  41573. * @param mode defines how to define the closest value
  41574. * @returns closest exponent of two of the given value
  41575. */
  41576. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41577. /**
  41578. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41579. * @param func - the function to be called
  41580. * @param requester - the object that will request the next frame. Falls back to window.
  41581. * @returns frame number
  41582. */
  41583. static QueueNewFrame(func: () => void, requester?: any): number;
  41584. /**
  41585. * Gets host document
  41586. * @returns the host document object
  41587. */
  41588. getHostDocument(): Nullable<Document>;
  41589. }
  41590. }
  41591. declare module "babylonjs/Materials/Textures/internalTexture" {
  41592. import { Observable } from "babylonjs/Misc/observable";
  41593. import { Nullable, int } from "babylonjs/types";
  41594. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41596. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41597. /**
  41598. * Defines the source of the internal texture
  41599. */
  41600. export enum InternalTextureSource {
  41601. /**
  41602. * The source of the texture data is unknown
  41603. */
  41604. Unknown = 0,
  41605. /**
  41606. * Texture data comes from an URL
  41607. */
  41608. Url = 1,
  41609. /**
  41610. * Texture data is only used for temporary storage
  41611. */
  41612. Temp = 2,
  41613. /**
  41614. * Texture data comes from raw data (ArrayBuffer)
  41615. */
  41616. Raw = 3,
  41617. /**
  41618. * Texture content is dynamic (video or dynamic texture)
  41619. */
  41620. Dynamic = 4,
  41621. /**
  41622. * Texture content is generated by rendering to it
  41623. */
  41624. RenderTarget = 5,
  41625. /**
  41626. * Texture content is part of a multi render target process
  41627. */
  41628. MultiRenderTarget = 6,
  41629. /**
  41630. * Texture data comes from a cube data file
  41631. */
  41632. Cube = 7,
  41633. /**
  41634. * Texture data comes from a raw cube data
  41635. */
  41636. CubeRaw = 8,
  41637. /**
  41638. * Texture data come from a prefiltered cube data file
  41639. */
  41640. CubePrefiltered = 9,
  41641. /**
  41642. * Texture content is raw 3D data
  41643. */
  41644. Raw3D = 10,
  41645. /**
  41646. * Texture content is raw 2D array data
  41647. */
  41648. Raw2DArray = 11,
  41649. /**
  41650. * Texture content is a depth texture
  41651. */
  41652. Depth = 12,
  41653. /**
  41654. * Texture data comes from a raw cube data encoded with RGBD
  41655. */
  41656. CubeRawRGBD = 13
  41657. }
  41658. /**
  41659. * Class used to store data associated with WebGL texture data for the engine
  41660. * This class should not be used directly
  41661. */
  41662. export class InternalTexture {
  41663. /** @hidden */
  41664. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41665. /**
  41666. * Defines if the texture is ready
  41667. */
  41668. isReady: boolean;
  41669. /**
  41670. * Defines if the texture is a cube texture
  41671. */
  41672. isCube: boolean;
  41673. /**
  41674. * Defines if the texture contains 3D data
  41675. */
  41676. is3D: boolean;
  41677. /**
  41678. * Defines if the texture contains 2D array data
  41679. */
  41680. is2DArray: boolean;
  41681. /**
  41682. * Defines if the texture contains multiview data
  41683. */
  41684. isMultiview: boolean;
  41685. /**
  41686. * Gets the URL used to load this texture
  41687. */
  41688. url: string;
  41689. /** @hidden */
  41690. _originalUrl: string;
  41691. /**
  41692. * Gets the sampling mode of the texture
  41693. */
  41694. samplingMode: number;
  41695. /**
  41696. * Gets a boolean indicating if the texture needs mipmaps generation
  41697. */
  41698. generateMipMaps: boolean;
  41699. /**
  41700. * Gets the number of samples used by the texture (WebGL2+ only)
  41701. */
  41702. samples: number;
  41703. /**
  41704. * Gets the type of the texture (int, float...)
  41705. */
  41706. type: number;
  41707. /**
  41708. * Gets the format of the texture (RGB, RGBA...)
  41709. */
  41710. format: number;
  41711. /**
  41712. * Observable called when the texture is loaded
  41713. */
  41714. onLoadedObservable: Observable<InternalTexture>;
  41715. /**
  41716. * Gets the width of the texture
  41717. */
  41718. width: number;
  41719. /**
  41720. * Gets the height of the texture
  41721. */
  41722. height: number;
  41723. /**
  41724. * Gets the depth of the texture
  41725. */
  41726. depth: number;
  41727. /**
  41728. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41729. */
  41730. baseWidth: number;
  41731. /**
  41732. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41733. */
  41734. baseHeight: number;
  41735. /**
  41736. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41737. */
  41738. baseDepth: number;
  41739. /**
  41740. * Gets a boolean indicating if the texture is inverted on Y axis
  41741. */
  41742. invertY: boolean;
  41743. /** @hidden */
  41744. _invertVScale: boolean;
  41745. /** @hidden */
  41746. _associatedChannel: number;
  41747. /** @hidden */
  41748. _source: InternalTextureSource;
  41749. /** @hidden */
  41750. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41751. /** @hidden */
  41752. _bufferView: Nullable<ArrayBufferView>;
  41753. /** @hidden */
  41754. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41755. /** @hidden */
  41756. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41757. /** @hidden */
  41758. _size: number;
  41759. /** @hidden */
  41760. _extension: string;
  41761. /** @hidden */
  41762. _files: Nullable<string[]>;
  41763. /** @hidden */
  41764. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41765. /** @hidden */
  41766. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41767. /** @hidden */
  41768. _framebuffer: Nullable<WebGLFramebuffer>;
  41769. /** @hidden */
  41770. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41771. /** @hidden */
  41772. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41773. /** @hidden */
  41774. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41775. /** @hidden */
  41776. _attachments: Nullable<number[]>;
  41777. /** @hidden */
  41778. _textureArray: Nullable<InternalTexture[]>;
  41779. /** @hidden */
  41780. _cachedCoordinatesMode: Nullable<number>;
  41781. /** @hidden */
  41782. _cachedWrapU: Nullable<number>;
  41783. /** @hidden */
  41784. _cachedWrapV: Nullable<number>;
  41785. /** @hidden */
  41786. _cachedWrapR: Nullable<number>;
  41787. /** @hidden */
  41788. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41789. /** @hidden */
  41790. _isDisabled: boolean;
  41791. /** @hidden */
  41792. _compression: Nullable<string>;
  41793. /** @hidden */
  41794. _generateStencilBuffer: boolean;
  41795. /** @hidden */
  41796. _generateDepthBuffer: boolean;
  41797. /** @hidden */
  41798. _comparisonFunction: number;
  41799. /** @hidden */
  41800. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41801. /** @hidden */
  41802. _lodGenerationScale: number;
  41803. /** @hidden */
  41804. _lodGenerationOffset: number;
  41805. /** @hidden */
  41806. _depthStencilTexture: Nullable<InternalTexture>;
  41807. /** @hidden */
  41808. _colorTextureArray: Nullable<WebGLTexture>;
  41809. /** @hidden */
  41810. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41811. /** @hidden */
  41812. _lodTextureHigh: Nullable<BaseTexture>;
  41813. /** @hidden */
  41814. _lodTextureMid: Nullable<BaseTexture>;
  41815. /** @hidden */
  41816. _lodTextureLow: Nullable<BaseTexture>;
  41817. /** @hidden */
  41818. _isRGBD: boolean;
  41819. /** @hidden */
  41820. _linearSpecularLOD: boolean;
  41821. /** @hidden */
  41822. _irradianceTexture: Nullable<BaseTexture>;
  41823. /** @hidden */
  41824. _webGLTexture: Nullable<WebGLTexture>;
  41825. /** @hidden */
  41826. _references: number;
  41827. /** @hidden */
  41828. _gammaSpace: Nullable<boolean>;
  41829. private _engine;
  41830. /**
  41831. * Gets the Engine the texture belongs to.
  41832. * @returns The babylon engine
  41833. */
  41834. getEngine(): ThinEngine;
  41835. /**
  41836. * Gets the data source type of the texture
  41837. */
  41838. get source(): InternalTextureSource;
  41839. /**
  41840. * Creates a new InternalTexture
  41841. * @param engine defines the engine to use
  41842. * @param source defines the type of data that will be used
  41843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41844. */
  41845. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41846. /**
  41847. * Increments the number of references (ie. the number of Texture that point to it)
  41848. */
  41849. incrementReferences(): void;
  41850. /**
  41851. * Change the size of the texture (not the size of the content)
  41852. * @param width defines the new width
  41853. * @param height defines the new height
  41854. * @param depth defines the new depth (1 by default)
  41855. */
  41856. updateSize(width: int, height: int, depth?: int): void;
  41857. /** @hidden */
  41858. _rebuild(): void;
  41859. /** @hidden */
  41860. _swapAndDie(target: InternalTexture): void;
  41861. /**
  41862. * Dispose the current allocated resources
  41863. */
  41864. dispose(): void;
  41865. }
  41866. }
  41867. declare module "babylonjs/Loading/loadingScreen" {
  41868. /**
  41869. * Interface used to present a loading screen while loading a scene
  41870. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41871. */
  41872. export interface ILoadingScreen {
  41873. /**
  41874. * Function called to display the loading screen
  41875. */
  41876. displayLoadingUI: () => void;
  41877. /**
  41878. * Function called to hide the loading screen
  41879. */
  41880. hideLoadingUI: () => void;
  41881. /**
  41882. * Gets or sets the color to use for the background
  41883. */
  41884. loadingUIBackgroundColor: string;
  41885. /**
  41886. * Gets or sets the text to display while loading
  41887. */
  41888. loadingUIText: string;
  41889. }
  41890. /**
  41891. * Class used for the default loading screen
  41892. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41893. */
  41894. export class DefaultLoadingScreen implements ILoadingScreen {
  41895. private _renderingCanvas;
  41896. private _loadingText;
  41897. private _loadingDivBackgroundColor;
  41898. private _loadingDiv;
  41899. private _loadingTextDiv;
  41900. /** Gets or sets the logo url to use for the default loading screen */
  41901. static DefaultLogoUrl: string;
  41902. /** Gets or sets the spinner url to use for the default loading screen */
  41903. static DefaultSpinnerUrl: string;
  41904. /**
  41905. * Creates a new default loading screen
  41906. * @param _renderingCanvas defines the canvas used to render the scene
  41907. * @param _loadingText defines the default text to display
  41908. * @param _loadingDivBackgroundColor defines the default background color
  41909. */
  41910. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41911. /**
  41912. * Function called to display the loading screen
  41913. */
  41914. displayLoadingUI(): void;
  41915. /**
  41916. * Function called to hide the loading screen
  41917. */
  41918. hideLoadingUI(): void;
  41919. /**
  41920. * Gets or sets the text to display while loading
  41921. */
  41922. set loadingUIText(text: string);
  41923. get loadingUIText(): string;
  41924. /**
  41925. * Gets or sets the color to use for the background
  41926. */
  41927. get loadingUIBackgroundColor(): string;
  41928. set loadingUIBackgroundColor(color: string);
  41929. private _resizeLoadingUI;
  41930. }
  41931. }
  41932. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41933. /**
  41934. * Interface for any object that can request an animation frame
  41935. */
  41936. export interface ICustomAnimationFrameRequester {
  41937. /**
  41938. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41939. */
  41940. renderFunction?: Function;
  41941. /**
  41942. * Called to request the next frame to render to
  41943. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41944. */
  41945. requestAnimationFrame: Function;
  41946. /**
  41947. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41948. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41949. */
  41950. requestID?: number;
  41951. }
  41952. }
  41953. declare module "babylonjs/Misc/performanceMonitor" {
  41954. /**
  41955. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41956. */
  41957. export class PerformanceMonitor {
  41958. private _enabled;
  41959. private _rollingFrameTime;
  41960. private _lastFrameTimeMs;
  41961. /**
  41962. * constructor
  41963. * @param frameSampleSize The number of samples required to saturate the sliding window
  41964. */
  41965. constructor(frameSampleSize?: number);
  41966. /**
  41967. * Samples current frame
  41968. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41969. */
  41970. sampleFrame(timeMs?: number): void;
  41971. /**
  41972. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41973. */
  41974. get averageFrameTime(): number;
  41975. /**
  41976. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41977. */
  41978. get averageFrameTimeVariance(): number;
  41979. /**
  41980. * Returns the frame time of the most recent frame
  41981. */
  41982. get instantaneousFrameTime(): number;
  41983. /**
  41984. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41985. */
  41986. get averageFPS(): number;
  41987. /**
  41988. * Returns the average framerate in frames per second using the most recent frame time
  41989. */
  41990. get instantaneousFPS(): number;
  41991. /**
  41992. * Returns true if enough samples have been taken to completely fill the sliding window
  41993. */
  41994. get isSaturated(): boolean;
  41995. /**
  41996. * Enables contributions to the sliding window sample set
  41997. */
  41998. enable(): void;
  41999. /**
  42000. * Disables contributions to the sliding window sample set
  42001. * Samples will not be interpolated over the disabled period
  42002. */
  42003. disable(): void;
  42004. /**
  42005. * Returns true if sampling is enabled
  42006. */
  42007. get isEnabled(): boolean;
  42008. /**
  42009. * Resets performance monitor
  42010. */
  42011. reset(): void;
  42012. }
  42013. /**
  42014. * RollingAverage
  42015. *
  42016. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42017. */
  42018. export class RollingAverage {
  42019. /**
  42020. * Current average
  42021. */
  42022. average: number;
  42023. /**
  42024. * Current variance
  42025. */
  42026. variance: number;
  42027. protected _samples: Array<number>;
  42028. protected _sampleCount: number;
  42029. protected _pos: number;
  42030. protected _m2: number;
  42031. /**
  42032. * constructor
  42033. * @param length The number of samples required to saturate the sliding window
  42034. */
  42035. constructor(length: number);
  42036. /**
  42037. * Adds a sample to the sample set
  42038. * @param v The sample value
  42039. */
  42040. add(v: number): void;
  42041. /**
  42042. * Returns previously added values or null if outside of history or outside the sliding window domain
  42043. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42044. * @return Value previously recorded with add() or null if outside of range
  42045. */
  42046. history(i: number): number;
  42047. /**
  42048. * Returns true if enough samples have been taken to completely fill the sliding window
  42049. * @return true if sample-set saturated
  42050. */
  42051. isSaturated(): boolean;
  42052. /**
  42053. * Resets the rolling average (equivalent to 0 samples taken so far)
  42054. */
  42055. reset(): void;
  42056. /**
  42057. * Wraps a value around the sample range boundaries
  42058. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42059. * @return Wrapped position in sample range
  42060. */
  42061. protected _wrapPosition(i: number): number;
  42062. }
  42063. }
  42064. declare module "babylonjs/Misc/perfCounter" {
  42065. /**
  42066. * This class is used to track a performance counter which is number based.
  42067. * The user has access to many properties which give statistics of different nature.
  42068. *
  42069. * The implementer can track two kinds of Performance Counter: time and count.
  42070. * 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.
  42071. * 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.
  42072. */
  42073. export class PerfCounter {
  42074. /**
  42075. * Gets or sets a global boolean to turn on and off all the counters
  42076. */
  42077. static Enabled: boolean;
  42078. /**
  42079. * Returns the smallest value ever
  42080. */
  42081. get min(): number;
  42082. /**
  42083. * Returns the biggest value ever
  42084. */
  42085. get max(): number;
  42086. /**
  42087. * Returns the average value since the performance counter is running
  42088. */
  42089. get average(): number;
  42090. /**
  42091. * Returns the average value of the last second the counter was monitored
  42092. */
  42093. get lastSecAverage(): number;
  42094. /**
  42095. * Returns the current value
  42096. */
  42097. get current(): number;
  42098. /**
  42099. * Gets the accumulated total
  42100. */
  42101. get total(): number;
  42102. /**
  42103. * Gets the total value count
  42104. */
  42105. get count(): number;
  42106. /**
  42107. * Creates a new counter
  42108. */
  42109. constructor();
  42110. /**
  42111. * Call this method to start monitoring a new frame.
  42112. * 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.
  42113. */
  42114. fetchNewFrame(): void;
  42115. /**
  42116. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42117. * @param newCount the count value to add to the monitored count
  42118. * @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.
  42119. */
  42120. addCount(newCount: number, fetchResult: boolean): void;
  42121. /**
  42122. * Start monitoring this performance counter
  42123. */
  42124. beginMonitoring(): void;
  42125. /**
  42126. * Compute the time lapsed since the previous beginMonitoring() call.
  42127. * @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
  42128. */
  42129. endMonitoring(newFrame?: boolean): void;
  42130. private _fetchResult;
  42131. private _startMonitoringTime;
  42132. private _min;
  42133. private _max;
  42134. private _average;
  42135. private _current;
  42136. private _totalValueCount;
  42137. private _totalAccumulated;
  42138. private _lastSecAverage;
  42139. private _lastSecAccumulated;
  42140. private _lastSecTime;
  42141. private _lastSecValueCount;
  42142. }
  42143. }
  42144. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42146. import { Nullable } from "babylonjs/types";
  42147. module "babylonjs/Engines/thinEngine" {
  42148. interface ThinEngine {
  42149. /** @hidden */
  42150. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42151. }
  42152. }
  42153. }
  42154. declare module "babylonjs/Audio/analyser" {
  42155. import { Scene } from "babylonjs/scene";
  42156. /**
  42157. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42159. */
  42160. export class Analyser {
  42161. /**
  42162. * Gets or sets the smoothing
  42163. * @ignorenaming
  42164. */
  42165. SMOOTHING: number;
  42166. /**
  42167. * Gets or sets the FFT table size
  42168. * @ignorenaming
  42169. */
  42170. FFT_SIZE: number;
  42171. /**
  42172. * Gets or sets the bar graph amplitude
  42173. * @ignorenaming
  42174. */
  42175. BARGRAPHAMPLITUDE: number;
  42176. /**
  42177. * Gets or sets the position of the debug canvas
  42178. * @ignorenaming
  42179. */
  42180. DEBUGCANVASPOS: {
  42181. x: number;
  42182. y: number;
  42183. };
  42184. /**
  42185. * Gets or sets the debug canvas size
  42186. * @ignorenaming
  42187. */
  42188. DEBUGCANVASSIZE: {
  42189. width: number;
  42190. height: number;
  42191. };
  42192. private _byteFreqs;
  42193. private _byteTime;
  42194. private _floatFreqs;
  42195. private _webAudioAnalyser;
  42196. private _debugCanvas;
  42197. private _debugCanvasContext;
  42198. private _scene;
  42199. private _registerFunc;
  42200. private _audioEngine;
  42201. /**
  42202. * Creates a new analyser
  42203. * @param scene defines hosting scene
  42204. */
  42205. constructor(scene: Scene);
  42206. /**
  42207. * Get the number of data values you will have to play with for the visualization
  42208. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42209. * @returns a number
  42210. */
  42211. getFrequencyBinCount(): number;
  42212. /**
  42213. * Gets the current frequency data as a byte array
  42214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42215. * @returns a Uint8Array
  42216. */
  42217. getByteFrequencyData(): Uint8Array;
  42218. /**
  42219. * Gets the current waveform as a byte array
  42220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42221. * @returns a Uint8Array
  42222. */
  42223. getByteTimeDomainData(): Uint8Array;
  42224. /**
  42225. * Gets the current frequency data as a float array
  42226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42227. * @returns a Float32Array
  42228. */
  42229. getFloatFrequencyData(): Float32Array;
  42230. /**
  42231. * Renders the debug canvas
  42232. */
  42233. drawDebugCanvas(): void;
  42234. /**
  42235. * Stops rendering the debug canvas and removes it
  42236. */
  42237. stopDebugCanvas(): void;
  42238. /**
  42239. * Connects two audio nodes
  42240. * @param inputAudioNode defines first node to connect
  42241. * @param outputAudioNode defines second node to connect
  42242. */
  42243. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42244. /**
  42245. * Releases all associated resources
  42246. */
  42247. dispose(): void;
  42248. }
  42249. }
  42250. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42251. import { Observable } from "babylonjs/Misc/observable";
  42252. import { IDisposable } from "babylonjs/scene";
  42253. import { Nullable } from "babylonjs/types";
  42254. import { Analyser } from "babylonjs/Audio/analyser";
  42255. /**
  42256. * This represents an audio engine and it is responsible
  42257. * to play, synchronize and analyse sounds throughout the application.
  42258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42259. */
  42260. export interface IAudioEngine extends IDisposable {
  42261. /**
  42262. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42263. */
  42264. readonly canUseWebAudio: boolean;
  42265. /**
  42266. * Gets the current AudioContext if available.
  42267. */
  42268. readonly audioContext: Nullable<AudioContext>;
  42269. /**
  42270. * The master gain node defines the global audio volume of your audio engine.
  42271. */
  42272. readonly masterGain: GainNode;
  42273. /**
  42274. * Gets whether or not mp3 are supported by your browser.
  42275. */
  42276. readonly isMP3supported: boolean;
  42277. /**
  42278. * Gets whether or not ogg are supported by your browser.
  42279. */
  42280. readonly isOGGsupported: boolean;
  42281. /**
  42282. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42283. * @ignoreNaming
  42284. */
  42285. WarnedWebAudioUnsupported: boolean;
  42286. /**
  42287. * Defines if the audio engine relies on a custom unlocked button.
  42288. * In this case, the embedded button will not be displayed.
  42289. */
  42290. useCustomUnlockedButton: boolean;
  42291. /**
  42292. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42293. */
  42294. readonly unlocked: boolean;
  42295. /**
  42296. * Event raised when audio has been unlocked on the browser.
  42297. */
  42298. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42299. /**
  42300. * Event raised when audio has been locked on the browser.
  42301. */
  42302. onAudioLockedObservable: Observable<IAudioEngine>;
  42303. /**
  42304. * Flags the audio engine in Locked state.
  42305. * This happens due to new browser policies preventing audio to autoplay.
  42306. */
  42307. lock(): void;
  42308. /**
  42309. * Unlocks the audio engine once a user action has been done on the dom.
  42310. * This is helpful to resume play once browser policies have been satisfied.
  42311. */
  42312. unlock(): void;
  42313. /**
  42314. * Gets the global volume sets on the master gain.
  42315. * @returns the global volume if set or -1 otherwise
  42316. */
  42317. getGlobalVolume(): number;
  42318. /**
  42319. * Sets the global volume of your experience (sets on the master gain).
  42320. * @param newVolume Defines the new global volume of the application
  42321. */
  42322. setGlobalVolume(newVolume: number): void;
  42323. /**
  42324. * Connect the audio engine to an audio analyser allowing some amazing
  42325. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42326. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42327. * @param analyser The analyser to connect to the engine
  42328. */
  42329. connectToAnalyser(analyser: Analyser): void;
  42330. }
  42331. }
  42332. declare module "babylonjs/Engines/engine" {
  42333. import { Observable } from "babylonjs/Misc/observable";
  42334. import { Nullable } from "babylonjs/types";
  42335. import { Scene } from "babylonjs/scene";
  42336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42337. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42338. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42339. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42340. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42341. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42342. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42343. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42345. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42347. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42348. import "babylonjs/Engines/Extensions/engine.alpha";
  42349. import "babylonjs/Engines/Extensions/engine.readTexture";
  42350. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42351. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42352. import { Material } from "babylonjs/Materials/material";
  42353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42354. /**
  42355. * Defines the interface used by display changed events
  42356. */
  42357. export interface IDisplayChangedEventArgs {
  42358. /** Gets the vrDisplay object (if any) */
  42359. vrDisplay: Nullable<any>;
  42360. /** Gets a boolean indicating if webVR is supported */
  42361. vrSupported: boolean;
  42362. }
  42363. /**
  42364. * Defines the interface used by objects containing a viewport (like a camera)
  42365. */
  42366. interface IViewportOwnerLike {
  42367. /**
  42368. * Gets or sets the viewport
  42369. */
  42370. viewport: IViewportLike;
  42371. }
  42372. /**
  42373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42374. */
  42375. export class Engine extends ThinEngine {
  42376. /** Defines that alpha blending is disabled */
  42377. static readonly ALPHA_DISABLE: number;
  42378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42379. static readonly ALPHA_ADD: number;
  42380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42381. static readonly ALPHA_COMBINE: number;
  42382. /** Defines that alpha blending to DEST - SRC * DEST */
  42383. static readonly ALPHA_SUBTRACT: number;
  42384. /** Defines that alpha blending to SRC * DEST */
  42385. static readonly ALPHA_MULTIPLY: number;
  42386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42387. static readonly ALPHA_MAXIMIZED: number;
  42388. /** Defines that alpha blending to SRC + DEST */
  42389. static readonly ALPHA_ONEONE: number;
  42390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42391. static readonly ALPHA_PREMULTIPLIED: number;
  42392. /**
  42393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42395. */
  42396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42398. static readonly ALPHA_INTERPOLATE: number;
  42399. /**
  42400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42402. */
  42403. static readonly ALPHA_SCREENMODE: number;
  42404. /** Defines that the ressource is not delayed*/
  42405. static readonly DELAYLOADSTATE_NONE: number;
  42406. /** Defines that the ressource was successfully delay loaded */
  42407. static readonly DELAYLOADSTATE_LOADED: number;
  42408. /** Defines that the ressource is currently delay loading */
  42409. static readonly DELAYLOADSTATE_LOADING: number;
  42410. /** Defines that the ressource is delayed and has not started loading */
  42411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42413. static readonly NEVER: number;
  42414. /** 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 */
  42415. static readonly ALWAYS: number;
  42416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42417. static readonly LESS: number;
  42418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42419. static readonly EQUAL: number;
  42420. /** 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 */
  42421. static readonly LEQUAL: number;
  42422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42423. static readonly GREATER: number;
  42424. /** 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 */
  42425. static readonly GEQUAL: number;
  42426. /** 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 */
  42427. static readonly NOTEQUAL: number;
  42428. /** Passed to stencilOperation to specify that stencil value must be kept */
  42429. static readonly KEEP: number;
  42430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42431. static readonly REPLACE: number;
  42432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42433. static readonly INCR: number;
  42434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42435. static readonly DECR: number;
  42436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42437. static readonly INVERT: number;
  42438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42439. static readonly INCR_WRAP: number;
  42440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42441. static readonly DECR_WRAP: number;
  42442. /** Texture is not repeating outside of 0..1 UVs */
  42443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42444. /** Texture is repeating outside of 0..1 UVs */
  42445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42446. /** Texture is repeating and mirrored */
  42447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42448. /** ALPHA */
  42449. static readonly TEXTUREFORMAT_ALPHA: number;
  42450. /** LUMINANCE */
  42451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42452. /** LUMINANCE_ALPHA */
  42453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42454. /** RGB */
  42455. static readonly TEXTUREFORMAT_RGB: number;
  42456. /** RGBA */
  42457. static readonly TEXTUREFORMAT_RGBA: number;
  42458. /** RED */
  42459. static readonly TEXTUREFORMAT_RED: number;
  42460. /** RED (2nd reference) */
  42461. static readonly TEXTUREFORMAT_R: number;
  42462. /** RG */
  42463. static readonly TEXTUREFORMAT_RG: number;
  42464. /** RED_INTEGER */
  42465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42466. /** RED_INTEGER (2nd reference) */
  42467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42468. /** RG_INTEGER */
  42469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42470. /** RGB_INTEGER */
  42471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42472. /** RGBA_INTEGER */
  42473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42474. /** UNSIGNED_BYTE */
  42475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42476. /** UNSIGNED_BYTE (2nd reference) */
  42477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42478. /** FLOAT */
  42479. static readonly TEXTURETYPE_FLOAT: number;
  42480. /** HALF_FLOAT */
  42481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42482. /** BYTE */
  42483. static readonly TEXTURETYPE_BYTE: number;
  42484. /** SHORT */
  42485. static readonly TEXTURETYPE_SHORT: number;
  42486. /** UNSIGNED_SHORT */
  42487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42488. /** INT */
  42489. static readonly TEXTURETYPE_INT: number;
  42490. /** UNSIGNED_INT */
  42491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42492. /** UNSIGNED_SHORT_4_4_4_4 */
  42493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42494. /** UNSIGNED_SHORT_5_5_5_1 */
  42495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42496. /** UNSIGNED_SHORT_5_6_5 */
  42497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42498. /** UNSIGNED_INT_2_10_10_10_REV */
  42499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42500. /** UNSIGNED_INT_24_8 */
  42501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42502. /** UNSIGNED_INT_10F_11F_11F_REV */
  42503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42504. /** UNSIGNED_INT_5_9_9_9_REV */
  42505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42508. /** nearest is mag = nearest and min = nearest and mip = linear */
  42509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42512. /** Trilinear is mag = linear and min = linear and mip = linear */
  42513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42514. /** nearest is mag = nearest and min = nearest and mip = linear */
  42515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42518. /** Trilinear is mag = linear and min = linear and mip = linear */
  42519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42520. /** mag = nearest and min = nearest and mip = nearest */
  42521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42522. /** mag = nearest and min = linear and mip = nearest */
  42523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42524. /** mag = nearest and min = linear and mip = linear */
  42525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42526. /** mag = nearest and min = linear and mip = none */
  42527. static readonly TEXTURE_NEAREST_LINEAR: number;
  42528. /** mag = nearest and min = nearest and mip = none */
  42529. static readonly TEXTURE_NEAREST_NEAREST: number;
  42530. /** mag = linear and min = nearest and mip = nearest */
  42531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42532. /** mag = linear and min = nearest and mip = linear */
  42533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42534. /** mag = linear and min = linear and mip = none */
  42535. static readonly TEXTURE_LINEAR_LINEAR: number;
  42536. /** mag = linear and min = nearest and mip = none */
  42537. static readonly TEXTURE_LINEAR_NEAREST: number;
  42538. /** Explicit coordinates mode */
  42539. static readonly TEXTURE_EXPLICIT_MODE: number;
  42540. /** Spherical coordinates mode */
  42541. static readonly TEXTURE_SPHERICAL_MODE: number;
  42542. /** Planar coordinates mode */
  42543. static readonly TEXTURE_PLANAR_MODE: number;
  42544. /** Cubic coordinates mode */
  42545. static readonly TEXTURE_CUBIC_MODE: number;
  42546. /** Projection coordinates mode */
  42547. static readonly TEXTURE_PROJECTION_MODE: number;
  42548. /** Skybox coordinates mode */
  42549. static readonly TEXTURE_SKYBOX_MODE: number;
  42550. /** Inverse Cubic coordinates mode */
  42551. static readonly TEXTURE_INVCUBIC_MODE: number;
  42552. /** Equirectangular coordinates mode */
  42553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42554. /** Equirectangular Fixed coordinates mode */
  42555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42556. /** Equirectangular Fixed Mirrored coordinates mode */
  42557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42559. static readonly SCALEMODE_FLOOR: number;
  42560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42561. static readonly SCALEMODE_NEAREST: number;
  42562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42563. static readonly SCALEMODE_CEILING: number;
  42564. /**
  42565. * Returns the current npm package of the sdk
  42566. */
  42567. static get NpmPackage(): string;
  42568. /**
  42569. * Returns the current version of the framework
  42570. */
  42571. static get Version(): string;
  42572. /** Gets the list of created engines */
  42573. static get Instances(): Engine[];
  42574. /**
  42575. * Gets the latest created engine
  42576. */
  42577. static get LastCreatedEngine(): Nullable<Engine>;
  42578. /**
  42579. * Gets the latest created scene
  42580. */
  42581. static get LastCreatedScene(): Nullable<Scene>;
  42582. /**
  42583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42584. * @param flag defines which part of the materials must be marked as dirty
  42585. * @param predicate defines a predicate used to filter which materials should be affected
  42586. */
  42587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42588. /**
  42589. * Method called to create the default loading screen.
  42590. * This can be overriden in your own app.
  42591. * @param canvas The rendering canvas element
  42592. * @returns The loading screen
  42593. */
  42594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42595. /**
  42596. * Method called to create the default rescale post process on each engine.
  42597. */
  42598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42599. /**
  42600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42601. **/
  42602. enableOfflineSupport: boolean;
  42603. /**
  42604. * 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)
  42605. **/
  42606. disableManifestCheck: boolean;
  42607. /**
  42608. * Gets the list of created scenes
  42609. */
  42610. scenes: Scene[];
  42611. /**
  42612. * Event raised when a new scene is created
  42613. */
  42614. onNewSceneAddedObservable: Observable<Scene>;
  42615. /**
  42616. * Gets the list of created postprocesses
  42617. */
  42618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42619. /**
  42620. * Gets a boolean indicating if the pointer is currently locked
  42621. */
  42622. isPointerLock: boolean;
  42623. /**
  42624. * Observable event triggered each time the rendering canvas is resized
  42625. */
  42626. onResizeObservable: Observable<Engine>;
  42627. /**
  42628. * Observable event triggered each time the canvas loses focus
  42629. */
  42630. onCanvasBlurObservable: Observable<Engine>;
  42631. /**
  42632. * Observable event triggered each time the canvas gains focus
  42633. */
  42634. onCanvasFocusObservable: Observable<Engine>;
  42635. /**
  42636. * Observable event triggered each time the canvas receives pointerout event
  42637. */
  42638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42639. /**
  42640. * Observable raised when the engine begins a new frame
  42641. */
  42642. onBeginFrameObservable: Observable<Engine>;
  42643. /**
  42644. * If set, will be used to request the next animation frame for the render loop
  42645. */
  42646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42647. /**
  42648. * Observable raised when the engine ends the current frame
  42649. */
  42650. onEndFrameObservable: Observable<Engine>;
  42651. /**
  42652. * Observable raised when the engine is about to compile a shader
  42653. */
  42654. onBeforeShaderCompilationObservable: Observable<Engine>;
  42655. /**
  42656. * Observable raised when the engine has jsut compiled a shader
  42657. */
  42658. onAfterShaderCompilationObservable: Observable<Engine>;
  42659. /**
  42660. * Gets the audio engine
  42661. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42662. * @ignorenaming
  42663. */
  42664. static audioEngine: IAudioEngine;
  42665. /**
  42666. * Default AudioEngine factory responsible of creating the Audio Engine.
  42667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42668. */
  42669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42670. /**
  42671. * Default offline support factory responsible of creating a tool used to store data locally.
  42672. * By default, this will create a Database object if the workload has been embedded.
  42673. */
  42674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42675. private _loadingScreen;
  42676. private _pointerLockRequested;
  42677. private _rescalePostProcess;
  42678. private _deterministicLockstep;
  42679. private _lockstepMaxSteps;
  42680. private _timeStep;
  42681. protected get _supportsHardwareTextureRescaling(): boolean;
  42682. private _fps;
  42683. private _deltaTime;
  42684. /** @hidden */
  42685. _drawCalls: PerfCounter;
  42686. /** 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 */
  42687. canvasTabIndex: number;
  42688. /**
  42689. * Turn this value on if you want to pause FPS computation when in background
  42690. */
  42691. disablePerformanceMonitorInBackground: boolean;
  42692. private _performanceMonitor;
  42693. /**
  42694. * Gets the performance monitor attached to this engine
  42695. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42696. */
  42697. get performanceMonitor(): PerformanceMonitor;
  42698. private _onFocus;
  42699. private _onBlur;
  42700. private _onCanvasPointerOut;
  42701. private _onCanvasBlur;
  42702. private _onCanvasFocus;
  42703. private _onFullscreenChange;
  42704. private _onPointerLockChange;
  42705. /**
  42706. * Gets the HTML element used to attach event listeners
  42707. * @returns a HTML element
  42708. */
  42709. getInputElement(): Nullable<HTMLElement>;
  42710. /**
  42711. * Creates a new engine
  42712. * @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
  42713. * @param antialias defines enable antialiasing (default: false)
  42714. * @param options defines further options to be sent to the getContext() function
  42715. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42716. */
  42717. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42718. /**
  42719. * Gets current aspect ratio
  42720. * @param viewportOwner defines the camera to use to get the aspect ratio
  42721. * @param useScreen defines if screen size must be used (or the current render target if any)
  42722. * @returns a number defining the aspect ratio
  42723. */
  42724. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42725. /**
  42726. * Gets current screen aspect ratio
  42727. * @returns a number defining the aspect ratio
  42728. */
  42729. getScreenAspectRatio(): number;
  42730. /**
  42731. * Gets the client rect of the HTML canvas attached with the current webGL context
  42732. * @returns a client rectanglee
  42733. */
  42734. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42735. /**
  42736. * Gets the client rect of the HTML element used for events
  42737. * @returns a client rectanglee
  42738. */
  42739. getInputElementClientRect(): Nullable<ClientRect>;
  42740. /**
  42741. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42742. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42743. * @returns true if engine is in deterministic lock step mode
  42744. */
  42745. isDeterministicLockStep(): boolean;
  42746. /**
  42747. * Gets the max steps when engine is running in deterministic lock step
  42748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42749. * @returns the max steps
  42750. */
  42751. getLockstepMaxSteps(): number;
  42752. /**
  42753. * Returns the time in ms between steps when using deterministic lock step.
  42754. * @returns time step in (ms)
  42755. */
  42756. getTimeStep(): number;
  42757. /**
  42758. * Force the mipmap generation for the given render target texture
  42759. * @param texture defines the render target texture to use
  42760. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42761. */
  42762. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42763. /** States */
  42764. /**
  42765. * Set various states to the webGL context
  42766. * @param culling defines backface culling state
  42767. * @param zOffset defines the value to apply to zOffset (0 by default)
  42768. * @param force defines if states must be applied even if cache is up to date
  42769. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42770. */
  42771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42772. /**
  42773. * Set the z offset to apply to current rendering
  42774. * @param value defines the offset to apply
  42775. */
  42776. setZOffset(value: number): void;
  42777. /**
  42778. * Gets the current value of the zOffset
  42779. * @returns the current zOffset state
  42780. */
  42781. getZOffset(): number;
  42782. /**
  42783. * Enable or disable depth buffering
  42784. * @param enable defines the state to set
  42785. */
  42786. setDepthBuffer(enable: boolean): void;
  42787. /**
  42788. * Gets a boolean indicating if depth writing is enabled
  42789. * @returns the current depth writing state
  42790. */
  42791. getDepthWrite(): boolean;
  42792. /**
  42793. * Enable or disable depth writing
  42794. * @param enable defines the state to set
  42795. */
  42796. setDepthWrite(enable: boolean): void;
  42797. /**
  42798. * Gets a boolean indicating if stencil buffer is enabled
  42799. * @returns the current stencil buffer state
  42800. */
  42801. getStencilBuffer(): boolean;
  42802. /**
  42803. * Enable or disable the stencil buffer
  42804. * @param enable defines if the stencil buffer must be enabled or disabled
  42805. */
  42806. setStencilBuffer(enable: boolean): void;
  42807. /**
  42808. * Gets the current stencil mask
  42809. * @returns a number defining the new stencil mask to use
  42810. */
  42811. getStencilMask(): number;
  42812. /**
  42813. * Sets the current stencil mask
  42814. * @param mask defines the new stencil mask to use
  42815. */
  42816. setStencilMask(mask: number): void;
  42817. /**
  42818. * Gets the current stencil function
  42819. * @returns a number defining the stencil function to use
  42820. */
  42821. getStencilFunction(): number;
  42822. /**
  42823. * Gets the current stencil reference value
  42824. * @returns a number defining the stencil reference value to use
  42825. */
  42826. getStencilFunctionReference(): number;
  42827. /**
  42828. * Gets the current stencil mask
  42829. * @returns a number defining the stencil mask to use
  42830. */
  42831. getStencilFunctionMask(): number;
  42832. /**
  42833. * Sets the current stencil function
  42834. * @param stencilFunc defines the new stencil function to use
  42835. */
  42836. setStencilFunction(stencilFunc: number): void;
  42837. /**
  42838. * Sets the current stencil reference
  42839. * @param reference defines the new stencil reference to use
  42840. */
  42841. setStencilFunctionReference(reference: number): void;
  42842. /**
  42843. * Sets the current stencil mask
  42844. * @param mask defines the new stencil mask to use
  42845. */
  42846. setStencilFunctionMask(mask: number): void;
  42847. /**
  42848. * Gets the current stencil operation when stencil fails
  42849. * @returns a number defining stencil operation to use when stencil fails
  42850. */
  42851. getStencilOperationFail(): number;
  42852. /**
  42853. * Gets the current stencil operation when depth fails
  42854. * @returns a number defining stencil operation to use when depth fails
  42855. */
  42856. getStencilOperationDepthFail(): number;
  42857. /**
  42858. * Gets the current stencil operation when stencil passes
  42859. * @returns a number defining stencil operation to use when stencil passes
  42860. */
  42861. getStencilOperationPass(): number;
  42862. /**
  42863. * Sets the stencil operation to use when stencil fails
  42864. * @param operation defines the stencil operation to use when stencil fails
  42865. */
  42866. setStencilOperationFail(operation: number): void;
  42867. /**
  42868. * Sets the stencil operation to use when depth fails
  42869. * @param operation defines the stencil operation to use when depth fails
  42870. */
  42871. setStencilOperationDepthFail(operation: number): void;
  42872. /**
  42873. * Sets the stencil operation to use when stencil passes
  42874. * @param operation defines the stencil operation to use when stencil passes
  42875. */
  42876. setStencilOperationPass(operation: number): void;
  42877. /**
  42878. * Sets a boolean indicating if the dithering state is enabled or disabled
  42879. * @param value defines the dithering state
  42880. */
  42881. setDitheringState(value: boolean): void;
  42882. /**
  42883. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42884. * @param value defines the rasterizer state
  42885. */
  42886. setRasterizerState(value: boolean): void;
  42887. /**
  42888. * Gets the current depth function
  42889. * @returns a number defining the depth function
  42890. */
  42891. getDepthFunction(): Nullable<number>;
  42892. /**
  42893. * Sets the current depth function
  42894. * @param depthFunc defines the function to use
  42895. */
  42896. setDepthFunction(depthFunc: number): void;
  42897. /**
  42898. * Sets the current depth function to GREATER
  42899. */
  42900. setDepthFunctionToGreater(): void;
  42901. /**
  42902. * Sets the current depth function to GEQUAL
  42903. */
  42904. setDepthFunctionToGreaterOrEqual(): void;
  42905. /**
  42906. * Sets the current depth function to LESS
  42907. */
  42908. setDepthFunctionToLess(): void;
  42909. /**
  42910. * Sets the current depth function to LEQUAL
  42911. */
  42912. setDepthFunctionToLessOrEqual(): void;
  42913. private _cachedStencilBuffer;
  42914. private _cachedStencilFunction;
  42915. private _cachedStencilMask;
  42916. private _cachedStencilOperationPass;
  42917. private _cachedStencilOperationFail;
  42918. private _cachedStencilOperationDepthFail;
  42919. private _cachedStencilReference;
  42920. /**
  42921. * Caches the the state of the stencil buffer
  42922. */
  42923. cacheStencilState(): void;
  42924. /**
  42925. * Restores the state of the stencil buffer
  42926. */
  42927. restoreStencilState(): void;
  42928. /**
  42929. * Directly set the WebGL Viewport
  42930. * @param x defines the x coordinate of the viewport (in screen space)
  42931. * @param y defines the y coordinate of the viewport (in screen space)
  42932. * @param width defines the width of the viewport (in screen space)
  42933. * @param height defines the height of the viewport (in screen space)
  42934. * @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
  42935. */
  42936. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42937. /**
  42938. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42939. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42940. * @param y defines the y-coordinate of the corner of the clear rectangle
  42941. * @param width defines the width of the clear rectangle
  42942. * @param height defines the height of the clear rectangle
  42943. * @param clearColor defines the clear color
  42944. */
  42945. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42946. /**
  42947. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42949. * @param y defines the y-coordinate of the corner of the clear rectangle
  42950. * @param width defines the width of the clear rectangle
  42951. * @param height defines the height of the clear rectangle
  42952. */
  42953. enableScissor(x: number, y: number, width: number, height: number): void;
  42954. /**
  42955. * Disable previously set scissor test rectangle
  42956. */
  42957. disableScissor(): void;
  42958. protected _reportDrawCall(): void;
  42959. /**
  42960. * Initializes a webVR display and starts listening to display change events
  42961. * The onVRDisplayChangedObservable will be notified upon these changes
  42962. * @returns The onVRDisplayChangedObservable
  42963. */
  42964. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42965. /** @hidden */
  42966. _prepareVRComponent(): void;
  42967. /** @hidden */
  42968. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42969. /** @hidden */
  42970. _submitVRFrame(): void;
  42971. /**
  42972. * Call this function to leave webVR mode
  42973. * Will do nothing if webVR is not supported or if there is no webVR device
  42974. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42975. */
  42976. disableVR(): void;
  42977. /**
  42978. * Gets a boolean indicating that the system is in VR mode and is presenting
  42979. * @returns true if VR mode is engaged
  42980. */
  42981. isVRPresenting(): boolean;
  42982. /** @hidden */
  42983. _requestVRFrame(): void;
  42984. /** @hidden */
  42985. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42986. /**
  42987. * Gets the source code of the vertex shader associated with a specific webGL program
  42988. * @param program defines the program to use
  42989. * @returns a string containing the source code of the vertex shader associated with the program
  42990. */
  42991. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42992. /**
  42993. * Gets the source code of the fragment shader associated with a specific webGL program
  42994. * @param program defines the program to use
  42995. * @returns a string containing the source code of the fragment shader associated with the program
  42996. */
  42997. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42998. /**
  42999. * Sets a depth stencil texture from a render target to the according uniform.
  43000. * @param channel The texture channel
  43001. * @param uniform The uniform to set
  43002. * @param texture The render target texture containing the depth stencil texture to apply
  43003. */
  43004. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  43005. /**
  43006. * Sets a texture to the webGL context from a postprocess
  43007. * @param channel defines the channel to use
  43008. * @param postProcess defines the source postprocess
  43009. */
  43010. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  43011. /**
  43012. * Binds the output of the passed in post process to the texture channel specified
  43013. * @param channel The channel the texture should be bound to
  43014. * @param postProcess The post process which's output should be bound
  43015. */
  43016. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  43017. protected _rebuildBuffers(): void;
  43018. /** @hidden */
  43019. _renderFrame(): void;
  43020. _renderLoop(): void;
  43021. /** @hidden */
  43022. _renderViews(): boolean;
  43023. /**
  43024. * Toggle full screen mode
  43025. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43026. */
  43027. switchFullscreen(requestPointerLock: boolean): void;
  43028. /**
  43029. * Enters full screen mode
  43030. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43031. */
  43032. enterFullscreen(requestPointerLock: boolean): void;
  43033. /**
  43034. * Exits full screen mode
  43035. */
  43036. exitFullscreen(): void;
  43037. /**
  43038. * Enters Pointerlock mode
  43039. */
  43040. enterPointerlock(): void;
  43041. /**
  43042. * Exits Pointerlock mode
  43043. */
  43044. exitPointerlock(): void;
  43045. /**
  43046. * Begin a new frame
  43047. */
  43048. beginFrame(): void;
  43049. /**
  43050. * Enf the current frame
  43051. */
  43052. endFrame(): void;
  43053. resize(): void;
  43054. /**
  43055. * Force a specific size of the canvas
  43056. * @param width defines the new canvas' width
  43057. * @param height defines the new canvas' height
  43058. * @returns true if the size was changed
  43059. */
  43060. setSize(width: number, height: number): boolean;
  43061. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43062. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43063. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43064. _releaseTexture(texture: InternalTexture): void;
  43065. /**
  43066. * @hidden
  43067. * Rescales a texture
  43068. * @param source input texutre
  43069. * @param destination destination texture
  43070. * @param scene scene to use to render the resize
  43071. * @param internalFormat format to use when resizing
  43072. * @param onComplete callback to be called when resize has completed
  43073. */
  43074. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43075. /**
  43076. * Gets the current framerate
  43077. * @returns a number representing the framerate
  43078. */
  43079. getFps(): number;
  43080. /**
  43081. * Gets the time spent between current and previous frame
  43082. * @returns a number representing the delta time in ms
  43083. */
  43084. getDeltaTime(): number;
  43085. private _measureFps;
  43086. /** @hidden */
  43087. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43088. /**
  43089. * Updates the sample count of a render target texture
  43090. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43091. * @param texture defines the texture to update
  43092. * @param samples defines the sample count to set
  43093. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43094. */
  43095. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43096. /**
  43097. * Updates a depth texture Comparison Mode and Function.
  43098. * If the comparison Function is equal to 0, the mode will be set to none.
  43099. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43100. * @param texture The texture to set the comparison function for
  43101. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43102. */
  43103. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43104. /**
  43105. * Creates a webGL buffer to use with instanciation
  43106. * @param capacity defines the size of the buffer
  43107. * @returns the webGL buffer
  43108. */
  43109. createInstancesBuffer(capacity: number): DataBuffer;
  43110. /**
  43111. * Delete a webGL buffer used with instanciation
  43112. * @param buffer defines the webGL buffer to delete
  43113. */
  43114. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43115. private _clientWaitAsync;
  43116. /** @hidden */
  43117. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43118. dispose(): void;
  43119. private _disableTouchAction;
  43120. /**
  43121. * Display the loading screen
  43122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43123. */
  43124. displayLoadingUI(): void;
  43125. /**
  43126. * Hide the loading screen
  43127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43128. */
  43129. hideLoadingUI(): void;
  43130. /**
  43131. * Gets the current loading screen object
  43132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43133. */
  43134. get loadingScreen(): ILoadingScreen;
  43135. /**
  43136. * Sets the current loading screen object
  43137. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43138. */
  43139. set loadingScreen(loadingScreen: ILoadingScreen);
  43140. /**
  43141. * Sets the current loading screen text
  43142. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43143. */
  43144. set loadingUIText(text: string);
  43145. /**
  43146. * Sets the current loading screen background color
  43147. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43148. */
  43149. set loadingUIBackgroundColor(color: string);
  43150. /** Pointerlock and fullscreen */
  43151. /**
  43152. * Ask the browser to promote the current element to pointerlock mode
  43153. * @param element defines the DOM element to promote
  43154. */
  43155. static _RequestPointerlock(element: HTMLElement): void;
  43156. /**
  43157. * Asks the browser to exit pointerlock mode
  43158. */
  43159. static _ExitPointerlock(): void;
  43160. /**
  43161. * Ask the browser to promote the current element to fullscreen rendering mode
  43162. * @param element defines the DOM element to promote
  43163. */
  43164. static _RequestFullscreen(element: HTMLElement): void;
  43165. /**
  43166. * Asks the browser to exit fullscreen mode
  43167. */
  43168. static _ExitFullscreen(): void;
  43169. }
  43170. }
  43171. declare module "babylonjs/Engines/engineStore" {
  43172. import { Nullable } from "babylonjs/types";
  43173. import { Engine } from "babylonjs/Engines/engine";
  43174. import { Scene } from "babylonjs/scene";
  43175. /**
  43176. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43177. * during the life time of the application.
  43178. */
  43179. export class EngineStore {
  43180. /** Gets the list of created engines */
  43181. static Instances: import("babylonjs/Engines/engine").Engine[];
  43182. /** @hidden */
  43183. static _LastCreatedScene: Nullable<Scene>;
  43184. /**
  43185. * Gets the latest created engine
  43186. */
  43187. static get LastCreatedEngine(): Nullable<Engine>;
  43188. /**
  43189. * Gets the latest created scene
  43190. */
  43191. static get LastCreatedScene(): Nullable<Scene>;
  43192. /**
  43193. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43194. * @ignorenaming
  43195. */
  43196. static UseFallbackTexture: boolean;
  43197. /**
  43198. * Texture content used if a texture cannot loaded
  43199. * @ignorenaming
  43200. */
  43201. static FallbackTexture: string;
  43202. }
  43203. }
  43204. declare module "babylonjs/Misc/promise" {
  43205. /**
  43206. * Helper class that provides a small promise polyfill
  43207. */
  43208. export class PromisePolyfill {
  43209. /**
  43210. * Static function used to check if the polyfill is required
  43211. * If this is the case then the function will inject the polyfill to window.Promise
  43212. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43213. */
  43214. static Apply(force?: boolean): void;
  43215. }
  43216. }
  43217. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43218. /**
  43219. * Interface for screenshot methods with describe argument called `size` as object with options
  43220. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43221. */
  43222. export interface IScreenshotSize {
  43223. /**
  43224. * number in pixels for canvas height
  43225. */
  43226. height?: number;
  43227. /**
  43228. * multiplier allowing render at a higher or lower resolution
  43229. * If value is defined then height and width will be ignored and taken from camera
  43230. */
  43231. precision?: number;
  43232. /**
  43233. * number in pixels for canvas width
  43234. */
  43235. width?: number;
  43236. }
  43237. }
  43238. declare module "babylonjs/Misc/tools" {
  43239. import { Nullable, float } from "babylonjs/types";
  43240. import { DomManagement } from "babylonjs/Misc/domManagement";
  43241. import { WebRequest } from "babylonjs/Misc/webRequest";
  43242. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43243. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43244. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43245. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43246. import { Camera } from "babylonjs/Cameras/camera";
  43247. import { Engine } from "babylonjs/Engines/engine";
  43248. interface IColor4Like {
  43249. r: float;
  43250. g: float;
  43251. b: float;
  43252. a: float;
  43253. }
  43254. /**
  43255. * Class containing a set of static utilities functions
  43256. */
  43257. export class Tools {
  43258. /**
  43259. * Gets or sets the base URL to use to load assets
  43260. */
  43261. static get BaseUrl(): string;
  43262. static set BaseUrl(value: string);
  43263. /**
  43264. * Enable/Disable Custom HTTP Request Headers globally.
  43265. * default = false
  43266. * @see CustomRequestHeaders
  43267. */
  43268. static UseCustomRequestHeaders: boolean;
  43269. /**
  43270. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43271. * i.e. when loading files, where the server/service expects an Authorization header
  43272. */
  43273. static CustomRequestHeaders: {
  43274. [key: string]: string;
  43275. };
  43276. /**
  43277. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43278. */
  43279. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43280. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43281. /**
  43282. * Default behaviour for cors in the application.
  43283. * It can be a string if the expected behavior is identical in the entire app.
  43284. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43285. */
  43286. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43287. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43288. /**
  43289. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43290. * @ignorenaming
  43291. */
  43292. static get UseFallbackTexture(): boolean;
  43293. static set UseFallbackTexture(value: boolean);
  43294. /**
  43295. * Use this object to register external classes like custom textures or material
  43296. * to allow the laoders to instantiate them
  43297. */
  43298. static get RegisteredExternalClasses(): {
  43299. [key: string]: Object;
  43300. };
  43301. static set RegisteredExternalClasses(classes: {
  43302. [key: string]: Object;
  43303. });
  43304. /**
  43305. * Texture content used if a texture cannot loaded
  43306. * @ignorenaming
  43307. */
  43308. static get fallbackTexture(): string;
  43309. static set fallbackTexture(value: string);
  43310. /**
  43311. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43312. * @param u defines the coordinate on X axis
  43313. * @param v defines the coordinate on Y axis
  43314. * @param width defines the width of the source data
  43315. * @param height defines the height of the source data
  43316. * @param pixels defines the source byte array
  43317. * @param color defines the output color
  43318. */
  43319. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43320. /**
  43321. * Interpolates between a and b via alpha
  43322. * @param a The lower value (returned when alpha = 0)
  43323. * @param b The upper value (returned when alpha = 1)
  43324. * @param alpha The interpolation-factor
  43325. * @return The mixed value
  43326. */
  43327. static Mix(a: number, b: number, alpha: number): number;
  43328. /**
  43329. * Tries to instantiate a new object from a given class name
  43330. * @param className defines the class name to instantiate
  43331. * @returns the new object or null if the system was not able to do the instantiation
  43332. */
  43333. static Instantiate(className: string): any;
  43334. /**
  43335. * Provides a slice function that will work even on IE
  43336. * @param data defines the array to slice
  43337. * @param start defines the start of the data (optional)
  43338. * @param end defines the end of the data (optional)
  43339. * @returns the new sliced array
  43340. */
  43341. static Slice<T>(data: T, start?: number, end?: number): T;
  43342. /**
  43343. * Provides a slice function that will work even on IE
  43344. * The difference between this and Slice is that this will force-convert to array
  43345. * @param data defines the array to slice
  43346. * @param start defines the start of the data (optional)
  43347. * @param end defines the end of the data (optional)
  43348. * @returns the new sliced array
  43349. */
  43350. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43351. /**
  43352. * Polyfill for setImmediate
  43353. * @param action defines the action to execute after the current execution block
  43354. */
  43355. static SetImmediate(action: () => void): void;
  43356. /**
  43357. * Function indicating if a number is an exponent of 2
  43358. * @param value defines the value to test
  43359. * @returns true if the value is an exponent of 2
  43360. */
  43361. static IsExponentOfTwo(value: number): boolean;
  43362. private static _tmpFloatArray;
  43363. /**
  43364. * Returns the nearest 32-bit single precision float representation of a Number
  43365. * @param value A Number. If the parameter is of a different type, it will get converted
  43366. * to a number or to NaN if it cannot be converted
  43367. * @returns number
  43368. */
  43369. static FloatRound(value: number): number;
  43370. /**
  43371. * Extracts the filename from a path
  43372. * @param path defines the path to use
  43373. * @returns the filename
  43374. */
  43375. static GetFilename(path: string): string;
  43376. /**
  43377. * Extracts the "folder" part of a path (everything before the filename).
  43378. * @param uri The URI to extract the info from
  43379. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43380. * @returns The "folder" part of the path
  43381. */
  43382. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43383. /**
  43384. * Extracts text content from a DOM element hierarchy
  43385. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43386. */
  43387. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43388. /**
  43389. * Convert an angle in radians to degrees
  43390. * @param angle defines the angle to convert
  43391. * @returns the angle in degrees
  43392. */
  43393. static ToDegrees(angle: number): number;
  43394. /**
  43395. * Convert an angle in degrees to radians
  43396. * @param angle defines the angle to convert
  43397. * @returns the angle in radians
  43398. */
  43399. static ToRadians(angle: number): number;
  43400. /**
  43401. * Returns an array if obj is not an array
  43402. * @param obj defines the object to evaluate as an array
  43403. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43404. * @returns either obj directly if obj is an array or a new array containing obj
  43405. */
  43406. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43407. /**
  43408. * Gets the pointer prefix to use
  43409. * @param engine defines the engine we are finding the prefix for
  43410. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43411. */
  43412. static GetPointerPrefix(engine: Engine): string;
  43413. /**
  43414. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43415. * @param url define the url we are trying
  43416. * @param element define the dom element where to configure the cors policy
  43417. */
  43418. static SetCorsBehavior(url: string | string[], element: {
  43419. crossOrigin: string | null;
  43420. }): void;
  43421. /**
  43422. * Removes unwanted characters from an url
  43423. * @param url defines the url to clean
  43424. * @returns the cleaned url
  43425. */
  43426. static CleanUrl(url: string): string;
  43427. /**
  43428. * Gets or sets a function used to pre-process url before using them to load assets
  43429. */
  43430. static get PreprocessUrl(): (url: string) => string;
  43431. static set PreprocessUrl(processor: (url: string) => string);
  43432. /**
  43433. * Loads an image as an HTMLImageElement.
  43434. * @param input url string, ArrayBuffer, or Blob to load
  43435. * @param onLoad callback called when the image successfully loads
  43436. * @param onError callback called when the image fails to load
  43437. * @param offlineProvider offline provider for caching
  43438. * @param mimeType optional mime type
  43439. * @returns the HTMLImageElement of the loaded image
  43440. */
  43441. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43442. /**
  43443. * Loads a file from a url
  43444. * @param url url string, ArrayBuffer, or Blob to load
  43445. * @param onSuccess callback called when the file successfully loads
  43446. * @param onProgress callback called while file is loading (if the server supports this mode)
  43447. * @param offlineProvider defines the offline provider for caching
  43448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43449. * @param onError callback called when the file fails to load
  43450. * @returns a file request object
  43451. */
  43452. 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;
  43453. /**
  43454. * Loads a file from a url
  43455. * @param url the file url to load
  43456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43457. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43458. */
  43459. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43460. /**
  43461. * Load a script (identified by an url). When the url returns, the
  43462. * content of this file is added into a new script element, attached to the DOM (body element)
  43463. * @param scriptUrl defines the url of the script to laod
  43464. * @param onSuccess defines the callback called when the script is loaded
  43465. * @param onError defines the callback to call if an error occurs
  43466. * @param scriptId defines the id of the script element
  43467. */
  43468. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43469. /**
  43470. * Load an asynchronous script (identified by an url). When the url returns, the
  43471. * content of this file is added into a new script element, attached to the DOM (body element)
  43472. * @param scriptUrl defines the url of the script to laod
  43473. * @param scriptId defines the id of the script element
  43474. * @returns a promise request object
  43475. */
  43476. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43477. /**
  43478. * Loads a file from a blob
  43479. * @param fileToLoad defines the blob to use
  43480. * @param callback defines the callback to call when data is loaded
  43481. * @param progressCallback defines the callback to call during loading process
  43482. * @returns a file request object
  43483. */
  43484. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43485. /**
  43486. * Reads a file from a File object
  43487. * @param file defines the file to load
  43488. * @param onSuccess defines the callback to call when data is loaded
  43489. * @param onProgress defines the callback to call during loading process
  43490. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43491. * @param onError defines the callback to call when an error occurs
  43492. * @returns a file request object
  43493. */
  43494. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43495. /**
  43496. * Creates a data url from a given string content
  43497. * @param content defines the content to convert
  43498. * @returns the new data url link
  43499. */
  43500. static FileAsURL(content: string): string;
  43501. /**
  43502. * Format the given number to a specific decimal format
  43503. * @param value defines the number to format
  43504. * @param decimals defines the number of decimals to use
  43505. * @returns the formatted string
  43506. */
  43507. static Format(value: number, decimals?: number): string;
  43508. /**
  43509. * Tries to copy an object by duplicating every property
  43510. * @param source defines the source object
  43511. * @param destination defines the target object
  43512. * @param doNotCopyList defines a list of properties to avoid
  43513. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43514. */
  43515. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43516. /**
  43517. * Gets a boolean indicating if the given object has no own property
  43518. * @param obj defines the object to test
  43519. * @returns true if object has no own property
  43520. */
  43521. static IsEmpty(obj: any): boolean;
  43522. /**
  43523. * Function used to register events at window level
  43524. * @param windowElement defines the Window object to use
  43525. * @param events defines the events to register
  43526. */
  43527. static RegisterTopRootEvents(windowElement: Window, events: {
  43528. name: string;
  43529. handler: Nullable<(e: FocusEvent) => any>;
  43530. }[]): void;
  43531. /**
  43532. * Function used to unregister events from window level
  43533. * @param windowElement defines the Window object to use
  43534. * @param events defines the events to unregister
  43535. */
  43536. static UnregisterTopRootEvents(windowElement: Window, events: {
  43537. name: string;
  43538. handler: Nullable<(e: FocusEvent) => any>;
  43539. }[]): void;
  43540. /**
  43541. * @ignore
  43542. */
  43543. static _ScreenshotCanvas: HTMLCanvasElement;
  43544. /**
  43545. * Dumps the current bound framebuffer
  43546. * @param width defines the rendering width
  43547. * @param height defines the rendering height
  43548. * @param engine defines the hosting engine
  43549. * @param successCallback defines the callback triggered once the data are available
  43550. * @param mimeType defines the mime type of the result
  43551. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43552. */
  43553. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43554. /**
  43555. * Converts the canvas data to blob.
  43556. * This acts as a polyfill for browsers not supporting the to blob function.
  43557. * @param canvas Defines the canvas to extract the data from
  43558. * @param successCallback Defines the callback triggered once the data are available
  43559. * @param mimeType Defines the mime type of the result
  43560. */
  43561. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43562. /**
  43563. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43564. * @param successCallback defines the callback triggered once the data are available
  43565. * @param mimeType defines the mime type of the result
  43566. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43567. */
  43568. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43569. /**
  43570. * Downloads a blob in the browser
  43571. * @param blob defines the blob to download
  43572. * @param fileName defines the name of the downloaded file
  43573. */
  43574. static Download(blob: Blob, fileName: string): void;
  43575. /**
  43576. * Will return the right value of the noPreventDefault variable
  43577. * Needed to keep backwards compatibility to the old API.
  43578. *
  43579. * @param args arguments passed to the attachControl function
  43580. * @returns the correct value for noPreventDefault
  43581. */
  43582. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43583. /**
  43584. * Captures a screenshot of the current rendering
  43585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43586. * @param engine defines the rendering engine
  43587. * @param camera defines the source camera
  43588. * @param size This parameter can be set to a single number or to an object with the
  43589. * following (optional) properties: precision, width, height. If a single number is passed,
  43590. * it will be used for both width and height. If an object is passed, the screenshot size
  43591. * will be derived from the parameters. The precision property is a multiplier allowing
  43592. * rendering at a higher or lower resolution
  43593. * @param successCallback defines the callback receives a single parameter which contains the
  43594. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43595. * src parameter of an <img> to display it
  43596. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43597. * Check your browser for supported MIME types
  43598. */
  43599. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43600. /**
  43601. * Captures a screenshot of the current rendering
  43602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43603. * @param engine defines the rendering engine
  43604. * @param camera defines the source camera
  43605. * @param size This parameter can be set to a single number or to an object with the
  43606. * following (optional) properties: precision, width, height. If a single number is passed,
  43607. * it will be used for both width and height. If an object is passed, the screenshot size
  43608. * will be derived from the parameters. The precision property is a multiplier allowing
  43609. * rendering at a higher or lower resolution
  43610. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43611. * Check your browser for supported MIME types
  43612. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43613. * to the src parameter of an <img> to display it
  43614. */
  43615. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43616. /**
  43617. * Generates an image screenshot from the specified camera.
  43618. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43619. * @param engine The engine to use for rendering
  43620. * @param camera The camera to use for rendering
  43621. * @param size This parameter can be set to a single number or to an object with the
  43622. * following (optional) properties: precision, width, height. If a single number is passed,
  43623. * it will be used for both width and height. If an object is passed, the screenshot size
  43624. * will be derived from the parameters. The precision property is a multiplier allowing
  43625. * rendering at a higher or lower resolution
  43626. * @param successCallback The callback receives a single parameter which contains the
  43627. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43628. * src parameter of an <img> to display it
  43629. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43630. * Check your browser for supported MIME types
  43631. * @param samples Texture samples (default: 1)
  43632. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43633. * @param fileName A name for for the downloaded file.
  43634. */
  43635. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43636. /**
  43637. * Generates an image screenshot from the specified camera.
  43638. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43639. * @param engine The engine to use for rendering
  43640. * @param camera The camera to use for rendering
  43641. * @param size This parameter can be set to a single number or to an object with the
  43642. * following (optional) properties: precision, width, height. If a single number is passed,
  43643. * it will be used for both width and height. If an object is passed, the screenshot size
  43644. * will be derived from the parameters. The precision property is a multiplier allowing
  43645. * rendering at a higher or lower resolution
  43646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43647. * Check your browser for supported MIME types
  43648. * @param samples Texture samples (default: 1)
  43649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43650. * @param fileName A name for for the downloaded file.
  43651. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43652. * to the src parameter of an <img> to display it
  43653. */
  43654. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43655. /**
  43656. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43657. * Be aware Math.random() could cause collisions, but:
  43658. * "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"
  43659. * @returns a pseudo random id
  43660. */
  43661. static RandomId(): string;
  43662. /**
  43663. * Test if the given uri is a base64 string
  43664. * @param uri The uri to test
  43665. * @return True if the uri is a base64 string or false otherwise
  43666. */
  43667. static IsBase64(uri: string): boolean;
  43668. /**
  43669. * Decode the given base64 uri.
  43670. * @param uri The uri to decode
  43671. * @return The decoded base64 data.
  43672. */
  43673. static DecodeBase64(uri: string): ArrayBuffer;
  43674. /**
  43675. * Gets the absolute url.
  43676. * @param url the input url
  43677. * @return the absolute url
  43678. */
  43679. static GetAbsoluteUrl(url: string): string;
  43680. /**
  43681. * No log
  43682. */
  43683. static readonly NoneLogLevel: number;
  43684. /**
  43685. * Only message logs
  43686. */
  43687. static readonly MessageLogLevel: number;
  43688. /**
  43689. * Only warning logs
  43690. */
  43691. static readonly WarningLogLevel: number;
  43692. /**
  43693. * Only error logs
  43694. */
  43695. static readonly ErrorLogLevel: number;
  43696. /**
  43697. * All logs
  43698. */
  43699. static readonly AllLogLevel: number;
  43700. /**
  43701. * Gets a value indicating the number of loading errors
  43702. * @ignorenaming
  43703. */
  43704. static get errorsCount(): number;
  43705. /**
  43706. * Callback called when a new log is added
  43707. */
  43708. static OnNewCacheEntry: (entry: string) => void;
  43709. /**
  43710. * Log a message to the console
  43711. * @param message defines the message to log
  43712. */
  43713. static Log(message: string): void;
  43714. /**
  43715. * Write a warning message to the console
  43716. * @param message defines the message to log
  43717. */
  43718. static Warn(message: string): void;
  43719. /**
  43720. * Write an error message to the console
  43721. * @param message defines the message to log
  43722. */
  43723. static Error(message: string): void;
  43724. /**
  43725. * Gets current log cache (list of logs)
  43726. */
  43727. static get LogCache(): string;
  43728. /**
  43729. * Clears the log cache
  43730. */
  43731. static ClearLogCache(): void;
  43732. /**
  43733. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43734. */
  43735. static set LogLevels(level: number);
  43736. /**
  43737. * Checks if the window object exists
  43738. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43739. */
  43740. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43741. /**
  43742. * No performance log
  43743. */
  43744. static readonly PerformanceNoneLogLevel: number;
  43745. /**
  43746. * Use user marks to log performance
  43747. */
  43748. static readonly PerformanceUserMarkLogLevel: number;
  43749. /**
  43750. * Log performance to the console
  43751. */
  43752. static readonly PerformanceConsoleLogLevel: number;
  43753. private static _performance;
  43754. /**
  43755. * Sets the current performance log level
  43756. */
  43757. static set PerformanceLogLevel(level: number);
  43758. private static _StartPerformanceCounterDisabled;
  43759. private static _EndPerformanceCounterDisabled;
  43760. private static _StartUserMark;
  43761. private static _EndUserMark;
  43762. private static _StartPerformanceConsole;
  43763. private static _EndPerformanceConsole;
  43764. /**
  43765. * Starts a performance counter
  43766. */
  43767. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43768. /**
  43769. * Ends a specific performance coutner
  43770. */
  43771. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43772. /**
  43773. * Gets either window.performance.now() if supported or Date.now() else
  43774. */
  43775. static get Now(): number;
  43776. /**
  43777. * This method will return the name of the class used to create the instance of the given object.
  43778. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43779. * @param object the object to get the class name from
  43780. * @param isType defines if the object is actually a type
  43781. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43782. */
  43783. static GetClassName(object: any, isType?: boolean): string;
  43784. /**
  43785. * Gets the first element of an array satisfying a given predicate
  43786. * @param array defines the array to browse
  43787. * @param predicate defines the predicate to use
  43788. * @returns null if not found or the element
  43789. */
  43790. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43791. /**
  43792. * This method will return the name of the full name of the class, including its owning module (if any).
  43793. * 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).
  43794. * @param object the object to get the class name from
  43795. * @param isType defines if the object is actually a type
  43796. * @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.
  43797. * @ignorenaming
  43798. */
  43799. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43800. /**
  43801. * Returns a promise that resolves after the given amount of time.
  43802. * @param delay Number of milliseconds to delay
  43803. * @returns Promise that resolves after the given amount of time
  43804. */
  43805. static DelayAsync(delay: number): Promise<void>;
  43806. /**
  43807. * Utility function to detect if the current user agent is Safari
  43808. * @returns whether or not the current user agent is safari
  43809. */
  43810. static IsSafari(): boolean;
  43811. }
  43812. /**
  43813. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43814. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43815. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43816. * @param name The name of the class, case should be preserved
  43817. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43818. */
  43819. export function className(name: string, module?: string): (target: Object) => void;
  43820. /**
  43821. * An implementation of a loop for asynchronous functions.
  43822. */
  43823. export class AsyncLoop {
  43824. /**
  43825. * Defines the number of iterations for the loop
  43826. */
  43827. iterations: number;
  43828. /**
  43829. * Defines the current index of the loop.
  43830. */
  43831. index: number;
  43832. private _done;
  43833. private _fn;
  43834. private _successCallback;
  43835. /**
  43836. * Constructor.
  43837. * @param iterations the number of iterations.
  43838. * @param func the function to run each iteration
  43839. * @param successCallback the callback that will be called upon succesful execution
  43840. * @param offset starting offset.
  43841. */
  43842. constructor(
  43843. /**
  43844. * Defines the number of iterations for the loop
  43845. */
  43846. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43847. /**
  43848. * Execute the next iteration. Must be called after the last iteration was finished.
  43849. */
  43850. executeNext(): void;
  43851. /**
  43852. * Break the loop and run the success callback.
  43853. */
  43854. breakLoop(): void;
  43855. /**
  43856. * Create and run an async loop.
  43857. * @param iterations the number of iterations.
  43858. * @param fn the function to run each iteration
  43859. * @param successCallback the callback that will be called upon succesful execution
  43860. * @param offset starting offset.
  43861. * @returns the created async loop object
  43862. */
  43863. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43864. /**
  43865. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43866. * @param iterations total number of iterations
  43867. * @param syncedIterations number of synchronous iterations in each async iteration.
  43868. * @param fn the function to call each iteration.
  43869. * @param callback a success call back that will be called when iterating stops.
  43870. * @param breakFunction a break condition (optional)
  43871. * @param timeout timeout settings for the setTimeout function. default - 0.
  43872. * @returns the created async loop object
  43873. */
  43874. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43875. }
  43876. }
  43877. declare module "babylonjs/Misc/stringDictionary" {
  43878. import { Nullable } from "babylonjs/types";
  43879. /**
  43880. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43881. * The underlying implementation relies on an associative array to ensure the best performances.
  43882. * The value can be anything including 'null' but except 'undefined'
  43883. */
  43884. export class StringDictionary<T> {
  43885. /**
  43886. * This will clear this dictionary and copy the content from the 'source' one.
  43887. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43888. * @param source the dictionary to take the content from and copy to this dictionary
  43889. */
  43890. copyFrom(source: StringDictionary<T>): void;
  43891. /**
  43892. * Get a value based from its key
  43893. * @param key the given key to get the matching value from
  43894. * @return the value if found, otherwise undefined is returned
  43895. */
  43896. get(key: string): T | undefined;
  43897. /**
  43898. * Get a value from its key or add it if it doesn't exist.
  43899. * This method will ensure you that a given key/data will be present in the dictionary.
  43900. * @param key the given key to get the matching value from
  43901. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43902. * The factory will only be invoked if there's no data for the given key.
  43903. * @return the value corresponding to the key.
  43904. */
  43905. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43906. /**
  43907. * Get a value from its key if present in the dictionary otherwise add it
  43908. * @param key the key to get the value from
  43909. * @param val if there's no such key/value pair in the dictionary add it with this value
  43910. * @return the value corresponding to the key
  43911. */
  43912. getOrAdd(key: string, val: T): T;
  43913. /**
  43914. * Check if there's a given key in the dictionary
  43915. * @param key the key to check for
  43916. * @return true if the key is present, false otherwise
  43917. */
  43918. contains(key: string): boolean;
  43919. /**
  43920. * Add a new key and its corresponding value
  43921. * @param key the key to add
  43922. * @param value the value corresponding to the key
  43923. * @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
  43924. */
  43925. add(key: string, value: T): boolean;
  43926. /**
  43927. * Update a specific value associated to a key
  43928. * @param key defines the key to use
  43929. * @param value defines the value to store
  43930. * @returns true if the value was updated (or false if the key was not found)
  43931. */
  43932. set(key: string, value: T): boolean;
  43933. /**
  43934. * Get the element of the given key and remove it from the dictionary
  43935. * @param key defines the key to search
  43936. * @returns the value associated with the key or null if not found
  43937. */
  43938. getAndRemove(key: string): Nullable<T>;
  43939. /**
  43940. * Remove a key/value from the dictionary.
  43941. * @param key the key to remove
  43942. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43943. */
  43944. remove(key: string): boolean;
  43945. /**
  43946. * Clear the whole content of the dictionary
  43947. */
  43948. clear(): void;
  43949. /**
  43950. * Gets the current count
  43951. */
  43952. get count(): number;
  43953. /**
  43954. * Execute a callback on each key/val of the dictionary.
  43955. * Note that you can remove any element in this dictionary in the callback implementation
  43956. * @param callback the callback to execute on a given key/value pair
  43957. */
  43958. forEach(callback: (key: string, val: T) => void): void;
  43959. /**
  43960. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43961. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43962. * Note that you can remove any element in this dictionary in the callback implementation
  43963. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43964. * @returns the first item
  43965. */
  43966. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43967. private _count;
  43968. private _data;
  43969. }
  43970. }
  43971. declare module "babylonjs/Collisions/collisionCoordinator" {
  43972. import { Nullable } from "babylonjs/types";
  43973. import { Scene } from "babylonjs/scene";
  43974. import { Vector3 } from "babylonjs/Maths/math.vector";
  43975. import { Collider } from "babylonjs/Collisions/collider";
  43976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43977. /** @hidden */
  43978. export interface ICollisionCoordinator {
  43979. createCollider(): Collider;
  43980. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43981. init(scene: Scene): void;
  43982. }
  43983. /** @hidden */
  43984. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43985. private _scene;
  43986. private _scaledPosition;
  43987. private _scaledVelocity;
  43988. private _finalPosition;
  43989. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43990. createCollider(): Collider;
  43991. init(scene: Scene): void;
  43992. private _collideWithWorld;
  43993. }
  43994. }
  43995. declare module "babylonjs/Inputs/scene.inputManager" {
  43996. import { Nullable } from "babylonjs/types";
  43997. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43998. import { Vector2 } from "babylonjs/Maths/math.vector";
  43999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44000. import { Scene } from "babylonjs/scene";
  44001. /**
  44002. * Class used to manage all inputs for the scene.
  44003. */
  44004. export class InputManager {
  44005. /** The distance in pixel that you have to move to prevent some events */
  44006. static DragMovementThreshold: number;
  44007. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44008. static LongPressDelay: number;
  44009. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44010. static DoubleClickDelay: number;
  44011. /** If you need to check double click without raising a single click at first click, enable this flag */
  44012. static ExclusiveDoubleClickMode: boolean;
  44013. /** 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. */
  44014. private _alreadyAttached;
  44015. private _alreadyAttachedTo;
  44016. private _wheelEventName;
  44017. private _onPointerMove;
  44018. private _onPointerDown;
  44019. private _onPointerUp;
  44020. private _initClickEvent;
  44021. private _initActionManager;
  44022. private _delayedSimpleClick;
  44023. private _delayedSimpleClickTimeout;
  44024. private _previousDelayedSimpleClickTimeout;
  44025. private _meshPickProceed;
  44026. private _previousButtonPressed;
  44027. private _currentPickResult;
  44028. private _previousPickResult;
  44029. private _totalPointersPressed;
  44030. private _doubleClickOccured;
  44031. private _pointerOverMesh;
  44032. private _pickedDownMesh;
  44033. private _pickedUpMesh;
  44034. private _pointerX;
  44035. private _pointerY;
  44036. private _unTranslatedPointerX;
  44037. private _unTranslatedPointerY;
  44038. private _startingPointerPosition;
  44039. private _previousStartingPointerPosition;
  44040. private _startingPointerTime;
  44041. private _previousStartingPointerTime;
  44042. private _pointerCaptures;
  44043. private _meshUnderPointerId;
  44044. private _onKeyDown;
  44045. private _onKeyUp;
  44046. private _keyboardIsAttached;
  44047. private _onCanvasFocusObserver;
  44048. private _onCanvasBlurObserver;
  44049. private _scene;
  44050. /**
  44051. * Creates a new InputManager
  44052. * @param scene defines the hosting scene
  44053. */
  44054. constructor(scene: Scene);
  44055. /**
  44056. * Gets the mesh that is currently under the pointer
  44057. */
  44058. get meshUnderPointer(): Nullable<AbstractMesh>;
  44059. /**
  44060. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44061. * @param pointerId the pointer id to use
  44062. * @returns The mesh under this pointer id or null if not found
  44063. */
  44064. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44065. /**
  44066. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44067. */
  44068. get unTranslatedPointer(): Vector2;
  44069. /**
  44070. * Gets or sets the current on-screen X position of the pointer
  44071. */
  44072. get pointerX(): number;
  44073. set pointerX(value: number);
  44074. /**
  44075. * Gets or sets the current on-screen Y position of the pointer
  44076. */
  44077. get pointerY(): number;
  44078. set pointerY(value: number);
  44079. private _updatePointerPosition;
  44080. private _processPointerMove;
  44081. private _setRayOnPointerInfo;
  44082. private _checkPrePointerObservable;
  44083. /**
  44084. * Use this method to simulate a pointer move on a mesh
  44085. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44086. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44087. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44088. */
  44089. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44090. /**
  44091. * Use this method to simulate a pointer down on a mesh
  44092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44095. */
  44096. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44097. private _processPointerDown;
  44098. /** @hidden */
  44099. _isPointerSwiping(): boolean;
  44100. /**
  44101. * Use this method to simulate a pointer up on a mesh
  44102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44105. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44106. */
  44107. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44108. private _processPointerUp;
  44109. /**
  44110. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44111. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44112. * @returns true if the pointer was captured
  44113. */
  44114. isPointerCaptured(pointerId?: number): boolean;
  44115. /**
  44116. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44117. * @param attachUp defines if you want to attach events to pointerup
  44118. * @param attachDown defines if you want to attach events to pointerdown
  44119. * @param attachMove defines if you want to attach events to pointermove
  44120. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44121. */
  44122. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44123. /**
  44124. * Detaches all event handlers
  44125. */
  44126. detachControl(): void;
  44127. /**
  44128. * Force the value of meshUnderPointer
  44129. * @param mesh defines the mesh to use
  44130. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44131. */
  44132. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44133. /**
  44134. * Gets the mesh under the pointer
  44135. * @returns a Mesh or null if no mesh is under the pointer
  44136. */
  44137. getPointerOverMesh(): Nullable<AbstractMesh>;
  44138. }
  44139. }
  44140. declare module "babylonjs/Animations/animationGroup" {
  44141. import { Animatable } from "babylonjs/Animations/animatable";
  44142. import { Animation } from "babylonjs/Animations/animation";
  44143. import { Scene, IDisposable } from "babylonjs/scene";
  44144. import { Observable } from "babylonjs/Misc/observable";
  44145. import { Nullable } from "babylonjs/types";
  44146. import "babylonjs/Animations/animatable";
  44147. /**
  44148. * This class defines the direct association between an animation and a target
  44149. */
  44150. export class TargetedAnimation {
  44151. /**
  44152. * Animation to perform
  44153. */
  44154. animation: Animation;
  44155. /**
  44156. * Target to animate
  44157. */
  44158. target: any;
  44159. /**
  44160. * Returns the string "TargetedAnimation"
  44161. * @returns "TargetedAnimation"
  44162. */
  44163. getClassName(): string;
  44164. /**
  44165. * Serialize the object
  44166. * @returns the JSON object representing the current entity
  44167. */
  44168. serialize(): any;
  44169. }
  44170. /**
  44171. * Use this class to create coordinated animations on multiple targets
  44172. */
  44173. export class AnimationGroup implements IDisposable {
  44174. /** The name of the animation group */
  44175. name: string;
  44176. private _scene;
  44177. private _targetedAnimations;
  44178. private _animatables;
  44179. private _from;
  44180. private _to;
  44181. private _isStarted;
  44182. private _isPaused;
  44183. private _speedRatio;
  44184. private _loopAnimation;
  44185. private _isAdditive;
  44186. /**
  44187. * Gets or sets the unique id of the node
  44188. */
  44189. uniqueId: number;
  44190. /**
  44191. * This observable will notify when one animation have ended
  44192. */
  44193. onAnimationEndObservable: Observable<TargetedAnimation>;
  44194. /**
  44195. * Observer raised when one animation loops
  44196. */
  44197. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44198. /**
  44199. * Observer raised when all animations have looped
  44200. */
  44201. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44202. /**
  44203. * This observable will notify when all animations have ended.
  44204. */
  44205. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44206. /**
  44207. * This observable will notify when all animations have paused.
  44208. */
  44209. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44210. /**
  44211. * This observable will notify when all animations are playing.
  44212. */
  44213. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44214. /**
  44215. * Gets the first frame
  44216. */
  44217. get from(): number;
  44218. /**
  44219. * Gets the last frame
  44220. */
  44221. get to(): number;
  44222. /**
  44223. * Define if the animations are started
  44224. */
  44225. get isStarted(): boolean;
  44226. /**
  44227. * Gets a value indicating that the current group is playing
  44228. */
  44229. get isPlaying(): boolean;
  44230. /**
  44231. * Gets or sets the speed ratio to use for all animations
  44232. */
  44233. get speedRatio(): number;
  44234. /**
  44235. * Gets or sets the speed ratio to use for all animations
  44236. */
  44237. set speedRatio(value: number);
  44238. /**
  44239. * Gets or sets if all animations should loop or not
  44240. */
  44241. get loopAnimation(): boolean;
  44242. set loopAnimation(value: boolean);
  44243. /**
  44244. * Gets or sets if all animations should be evaluated additively
  44245. */
  44246. get isAdditive(): boolean;
  44247. set isAdditive(value: boolean);
  44248. /**
  44249. * Gets the targeted animations for this animation group
  44250. */
  44251. get targetedAnimations(): Array<TargetedAnimation>;
  44252. /**
  44253. * returning the list of animatables controlled by this animation group.
  44254. */
  44255. get animatables(): Array<Animatable>;
  44256. /**
  44257. * Gets the list of target animations
  44258. */
  44259. get children(): TargetedAnimation[];
  44260. /**
  44261. * Instantiates a new Animation Group.
  44262. * This helps managing several animations at once.
  44263. * @see https://doc.babylonjs.com/how_to/group
  44264. * @param name Defines the name of the group
  44265. * @param scene Defines the scene the group belongs to
  44266. */
  44267. constructor(
  44268. /** The name of the animation group */
  44269. name: string, scene?: Nullable<Scene>);
  44270. /**
  44271. * Add an animation (with its target) in the group
  44272. * @param animation defines the animation we want to add
  44273. * @param target defines the target of the animation
  44274. * @returns the TargetedAnimation object
  44275. */
  44276. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44277. /**
  44278. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44279. * It can add constant keys at begin or end
  44280. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44281. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44282. * @returns the animation group
  44283. */
  44284. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44285. private _animationLoopCount;
  44286. private _animationLoopFlags;
  44287. private _processLoop;
  44288. /**
  44289. * Start all animations on given targets
  44290. * @param loop defines if animations must loop
  44291. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44292. * @param from defines the from key (optional)
  44293. * @param to defines the to key (optional)
  44294. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44295. * @returns the current animation group
  44296. */
  44297. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44298. /**
  44299. * Pause all animations
  44300. * @returns the animation group
  44301. */
  44302. pause(): AnimationGroup;
  44303. /**
  44304. * Play all animations to initial state
  44305. * This function will start() the animations if they were not started or will restart() them if they were paused
  44306. * @param loop defines if animations must loop
  44307. * @returns the animation group
  44308. */
  44309. play(loop?: boolean): AnimationGroup;
  44310. /**
  44311. * Reset all animations to initial state
  44312. * @returns the animation group
  44313. */
  44314. reset(): AnimationGroup;
  44315. /**
  44316. * Restart animations from key 0
  44317. * @returns the animation group
  44318. */
  44319. restart(): AnimationGroup;
  44320. /**
  44321. * Stop all animations
  44322. * @returns the animation group
  44323. */
  44324. stop(): AnimationGroup;
  44325. /**
  44326. * Set animation weight for all animatables
  44327. * @param weight defines the weight to use
  44328. * @return the animationGroup
  44329. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44330. */
  44331. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44332. /**
  44333. * Synchronize and normalize all animatables with a source animatable
  44334. * @param root defines the root animatable to synchronize with
  44335. * @return the animationGroup
  44336. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44337. */
  44338. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44339. /**
  44340. * Goes to a specific frame in this animation group
  44341. * @param frame the frame number to go to
  44342. * @return the animationGroup
  44343. */
  44344. goToFrame(frame: number): AnimationGroup;
  44345. /**
  44346. * Dispose all associated resources
  44347. */
  44348. dispose(): void;
  44349. private _checkAnimationGroupEnded;
  44350. /**
  44351. * Clone the current animation group and returns a copy
  44352. * @param newName defines the name of the new group
  44353. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44354. * @returns the new aniamtion group
  44355. */
  44356. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44357. /**
  44358. * Serializes the animationGroup to an object
  44359. * @returns Serialized object
  44360. */
  44361. serialize(): any;
  44362. /**
  44363. * Returns a new AnimationGroup object parsed from the source provided.
  44364. * @param parsedAnimationGroup defines the source
  44365. * @param scene defines the scene that will receive the animationGroup
  44366. * @returns a new AnimationGroup
  44367. */
  44368. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44369. /**
  44370. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44371. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44372. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44373. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44374. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44375. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44376. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44377. */
  44378. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44379. /**
  44380. * Returns the string "AnimationGroup"
  44381. * @returns "AnimationGroup"
  44382. */
  44383. getClassName(): string;
  44384. /**
  44385. * Creates a detailled string about the object
  44386. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44387. * @returns a string representing the object
  44388. */
  44389. toString(fullDetails?: boolean): string;
  44390. }
  44391. }
  44392. declare module "babylonjs/scene" {
  44393. import { Nullable } from "babylonjs/types";
  44394. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44397. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44398. import { Geometry } from "babylonjs/Meshes/geometry";
  44399. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44400. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44402. import { Mesh } from "babylonjs/Meshes/mesh";
  44403. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44404. import { Bone } from "babylonjs/Bones/bone";
  44405. import { Skeleton } from "babylonjs/Bones/skeleton";
  44406. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44407. import { Camera } from "babylonjs/Cameras/camera";
  44408. import { AbstractScene } from "babylonjs/abstractScene";
  44409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44411. import { Material } from "babylonjs/Materials/material";
  44412. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44413. import { Effect } from "babylonjs/Materials/effect";
  44414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44415. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44416. import { Light } from "babylonjs/Lights/light";
  44417. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44418. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44419. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44420. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44421. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44422. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44423. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44424. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44425. import { Engine } from "babylonjs/Engines/engine";
  44426. import { Node } from "babylonjs/node";
  44427. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44428. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44429. import { WebRequest } from "babylonjs/Misc/webRequest";
  44430. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44431. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44432. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44433. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44434. import { Plane } from "babylonjs/Maths/math.plane";
  44435. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44436. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44437. import { Ray } from "babylonjs/Culling/ray";
  44438. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44439. import { Animation } from "babylonjs/Animations/animation";
  44440. import { Animatable } from "babylonjs/Animations/animatable";
  44441. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44442. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44443. import { Collider } from "babylonjs/Collisions/collider";
  44444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44445. /**
  44446. * Define an interface for all classes that will hold resources
  44447. */
  44448. export interface IDisposable {
  44449. /**
  44450. * Releases all held resources
  44451. */
  44452. dispose(): void;
  44453. }
  44454. /** Interface defining initialization parameters for Scene class */
  44455. export interface SceneOptions {
  44456. /**
  44457. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44458. * It will improve performance when the number of geometries becomes important.
  44459. */
  44460. useGeometryUniqueIdsMap?: boolean;
  44461. /**
  44462. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44463. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44464. */
  44465. useMaterialMeshMap?: boolean;
  44466. /**
  44467. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44468. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44469. */
  44470. useClonedMeshMap?: boolean;
  44471. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44472. virtual?: boolean;
  44473. }
  44474. /**
  44475. * Represents a scene to be rendered by the engine.
  44476. * @see https://doc.babylonjs.com/features/scene
  44477. */
  44478. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44479. /** The fog is deactivated */
  44480. static readonly FOGMODE_NONE: number;
  44481. /** The fog density is following an exponential function */
  44482. static readonly FOGMODE_EXP: number;
  44483. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44484. static readonly FOGMODE_EXP2: number;
  44485. /** The fog density is following a linear function. */
  44486. static readonly FOGMODE_LINEAR: number;
  44487. /**
  44488. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44489. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44490. */
  44491. static MinDeltaTime: number;
  44492. /**
  44493. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44495. */
  44496. static MaxDeltaTime: number;
  44497. /**
  44498. * Factory used to create the default material.
  44499. * @param name The name of the material to create
  44500. * @param scene The scene to create the material for
  44501. * @returns The default material
  44502. */
  44503. static DefaultMaterialFactory(scene: Scene): Material;
  44504. /**
  44505. * Factory used to create the a collision coordinator.
  44506. * @returns The collision coordinator
  44507. */
  44508. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44509. /** @hidden */
  44510. _inputManager: InputManager;
  44511. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44512. cameraToUseForPointers: Nullable<Camera>;
  44513. /** @hidden */
  44514. readonly _isScene: boolean;
  44515. /** @hidden */
  44516. _blockEntityCollection: boolean;
  44517. /**
  44518. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44519. */
  44520. autoClear: boolean;
  44521. /**
  44522. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44523. */
  44524. autoClearDepthAndStencil: boolean;
  44525. /**
  44526. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44527. */
  44528. clearColor: Color4;
  44529. /**
  44530. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44531. */
  44532. ambientColor: Color3;
  44533. /**
  44534. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44535. * It should only be one of the following (if not the default embedded one):
  44536. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44537. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44538. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44539. * The material properties need to be setup according to the type of texture in use.
  44540. */
  44541. environmentBRDFTexture: BaseTexture;
  44542. /**
  44543. * Texture used in all pbr material as the reflection texture.
  44544. * As in the majority of the scene they are the same (exception for multi room and so on),
  44545. * this is easier to reference from here than from all the materials.
  44546. */
  44547. get environmentTexture(): Nullable<BaseTexture>;
  44548. /**
  44549. * Texture used in all pbr material as the reflection texture.
  44550. * As in the majority of the scene they are the same (exception for multi room and so on),
  44551. * this is easier to set here than in all the materials.
  44552. */
  44553. set environmentTexture(value: Nullable<BaseTexture>);
  44554. /** @hidden */
  44555. protected _environmentIntensity: number;
  44556. /**
  44557. * Intensity of the environment in all pbr material.
  44558. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44559. * As in the majority of the scene they are the same (exception for multi room and so on),
  44560. * this is easier to reference from here than from all the materials.
  44561. */
  44562. get environmentIntensity(): number;
  44563. /**
  44564. * Intensity of the environment in all pbr material.
  44565. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44566. * As in the majority of the scene they are the same (exception for multi room and so on),
  44567. * this is easier to set here than in all the materials.
  44568. */
  44569. set environmentIntensity(value: number);
  44570. /** @hidden */
  44571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44572. /**
  44573. * Default image processing configuration used either in the rendering
  44574. * Forward main pass or through the imageProcessingPostProcess if present.
  44575. * As in the majority of the scene they are the same (exception for multi camera),
  44576. * this is easier to reference from here than from all the materials and post process.
  44577. *
  44578. * No setter as we it is a shared configuration, you can set the values instead.
  44579. */
  44580. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44581. private _forceWireframe;
  44582. /**
  44583. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44584. */
  44585. set forceWireframe(value: boolean);
  44586. get forceWireframe(): boolean;
  44587. private _skipFrustumClipping;
  44588. /**
  44589. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44590. */
  44591. set skipFrustumClipping(value: boolean);
  44592. get skipFrustumClipping(): boolean;
  44593. private _forcePointsCloud;
  44594. /**
  44595. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44596. */
  44597. set forcePointsCloud(value: boolean);
  44598. get forcePointsCloud(): boolean;
  44599. /**
  44600. * Gets or sets the active clipplane 1
  44601. */
  44602. clipPlane: Nullable<Plane>;
  44603. /**
  44604. * Gets or sets the active clipplane 2
  44605. */
  44606. clipPlane2: Nullable<Plane>;
  44607. /**
  44608. * Gets or sets the active clipplane 3
  44609. */
  44610. clipPlane3: Nullable<Plane>;
  44611. /**
  44612. * Gets or sets the active clipplane 4
  44613. */
  44614. clipPlane4: Nullable<Plane>;
  44615. /**
  44616. * Gets or sets the active clipplane 5
  44617. */
  44618. clipPlane5: Nullable<Plane>;
  44619. /**
  44620. * Gets or sets the active clipplane 6
  44621. */
  44622. clipPlane6: Nullable<Plane>;
  44623. /**
  44624. * Gets or sets a boolean indicating if animations are enabled
  44625. */
  44626. animationsEnabled: boolean;
  44627. private _animationPropertiesOverride;
  44628. /**
  44629. * Gets or sets the animation properties override
  44630. */
  44631. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44632. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44633. /**
  44634. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44635. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44636. */
  44637. useConstantAnimationDeltaTime: boolean;
  44638. /**
  44639. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44640. * Please note that it requires to run a ray cast through the scene on every frame
  44641. */
  44642. constantlyUpdateMeshUnderPointer: boolean;
  44643. /**
  44644. * Defines the HTML cursor to use when hovering over interactive elements
  44645. */
  44646. hoverCursor: string;
  44647. /**
  44648. * Defines the HTML default cursor to use (empty by default)
  44649. */
  44650. defaultCursor: string;
  44651. /**
  44652. * Defines whether cursors are handled by the scene.
  44653. */
  44654. doNotHandleCursors: boolean;
  44655. /**
  44656. * This is used to call preventDefault() on pointer down
  44657. * in order to block unwanted artifacts like system double clicks
  44658. */
  44659. preventDefaultOnPointerDown: boolean;
  44660. /**
  44661. * This is used to call preventDefault() on pointer up
  44662. * in order to block unwanted artifacts like system double clicks
  44663. */
  44664. preventDefaultOnPointerUp: boolean;
  44665. /**
  44666. * Gets or sets user defined metadata
  44667. */
  44668. metadata: any;
  44669. /**
  44670. * For internal use only. Please do not use.
  44671. */
  44672. reservedDataStore: any;
  44673. /**
  44674. * Gets the name of the plugin used to load this scene (null by default)
  44675. */
  44676. loadingPluginName: string;
  44677. /**
  44678. * Use this array to add regular expressions used to disable offline support for specific urls
  44679. */
  44680. disableOfflineSupportExceptionRules: RegExp[];
  44681. /**
  44682. * An event triggered when the scene is disposed.
  44683. */
  44684. onDisposeObservable: Observable<Scene>;
  44685. private _onDisposeObserver;
  44686. /** Sets a function to be executed when this scene is disposed. */
  44687. set onDispose(callback: () => void);
  44688. /**
  44689. * An event triggered before rendering the scene (right after animations and physics)
  44690. */
  44691. onBeforeRenderObservable: Observable<Scene>;
  44692. private _onBeforeRenderObserver;
  44693. /** Sets a function to be executed before rendering this scene */
  44694. set beforeRender(callback: Nullable<() => void>);
  44695. /**
  44696. * An event triggered after rendering the scene
  44697. */
  44698. onAfterRenderObservable: Observable<Scene>;
  44699. /**
  44700. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44701. */
  44702. onAfterRenderCameraObservable: Observable<Camera>;
  44703. private _onAfterRenderObserver;
  44704. /** Sets a function to be executed after rendering this scene */
  44705. set afterRender(callback: Nullable<() => void>);
  44706. /**
  44707. * An event triggered before animating the scene
  44708. */
  44709. onBeforeAnimationsObservable: Observable<Scene>;
  44710. /**
  44711. * An event triggered after animations processing
  44712. */
  44713. onAfterAnimationsObservable: Observable<Scene>;
  44714. /**
  44715. * An event triggered before draw calls are ready to be sent
  44716. */
  44717. onBeforeDrawPhaseObservable: Observable<Scene>;
  44718. /**
  44719. * An event triggered after draw calls have been sent
  44720. */
  44721. onAfterDrawPhaseObservable: Observable<Scene>;
  44722. /**
  44723. * An event triggered when the scene is ready
  44724. */
  44725. onReadyObservable: Observable<Scene>;
  44726. /**
  44727. * An event triggered before rendering a camera
  44728. */
  44729. onBeforeCameraRenderObservable: Observable<Camera>;
  44730. private _onBeforeCameraRenderObserver;
  44731. /** Sets a function to be executed before rendering a camera*/
  44732. set beforeCameraRender(callback: () => void);
  44733. /**
  44734. * An event triggered after rendering a camera
  44735. */
  44736. onAfterCameraRenderObservable: Observable<Camera>;
  44737. private _onAfterCameraRenderObserver;
  44738. /** Sets a function to be executed after rendering a camera*/
  44739. set afterCameraRender(callback: () => void);
  44740. /**
  44741. * An event triggered when active meshes evaluation is about to start
  44742. */
  44743. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44744. /**
  44745. * An event triggered when active meshes evaluation is done
  44746. */
  44747. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44748. /**
  44749. * An event triggered when particles rendering is about to start
  44750. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44751. */
  44752. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44753. /**
  44754. * An event triggered when particles rendering is done
  44755. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44756. */
  44757. onAfterParticlesRenderingObservable: Observable<Scene>;
  44758. /**
  44759. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44760. */
  44761. onDataLoadedObservable: Observable<Scene>;
  44762. /**
  44763. * An event triggered when a camera is created
  44764. */
  44765. onNewCameraAddedObservable: Observable<Camera>;
  44766. /**
  44767. * An event triggered when a camera is removed
  44768. */
  44769. onCameraRemovedObservable: Observable<Camera>;
  44770. /**
  44771. * An event triggered when a light is created
  44772. */
  44773. onNewLightAddedObservable: Observable<Light>;
  44774. /**
  44775. * An event triggered when a light is removed
  44776. */
  44777. onLightRemovedObservable: Observable<Light>;
  44778. /**
  44779. * An event triggered when a geometry is created
  44780. */
  44781. onNewGeometryAddedObservable: Observable<Geometry>;
  44782. /**
  44783. * An event triggered when a geometry is removed
  44784. */
  44785. onGeometryRemovedObservable: Observable<Geometry>;
  44786. /**
  44787. * An event triggered when a transform node is created
  44788. */
  44789. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44790. /**
  44791. * An event triggered when a transform node is removed
  44792. */
  44793. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44794. /**
  44795. * An event triggered when a mesh is created
  44796. */
  44797. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44798. /**
  44799. * An event triggered when a mesh is removed
  44800. */
  44801. onMeshRemovedObservable: Observable<AbstractMesh>;
  44802. /**
  44803. * An event triggered when a skeleton is created
  44804. */
  44805. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44806. /**
  44807. * An event triggered when a skeleton is removed
  44808. */
  44809. onSkeletonRemovedObservable: Observable<Skeleton>;
  44810. /**
  44811. * An event triggered when a material is created
  44812. */
  44813. onNewMaterialAddedObservable: Observable<Material>;
  44814. /**
  44815. * An event triggered when a multi material is created
  44816. */
  44817. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44818. /**
  44819. * An event triggered when a material is removed
  44820. */
  44821. onMaterialRemovedObservable: Observable<Material>;
  44822. /**
  44823. * An event triggered when a multi material is removed
  44824. */
  44825. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44826. /**
  44827. * An event triggered when a texture is created
  44828. */
  44829. onNewTextureAddedObservable: Observable<BaseTexture>;
  44830. /**
  44831. * An event triggered when a texture is removed
  44832. */
  44833. onTextureRemovedObservable: Observable<BaseTexture>;
  44834. /**
  44835. * An event triggered when render targets are about to be rendered
  44836. * Can happen multiple times per frame.
  44837. */
  44838. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44839. /**
  44840. * An event triggered when render targets were rendered.
  44841. * Can happen multiple times per frame.
  44842. */
  44843. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44844. /**
  44845. * An event triggered before calculating deterministic simulation step
  44846. */
  44847. onBeforeStepObservable: Observable<Scene>;
  44848. /**
  44849. * An event triggered after calculating deterministic simulation step
  44850. */
  44851. onAfterStepObservable: Observable<Scene>;
  44852. /**
  44853. * An event triggered when the activeCamera property is updated
  44854. */
  44855. onActiveCameraChanged: Observable<Scene>;
  44856. /**
  44857. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44858. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44859. * 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)
  44860. */
  44861. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44862. /**
  44863. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44864. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44865. * 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)
  44866. */
  44867. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44868. /**
  44869. * This Observable will when a mesh has been imported into the scene.
  44870. */
  44871. onMeshImportedObservable: Observable<AbstractMesh>;
  44872. /**
  44873. * This Observable will when an animation file has been imported into the scene.
  44874. */
  44875. onAnimationFileImportedObservable: Observable<Scene>;
  44876. /**
  44877. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44878. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44879. */
  44880. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44881. /** @hidden */
  44882. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44883. /**
  44884. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44885. */
  44886. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44887. /**
  44888. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44889. */
  44890. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44891. /**
  44892. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44893. */
  44894. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44895. /** Callback called when a pointer move is detected */
  44896. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44897. /** Callback called when a pointer down is detected */
  44898. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44899. /** Callback called when a pointer up is detected */
  44900. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44901. /** Callback called when a pointer pick is detected */
  44902. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44903. /**
  44904. * 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).
  44905. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44906. */
  44907. onPrePointerObservable: Observable<PointerInfoPre>;
  44908. /**
  44909. * Observable event triggered each time an input event is received from the rendering canvas
  44910. */
  44911. onPointerObservable: Observable<PointerInfo>;
  44912. /**
  44913. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44914. */
  44915. get unTranslatedPointer(): Vector2;
  44916. /**
  44917. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44918. */
  44919. static get DragMovementThreshold(): number;
  44920. static set DragMovementThreshold(value: number);
  44921. /**
  44922. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44923. */
  44924. static get LongPressDelay(): number;
  44925. static set LongPressDelay(value: number);
  44926. /**
  44927. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44928. */
  44929. static get DoubleClickDelay(): number;
  44930. static set DoubleClickDelay(value: number);
  44931. /** If you need to check double click without raising a single click at first click, enable this flag */
  44932. static get ExclusiveDoubleClickMode(): boolean;
  44933. static set ExclusiveDoubleClickMode(value: boolean);
  44934. /** @hidden */
  44935. _mirroredCameraPosition: Nullable<Vector3>;
  44936. /**
  44937. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44938. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44939. */
  44940. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44941. /**
  44942. * Observable event triggered each time an keyboard event is received from the hosting window
  44943. */
  44944. onKeyboardObservable: Observable<KeyboardInfo>;
  44945. private _useRightHandedSystem;
  44946. /**
  44947. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44948. */
  44949. set useRightHandedSystem(value: boolean);
  44950. get useRightHandedSystem(): boolean;
  44951. private _timeAccumulator;
  44952. private _currentStepId;
  44953. private _currentInternalStep;
  44954. /**
  44955. * Sets the step Id used by deterministic lock step
  44956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44957. * @param newStepId defines the step Id
  44958. */
  44959. setStepId(newStepId: number): void;
  44960. /**
  44961. * Gets the step Id used by deterministic lock step
  44962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44963. * @returns the step Id
  44964. */
  44965. getStepId(): number;
  44966. /**
  44967. * Gets the internal step used by deterministic lock step
  44968. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44969. * @returns the internal step
  44970. */
  44971. getInternalStep(): number;
  44972. private _fogEnabled;
  44973. /**
  44974. * Gets or sets a boolean indicating if fog is enabled on this scene
  44975. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44976. * (Default is true)
  44977. */
  44978. set fogEnabled(value: boolean);
  44979. get fogEnabled(): boolean;
  44980. private _fogMode;
  44981. /**
  44982. * Gets or sets the fog mode to use
  44983. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44984. * | mode | value |
  44985. * | --- | --- |
  44986. * | FOGMODE_NONE | 0 |
  44987. * | FOGMODE_EXP | 1 |
  44988. * | FOGMODE_EXP2 | 2 |
  44989. * | FOGMODE_LINEAR | 3 |
  44990. */
  44991. set fogMode(value: number);
  44992. get fogMode(): number;
  44993. /**
  44994. * Gets or sets the fog color to use
  44995. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44996. * (Default is Color3(0.2, 0.2, 0.3))
  44997. */
  44998. fogColor: Color3;
  44999. /**
  45000. * Gets or sets the fog density to use
  45001. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45002. * (Default is 0.1)
  45003. */
  45004. fogDensity: number;
  45005. /**
  45006. * Gets or sets the fog start distance to use
  45007. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45008. * (Default is 0)
  45009. */
  45010. fogStart: number;
  45011. /**
  45012. * Gets or sets the fog end distance to use
  45013. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45014. * (Default is 1000)
  45015. */
  45016. fogEnd: number;
  45017. /**
  45018. * Flag indicating that the frame buffer binding is handled by another component
  45019. */
  45020. prePass: boolean;
  45021. private _shadowsEnabled;
  45022. /**
  45023. * Gets or sets a boolean indicating if shadows are enabled on this scene
  45024. */
  45025. set shadowsEnabled(value: boolean);
  45026. get shadowsEnabled(): boolean;
  45027. private _lightsEnabled;
  45028. /**
  45029. * Gets or sets a boolean indicating if lights are enabled on this scene
  45030. */
  45031. set lightsEnabled(value: boolean);
  45032. get lightsEnabled(): boolean;
  45033. /** All of the active cameras added to this scene. */
  45034. activeCameras: Nullable<Camera[]>;
  45035. /** @hidden */
  45036. _activeCamera: Nullable<Camera>;
  45037. /** Gets or sets the current active camera */
  45038. get activeCamera(): Nullable<Camera>;
  45039. set activeCamera(value: Nullable<Camera>);
  45040. private _defaultMaterial;
  45041. /** The default material used on meshes when no material is affected */
  45042. get defaultMaterial(): Material;
  45043. /** The default material used on meshes when no material is affected */
  45044. set defaultMaterial(value: Material);
  45045. private _texturesEnabled;
  45046. /**
  45047. * Gets or sets a boolean indicating if textures are enabled on this scene
  45048. */
  45049. set texturesEnabled(value: boolean);
  45050. get texturesEnabled(): boolean;
  45051. /**
  45052. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45053. */
  45054. physicsEnabled: boolean;
  45055. /**
  45056. * Gets or sets a boolean indicating if particles are enabled on this scene
  45057. */
  45058. particlesEnabled: boolean;
  45059. /**
  45060. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45061. */
  45062. spritesEnabled: boolean;
  45063. private _skeletonsEnabled;
  45064. /**
  45065. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45066. */
  45067. set skeletonsEnabled(value: boolean);
  45068. get skeletonsEnabled(): boolean;
  45069. /**
  45070. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45071. */
  45072. lensFlaresEnabled: boolean;
  45073. /**
  45074. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45075. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45076. */
  45077. collisionsEnabled: boolean;
  45078. private _collisionCoordinator;
  45079. /** @hidden */
  45080. get collisionCoordinator(): ICollisionCoordinator;
  45081. /**
  45082. * Defines the gravity applied to this scene (used only for collisions)
  45083. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45084. */
  45085. gravity: Vector3;
  45086. /**
  45087. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45088. */
  45089. postProcessesEnabled: boolean;
  45090. /**
  45091. * Gets the current postprocess manager
  45092. */
  45093. postProcessManager: PostProcessManager;
  45094. /**
  45095. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45096. */
  45097. renderTargetsEnabled: boolean;
  45098. /**
  45099. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45100. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45101. */
  45102. dumpNextRenderTargets: boolean;
  45103. /**
  45104. * The list of user defined render targets added to the scene
  45105. */
  45106. customRenderTargets: RenderTargetTexture[];
  45107. /**
  45108. * Defines if texture loading must be delayed
  45109. * If true, textures will only be loaded when they need to be rendered
  45110. */
  45111. useDelayedTextureLoading: boolean;
  45112. /**
  45113. * Gets the list of meshes imported to the scene through SceneLoader
  45114. */
  45115. importedMeshesFiles: String[];
  45116. /**
  45117. * Gets or sets a boolean indicating if probes are enabled on this scene
  45118. */
  45119. probesEnabled: boolean;
  45120. /**
  45121. * Gets or sets the current offline provider to use to store scene data
  45122. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45123. */
  45124. offlineProvider: IOfflineProvider;
  45125. /**
  45126. * Gets or sets the action manager associated with the scene
  45127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45128. */
  45129. actionManager: AbstractActionManager;
  45130. private _meshesForIntersections;
  45131. /**
  45132. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45133. */
  45134. proceduralTexturesEnabled: boolean;
  45135. private _engine;
  45136. private _totalVertices;
  45137. /** @hidden */
  45138. _activeIndices: PerfCounter;
  45139. /** @hidden */
  45140. _activeParticles: PerfCounter;
  45141. /** @hidden */
  45142. _activeBones: PerfCounter;
  45143. private _animationRatio;
  45144. /** @hidden */
  45145. _animationTimeLast: number;
  45146. /** @hidden */
  45147. _animationTime: number;
  45148. /**
  45149. * Gets or sets a general scale for animation speed
  45150. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45151. */
  45152. animationTimeScale: number;
  45153. /** @hidden */
  45154. _cachedMaterial: Nullable<Material>;
  45155. /** @hidden */
  45156. _cachedEffect: Nullable<Effect>;
  45157. /** @hidden */
  45158. _cachedVisibility: Nullable<number>;
  45159. private _renderId;
  45160. private _frameId;
  45161. private _executeWhenReadyTimeoutId;
  45162. private _intermediateRendering;
  45163. private _viewUpdateFlag;
  45164. private _projectionUpdateFlag;
  45165. /** @hidden */
  45166. _toBeDisposed: Nullable<IDisposable>[];
  45167. private _activeRequests;
  45168. /** @hidden */
  45169. _pendingData: any[];
  45170. private _isDisposed;
  45171. /**
  45172. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45173. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45174. */
  45175. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45176. private _activeMeshes;
  45177. private _processedMaterials;
  45178. private _renderTargets;
  45179. /** @hidden */
  45180. _activeParticleSystems: SmartArray<IParticleSystem>;
  45181. private _activeSkeletons;
  45182. private _softwareSkinnedMeshes;
  45183. private _renderingManager;
  45184. /** @hidden */
  45185. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45186. private _transformMatrix;
  45187. private _sceneUbo;
  45188. /** @hidden */
  45189. _viewMatrix: Matrix;
  45190. private _projectionMatrix;
  45191. /** @hidden */
  45192. _forcedViewPosition: Nullable<Vector3>;
  45193. /** @hidden */
  45194. _frustumPlanes: Plane[];
  45195. /**
  45196. * Gets the list of frustum planes (built from the active camera)
  45197. */
  45198. get frustumPlanes(): Plane[];
  45199. /**
  45200. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45201. * This is useful if there are more lights that the maximum simulteanous authorized
  45202. */
  45203. requireLightSorting: boolean;
  45204. /** @hidden */
  45205. readonly useMaterialMeshMap: boolean;
  45206. /** @hidden */
  45207. readonly useClonedMeshMap: boolean;
  45208. private _externalData;
  45209. private _uid;
  45210. /**
  45211. * @hidden
  45212. * Backing store of defined scene components.
  45213. */
  45214. _components: ISceneComponent[];
  45215. /**
  45216. * @hidden
  45217. * Backing store of defined scene components.
  45218. */
  45219. _serializableComponents: ISceneSerializableComponent[];
  45220. /**
  45221. * List of components to register on the next registration step.
  45222. */
  45223. private _transientComponents;
  45224. /**
  45225. * Registers the transient components if needed.
  45226. */
  45227. private _registerTransientComponents;
  45228. /**
  45229. * @hidden
  45230. * Add a component to the scene.
  45231. * Note that the ccomponent could be registered on th next frame if this is called after
  45232. * the register component stage.
  45233. * @param component Defines the component to add to the scene
  45234. */
  45235. _addComponent(component: ISceneComponent): void;
  45236. /**
  45237. * @hidden
  45238. * Gets a component from the scene.
  45239. * @param name defines the name of the component to retrieve
  45240. * @returns the component or null if not present
  45241. */
  45242. _getComponent(name: string): Nullable<ISceneComponent>;
  45243. /**
  45244. * @hidden
  45245. * Defines the actions happening before camera updates.
  45246. */
  45247. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45248. /**
  45249. * @hidden
  45250. * Defines the actions happening before clear the canvas.
  45251. */
  45252. _beforeClearStage: Stage<SimpleStageAction>;
  45253. /**
  45254. * @hidden
  45255. * Defines the actions when collecting render targets for the frame.
  45256. */
  45257. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45258. /**
  45259. * @hidden
  45260. * Defines the actions happening for one camera in the frame.
  45261. */
  45262. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45263. /**
  45264. * @hidden
  45265. * Defines the actions happening during the per mesh ready checks.
  45266. */
  45267. _isReadyForMeshStage: Stage<MeshStageAction>;
  45268. /**
  45269. * @hidden
  45270. * Defines the actions happening before evaluate active mesh checks.
  45271. */
  45272. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45273. /**
  45274. * @hidden
  45275. * Defines the actions happening during the evaluate sub mesh checks.
  45276. */
  45277. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45278. /**
  45279. * @hidden
  45280. * Defines the actions happening during the active mesh stage.
  45281. */
  45282. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45283. /**
  45284. * @hidden
  45285. * Defines the actions happening during the per camera render target step.
  45286. */
  45287. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45288. /**
  45289. * @hidden
  45290. * Defines the actions happening just before the active camera is drawing.
  45291. */
  45292. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45293. /**
  45294. * @hidden
  45295. * Defines the actions happening just before a render target is drawing.
  45296. */
  45297. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45298. /**
  45299. * @hidden
  45300. * Defines the actions happening just before a rendering group is drawing.
  45301. */
  45302. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45303. /**
  45304. * @hidden
  45305. * Defines the actions happening just before a mesh is drawing.
  45306. */
  45307. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45308. /**
  45309. * @hidden
  45310. * Defines the actions happening just after a mesh has been drawn.
  45311. */
  45312. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45313. /**
  45314. * @hidden
  45315. * Defines the actions happening just after a rendering group has been drawn.
  45316. */
  45317. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45318. /**
  45319. * @hidden
  45320. * Defines the actions happening just after the active camera has been drawn.
  45321. */
  45322. _afterCameraDrawStage: Stage<CameraStageAction>;
  45323. /**
  45324. * @hidden
  45325. * Defines the actions happening just after a render target has been drawn.
  45326. */
  45327. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45328. /**
  45329. * @hidden
  45330. * Defines the actions happening just after rendering all cameras and computing intersections.
  45331. */
  45332. _afterRenderStage: Stage<SimpleStageAction>;
  45333. /**
  45334. * @hidden
  45335. * Defines the actions happening when a pointer move event happens.
  45336. */
  45337. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45338. /**
  45339. * @hidden
  45340. * Defines the actions happening when a pointer down event happens.
  45341. */
  45342. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45343. /**
  45344. * @hidden
  45345. * Defines the actions happening when a pointer up event happens.
  45346. */
  45347. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45348. /**
  45349. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45350. */
  45351. private geometriesByUniqueId;
  45352. /**
  45353. * Creates a new Scene
  45354. * @param engine defines the engine to use to render this scene
  45355. * @param options defines the scene options
  45356. */
  45357. constructor(engine: Engine, options?: SceneOptions);
  45358. /**
  45359. * Gets a string identifying the name of the class
  45360. * @returns "Scene" string
  45361. */
  45362. getClassName(): string;
  45363. private _defaultMeshCandidates;
  45364. /**
  45365. * @hidden
  45366. */
  45367. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45368. private _defaultSubMeshCandidates;
  45369. /**
  45370. * @hidden
  45371. */
  45372. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45373. /**
  45374. * Sets the default candidate providers for the scene.
  45375. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45376. * and getCollidingSubMeshCandidates to their default function
  45377. */
  45378. setDefaultCandidateProviders(): void;
  45379. /**
  45380. * Gets the mesh that is currently under the pointer
  45381. */
  45382. get meshUnderPointer(): Nullable<AbstractMesh>;
  45383. /**
  45384. * Gets or sets the current on-screen X position of the pointer
  45385. */
  45386. get pointerX(): number;
  45387. set pointerX(value: number);
  45388. /**
  45389. * Gets or sets the current on-screen Y position of the pointer
  45390. */
  45391. get pointerY(): number;
  45392. set pointerY(value: number);
  45393. /**
  45394. * Gets the cached material (ie. the latest rendered one)
  45395. * @returns the cached material
  45396. */
  45397. getCachedMaterial(): Nullable<Material>;
  45398. /**
  45399. * Gets the cached effect (ie. the latest rendered one)
  45400. * @returns the cached effect
  45401. */
  45402. getCachedEffect(): Nullable<Effect>;
  45403. /**
  45404. * Gets the cached visibility state (ie. the latest rendered one)
  45405. * @returns the cached visibility state
  45406. */
  45407. getCachedVisibility(): Nullable<number>;
  45408. /**
  45409. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45410. * @param material defines the current material
  45411. * @param effect defines the current effect
  45412. * @param visibility defines the current visibility state
  45413. * @returns true if one parameter is not cached
  45414. */
  45415. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45416. /**
  45417. * Gets the engine associated with the scene
  45418. * @returns an Engine
  45419. */
  45420. getEngine(): Engine;
  45421. /**
  45422. * Gets the total number of vertices rendered per frame
  45423. * @returns the total number of vertices rendered per frame
  45424. */
  45425. getTotalVertices(): number;
  45426. /**
  45427. * Gets the performance counter for total vertices
  45428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45429. */
  45430. get totalVerticesPerfCounter(): PerfCounter;
  45431. /**
  45432. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45433. * @returns the total number of active indices rendered per frame
  45434. */
  45435. getActiveIndices(): number;
  45436. /**
  45437. * Gets the performance counter for active indices
  45438. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45439. */
  45440. get totalActiveIndicesPerfCounter(): PerfCounter;
  45441. /**
  45442. * Gets the total number of active particles rendered per frame
  45443. * @returns the total number of active particles rendered per frame
  45444. */
  45445. getActiveParticles(): number;
  45446. /**
  45447. * Gets the performance counter for active particles
  45448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45449. */
  45450. get activeParticlesPerfCounter(): PerfCounter;
  45451. /**
  45452. * Gets the total number of active bones rendered per frame
  45453. * @returns the total number of active bones rendered per frame
  45454. */
  45455. getActiveBones(): number;
  45456. /**
  45457. * Gets the performance counter for active bones
  45458. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45459. */
  45460. get activeBonesPerfCounter(): PerfCounter;
  45461. /**
  45462. * Gets the array of active meshes
  45463. * @returns an array of AbstractMesh
  45464. */
  45465. getActiveMeshes(): SmartArray<AbstractMesh>;
  45466. /**
  45467. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45468. * @returns a number
  45469. */
  45470. getAnimationRatio(): number;
  45471. /**
  45472. * Gets an unique Id for the current render phase
  45473. * @returns a number
  45474. */
  45475. getRenderId(): number;
  45476. /**
  45477. * Gets an unique Id for the current frame
  45478. * @returns a number
  45479. */
  45480. getFrameId(): number;
  45481. /** Call this function if you want to manually increment the render Id*/
  45482. incrementRenderId(): void;
  45483. private _createUbo;
  45484. /**
  45485. * Use this method to simulate a pointer move on a mesh
  45486. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45487. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45488. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45489. * @returns the current scene
  45490. */
  45491. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45492. /**
  45493. * Use this method to simulate a pointer down on a mesh
  45494. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45495. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45496. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45497. * @returns the current scene
  45498. */
  45499. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45500. /**
  45501. * Use this method to simulate a pointer up on a mesh
  45502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45505. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45506. * @returns the current scene
  45507. */
  45508. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45509. /**
  45510. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45511. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45512. * @returns true if the pointer was captured
  45513. */
  45514. isPointerCaptured(pointerId?: number): boolean;
  45515. /**
  45516. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45517. * @param attachUp defines if you want to attach events to pointerup
  45518. * @param attachDown defines if you want to attach events to pointerdown
  45519. * @param attachMove defines if you want to attach events to pointermove
  45520. */
  45521. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45522. /** Detaches all event handlers*/
  45523. detachControl(): void;
  45524. /**
  45525. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45526. * Delay loaded resources are not taking in account
  45527. * @return true if all required resources are ready
  45528. */
  45529. isReady(): boolean;
  45530. /** Resets all cached information relative to material (including effect and visibility) */
  45531. resetCachedMaterial(): void;
  45532. /**
  45533. * Registers a function to be called before every frame render
  45534. * @param func defines the function to register
  45535. */
  45536. registerBeforeRender(func: () => void): void;
  45537. /**
  45538. * Unregisters a function called before every frame render
  45539. * @param func defines the function to unregister
  45540. */
  45541. unregisterBeforeRender(func: () => void): void;
  45542. /**
  45543. * Registers a function to be called after every frame render
  45544. * @param func defines the function to register
  45545. */
  45546. registerAfterRender(func: () => void): void;
  45547. /**
  45548. * Unregisters a function called after every frame render
  45549. * @param func defines the function to unregister
  45550. */
  45551. unregisterAfterRender(func: () => void): void;
  45552. private _executeOnceBeforeRender;
  45553. /**
  45554. * The provided function will run before render once and will be disposed afterwards.
  45555. * A timeout delay can be provided so that the function will be executed in N ms.
  45556. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45557. * @param func The function to be executed.
  45558. * @param timeout optional delay in ms
  45559. */
  45560. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45561. /** @hidden */
  45562. _addPendingData(data: any): void;
  45563. /** @hidden */
  45564. _removePendingData(data: any): void;
  45565. /**
  45566. * Returns the number of items waiting to be loaded
  45567. * @returns the number of items waiting to be loaded
  45568. */
  45569. getWaitingItemsCount(): number;
  45570. /**
  45571. * Returns a boolean indicating if the scene is still loading data
  45572. */
  45573. get isLoading(): boolean;
  45574. /**
  45575. * Registers a function to be executed when the scene is ready
  45576. * @param {Function} func - the function to be executed
  45577. */
  45578. executeWhenReady(func: () => void): void;
  45579. /**
  45580. * Returns a promise that resolves when the scene is ready
  45581. * @returns A promise that resolves when the scene is ready
  45582. */
  45583. whenReadyAsync(): Promise<void>;
  45584. /** @hidden */
  45585. _checkIsReady(): void;
  45586. /**
  45587. * Gets all animatable attached to the scene
  45588. */
  45589. get animatables(): Animatable[];
  45590. /**
  45591. * Resets the last animation time frame.
  45592. * Useful to override when animations start running when loading a scene for the first time.
  45593. */
  45594. resetLastAnimationTimeFrame(): void;
  45595. /**
  45596. * Gets the current view matrix
  45597. * @returns a Matrix
  45598. */
  45599. getViewMatrix(): Matrix;
  45600. /**
  45601. * Gets the current projection matrix
  45602. * @returns a Matrix
  45603. */
  45604. getProjectionMatrix(): Matrix;
  45605. /**
  45606. * Gets the current transform matrix
  45607. * @returns a Matrix made of View * Projection
  45608. */
  45609. getTransformMatrix(): Matrix;
  45610. /**
  45611. * Sets the current transform matrix
  45612. * @param viewL defines the View matrix to use
  45613. * @param projectionL defines the Projection matrix to use
  45614. * @param viewR defines the right View matrix to use (if provided)
  45615. * @param projectionR defines the right Projection matrix to use (if provided)
  45616. */
  45617. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45618. /**
  45619. * Gets the uniform buffer used to store scene data
  45620. * @returns a UniformBuffer
  45621. */
  45622. getSceneUniformBuffer(): UniformBuffer;
  45623. /**
  45624. * Gets an unique (relatively to the current scene) Id
  45625. * @returns an unique number for the scene
  45626. */
  45627. getUniqueId(): number;
  45628. /**
  45629. * Add a mesh to the list of scene's meshes
  45630. * @param newMesh defines the mesh to add
  45631. * @param recursive if all child meshes should also be added to the scene
  45632. */
  45633. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45634. /**
  45635. * Remove a mesh for the list of scene's meshes
  45636. * @param toRemove defines the mesh to remove
  45637. * @param recursive if all child meshes should also be removed from the scene
  45638. * @returns the index where the mesh was in the mesh list
  45639. */
  45640. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45641. /**
  45642. * Add a transform node to the list of scene's transform nodes
  45643. * @param newTransformNode defines the transform node to add
  45644. */
  45645. addTransformNode(newTransformNode: TransformNode): void;
  45646. /**
  45647. * Remove a transform node for the list of scene's transform nodes
  45648. * @param toRemove defines the transform node to remove
  45649. * @returns the index where the transform node was in the transform node list
  45650. */
  45651. removeTransformNode(toRemove: TransformNode): number;
  45652. /**
  45653. * Remove a skeleton for the list of scene's skeletons
  45654. * @param toRemove defines the skeleton to remove
  45655. * @returns the index where the skeleton was in the skeleton list
  45656. */
  45657. removeSkeleton(toRemove: Skeleton): number;
  45658. /**
  45659. * Remove a morph target for the list of scene's morph targets
  45660. * @param toRemove defines the morph target to remove
  45661. * @returns the index where the morph target was in the morph target list
  45662. */
  45663. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45664. /**
  45665. * Remove a light for the list of scene's lights
  45666. * @param toRemove defines the light to remove
  45667. * @returns the index where the light was in the light list
  45668. */
  45669. removeLight(toRemove: Light): number;
  45670. /**
  45671. * Remove a camera for the list of scene's cameras
  45672. * @param toRemove defines the camera to remove
  45673. * @returns the index where the camera was in the camera list
  45674. */
  45675. removeCamera(toRemove: Camera): number;
  45676. /**
  45677. * Remove a particle system for the list of scene's particle systems
  45678. * @param toRemove defines the particle system to remove
  45679. * @returns the index where the particle system was in the particle system list
  45680. */
  45681. removeParticleSystem(toRemove: IParticleSystem): number;
  45682. /**
  45683. * Remove a animation for the list of scene's animations
  45684. * @param toRemove defines the animation to remove
  45685. * @returns the index where the animation was in the animation list
  45686. */
  45687. removeAnimation(toRemove: Animation): number;
  45688. /**
  45689. * Will stop the animation of the given target
  45690. * @param target - the target
  45691. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45692. * @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)
  45693. */
  45694. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45695. /**
  45696. * Removes the given animation group from this scene.
  45697. * @param toRemove The animation group to remove
  45698. * @returns The index of the removed animation group
  45699. */
  45700. removeAnimationGroup(toRemove: AnimationGroup): number;
  45701. /**
  45702. * Removes the given multi-material from this scene.
  45703. * @param toRemove The multi-material to remove
  45704. * @returns The index of the removed multi-material
  45705. */
  45706. removeMultiMaterial(toRemove: MultiMaterial): number;
  45707. /**
  45708. * Removes the given material from this scene.
  45709. * @param toRemove The material to remove
  45710. * @returns The index of the removed material
  45711. */
  45712. removeMaterial(toRemove: Material): number;
  45713. /**
  45714. * Removes the given action manager from this scene.
  45715. * @param toRemove The action manager to remove
  45716. * @returns The index of the removed action manager
  45717. */
  45718. removeActionManager(toRemove: AbstractActionManager): number;
  45719. /**
  45720. * Removes the given texture from this scene.
  45721. * @param toRemove The texture to remove
  45722. * @returns The index of the removed texture
  45723. */
  45724. removeTexture(toRemove: BaseTexture): number;
  45725. /**
  45726. * Adds the given light to this scene
  45727. * @param newLight The light to add
  45728. */
  45729. addLight(newLight: Light): void;
  45730. /**
  45731. * Sorts the list list based on light priorities
  45732. */
  45733. sortLightsByPriority(): void;
  45734. /**
  45735. * Adds the given camera to this scene
  45736. * @param newCamera The camera to add
  45737. */
  45738. addCamera(newCamera: Camera): void;
  45739. /**
  45740. * Adds the given skeleton to this scene
  45741. * @param newSkeleton The skeleton to add
  45742. */
  45743. addSkeleton(newSkeleton: Skeleton): void;
  45744. /**
  45745. * Adds the given particle system to this scene
  45746. * @param newParticleSystem The particle system to add
  45747. */
  45748. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45749. /**
  45750. * Adds the given animation to this scene
  45751. * @param newAnimation The animation to add
  45752. */
  45753. addAnimation(newAnimation: Animation): void;
  45754. /**
  45755. * Adds the given animation group to this scene.
  45756. * @param newAnimationGroup The animation group to add
  45757. */
  45758. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45759. /**
  45760. * Adds the given multi-material to this scene
  45761. * @param newMultiMaterial The multi-material to add
  45762. */
  45763. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45764. /**
  45765. * Adds the given material to this scene
  45766. * @param newMaterial The material to add
  45767. */
  45768. addMaterial(newMaterial: Material): void;
  45769. /**
  45770. * Adds the given morph target to this scene
  45771. * @param newMorphTargetManager The morph target to add
  45772. */
  45773. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45774. /**
  45775. * Adds the given geometry to this scene
  45776. * @param newGeometry The geometry to add
  45777. */
  45778. addGeometry(newGeometry: Geometry): void;
  45779. /**
  45780. * Adds the given action manager to this scene
  45781. * @param newActionManager The action manager to add
  45782. */
  45783. addActionManager(newActionManager: AbstractActionManager): void;
  45784. /**
  45785. * Adds the given texture to this scene.
  45786. * @param newTexture The texture to add
  45787. */
  45788. addTexture(newTexture: BaseTexture): void;
  45789. /**
  45790. * Switch active camera
  45791. * @param newCamera defines the new active camera
  45792. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45793. */
  45794. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45795. /**
  45796. * sets the active camera of the scene using its ID
  45797. * @param id defines the camera's ID
  45798. * @return the new active camera or null if none found.
  45799. */
  45800. setActiveCameraByID(id: string): Nullable<Camera>;
  45801. /**
  45802. * sets the active camera of the scene using its name
  45803. * @param name defines the camera's name
  45804. * @returns the new active camera or null if none found.
  45805. */
  45806. setActiveCameraByName(name: string): Nullable<Camera>;
  45807. /**
  45808. * get an animation group using its name
  45809. * @param name defines the material's name
  45810. * @return the animation group or null if none found.
  45811. */
  45812. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45813. /**
  45814. * Get a material using its unique id
  45815. * @param uniqueId defines the material's unique id
  45816. * @return the material or null if none found.
  45817. */
  45818. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45819. /**
  45820. * get a material using its id
  45821. * @param id defines the material's ID
  45822. * @return the material or null if none found.
  45823. */
  45824. getMaterialByID(id: string): Nullable<Material>;
  45825. /**
  45826. * Gets a the last added material using a given id
  45827. * @param id defines the material's ID
  45828. * @return the last material with the given id or null if none found.
  45829. */
  45830. getLastMaterialByID(id: string): Nullable<Material>;
  45831. /**
  45832. * Gets a material using its name
  45833. * @param name defines the material's name
  45834. * @return the material or null if none found.
  45835. */
  45836. getMaterialByName(name: string): Nullable<Material>;
  45837. /**
  45838. * Get a texture using its unique id
  45839. * @param uniqueId defines the texture's unique id
  45840. * @return the texture or null if none found.
  45841. */
  45842. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45843. /**
  45844. * Gets a camera using its id
  45845. * @param id defines the id to look for
  45846. * @returns the camera or null if not found
  45847. */
  45848. getCameraByID(id: string): Nullable<Camera>;
  45849. /**
  45850. * Gets a camera using its unique id
  45851. * @param uniqueId defines the unique id to look for
  45852. * @returns the camera or null if not found
  45853. */
  45854. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45855. /**
  45856. * Gets a camera using its name
  45857. * @param name defines the camera's name
  45858. * @return the camera or null if none found.
  45859. */
  45860. getCameraByName(name: string): Nullable<Camera>;
  45861. /**
  45862. * Gets a bone using its id
  45863. * @param id defines the bone's id
  45864. * @return the bone or null if not found
  45865. */
  45866. getBoneByID(id: string): Nullable<Bone>;
  45867. /**
  45868. * Gets a bone using its id
  45869. * @param name defines the bone's name
  45870. * @return the bone or null if not found
  45871. */
  45872. getBoneByName(name: string): Nullable<Bone>;
  45873. /**
  45874. * Gets a light node using its name
  45875. * @param name defines the the light's name
  45876. * @return the light or null if none found.
  45877. */
  45878. getLightByName(name: string): Nullable<Light>;
  45879. /**
  45880. * Gets a light node using its id
  45881. * @param id defines the light's id
  45882. * @return the light or null if none found.
  45883. */
  45884. getLightByID(id: string): Nullable<Light>;
  45885. /**
  45886. * Gets a light node using its scene-generated unique ID
  45887. * @param uniqueId defines the light's unique id
  45888. * @return the light or null if none found.
  45889. */
  45890. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45891. /**
  45892. * Gets a particle system by id
  45893. * @param id defines the particle system id
  45894. * @return the corresponding system or null if none found
  45895. */
  45896. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45897. /**
  45898. * Gets a geometry using its ID
  45899. * @param id defines the geometry's id
  45900. * @return the geometry or null if none found.
  45901. */
  45902. getGeometryByID(id: string): Nullable<Geometry>;
  45903. private _getGeometryByUniqueID;
  45904. /**
  45905. * Add a new geometry to this scene
  45906. * @param geometry defines the geometry to be added to the scene.
  45907. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45908. * @return a boolean defining if the geometry was added or not
  45909. */
  45910. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45911. /**
  45912. * Removes an existing geometry
  45913. * @param geometry defines the geometry to be removed from the scene
  45914. * @return a boolean defining if the geometry was removed or not
  45915. */
  45916. removeGeometry(geometry: Geometry): boolean;
  45917. /**
  45918. * Gets the list of geometries attached to the scene
  45919. * @returns an array of Geometry
  45920. */
  45921. getGeometries(): Geometry[];
  45922. /**
  45923. * Gets the first added mesh found of a given ID
  45924. * @param id defines the id to search for
  45925. * @return the mesh found or null if not found at all
  45926. */
  45927. getMeshByID(id: string): Nullable<AbstractMesh>;
  45928. /**
  45929. * Gets a list of meshes using their id
  45930. * @param id defines the id to search for
  45931. * @returns a list of meshes
  45932. */
  45933. getMeshesByID(id: string): Array<AbstractMesh>;
  45934. /**
  45935. * Gets the first added transform node found of a given ID
  45936. * @param id defines the id to search for
  45937. * @return the found transform node or null if not found at all.
  45938. */
  45939. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45940. /**
  45941. * Gets a transform node with its auto-generated unique id
  45942. * @param uniqueId efines the unique id to search for
  45943. * @return the found transform node or null if not found at all.
  45944. */
  45945. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45946. /**
  45947. * Gets a list of transform nodes using their id
  45948. * @param id defines the id to search for
  45949. * @returns a list of transform nodes
  45950. */
  45951. getTransformNodesByID(id: string): Array<TransformNode>;
  45952. /**
  45953. * Gets a mesh with its auto-generated unique id
  45954. * @param uniqueId defines the unique id to search for
  45955. * @return the found mesh or null if not found at all.
  45956. */
  45957. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45958. /**
  45959. * Gets a the last added mesh using a given id
  45960. * @param id defines the id to search for
  45961. * @return the found mesh or null if not found at all.
  45962. */
  45963. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45964. /**
  45965. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45966. * @param id defines the id to search for
  45967. * @return the found node or null if not found at all
  45968. */
  45969. getLastEntryByID(id: string): Nullable<Node>;
  45970. /**
  45971. * Gets a node (Mesh, Camera, Light) using a given id
  45972. * @param id defines the id to search for
  45973. * @return the found node or null if not found at all
  45974. */
  45975. getNodeByID(id: string): Nullable<Node>;
  45976. /**
  45977. * Gets a node (Mesh, Camera, Light) using a given name
  45978. * @param name defines the name to search for
  45979. * @return the found node or null if not found at all.
  45980. */
  45981. getNodeByName(name: string): Nullable<Node>;
  45982. /**
  45983. * Gets a mesh using a given name
  45984. * @param name defines the name to search for
  45985. * @return the found mesh or null if not found at all.
  45986. */
  45987. getMeshByName(name: string): Nullable<AbstractMesh>;
  45988. /**
  45989. * Gets a transform node using a given name
  45990. * @param name defines the name to search for
  45991. * @return the found transform node or null if not found at all.
  45992. */
  45993. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45994. /**
  45995. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45996. * @param id defines the id to search for
  45997. * @return the found skeleton or null if not found at all.
  45998. */
  45999. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  46000. /**
  46001. * Gets a skeleton using a given auto generated unique id
  46002. * @param uniqueId defines the unique id to search for
  46003. * @return the found skeleton or null if not found at all.
  46004. */
  46005. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  46006. /**
  46007. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  46008. * @param id defines the id to search for
  46009. * @return the found skeleton or null if not found at all.
  46010. */
  46011. getSkeletonById(id: string): Nullable<Skeleton>;
  46012. /**
  46013. * Gets a skeleton using a given name
  46014. * @param name defines the name to search for
  46015. * @return the found skeleton or null if not found at all.
  46016. */
  46017. getSkeletonByName(name: string): Nullable<Skeleton>;
  46018. /**
  46019. * Gets a morph target manager 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 morph target manager or null if not found at all.
  46022. */
  46023. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  46024. /**
  46025. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  46026. * @param id defines the id to search for
  46027. * @return the found morph target or null if not found at all.
  46028. */
  46029. getMorphTargetById(id: string): Nullable<MorphTarget>;
  46030. /**
  46031. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  46032. * @param name defines the name to search for
  46033. * @return the found morph target or null if not found at all.
  46034. */
  46035. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  46036. /**
  46037. * Gets a post process using a given name (if many are found, this function will pick the first one)
  46038. * @param name defines the name to search for
  46039. * @return the found post process or null if not found at all.
  46040. */
  46041. getPostProcessByName(name: string): Nullable<PostProcess>;
  46042. /**
  46043. * Gets a boolean indicating if the given mesh is active
  46044. * @param mesh defines the mesh to look for
  46045. * @returns true if the mesh is in the active list
  46046. */
  46047. isActiveMesh(mesh: AbstractMesh): boolean;
  46048. /**
  46049. * Return a unique id as a string which can serve as an identifier for the scene
  46050. */
  46051. get uid(): string;
  46052. /**
  46053. * Add an externaly attached data from its key.
  46054. * This method call will fail and return false, if such key already exists.
  46055. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46056. * @param key the unique key that identifies the data
  46057. * @param data the data object to associate to the key for this Engine instance
  46058. * @return true if no such key were already present and the data was added successfully, false otherwise
  46059. */
  46060. addExternalData<T>(key: string, data: T): boolean;
  46061. /**
  46062. * Get an externaly attached data from its key
  46063. * @param key the unique key that identifies the data
  46064. * @return the associated data, if present (can be null), or undefined if not present
  46065. */
  46066. getExternalData<T>(key: string): Nullable<T>;
  46067. /**
  46068. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46069. * @param key the unique key that identifies the data
  46070. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46071. * @return the associated data, can be null if the factory returned null.
  46072. */
  46073. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46074. /**
  46075. * Remove an externaly attached data from the Engine instance
  46076. * @param key the unique key that identifies the data
  46077. * @return true if the data was successfully removed, false if it doesn't exist
  46078. */
  46079. removeExternalData(key: string): boolean;
  46080. private _evaluateSubMesh;
  46081. /**
  46082. * Clear the processed materials smart array preventing retention point in material dispose.
  46083. */
  46084. freeProcessedMaterials(): void;
  46085. private _preventFreeActiveMeshesAndRenderingGroups;
  46086. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46087. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46088. * when disposing several meshes in a row or a hierarchy of meshes.
  46089. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46090. */
  46091. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46092. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46093. /**
  46094. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46095. */
  46096. freeActiveMeshes(): void;
  46097. /**
  46098. * Clear the info related to rendering groups preventing retention points during dispose.
  46099. */
  46100. freeRenderingGroups(): void;
  46101. /** @hidden */
  46102. _isInIntermediateRendering(): boolean;
  46103. /**
  46104. * Lambda returning the list of potentially active meshes.
  46105. */
  46106. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46107. /**
  46108. * Lambda returning the list of potentially active sub meshes.
  46109. */
  46110. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46111. /**
  46112. * Lambda returning the list of potentially intersecting sub meshes.
  46113. */
  46114. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46115. /**
  46116. * Lambda returning the list of potentially colliding sub meshes.
  46117. */
  46118. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46119. /** @hidden */
  46120. _activeMeshesFrozen: boolean;
  46121. private _skipEvaluateActiveMeshesCompletely;
  46122. /**
  46123. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46124. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46125. * @param onSuccess optional success callback
  46126. * @param onError optional error callback
  46127. * @returns the current scene
  46128. */
  46129. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46130. /**
  46131. * Use this function to restart evaluating active meshes on every frame
  46132. * @returns the current scene
  46133. */
  46134. unfreezeActiveMeshes(): Scene;
  46135. private _evaluateActiveMeshes;
  46136. private _activeMesh;
  46137. /**
  46138. * Update the transform matrix to update from the current active camera
  46139. * @param force defines a boolean used to force the update even if cache is up to date
  46140. */
  46141. updateTransformMatrix(force?: boolean): void;
  46142. private _bindFrameBuffer;
  46143. /** @hidden */
  46144. _allowPostProcessClearColor: boolean;
  46145. /** @hidden */
  46146. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46147. private _processSubCameras;
  46148. private _checkIntersections;
  46149. /** @hidden */
  46150. _advancePhysicsEngineStep(step: number): void;
  46151. /**
  46152. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46153. */
  46154. getDeterministicFrameTime: () => number;
  46155. /** @hidden */
  46156. _animate(): void;
  46157. /** Execute all animations (for a frame) */
  46158. animate(): void;
  46159. /**
  46160. * Render the scene
  46161. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46162. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46163. */
  46164. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46165. /**
  46166. * Freeze all materials
  46167. * A frozen material will not be updatable but should be faster to render
  46168. */
  46169. freezeMaterials(): void;
  46170. /**
  46171. * Unfreeze all materials
  46172. * A frozen material will not be updatable but should be faster to render
  46173. */
  46174. unfreezeMaterials(): void;
  46175. /**
  46176. * Releases all held ressources
  46177. */
  46178. dispose(): void;
  46179. /**
  46180. * Gets if the scene is already disposed
  46181. */
  46182. get isDisposed(): boolean;
  46183. /**
  46184. * Call this function to reduce memory footprint of the scene.
  46185. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46186. */
  46187. clearCachedVertexData(): void;
  46188. /**
  46189. * This function will remove the local cached buffer data from texture.
  46190. * It will save memory but will prevent the texture from being rebuilt
  46191. */
  46192. cleanCachedTextureBuffer(): void;
  46193. /**
  46194. * Get the world extend vectors with an optional filter
  46195. *
  46196. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46197. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46198. */
  46199. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46200. min: Vector3;
  46201. max: Vector3;
  46202. };
  46203. /**
  46204. * Creates a ray that can be used to pick in the scene
  46205. * @param x defines the x coordinate of the origin (on-screen)
  46206. * @param y defines the y coordinate of the origin (on-screen)
  46207. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46208. * @param camera defines the camera to use for the picking
  46209. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46210. * @returns a Ray
  46211. */
  46212. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46213. /**
  46214. * Creates a ray that can be used to pick in the scene
  46215. * @param x defines the x coordinate of the origin (on-screen)
  46216. * @param y defines the y coordinate of the origin (on-screen)
  46217. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46218. * @param result defines the ray where to store the picking ray
  46219. * @param camera defines the camera to use for the picking
  46220. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46221. * @returns the current scene
  46222. */
  46223. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46224. /**
  46225. * Creates a ray that can be used to pick in the scene
  46226. * @param x defines the x coordinate of the origin (on-screen)
  46227. * @param y defines the y coordinate of the origin (on-screen)
  46228. * @param camera defines the camera to use for the picking
  46229. * @returns a Ray
  46230. */
  46231. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46232. /**
  46233. * Creates a ray that can be used to pick in the scene
  46234. * @param x defines the x coordinate of the origin (on-screen)
  46235. * @param y defines the y coordinate of the origin (on-screen)
  46236. * @param result defines the ray where to store the picking ray
  46237. * @param camera defines the camera to use for the picking
  46238. * @returns the current scene
  46239. */
  46240. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46241. /** Launch a ray to try to pick a mesh in the scene
  46242. * @param x position on screen
  46243. * @param y position on screen
  46244. * @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
  46245. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46246. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46248. * @returns a PickingInfo
  46249. */
  46250. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46251. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46252. * @param x position on screen
  46253. * @param y position on screen
  46254. * @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
  46255. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46256. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46257. * @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)
  46258. */
  46259. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46260. /** Use the given ray to pick a mesh in the scene
  46261. * @param ray The ray to use to pick meshes
  46262. * @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
  46263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46265. * @returns a PickingInfo
  46266. */
  46267. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46268. /**
  46269. * Launch a ray to try to pick a mesh in the scene
  46270. * @param x X position on screen
  46271. * @param y Y position on screen
  46272. * @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
  46273. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46275. * @returns an array of PickingInfo
  46276. */
  46277. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46278. /**
  46279. * Launch a ray to try to pick a mesh in the scene
  46280. * @param ray Ray to use
  46281. * @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
  46282. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46283. * @returns an array of PickingInfo
  46284. */
  46285. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46286. /**
  46287. * Force the value of meshUnderPointer
  46288. * @param mesh defines the mesh to use
  46289. * @param pointerId optional pointer id when using more than one pointer
  46290. */
  46291. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46292. /**
  46293. * Gets the mesh under the pointer
  46294. * @returns a Mesh or null if no mesh is under the pointer
  46295. */
  46296. getPointerOverMesh(): Nullable<AbstractMesh>;
  46297. /** @hidden */
  46298. _rebuildGeometries(): void;
  46299. /** @hidden */
  46300. _rebuildTextures(): void;
  46301. private _getByTags;
  46302. /**
  46303. * Get a list of meshes by tags
  46304. * @param tagsQuery defines the tags query to use
  46305. * @param forEach defines a predicate used to filter results
  46306. * @returns an array of Mesh
  46307. */
  46308. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46309. /**
  46310. * Get a list of cameras by tags
  46311. * @param tagsQuery defines the tags query to use
  46312. * @param forEach defines a predicate used to filter results
  46313. * @returns an array of Camera
  46314. */
  46315. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46316. /**
  46317. * Get a list of lights by tags
  46318. * @param tagsQuery defines the tags query to use
  46319. * @param forEach defines a predicate used to filter results
  46320. * @returns an array of Light
  46321. */
  46322. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46323. /**
  46324. * Get a list of materials by tags
  46325. * @param tagsQuery defines the tags query to use
  46326. * @param forEach defines a predicate used to filter results
  46327. * @returns an array of Material
  46328. */
  46329. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46330. /**
  46331. * Get a list of transform nodes by tags
  46332. * @param tagsQuery defines the tags query to use
  46333. * @param forEach defines a predicate used to filter results
  46334. * @returns an array of TransformNode
  46335. */
  46336. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46337. /**
  46338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46339. * This allowed control for front to back rendering or reversly depending of the special needs.
  46340. *
  46341. * @param renderingGroupId The rendering group id corresponding to its index
  46342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46345. */
  46346. 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;
  46347. /**
  46348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46349. *
  46350. * @param renderingGroupId The rendering group id corresponding to its index
  46351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46352. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46353. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46354. */
  46355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46356. /**
  46357. * Gets the current auto clear configuration for one rendering group of the rendering
  46358. * manager.
  46359. * @param index the rendering group index to get the information for
  46360. * @returns The auto clear setup for the requested rendering group
  46361. */
  46362. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46363. private _blockMaterialDirtyMechanism;
  46364. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46365. get blockMaterialDirtyMechanism(): boolean;
  46366. set blockMaterialDirtyMechanism(value: boolean);
  46367. /**
  46368. * Will flag all materials as dirty to trigger new shader compilation
  46369. * @param flag defines the flag used to specify which material part must be marked as dirty
  46370. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46371. */
  46372. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46373. /** @hidden */
  46374. _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;
  46375. /** @hidden */
  46376. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46377. /** @hidden */
  46378. _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;
  46379. /** @hidden */
  46380. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46381. /** @hidden */
  46382. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46383. /** @hidden */
  46384. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46385. }
  46386. }
  46387. declare module "babylonjs/assetContainer" {
  46388. import { AbstractScene } from "babylonjs/abstractScene";
  46389. import { Scene } from "babylonjs/scene";
  46390. import { Mesh } from "babylonjs/Meshes/mesh";
  46391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46392. import { Skeleton } from "babylonjs/Bones/skeleton";
  46393. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46394. import { Animatable } from "babylonjs/Animations/animatable";
  46395. import { Nullable } from "babylonjs/types";
  46396. import { Node } from "babylonjs/node";
  46397. /**
  46398. * Set of assets to keep when moving a scene into an asset container.
  46399. */
  46400. export class KeepAssets extends AbstractScene {
  46401. }
  46402. /**
  46403. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46404. */
  46405. export class InstantiatedEntries {
  46406. /**
  46407. * List of new root nodes (eg. nodes with no parent)
  46408. */
  46409. rootNodes: TransformNode[];
  46410. /**
  46411. * List of new skeletons
  46412. */
  46413. skeletons: Skeleton[];
  46414. /**
  46415. * List of new animation groups
  46416. */
  46417. animationGroups: AnimationGroup[];
  46418. }
  46419. /**
  46420. * Container with a set of assets that can be added or removed from a scene.
  46421. */
  46422. export class AssetContainer extends AbstractScene {
  46423. private _wasAddedToScene;
  46424. /**
  46425. * The scene the AssetContainer belongs to.
  46426. */
  46427. scene: Scene;
  46428. /**
  46429. * Instantiates an AssetContainer.
  46430. * @param scene The scene the AssetContainer belongs to.
  46431. */
  46432. constructor(scene: Scene);
  46433. /**
  46434. * Instantiate or clone all meshes and add the new ones to the scene.
  46435. * Skeletons and animation groups will all be cloned
  46436. * @param nameFunction defines an optional function used to get new names for clones
  46437. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46438. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46439. */
  46440. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46441. /**
  46442. * Adds all the assets from the container to the scene.
  46443. */
  46444. addAllToScene(): void;
  46445. /**
  46446. * Removes all the assets in the container from the scene
  46447. */
  46448. removeAllFromScene(): void;
  46449. /**
  46450. * Disposes all the assets in the container
  46451. */
  46452. dispose(): void;
  46453. private _moveAssets;
  46454. /**
  46455. * Removes all the assets contained in the scene and adds them to the container.
  46456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46457. */
  46458. moveAllFromScene(keepAssets?: KeepAssets): void;
  46459. /**
  46460. * 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.
  46461. * @returns the root mesh
  46462. */
  46463. createRootMesh(): Mesh;
  46464. /**
  46465. * Merge animations (direct and animation groups) from this asset container into a scene
  46466. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46467. * @param animatables set of animatables to retarget to a node from the scene
  46468. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46469. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46470. */
  46471. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46472. }
  46473. }
  46474. declare module "babylonjs/abstractScene" {
  46475. import { Scene } from "babylonjs/scene";
  46476. import { Nullable } from "babylonjs/types";
  46477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46478. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46479. import { Geometry } from "babylonjs/Meshes/geometry";
  46480. import { Skeleton } from "babylonjs/Bones/skeleton";
  46481. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46482. import { AssetContainer } from "babylonjs/assetContainer";
  46483. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46484. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46486. import { Material } from "babylonjs/Materials/material";
  46487. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46488. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46489. import { Camera } from "babylonjs/Cameras/camera";
  46490. import { Light } from "babylonjs/Lights/light";
  46491. import { Node } from "babylonjs/node";
  46492. import { Animation } from "babylonjs/Animations/animation";
  46493. /**
  46494. * Defines how the parser contract is defined.
  46495. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46496. */
  46497. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46498. /**
  46499. * Defines how the individual parser contract is defined.
  46500. * These parser can parse an individual asset
  46501. */
  46502. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46503. /**
  46504. * Base class of the scene acting as a container for the different elements composing a scene.
  46505. * This class is dynamically extended by the different components of the scene increasing
  46506. * flexibility and reducing coupling
  46507. */
  46508. export abstract class AbstractScene {
  46509. /**
  46510. * Stores the list of available parsers in the application.
  46511. */
  46512. private static _BabylonFileParsers;
  46513. /**
  46514. * Stores the list of available individual parsers in the application.
  46515. */
  46516. private static _IndividualBabylonFileParsers;
  46517. /**
  46518. * Adds a parser in the list of available ones
  46519. * @param name Defines the name of the parser
  46520. * @param parser Defines the parser to add
  46521. */
  46522. static AddParser(name: string, parser: BabylonFileParser): void;
  46523. /**
  46524. * Gets a general parser from the list of avaialble ones
  46525. * @param name Defines the name of the parser
  46526. * @returns the requested parser or null
  46527. */
  46528. static GetParser(name: string): Nullable<BabylonFileParser>;
  46529. /**
  46530. * Adds n individual parser in the list of available ones
  46531. * @param name Defines the name of the parser
  46532. * @param parser Defines the parser to add
  46533. */
  46534. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46535. /**
  46536. * Gets an individual parser from the list of avaialble ones
  46537. * @param name Defines the name of the parser
  46538. * @returns the requested parser or null
  46539. */
  46540. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46541. /**
  46542. * Parser json data and populate both a scene and its associated container object
  46543. * @param jsonData Defines the data to parse
  46544. * @param scene Defines the scene to parse the data for
  46545. * @param container Defines the container attached to the parsing sequence
  46546. * @param rootUrl Defines the root url of the data
  46547. */
  46548. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46549. /**
  46550. * Gets the list of root nodes (ie. nodes with no parent)
  46551. */
  46552. rootNodes: Node[];
  46553. /** All of the cameras added to this scene
  46554. * @see https://doc.babylonjs.com/babylon101/cameras
  46555. */
  46556. cameras: Camera[];
  46557. /**
  46558. * All of the lights added to this scene
  46559. * @see https://doc.babylonjs.com/babylon101/lights
  46560. */
  46561. lights: Light[];
  46562. /**
  46563. * All of the (abstract) meshes added to this scene
  46564. */
  46565. meshes: AbstractMesh[];
  46566. /**
  46567. * The list of skeletons added to the scene
  46568. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46569. */
  46570. skeletons: Skeleton[];
  46571. /**
  46572. * All of the particle systems added to this scene
  46573. * @see https://doc.babylonjs.com/babylon101/particles
  46574. */
  46575. particleSystems: IParticleSystem[];
  46576. /**
  46577. * Gets a list of Animations associated with the scene
  46578. */
  46579. animations: Animation[];
  46580. /**
  46581. * All of the animation groups added to this scene
  46582. * @see https://doc.babylonjs.com/how_to/group
  46583. */
  46584. animationGroups: AnimationGroup[];
  46585. /**
  46586. * All of the multi-materials added to this scene
  46587. * @see https://doc.babylonjs.com/how_to/multi_materials
  46588. */
  46589. multiMaterials: MultiMaterial[];
  46590. /**
  46591. * All of the materials added to this scene
  46592. * In the context of a Scene, it is not supposed to be modified manually.
  46593. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46594. * Note also that the order of the Material within the array is not significant and might change.
  46595. * @see https://doc.babylonjs.com/babylon101/materials
  46596. */
  46597. materials: Material[];
  46598. /**
  46599. * The list of morph target managers added to the scene
  46600. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46601. */
  46602. morphTargetManagers: MorphTargetManager[];
  46603. /**
  46604. * The list of geometries used in the scene.
  46605. */
  46606. geometries: Geometry[];
  46607. /**
  46608. * All of the tranform nodes added to this scene
  46609. * In the context of a Scene, it is not supposed to be modified manually.
  46610. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46611. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46612. * @see https://doc.babylonjs.com/how_to/transformnode
  46613. */
  46614. transformNodes: TransformNode[];
  46615. /**
  46616. * ActionManagers available on the scene.
  46617. */
  46618. actionManagers: AbstractActionManager[];
  46619. /**
  46620. * Textures to keep.
  46621. */
  46622. textures: BaseTexture[];
  46623. /** @hidden */
  46624. protected _environmentTexture: Nullable<BaseTexture>;
  46625. /**
  46626. * Texture used in all pbr material as the reflection texture.
  46627. * As in the majority of the scene they are the same (exception for multi room and so on),
  46628. * this is easier to reference from here than from all the materials.
  46629. */
  46630. get environmentTexture(): Nullable<BaseTexture>;
  46631. set environmentTexture(value: Nullable<BaseTexture>);
  46632. /**
  46633. * The list of postprocesses added to the scene
  46634. */
  46635. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46636. /**
  46637. * @returns all meshes, lights, cameras, transformNodes and bones
  46638. */
  46639. getNodes(): Array<Node>;
  46640. }
  46641. }
  46642. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46643. /**
  46644. * Interface used to define options for Sound class
  46645. */
  46646. export interface ISoundOptions {
  46647. /**
  46648. * Does the sound autoplay once loaded.
  46649. */
  46650. autoplay?: boolean;
  46651. /**
  46652. * Does the sound loop after it finishes playing once.
  46653. */
  46654. loop?: boolean;
  46655. /**
  46656. * Sound's volume
  46657. */
  46658. volume?: number;
  46659. /**
  46660. * Is it a spatial sound?
  46661. */
  46662. spatialSound?: boolean;
  46663. /**
  46664. * Maximum distance to hear that sound
  46665. */
  46666. maxDistance?: number;
  46667. /**
  46668. * Uses user defined attenuation function
  46669. */
  46670. useCustomAttenuation?: boolean;
  46671. /**
  46672. * Define the roll off factor of spatial sounds.
  46673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46674. */
  46675. rolloffFactor?: number;
  46676. /**
  46677. * Define the reference distance the sound should be heard perfectly.
  46678. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46679. */
  46680. refDistance?: number;
  46681. /**
  46682. * Define the distance attenuation model the sound will follow.
  46683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46684. */
  46685. distanceModel?: string;
  46686. /**
  46687. * Defines the playback speed (1 by default)
  46688. */
  46689. playbackRate?: number;
  46690. /**
  46691. * Defines if the sound is from a streaming source
  46692. */
  46693. streaming?: boolean;
  46694. /**
  46695. * Defines an optional length (in seconds) inside the sound file
  46696. */
  46697. length?: number;
  46698. /**
  46699. * Defines an optional offset (in seconds) inside the sound file
  46700. */
  46701. offset?: number;
  46702. /**
  46703. * If true, URLs will not be required to state the audio file codec to use.
  46704. */
  46705. skipCodecCheck?: boolean;
  46706. }
  46707. }
  46708. declare module "babylonjs/Audio/sound" {
  46709. import { Observable } from "babylonjs/Misc/observable";
  46710. import { Vector3 } from "babylonjs/Maths/math.vector";
  46711. import { Nullable } from "babylonjs/types";
  46712. import { Scene } from "babylonjs/scene";
  46713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46714. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46715. /**
  46716. * Defines a sound that can be played in the application.
  46717. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46719. */
  46720. export class Sound {
  46721. /**
  46722. * The name of the sound in the scene.
  46723. */
  46724. name: string;
  46725. /**
  46726. * Does the sound autoplay once loaded.
  46727. */
  46728. autoplay: boolean;
  46729. /**
  46730. * Does the sound loop after it finishes playing once.
  46731. */
  46732. loop: boolean;
  46733. /**
  46734. * Does the sound use a custom attenuation curve to simulate the falloff
  46735. * happening when the source gets further away from the camera.
  46736. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46737. */
  46738. useCustomAttenuation: boolean;
  46739. /**
  46740. * The sound track id this sound belongs to.
  46741. */
  46742. soundTrackId: number;
  46743. /**
  46744. * Is this sound currently played.
  46745. */
  46746. isPlaying: boolean;
  46747. /**
  46748. * Is this sound currently paused.
  46749. */
  46750. isPaused: boolean;
  46751. /**
  46752. * Does this sound enables spatial sound.
  46753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46754. */
  46755. spatialSound: boolean;
  46756. /**
  46757. * Define the reference distance the sound should be heard perfectly.
  46758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46759. */
  46760. refDistance: number;
  46761. /**
  46762. * Define the roll off factor of spatial sounds.
  46763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46764. */
  46765. rolloffFactor: number;
  46766. /**
  46767. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46769. */
  46770. maxDistance: number;
  46771. /**
  46772. * Define the distance attenuation model the sound will follow.
  46773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46774. */
  46775. distanceModel: string;
  46776. /**
  46777. * @hidden
  46778. * Back Compat
  46779. **/
  46780. onended: () => any;
  46781. /**
  46782. * Gets or sets an object used to store user defined information for the sound.
  46783. */
  46784. metadata: any;
  46785. /**
  46786. * Observable event when the current playing sound finishes.
  46787. */
  46788. onEndedObservable: Observable<Sound>;
  46789. /**
  46790. * Gets the current time for the sound.
  46791. */
  46792. get currentTime(): number;
  46793. private _panningModel;
  46794. private _playbackRate;
  46795. private _streaming;
  46796. private _startTime;
  46797. private _startOffset;
  46798. private _position;
  46799. /** @hidden */
  46800. _positionInEmitterSpace: boolean;
  46801. private _localDirection;
  46802. private _volume;
  46803. private _isReadyToPlay;
  46804. private _isDirectional;
  46805. private _readyToPlayCallback;
  46806. private _audioBuffer;
  46807. private _soundSource;
  46808. private _streamingSource;
  46809. private _soundPanner;
  46810. private _soundGain;
  46811. private _inputAudioNode;
  46812. private _outputAudioNode;
  46813. private _coneInnerAngle;
  46814. private _coneOuterAngle;
  46815. private _coneOuterGain;
  46816. private _scene;
  46817. private _connectedTransformNode;
  46818. private _customAttenuationFunction;
  46819. private _registerFunc;
  46820. private _isOutputConnected;
  46821. private _htmlAudioElement;
  46822. private _urlType;
  46823. private _length?;
  46824. private _offset?;
  46825. /** @hidden */
  46826. static _SceneComponentInitialization: (scene: Scene) => void;
  46827. /**
  46828. * Create a sound and attach it to a scene
  46829. * @param name Name of your sound
  46830. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46831. * @param scene defines the scene the sound belongs to
  46832. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46833. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46834. */
  46835. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46836. /**
  46837. * Release the sound and its associated resources
  46838. */
  46839. dispose(): void;
  46840. /**
  46841. * Gets if the sounds is ready to be played or not.
  46842. * @returns true if ready, otherwise false
  46843. */
  46844. isReady(): boolean;
  46845. private _soundLoaded;
  46846. /**
  46847. * Sets the data of the sound from an audiobuffer
  46848. * @param audioBuffer The audioBuffer containing the data
  46849. */
  46850. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46851. /**
  46852. * Updates the current sounds options such as maxdistance, loop...
  46853. * @param options A JSON object containing values named as the object properties
  46854. */
  46855. updateOptions(options: ISoundOptions): void;
  46856. private _createSpatialParameters;
  46857. private _updateSpatialParameters;
  46858. /**
  46859. * Switch the panning model to HRTF:
  46860. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46862. */
  46863. switchPanningModelToHRTF(): void;
  46864. /**
  46865. * Switch the panning model to Equal Power:
  46866. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46867. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46868. */
  46869. switchPanningModelToEqualPower(): void;
  46870. private _switchPanningModel;
  46871. /**
  46872. * Connect this sound to a sound track audio node like gain...
  46873. * @param soundTrackAudioNode the sound track audio node to connect to
  46874. */
  46875. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46876. /**
  46877. * Transform this sound into a directional source
  46878. * @param coneInnerAngle Size of the inner cone in degree
  46879. * @param coneOuterAngle Size of the outer cone in degree
  46880. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46881. */
  46882. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46883. /**
  46884. * Gets or sets the inner angle for the directional cone.
  46885. */
  46886. get directionalConeInnerAngle(): number;
  46887. /**
  46888. * Gets or sets the inner angle for the directional cone.
  46889. */
  46890. set directionalConeInnerAngle(value: number);
  46891. /**
  46892. * Gets or sets the outer angle for the directional cone.
  46893. */
  46894. get directionalConeOuterAngle(): number;
  46895. /**
  46896. * Gets or sets the outer angle for the directional cone.
  46897. */
  46898. set directionalConeOuterAngle(value: number);
  46899. /**
  46900. * Sets the position of the emitter if spatial sound is enabled
  46901. * @param newPosition Defines the new posisiton
  46902. */
  46903. setPosition(newPosition: Vector3): void;
  46904. /**
  46905. * Sets the local direction of the emitter if spatial sound is enabled
  46906. * @param newLocalDirection Defines the new local direction
  46907. */
  46908. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46909. private _updateDirection;
  46910. /** @hidden */
  46911. updateDistanceFromListener(): void;
  46912. /**
  46913. * Sets a new custom attenuation function for the sound.
  46914. * @param callback Defines the function used for the attenuation
  46915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46916. */
  46917. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46918. /**
  46919. * Play the sound
  46920. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46921. * @param offset (optional) Start the sound at a specific time in seconds
  46922. * @param length (optional) Sound duration (in seconds)
  46923. */
  46924. play(time?: number, offset?: number, length?: number): void;
  46925. private _onended;
  46926. /**
  46927. * Stop the sound
  46928. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46929. */
  46930. stop(time?: number): void;
  46931. /**
  46932. * Put the sound in pause
  46933. */
  46934. pause(): void;
  46935. /**
  46936. * Sets a dedicated volume for this sounds
  46937. * @param newVolume Define the new volume of the sound
  46938. * @param time Define time for gradual change to new volume
  46939. */
  46940. setVolume(newVolume: number, time?: number): void;
  46941. /**
  46942. * Set the sound play back rate
  46943. * @param newPlaybackRate Define the playback rate the sound should be played at
  46944. */
  46945. setPlaybackRate(newPlaybackRate: number): void;
  46946. /**
  46947. * Gets the volume of the sound.
  46948. * @returns the volume of the sound
  46949. */
  46950. getVolume(): number;
  46951. /**
  46952. * Attach the sound to a dedicated mesh
  46953. * @param transformNode The transform node to connect the sound with
  46954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46955. */
  46956. attachToMesh(transformNode: TransformNode): void;
  46957. /**
  46958. * Detach the sound from the previously attached mesh
  46959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46960. */
  46961. detachFromMesh(): void;
  46962. private _onRegisterAfterWorldMatrixUpdate;
  46963. /**
  46964. * Clone the current sound in the scene.
  46965. * @returns the new sound clone
  46966. */
  46967. clone(): Nullable<Sound>;
  46968. /**
  46969. * Gets the current underlying audio buffer containing the data
  46970. * @returns the audio buffer
  46971. */
  46972. getAudioBuffer(): Nullable<AudioBuffer>;
  46973. /**
  46974. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46975. * @returns the source node
  46976. */
  46977. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46978. /**
  46979. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46980. * @returns the gain node
  46981. */
  46982. getSoundGain(): Nullable<GainNode>;
  46983. /**
  46984. * Serializes the Sound in a JSON representation
  46985. * @returns the JSON representation of the sound
  46986. */
  46987. serialize(): any;
  46988. /**
  46989. * Parse a JSON representation of a sound to innstantiate in a given scene
  46990. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46991. * @param scene Define the scene the new parsed sound should be created in
  46992. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46993. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46994. * @returns the newly parsed sound
  46995. */
  46996. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46997. }
  46998. }
  46999. declare module "babylonjs/Actions/directAudioActions" {
  47000. import { Action } from "babylonjs/Actions/action";
  47001. import { Condition } from "babylonjs/Actions/condition";
  47002. import { Sound } from "babylonjs/Audio/sound";
  47003. /**
  47004. * This defines an action helpful to play a defined sound on a triggered action.
  47005. */
  47006. export class PlaySoundAction extends Action {
  47007. private _sound;
  47008. /**
  47009. * Instantiate the action
  47010. * @param triggerOptions defines the trigger options
  47011. * @param sound defines the sound to play
  47012. * @param condition defines the trigger related conditions
  47013. */
  47014. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47015. /** @hidden */
  47016. _prepare(): void;
  47017. /**
  47018. * Execute the action and play the sound.
  47019. */
  47020. execute(): void;
  47021. /**
  47022. * Serializes the actions and its related information.
  47023. * @param parent defines the object to serialize in
  47024. * @returns the serialized object
  47025. */
  47026. serialize(parent: any): any;
  47027. }
  47028. /**
  47029. * This defines an action helpful to stop a defined sound on a triggered action.
  47030. */
  47031. export class StopSoundAction extends Action {
  47032. private _sound;
  47033. /**
  47034. * Instantiate the action
  47035. * @param triggerOptions defines the trigger options
  47036. * @param sound defines the sound to stop
  47037. * @param condition defines the trigger related conditions
  47038. */
  47039. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47040. /** @hidden */
  47041. _prepare(): void;
  47042. /**
  47043. * Execute the action and stop the sound.
  47044. */
  47045. execute(): void;
  47046. /**
  47047. * Serializes the actions and its related information.
  47048. * @param parent defines the object to serialize in
  47049. * @returns the serialized object
  47050. */
  47051. serialize(parent: any): any;
  47052. }
  47053. }
  47054. declare module "babylonjs/Actions/interpolateValueAction" {
  47055. import { Action } from "babylonjs/Actions/action";
  47056. import { Condition } from "babylonjs/Actions/condition";
  47057. import { Observable } from "babylonjs/Misc/observable";
  47058. /**
  47059. * This defines an action responsible to change the value of a property
  47060. * by interpolating between its current value and the newly set one once triggered.
  47061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47062. */
  47063. export class InterpolateValueAction extends Action {
  47064. /**
  47065. * Defines the path of the property where the value should be interpolated
  47066. */
  47067. propertyPath: string;
  47068. /**
  47069. * Defines the target value at the end of the interpolation.
  47070. */
  47071. value: any;
  47072. /**
  47073. * Defines the time it will take for the property to interpolate to the value.
  47074. */
  47075. duration: number;
  47076. /**
  47077. * Defines if the other scene animations should be stopped when the action has been triggered
  47078. */
  47079. stopOtherAnimations?: boolean;
  47080. /**
  47081. * Defines a callback raised once the interpolation animation has been done.
  47082. */
  47083. onInterpolationDone?: () => void;
  47084. /**
  47085. * Observable triggered once the interpolation animation has been done.
  47086. */
  47087. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47088. private _target;
  47089. private _effectiveTarget;
  47090. private _property;
  47091. /**
  47092. * Instantiate the action
  47093. * @param triggerOptions defines the trigger options
  47094. * @param target defines the object containing the value to interpolate
  47095. * @param propertyPath defines the path to the property in the target object
  47096. * @param value defines the target value at the end of the interpolation
  47097. * @param duration deines the time it will take for the property to interpolate to the value.
  47098. * @param condition defines the trigger related conditions
  47099. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47100. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47101. */
  47102. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47103. /** @hidden */
  47104. _prepare(): void;
  47105. /**
  47106. * Execute the action starts the value interpolation.
  47107. */
  47108. execute(): void;
  47109. /**
  47110. * Serializes the actions and its related information.
  47111. * @param parent defines the object to serialize in
  47112. * @returns the serialized object
  47113. */
  47114. serialize(parent: any): any;
  47115. }
  47116. }
  47117. declare module "babylonjs/Actions/index" {
  47118. export * from "babylonjs/Actions/abstractActionManager";
  47119. export * from "babylonjs/Actions/action";
  47120. export * from "babylonjs/Actions/actionEvent";
  47121. export * from "babylonjs/Actions/actionManager";
  47122. export * from "babylonjs/Actions/condition";
  47123. export * from "babylonjs/Actions/directActions";
  47124. export * from "babylonjs/Actions/directAudioActions";
  47125. export * from "babylonjs/Actions/interpolateValueAction";
  47126. }
  47127. declare module "babylonjs/Animations/index" {
  47128. export * from "babylonjs/Animations/animatable";
  47129. export * from "babylonjs/Animations/animation";
  47130. export * from "babylonjs/Animations/animationGroup";
  47131. export * from "babylonjs/Animations/animationPropertiesOverride";
  47132. export * from "babylonjs/Animations/easing";
  47133. export * from "babylonjs/Animations/runtimeAnimation";
  47134. export * from "babylonjs/Animations/animationEvent";
  47135. export * from "babylonjs/Animations/animationGroup";
  47136. export * from "babylonjs/Animations/animationKey";
  47137. export * from "babylonjs/Animations/animationRange";
  47138. export * from "babylonjs/Animations/animatable.interface";
  47139. }
  47140. declare module "babylonjs/Audio/audioEngine" {
  47141. import { Analyser } from "babylonjs/Audio/analyser";
  47142. import { Nullable } from "babylonjs/types";
  47143. import { Observable } from "babylonjs/Misc/observable";
  47144. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47145. /**
  47146. * This represents the default audio engine used in babylon.
  47147. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47149. */
  47150. export class AudioEngine implements IAudioEngine {
  47151. private _audioContext;
  47152. private _audioContextInitialized;
  47153. private _muteButton;
  47154. private _hostElement;
  47155. /**
  47156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47157. */
  47158. canUseWebAudio: boolean;
  47159. /**
  47160. * The master gain node defines the global audio volume of your audio engine.
  47161. */
  47162. masterGain: GainNode;
  47163. /**
  47164. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47165. * @ignoreNaming
  47166. */
  47167. WarnedWebAudioUnsupported: boolean;
  47168. /**
  47169. * Gets whether or not mp3 are supported by your browser.
  47170. */
  47171. isMP3supported: boolean;
  47172. /**
  47173. * Gets whether or not ogg are supported by your browser.
  47174. */
  47175. isOGGsupported: boolean;
  47176. /**
  47177. * Gets whether audio has been unlocked on the device.
  47178. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47179. * a user interaction has happened.
  47180. */
  47181. unlocked: boolean;
  47182. /**
  47183. * Defines if the audio engine relies on a custom unlocked button.
  47184. * In this case, the embedded button will not be displayed.
  47185. */
  47186. useCustomUnlockedButton: boolean;
  47187. /**
  47188. * Event raised when audio has been unlocked on the browser.
  47189. */
  47190. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47191. /**
  47192. * Event raised when audio has been locked on the browser.
  47193. */
  47194. onAudioLockedObservable: Observable<IAudioEngine>;
  47195. /**
  47196. * Gets the current AudioContext if available.
  47197. */
  47198. get audioContext(): Nullable<AudioContext>;
  47199. private _connectedAnalyser;
  47200. /**
  47201. * Instantiates a new audio engine.
  47202. *
  47203. * There should be only one per page as some browsers restrict the number
  47204. * of audio contexts you can create.
  47205. * @param hostElement defines the host element where to display the mute icon if necessary
  47206. */
  47207. constructor(hostElement?: Nullable<HTMLElement>);
  47208. /**
  47209. * Flags the audio engine in Locked state.
  47210. * This happens due to new browser policies preventing audio to autoplay.
  47211. */
  47212. lock(): void;
  47213. /**
  47214. * Unlocks the audio engine once a user action has been done on the dom.
  47215. * This is helpful to resume play once browser policies have been satisfied.
  47216. */
  47217. unlock(): void;
  47218. private _resumeAudioContext;
  47219. private _initializeAudioContext;
  47220. private _tryToRun;
  47221. private _triggerRunningState;
  47222. private _triggerSuspendedState;
  47223. private _displayMuteButton;
  47224. private _moveButtonToTopLeft;
  47225. private _onResize;
  47226. private _hideMuteButton;
  47227. /**
  47228. * Destroy and release the resources associated with the audio ccontext.
  47229. */
  47230. dispose(): void;
  47231. /**
  47232. * Gets the global volume sets on the master gain.
  47233. * @returns the global volume if set or -1 otherwise
  47234. */
  47235. getGlobalVolume(): number;
  47236. /**
  47237. * Sets the global volume of your experience (sets on the master gain).
  47238. * @param newVolume Defines the new global volume of the application
  47239. */
  47240. setGlobalVolume(newVolume: number): void;
  47241. /**
  47242. * Connect the audio engine to an audio analyser allowing some amazing
  47243. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47245. * @param analyser The analyser to connect to the engine
  47246. */
  47247. connectToAnalyser(analyser: Analyser): void;
  47248. }
  47249. }
  47250. declare module "babylonjs/Audio/soundTrack" {
  47251. import { Sound } from "babylonjs/Audio/sound";
  47252. import { Analyser } from "babylonjs/Audio/analyser";
  47253. import { Scene } from "babylonjs/scene";
  47254. /**
  47255. * Options allowed during the creation of a sound track.
  47256. */
  47257. export interface ISoundTrackOptions {
  47258. /**
  47259. * The volume the sound track should take during creation
  47260. */
  47261. volume?: number;
  47262. /**
  47263. * Define if the sound track is the main sound track of the scene
  47264. */
  47265. mainTrack?: boolean;
  47266. }
  47267. /**
  47268. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47269. * It will be also used in a future release to apply effects on a specific track.
  47270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47271. */
  47272. export class SoundTrack {
  47273. /**
  47274. * The unique identifier of the sound track in the scene.
  47275. */
  47276. id: number;
  47277. /**
  47278. * The list of sounds included in the sound track.
  47279. */
  47280. soundCollection: Array<Sound>;
  47281. private _outputAudioNode;
  47282. private _scene;
  47283. private _connectedAnalyser;
  47284. private _options;
  47285. private _isInitialized;
  47286. /**
  47287. * Creates a new sound track.
  47288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47289. * @param scene Define the scene the sound track belongs to
  47290. * @param options
  47291. */
  47292. constructor(scene: Scene, options?: ISoundTrackOptions);
  47293. private _initializeSoundTrackAudioGraph;
  47294. /**
  47295. * Release the sound track and its associated resources
  47296. */
  47297. dispose(): void;
  47298. /**
  47299. * Adds a sound to this sound track
  47300. * @param sound define the cound to add
  47301. * @ignoreNaming
  47302. */
  47303. addSound(sound: Sound): void;
  47304. /**
  47305. * Removes a sound to this sound track
  47306. * @param sound define the cound to remove
  47307. * @ignoreNaming
  47308. */
  47309. removeSound(sound: Sound): void;
  47310. /**
  47311. * Set a global volume for the full sound track.
  47312. * @param newVolume Define the new volume of the sound track
  47313. */
  47314. setVolume(newVolume: number): void;
  47315. /**
  47316. * Switch the panning model to HRTF:
  47317. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47318. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47319. */
  47320. switchPanningModelToHRTF(): void;
  47321. /**
  47322. * Switch the panning model to Equal Power:
  47323. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47324. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47325. */
  47326. switchPanningModelToEqualPower(): void;
  47327. /**
  47328. * Connect the sound track to an audio analyser allowing some amazing
  47329. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47331. * @param analyser The analyser to connect to the engine
  47332. */
  47333. connectToAnalyser(analyser: Analyser): void;
  47334. }
  47335. }
  47336. declare module "babylonjs/Audio/audioSceneComponent" {
  47337. import { Sound } from "babylonjs/Audio/sound";
  47338. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47339. import { Nullable } from "babylonjs/types";
  47340. import { Vector3 } from "babylonjs/Maths/math.vector";
  47341. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47342. import { Scene } from "babylonjs/scene";
  47343. import { AbstractScene } from "babylonjs/abstractScene";
  47344. import "babylonjs/Audio/audioEngine";
  47345. module "babylonjs/abstractScene" {
  47346. interface AbstractScene {
  47347. /**
  47348. * The list of sounds used in the scene.
  47349. */
  47350. sounds: Nullable<Array<Sound>>;
  47351. }
  47352. }
  47353. module "babylonjs/scene" {
  47354. interface Scene {
  47355. /**
  47356. * @hidden
  47357. * Backing field
  47358. */
  47359. _mainSoundTrack: SoundTrack;
  47360. /**
  47361. * The main sound track played by the scene.
  47362. * It cotains your primary collection of sounds.
  47363. */
  47364. mainSoundTrack: SoundTrack;
  47365. /**
  47366. * The list of sound tracks added to the scene
  47367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47368. */
  47369. soundTracks: Nullable<Array<SoundTrack>>;
  47370. /**
  47371. * Gets a sound using a given name
  47372. * @param name defines the name to search for
  47373. * @return the found sound or null if not found at all.
  47374. */
  47375. getSoundByName(name: string): Nullable<Sound>;
  47376. /**
  47377. * Gets or sets if audio support is enabled
  47378. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47379. */
  47380. audioEnabled: boolean;
  47381. /**
  47382. * Gets or sets if audio will be output to headphones
  47383. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47384. */
  47385. headphone: boolean;
  47386. /**
  47387. * Gets or sets custom audio listener position provider
  47388. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47389. */
  47390. audioListenerPositionProvider: Nullable<() => Vector3>;
  47391. /**
  47392. * Gets or sets a refresh rate when using 3D audio positioning
  47393. */
  47394. audioPositioningRefreshRate: number;
  47395. }
  47396. }
  47397. /**
  47398. * Defines the sound scene component responsible to manage any sounds
  47399. * in a given scene.
  47400. */
  47401. export class AudioSceneComponent implements ISceneSerializableComponent {
  47402. private static _CameraDirectionLH;
  47403. private static _CameraDirectionRH;
  47404. /**
  47405. * The component name helpfull to identify the component in the list of scene components.
  47406. */
  47407. readonly name: string;
  47408. /**
  47409. * The scene the component belongs to.
  47410. */
  47411. scene: Scene;
  47412. private _audioEnabled;
  47413. /**
  47414. * Gets whether audio is enabled or not.
  47415. * Please use related enable/disable method to switch state.
  47416. */
  47417. get audioEnabled(): boolean;
  47418. private _headphone;
  47419. /**
  47420. * Gets whether audio is outputing to headphone or not.
  47421. * Please use the according Switch methods to change output.
  47422. */
  47423. get headphone(): boolean;
  47424. /**
  47425. * Gets or sets a refresh rate when using 3D audio positioning
  47426. */
  47427. audioPositioningRefreshRate: number;
  47428. private _audioListenerPositionProvider;
  47429. /**
  47430. * Gets the current audio listener position provider
  47431. */
  47432. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47433. /**
  47434. * Sets a custom listener position for all sounds in the scene
  47435. * By default, this is the position of the first active camera
  47436. */
  47437. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47438. /**
  47439. * Creates a new instance of the component for the given scene
  47440. * @param scene Defines the scene to register the component in
  47441. */
  47442. constructor(scene: Scene);
  47443. /**
  47444. * Registers the component in a given scene
  47445. */
  47446. register(): void;
  47447. /**
  47448. * Rebuilds the elements related to this component in case of
  47449. * context lost for instance.
  47450. */
  47451. rebuild(): void;
  47452. /**
  47453. * Serializes the component data to the specified json object
  47454. * @param serializationObject The object to serialize to
  47455. */
  47456. serialize(serializationObject: any): void;
  47457. /**
  47458. * Adds all the elements from the container to the scene
  47459. * @param container the container holding the elements
  47460. */
  47461. addFromContainer(container: AbstractScene): void;
  47462. /**
  47463. * Removes all the elements in the container from the scene
  47464. * @param container contains the elements to remove
  47465. * @param dispose if the removed element should be disposed (default: false)
  47466. */
  47467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47468. /**
  47469. * Disposes the component and the associated ressources.
  47470. */
  47471. dispose(): void;
  47472. /**
  47473. * Disables audio in the associated scene.
  47474. */
  47475. disableAudio(): void;
  47476. /**
  47477. * Enables audio in the associated scene.
  47478. */
  47479. enableAudio(): void;
  47480. /**
  47481. * Switch audio to headphone output.
  47482. */
  47483. switchAudioModeForHeadphones(): void;
  47484. /**
  47485. * Switch audio to normal speakers.
  47486. */
  47487. switchAudioModeForNormalSpeakers(): void;
  47488. private _cachedCameraDirection;
  47489. private _cachedCameraPosition;
  47490. private _lastCheck;
  47491. private _afterRender;
  47492. }
  47493. }
  47494. declare module "babylonjs/Audio/weightedsound" {
  47495. import { Sound } from "babylonjs/Audio/sound";
  47496. /**
  47497. * Wraps one or more Sound objects and selects one with random weight for playback.
  47498. */
  47499. export class WeightedSound {
  47500. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47501. loop: boolean;
  47502. private _coneInnerAngle;
  47503. private _coneOuterAngle;
  47504. private _volume;
  47505. /** A Sound is currently playing. */
  47506. isPlaying: boolean;
  47507. /** A Sound is currently paused. */
  47508. isPaused: boolean;
  47509. private _sounds;
  47510. private _weights;
  47511. private _currentIndex?;
  47512. /**
  47513. * Creates a new WeightedSound from the list of sounds given.
  47514. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47515. * @param sounds Array of Sounds that will be selected from.
  47516. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47517. */
  47518. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47519. /**
  47520. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47521. */
  47522. get directionalConeInnerAngle(): number;
  47523. /**
  47524. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47525. */
  47526. set directionalConeInnerAngle(value: number);
  47527. /**
  47528. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47529. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47530. */
  47531. get directionalConeOuterAngle(): number;
  47532. /**
  47533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47535. */
  47536. set directionalConeOuterAngle(value: number);
  47537. /**
  47538. * Playback volume.
  47539. */
  47540. get volume(): number;
  47541. /**
  47542. * Playback volume.
  47543. */
  47544. set volume(value: number);
  47545. private _onended;
  47546. /**
  47547. * Suspend playback
  47548. */
  47549. pause(): void;
  47550. /**
  47551. * Stop playback
  47552. */
  47553. stop(): void;
  47554. /**
  47555. * Start playback.
  47556. * @param startOffset Position the clip head at a specific time in seconds.
  47557. */
  47558. play(startOffset?: number): void;
  47559. }
  47560. }
  47561. declare module "babylonjs/Audio/index" {
  47562. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47563. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47564. export * from "babylonjs/Audio/analyser";
  47565. export * from "babylonjs/Audio/audioEngine";
  47566. export * from "babylonjs/Audio/audioSceneComponent";
  47567. export * from "babylonjs/Audio/sound";
  47568. export * from "babylonjs/Audio/soundTrack";
  47569. export * from "babylonjs/Audio/weightedsound";
  47570. }
  47571. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47572. import { Behavior } from "babylonjs/Behaviors/behavior";
  47573. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47574. import { BackEase } from "babylonjs/Animations/easing";
  47575. /**
  47576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47577. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47578. */
  47579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47580. /**
  47581. * Gets the name of the behavior.
  47582. */
  47583. get name(): string;
  47584. /**
  47585. * The easing function used by animations
  47586. */
  47587. static EasingFunction: BackEase;
  47588. /**
  47589. * The easing mode used by animations
  47590. */
  47591. static EasingMode: number;
  47592. /**
  47593. * The duration of the animation, in milliseconds
  47594. */
  47595. transitionDuration: number;
  47596. /**
  47597. * Length of the distance animated by the transition when lower radius is reached
  47598. */
  47599. lowerRadiusTransitionRange: number;
  47600. /**
  47601. * Length of the distance animated by the transition when upper radius is reached
  47602. */
  47603. upperRadiusTransitionRange: number;
  47604. private _autoTransitionRange;
  47605. /**
  47606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47607. */
  47608. get autoTransitionRange(): boolean;
  47609. /**
  47610. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47611. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47612. */
  47613. set autoTransitionRange(value: boolean);
  47614. private _attachedCamera;
  47615. private _onAfterCheckInputsObserver;
  47616. private _onMeshTargetChangedObserver;
  47617. /**
  47618. * Initializes the behavior.
  47619. */
  47620. init(): void;
  47621. /**
  47622. * Attaches the behavior to its arc rotate camera.
  47623. * @param camera Defines the camera to attach the behavior to
  47624. */
  47625. attach(camera: ArcRotateCamera): void;
  47626. /**
  47627. * Detaches the behavior from its current arc rotate camera.
  47628. */
  47629. detach(): void;
  47630. private _radiusIsAnimating;
  47631. private _radiusBounceTransition;
  47632. private _animatables;
  47633. private _cachedWheelPrecision;
  47634. /**
  47635. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47636. * @param radiusLimit The limit to check against.
  47637. * @return Bool to indicate if at limit.
  47638. */
  47639. private _isRadiusAtLimit;
  47640. /**
  47641. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47642. * @param radiusDelta The delta by which to animate to. Can be negative.
  47643. */
  47644. private _applyBoundRadiusAnimation;
  47645. /**
  47646. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47647. */
  47648. protected _clearAnimationLocks(): void;
  47649. /**
  47650. * Stops and removes all animations that have been applied to the camera
  47651. */
  47652. stopAllAnimations(): void;
  47653. }
  47654. }
  47655. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47656. import { Behavior } from "babylonjs/Behaviors/behavior";
  47657. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47658. import { ExponentialEase } from "babylonjs/Animations/easing";
  47659. import { Nullable } from "babylonjs/types";
  47660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47661. import { Vector3 } from "babylonjs/Maths/math.vector";
  47662. /**
  47663. * 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.
  47664. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47665. */
  47666. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47667. /**
  47668. * Gets the name of the behavior.
  47669. */
  47670. get name(): string;
  47671. private _mode;
  47672. private _radiusScale;
  47673. private _positionScale;
  47674. private _defaultElevation;
  47675. private _elevationReturnTime;
  47676. private _elevationReturnWaitTime;
  47677. private _zoomStopsAnimation;
  47678. private _framingTime;
  47679. /**
  47680. * The easing function used by animations
  47681. */
  47682. static EasingFunction: ExponentialEase;
  47683. /**
  47684. * The easing mode used by animations
  47685. */
  47686. static EasingMode: number;
  47687. /**
  47688. * Sets the current mode used by the behavior
  47689. */
  47690. set mode(mode: number);
  47691. /**
  47692. * Gets current mode used by the behavior.
  47693. */
  47694. get mode(): number;
  47695. /**
  47696. * Sets the scale applied to the radius (1 by default)
  47697. */
  47698. set radiusScale(radius: number);
  47699. /**
  47700. * Gets the scale applied to the radius
  47701. */
  47702. get radiusScale(): number;
  47703. /**
  47704. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47705. */
  47706. set positionScale(scale: number);
  47707. /**
  47708. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47709. */
  47710. get positionScale(): number;
  47711. /**
  47712. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47713. * behaviour is triggered, in radians.
  47714. */
  47715. set defaultElevation(elevation: number);
  47716. /**
  47717. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47718. * behaviour is triggered, in radians.
  47719. */
  47720. get defaultElevation(): number;
  47721. /**
  47722. * Sets the time (in milliseconds) taken to return to the default beta position.
  47723. * Negative value indicates camera should not return to default.
  47724. */
  47725. set elevationReturnTime(speed: number);
  47726. /**
  47727. * Gets the time (in milliseconds) taken to return to the default beta position.
  47728. * Negative value indicates camera should not return to default.
  47729. */
  47730. get elevationReturnTime(): number;
  47731. /**
  47732. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47733. */
  47734. set elevationReturnWaitTime(time: number);
  47735. /**
  47736. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47737. */
  47738. get elevationReturnWaitTime(): number;
  47739. /**
  47740. * Sets the flag that indicates if user zooming should stop animation.
  47741. */
  47742. set zoomStopsAnimation(flag: boolean);
  47743. /**
  47744. * Gets the flag that indicates if user zooming should stop animation.
  47745. */
  47746. get zoomStopsAnimation(): boolean;
  47747. /**
  47748. * Sets the transition time when framing the mesh, in milliseconds
  47749. */
  47750. set framingTime(time: number);
  47751. /**
  47752. * Gets the transition time when framing the mesh, in milliseconds
  47753. */
  47754. get framingTime(): number;
  47755. /**
  47756. * Define if the behavior should automatically change the configured
  47757. * camera limits and sensibilities.
  47758. */
  47759. autoCorrectCameraLimitsAndSensibility: boolean;
  47760. private _onPrePointerObservableObserver;
  47761. private _onAfterCheckInputsObserver;
  47762. private _onMeshTargetChangedObserver;
  47763. private _attachedCamera;
  47764. private _isPointerDown;
  47765. private _lastInteractionTime;
  47766. /**
  47767. * Initializes the behavior.
  47768. */
  47769. init(): void;
  47770. /**
  47771. * Attaches the behavior to its arc rotate camera.
  47772. * @param camera Defines the camera to attach the behavior to
  47773. */
  47774. attach(camera: ArcRotateCamera): void;
  47775. /**
  47776. * Detaches the behavior from its current arc rotate camera.
  47777. */
  47778. detach(): void;
  47779. private _animatables;
  47780. private _betaIsAnimating;
  47781. private _betaTransition;
  47782. private _radiusTransition;
  47783. private _vectorTransition;
  47784. /**
  47785. * Targets the given mesh and updates zoom level accordingly.
  47786. * @param mesh The mesh to target.
  47787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47789. */
  47790. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47791. /**
  47792. * Targets the given mesh with its children and updates zoom level accordingly.
  47793. * @param mesh The mesh to target.
  47794. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47795. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47796. */
  47797. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47798. /**
  47799. * Targets the given meshes with their children and updates zoom level accordingly.
  47800. * @param meshes The mesh to target.
  47801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47803. */
  47804. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47805. /**
  47806. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47807. * @param minimumWorld Determines the smaller position of the bounding box extend
  47808. * @param maximumWorld Determines the bigger position of the bounding box extend
  47809. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47810. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47811. */
  47812. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47813. /**
  47814. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47815. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47816. * frustum width.
  47817. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47818. * to fully enclose the mesh in the viewing frustum.
  47819. */
  47820. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47821. /**
  47822. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47823. * is automatically returned to its default position (expected to be above ground plane).
  47824. */
  47825. private _maintainCameraAboveGround;
  47826. /**
  47827. * Returns the frustum slope based on the canvas ratio and camera FOV
  47828. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47829. */
  47830. private _getFrustumSlope;
  47831. /**
  47832. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47833. */
  47834. private _clearAnimationLocks;
  47835. /**
  47836. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47837. */
  47838. private _applyUserInteraction;
  47839. /**
  47840. * Stops and removes all animations that have been applied to the camera
  47841. */
  47842. stopAllAnimations(): void;
  47843. /**
  47844. * Gets a value indicating if the user is moving the camera
  47845. */
  47846. get isUserIsMoving(): boolean;
  47847. /**
  47848. * The camera can move all the way towards the mesh.
  47849. */
  47850. static IgnoreBoundsSizeMode: number;
  47851. /**
  47852. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47853. */
  47854. static FitFrustumSidesMode: number;
  47855. }
  47856. }
  47857. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47858. import { Nullable } from "babylonjs/types";
  47859. import { Camera } from "babylonjs/Cameras/camera";
  47860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47861. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47862. /**
  47863. * Base class for Camera Pointer Inputs.
  47864. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47865. * for example usage.
  47866. */
  47867. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47868. /**
  47869. * Defines the camera the input is attached to.
  47870. */
  47871. abstract camera: Camera;
  47872. /**
  47873. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47874. */
  47875. protected _altKey: boolean;
  47876. protected _ctrlKey: boolean;
  47877. protected _metaKey: boolean;
  47878. protected _shiftKey: boolean;
  47879. /**
  47880. * Which mouse buttons were pressed at time of last mouse event.
  47881. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47882. */
  47883. protected _buttonsPressed: number;
  47884. /**
  47885. * Defines the buttons associated with the input to handle camera move.
  47886. */
  47887. buttons: number[];
  47888. /**
  47889. * Attach the input controls to a specific dom element to get the input from.
  47890. * @param element Defines the element the controls should be listened from
  47891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47892. */
  47893. attachControl(noPreventDefault?: boolean): void;
  47894. /**
  47895. * Detach the current controls from the specified dom element.
  47896. */
  47897. detachControl(): void;
  47898. /**
  47899. * Gets the class name of the current input.
  47900. * @returns the class name
  47901. */
  47902. getClassName(): string;
  47903. /**
  47904. * Get the friendly name associated with the input class.
  47905. * @returns the input friendly name
  47906. */
  47907. getSimpleName(): string;
  47908. /**
  47909. * Called on pointer POINTERDOUBLETAP event.
  47910. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47911. */
  47912. protected onDoubleTap(type: string): void;
  47913. /**
  47914. * Called on pointer POINTERMOVE event if only a single touch is active.
  47915. * Override this method to provide functionality.
  47916. */
  47917. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47918. /**
  47919. * Called on pointer POINTERMOVE event if multiple touches are active.
  47920. * Override this method to provide functionality.
  47921. */
  47922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47923. /**
  47924. * Called on JS contextmenu event.
  47925. * Override this method to provide functionality.
  47926. */
  47927. protected onContextMenu(evt: PointerEvent): void;
  47928. /**
  47929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47930. * press.
  47931. * Override this method to provide functionality.
  47932. */
  47933. protected onButtonDown(evt: PointerEvent): void;
  47934. /**
  47935. * Called each time a new POINTERUP event occurs. Ie, for each button
  47936. * release.
  47937. * Override this method to provide functionality.
  47938. */
  47939. protected onButtonUp(evt: PointerEvent): void;
  47940. /**
  47941. * Called when window becomes inactive.
  47942. * Override this method to provide functionality.
  47943. */
  47944. protected onLostFocus(): void;
  47945. private _pointerInput;
  47946. private _observer;
  47947. private _onLostFocus;
  47948. private pointA;
  47949. private pointB;
  47950. }
  47951. }
  47952. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47953. import { Nullable } from "babylonjs/types";
  47954. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47955. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47956. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47957. /**
  47958. * Manage the pointers inputs to control an arc rotate camera.
  47959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47960. */
  47961. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47962. /**
  47963. * Defines the camera the input is attached to.
  47964. */
  47965. camera: ArcRotateCamera;
  47966. /**
  47967. * Gets the class name of the current input.
  47968. * @returns the class name
  47969. */
  47970. getClassName(): string;
  47971. /**
  47972. * Defines the buttons associated with the input to handle camera move.
  47973. */
  47974. buttons: number[];
  47975. /**
  47976. * Defines the pointer angular sensibility along the X axis or how fast is
  47977. * the camera rotating.
  47978. */
  47979. angularSensibilityX: number;
  47980. /**
  47981. * Defines the pointer angular sensibility along the Y axis or how fast is
  47982. * the camera rotating.
  47983. */
  47984. angularSensibilityY: number;
  47985. /**
  47986. * Defines the pointer pinch precision or how fast is the camera zooming.
  47987. */
  47988. pinchPrecision: number;
  47989. /**
  47990. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47991. * from 0.
  47992. * It defines the percentage of current camera.radius to use as delta when
  47993. * pinch zoom is used.
  47994. */
  47995. pinchDeltaPercentage: number;
  47996. /**
  47997. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47998. * that any object in the plane at the camera's target point will scale
  47999. * perfectly with finger motion.
  48000. * Overrides pinchDeltaPercentage and pinchPrecision.
  48001. */
  48002. useNaturalPinchZoom: boolean;
  48003. /**
  48004. * Defines the pointer panning sensibility or how fast is the camera moving.
  48005. */
  48006. panningSensibility: number;
  48007. /**
  48008. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  48009. */
  48010. multiTouchPanning: boolean;
  48011. /**
  48012. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  48013. * zoom (pinch) through multitouch.
  48014. */
  48015. multiTouchPanAndZoom: boolean;
  48016. /**
  48017. * Revers pinch action direction.
  48018. */
  48019. pinchInwards: boolean;
  48020. private _isPanClick;
  48021. private _twoFingerActivityCount;
  48022. private _isPinching;
  48023. /**
  48024. * Called on pointer POINTERMOVE event if only a single touch is active.
  48025. */
  48026. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48027. /**
  48028. * Called on pointer POINTERDOUBLETAP event.
  48029. */
  48030. protected onDoubleTap(type: string): void;
  48031. /**
  48032. * Called on pointer POINTERMOVE event if multiple touches are active.
  48033. */
  48034. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48035. /**
  48036. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48037. * press.
  48038. */
  48039. protected onButtonDown(evt: PointerEvent): void;
  48040. /**
  48041. * Called each time a new POINTERUP event occurs. Ie, for each button
  48042. * release.
  48043. */
  48044. protected onButtonUp(evt: PointerEvent): void;
  48045. /**
  48046. * Called when window becomes inactive.
  48047. */
  48048. protected onLostFocus(): void;
  48049. }
  48050. }
  48051. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48053. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48054. /**
  48055. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48057. */
  48058. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48059. /**
  48060. * Defines the camera the input is attached to.
  48061. */
  48062. camera: ArcRotateCamera;
  48063. /**
  48064. * Defines the list of key codes associated with the up action (increase alpha)
  48065. */
  48066. keysUp: number[];
  48067. /**
  48068. * Defines the list of key codes associated with the down action (decrease alpha)
  48069. */
  48070. keysDown: number[];
  48071. /**
  48072. * Defines the list of key codes associated with the left action (increase beta)
  48073. */
  48074. keysLeft: number[];
  48075. /**
  48076. * Defines the list of key codes associated with the right action (decrease beta)
  48077. */
  48078. keysRight: number[];
  48079. /**
  48080. * Defines the list of key codes associated with the reset action.
  48081. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48082. */
  48083. keysReset: number[];
  48084. /**
  48085. * Defines the panning sensibility of the inputs.
  48086. * (How fast is the camera panning)
  48087. */
  48088. panningSensibility: number;
  48089. /**
  48090. * Defines the zooming sensibility of the inputs.
  48091. * (How fast is the camera zooming)
  48092. */
  48093. zoomingSensibility: number;
  48094. /**
  48095. * Defines whether maintaining the alt key down switch the movement mode from
  48096. * orientation to zoom.
  48097. */
  48098. useAltToZoom: boolean;
  48099. /**
  48100. * Rotation speed of the camera
  48101. */
  48102. angularSpeed: number;
  48103. private _keys;
  48104. private _ctrlPressed;
  48105. private _altPressed;
  48106. private _onCanvasBlurObserver;
  48107. private _onKeyboardObserver;
  48108. private _engine;
  48109. private _scene;
  48110. /**
  48111. * Attach the input controls to a specific dom element to get the input from.
  48112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48113. */
  48114. attachControl(noPreventDefault?: boolean): void;
  48115. /**
  48116. * Detach the current controls from the specified dom element.
  48117. */
  48118. detachControl(): void;
  48119. /**
  48120. * Update the current camera state depending on the inputs that have been used this frame.
  48121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48122. */
  48123. checkInputs(): void;
  48124. /**
  48125. * Gets the class name of the current intput.
  48126. * @returns the class name
  48127. */
  48128. getClassName(): string;
  48129. /**
  48130. * Get the friendly name associated with the input class.
  48131. * @returns the input friendly name
  48132. */
  48133. getSimpleName(): string;
  48134. }
  48135. }
  48136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48139. /**
  48140. * Manage the mouse wheel inputs to control an arc rotate camera.
  48141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48142. */
  48143. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48144. /**
  48145. * Defines the camera the input is attached to.
  48146. */
  48147. camera: ArcRotateCamera;
  48148. /**
  48149. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48150. */
  48151. wheelPrecision: number;
  48152. /**
  48153. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48154. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48155. */
  48156. wheelDeltaPercentage: number;
  48157. private _wheel;
  48158. private _observer;
  48159. private computeDeltaFromMouseWheelLegacyEvent;
  48160. /**
  48161. * Attach the input controls to a specific dom element to get the input from.
  48162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48163. */
  48164. attachControl(noPreventDefault?: boolean): void;
  48165. /**
  48166. * Detach the current controls from the specified dom element.
  48167. */
  48168. detachControl(): void;
  48169. /**
  48170. * Gets the class name of the current intput.
  48171. * @returns the class name
  48172. */
  48173. getClassName(): string;
  48174. /**
  48175. * Get the friendly name associated with the input class.
  48176. * @returns the input friendly name
  48177. */
  48178. getSimpleName(): string;
  48179. }
  48180. }
  48181. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48182. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48183. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48184. /**
  48185. * Default Inputs manager for the ArcRotateCamera.
  48186. * It groups all the default supported inputs for ease of use.
  48187. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48188. */
  48189. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48190. /**
  48191. * Instantiates a new ArcRotateCameraInputsManager.
  48192. * @param camera Defines the camera the inputs belong to
  48193. */
  48194. constructor(camera: ArcRotateCamera);
  48195. /**
  48196. * Add mouse wheel input support to the input manager.
  48197. * @returns the current input manager
  48198. */
  48199. addMouseWheel(): ArcRotateCameraInputsManager;
  48200. /**
  48201. * Add pointers input support to the input manager.
  48202. * @returns the current input manager
  48203. */
  48204. addPointers(): ArcRotateCameraInputsManager;
  48205. /**
  48206. * Add keyboard input support to the input manager.
  48207. * @returns the current input manager
  48208. */
  48209. addKeyboard(): ArcRotateCameraInputsManager;
  48210. }
  48211. }
  48212. declare module "babylonjs/Cameras/arcRotateCamera" {
  48213. import { Observable } from "babylonjs/Misc/observable";
  48214. import { Nullable } from "babylonjs/types";
  48215. import { Scene } from "babylonjs/scene";
  48216. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48218. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48219. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48220. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48221. import { Camera } from "babylonjs/Cameras/camera";
  48222. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48223. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48224. import { Collider } from "babylonjs/Collisions/collider";
  48225. /**
  48226. * This represents an orbital type of camera.
  48227. *
  48228. * 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.
  48229. * 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.
  48230. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48231. */
  48232. export class ArcRotateCamera extends TargetCamera {
  48233. /**
  48234. * Defines the rotation angle of the camera along the longitudinal axis.
  48235. */
  48236. alpha: number;
  48237. /**
  48238. * Defines the rotation angle of the camera along the latitudinal axis.
  48239. */
  48240. beta: number;
  48241. /**
  48242. * Defines the radius of the camera from it s target point.
  48243. */
  48244. radius: number;
  48245. protected _target: Vector3;
  48246. protected _targetHost: Nullable<AbstractMesh>;
  48247. /**
  48248. * Defines the target point of the camera.
  48249. * The camera looks towards it form the radius distance.
  48250. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48251. */
  48252. get target(): Vector3;
  48253. set target(value: Vector3);
  48254. /**
  48255. * Define the current local position of the camera in the scene
  48256. */
  48257. get position(): Vector3;
  48258. set position(newPosition: Vector3);
  48259. protected _upToYMatrix: Matrix;
  48260. protected _YToUpMatrix: Matrix;
  48261. /**
  48262. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48263. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48264. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48265. */
  48266. set upVector(vec: Vector3);
  48267. get upVector(): Vector3;
  48268. /**
  48269. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48270. */
  48271. setMatUp(): void;
  48272. /**
  48273. * Current inertia value on the longitudinal axis.
  48274. * The bigger this number the longer it will take for the camera to stop.
  48275. */
  48276. inertialAlphaOffset: number;
  48277. /**
  48278. * Current inertia value on the latitudinal axis.
  48279. * The bigger this number the longer it will take for the camera to stop.
  48280. */
  48281. inertialBetaOffset: number;
  48282. /**
  48283. * Current inertia value on the radius axis.
  48284. * The bigger this number the longer it will take for the camera to stop.
  48285. */
  48286. inertialRadiusOffset: number;
  48287. /**
  48288. * Minimum allowed angle on the longitudinal axis.
  48289. * This can help limiting how the Camera is able to move in the scene.
  48290. */
  48291. lowerAlphaLimit: Nullable<number>;
  48292. /**
  48293. * Maximum allowed angle on the longitudinal axis.
  48294. * This can help limiting how the Camera is able to move in the scene.
  48295. */
  48296. upperAlphaLimit: Nullable<number>;
  48297. /**
  48298. * Minimum allowed angle on the latitudinal axis.
  48299. * This can help limiting how the Camera is able to move in the scene.
  48300. */
  48301. lowerBetaLimit: number;
  48302. /**
  48303. * Maximum allowed angle on the latitudinal axis.
  48304. * This can help limiting how the Camera is able to move in the scene.
  48305. */
  48306. upperBetaLimit: number;
  48307. /**
  48308. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48309. * This can help limiting how the Camera is able to move in the scene.
  48310. */
  48311. lowerRadiusLimit: Nullable<number>;
  48312. /**
  48313. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48314. * This can help limiting how the Camera is able to move in the scene.
  48315. */
  48316. upperRadiusLimit: Nullable<number>;
  48317. /**
  48318. * Defines the current inertia value used during panning of the camera along the X axis.
  48319. */
  48320. inertialPanningX: number;
  48321. /**
  48322. * Defines the current inertia value used during panning of the camera along the Y axis.
  48323. */
  48324. inertialPanningY: number;
  48325. /**
  48326. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48327. * Basically if your fingers moves away from more than this distance you will be considered
  48328. * in pinch mode.
  48329. */
  48330. pinchToPanMaxDistance: number;
  48331. /**
  48332. * Defines the maximum distance the camera can pan.
  48333. * This could help keeping the cammera always in your scene.
  48334. */
  48335. panningDistanceLimit: Nullable<number>;
  48336. /**
  48337. * Defines the target of the camera before paning.
  48338. */
  48339. panningOriginTarget: Vector3;
  48340. /**
  48341. * Defines the value of the inertia used during panning.
  48342. * 0 would mean stop inertia and one would mean no decelleration at all.
  48343. */
  48344. panningInertia: number;
  48345. /**
  48346. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48347. */
  48348. get angularSensibilityX(): number;
  48349. set angularSensibilityX(value: number);
  48350. /**
  48351. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48352. */
  48353. get angularSensibilityY(): number;
  48354. set angularSensibilityY(value: number);
  48355. /**
  48356. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48357. */
  48358. get pinchPrecision(): number;
  48359. set pinchPrecision(value: number);
  48360. /**
  48361. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48362. * It will be used instead of pinchDeltaPrecision if different from 0.
  48363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48364. */
  48365. get pinchDeltaPercentage(): number;
  48366. set pinchDeltaPercentage(value: number);
  48367. /**
  48368. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48369. * and pinch delta percentage.
  48370. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48371. * that any object in the plane at the camera's target point will scale
  48372. * perfectly with finger motion.
  48373. */
  48374. get useNaturalPinchZoom(): boolean;
  48375. set useNaturalPinchZoom(value: boolean);
  48376. /**
  48377. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48378. */
  48379. get panningSensibility(): number;
  48380. set panningSensibility(value: number);
  48381. /**
  48382. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48383. */
  48384. get keysUp(): number[];
  48385. set keysUp(value: number[]);
  48386. /**
  48387. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48388. */
  48389. get keysDown(): number[];
  48390. set keysDown(value: number[]);
  48391. /**
  48392. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48393. */
  48394. get keysLeft(): number[];
  48395. set keysLeft(value: number[]);
  48396. /**
  48397. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48398. */
  48399. get keysRight(): number[];
  48400. set keysRight(value: number[]);
  48401. /**
  48402. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48403. */
  48404. get wheelPrecision(): number;
  48405. set wheelPrecision(value: number);
  48406. /**
  48407. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48408. * It will be used instead of pinchDeltaPrecision if different from 0.
  48409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48410. */
  48411. get wheelDeltaPercentage(): number;
  48412. set wheelDeltaPercentage(value: number);
  48413. /**
  48414. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48415. */
  48416. zoomOnFactor: number;
  48417. /**
  48418. * Defines a screen offset for the camera position.
  48419. */
  48420. targetScreenOffset: Vector2;
  48421. /**
  48422. * Allows the camera to be completely reversed.
  48423. * If false the camera can not arrive upside down.
  48424. */
  48425. allowUpsideDown: boolean;
  48426. /**
  48427. * Define if double tap/click is used to restore the previously saved state of the camera.
  48428. */
  48429. useInputToRestoreState: boolean;
  48430. /** @hidden */
  48431. _viewMatrix: Matrix;
  48432. /** @hidden */
  48433. _useCtrlForPanning: boolean;
  48434. /** @hidden */
  48435. _panningMouseButton: number;
  48436. /**
  48437. * Defines the input associated to the camera.
  48438. */
  48439. inputs: ArcRotateCameraInputsManager;
  48440. /** @hidden */
  48441. _reset: () => void;
  48442. /**
  48443. * Defines the allowed panning axis.
  48444. */
  48445. panningAxis: Vector3;
  48446. protected _localDirection: Vector3;
  48447. protected _transformedDirection: Vector3;
  48448. private _bouncingBehavior;
  48449. /**
  48450. * Gets the bouncing behavior of the camera if it has been enabled.
  48451. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48452. */
  48453. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48454. /**
  48455. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48456. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48457. */
  48458. get useBouncingBehavior(): boolean;
  48459. set useBouncingBehavior(value: boolean);
  48460. private _framingBehavior;
  48461. /**
  48462. * Gets the framing behavior of the camera if it has been enabled.
  48463. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48464. */
  48465. get framingBehavior(): Nullable<FramingBehavior>;
  48466. /**
  48467. * Defines if the framing behavior of the camera is enabled on the camera.
  48468. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48469. */
  48470. get useFramingBehavior(): boolean;
  48471. set useFramingBehavior(value: boolean);
  48472. private _autoRotationBehavior;
  48473. /**
  48474. * Gets the auto rotation behavior of the camera if it has been enabled.
  48475. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48476. */
  48477. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48478. /**
  48479. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48480. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48481. */
  48482. get useAutoRotationBehavior(): boolean;
  48483. set useAutoRotationBehavior(value: boolean);
  48484. /**
  48485. * Observable triggered when the mesh target has been changed on the camera.
  48486. */
  48487. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48488. /**
  48489. * Event raised when the camera is colliding with a mesh.
  48490. */
  48491. onCollide: (collidedMesh: AbstractMesh) => void;
  48492. /**
  48493. * Defines whether the camera should check collision with the objects oh the scene.
  48494. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48495. */
  48496. checkCollisions: boolean;
  48497. /**
  48498. * Defines the collision radius of the camera.
  48499. * This simulates a sphere around the camera.
  48500. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48501. */
  48502. collisionRadius: Vector3;
  48503. protected _collider: Collider;
  48504. protected _previousPosition: Vector3;
  48505. protected _collisionVelocity: Vector3;
  48506. protected _newPosition: Vector3;
  48507. protected _previousAlpha: number;
  48508. protected _previousBeta: number;
  48509. protected _previousRadius: number;
  48510. protected _collisionTriggered: boolean;
  48511. protected _targetBoundingCenter: Nullable<Vector3>;
  48512. private _computationVector;
  48513. /**
  48514. * Instantiates a new ArcRotateCamera in a given scene
  48515. * @param name Defines the name of the camera
  48516. * @param alpha Defines the camera rotation along the logitudinal axis
  48517. * @param beta Defines the camera rotation along the latitudinal axis
  48518. * @param radius Defines the camera distance from its target
  48519. * @param target Defines the camera target
  48520. * @param scene Defines the scene the camera belongs to
  48521. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48522. */
  48523. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48524. /** @hidden */
  48525. _initCache(): void;
  48526. /** @hidden */
  48527. _updateCache(ignoreParentClass?: boolean): void;
  48528. protected _getTargetPosition(): Vector3;
  48529. private _storedAlpha;
  48530. private _storedBeta;
  48531. private _storedRadius;
  48532. private _storedTarget;
  48533. private _storedTargetScreenOffset;
  48534. /**
  48535. * Stores the current state of the camera (alpha, beta, radius and target)
  48536. * @returns the camera itself
  48537. */
  48538. storeState(): Camera;
  48539. /**
  48540. * @hidden
  48541. * Restored camera state. You must call storeState() first
  48542. */
  48543. _restoreStateValues(): boolean;
  48544. /** @hidden */
  48545. _isSynchronizedViewMatrix(): boolean;
  48546. /**
  48547. * Attach the input controls to a specific dom element to get the input from.
  48548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48549. */
  48550. attachControl(noPreventDefault?: boolean): void;
  48551. /**
  48552. * Attach the input controls to a specific dom element to get the input from.
  48553. * @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
  48554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48555. */
  48556. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48557. /**
  48558. * Attached controls to the current camera.
  48559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48560. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48561. */
  48562. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48563. /**
  48564. * Attached controls to the current camera.
  48565. * @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
  48566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48567. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48568. */
  48569. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48570. /**
  48571. * Attached controls to the current camera.
  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. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48574. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48575. */
  48576. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48577. /**
  48578. * Detach the current controls from the specified dom element.
  48579. */
  48580. detachControl(): void;
  48581. /**
  48582. * Detach the current controls from the specified dom element.
  48583. * @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
  48584. */
  48585. detachControl(ignored: any): void;
  48586. /** @hidden */
  48587. _checkInputs(): void;
  48588. protected _checkLimits(): void;
  48589. /**
  48590. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48591. */
  48592. rebuildAnglesAndRadius(): void;
  48593. /**
  48594. * Use a position to define the current camera related information like alpha, beta and radius
  48595. * @param position Defines the position to set the camera at
  48596. */
  48597. setPosition(position: Vector3): void;
  48598. /**
  48599. * Defines the target the camera should look at.
  48600. * This will automatically adapt alpha beta and radius to fit within the new target.
  48601. * @param target Defines the new target as a Vector or a mesh
  48602. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48603. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48604. */
  48605. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48606. /** @hidden */
  48607. _getViewMatrix(): Matrix;
  48608. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48609. /**
  48610. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48611. * @param meshes Defines the mesh to zoom on
  48612. * @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)
  48613. */
  48614. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48615. /**
  48616. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48617. * The target will be changed but the radius
  48618. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48619. * @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)
  48620. */
  48621. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48622. min: Vector3;
  48623. max: Vector3;
  48624. distance: number;
  48625. }, doNotUpdateMaxZ?: boolean): void;
  48626. /**
  48627. * @override
  48628. * Override Camera.createRigCamera
  48629. */
  48630. createRigCamera(name: string, cameraIndex: number): Camera;
  48631. /**
  48632. * @hidden
  48633. * @override
  48634. * Override Camera._updateRigCameras
  48635. */
  48636. _updateRigCameras(): void;
  48637. /**
  48638. * Destroy the camera and release the current resources hold by it.
  48639. */
  48640. dispose(): void;
  48641. /**
  48642. * Gets the current object class name.
  48643. * @return the class name
  48644. */
  48645. getClassName(): string;
  48646. }
  48647. }
  48648. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48649. import { Behavior } from "babylonjs/Behaviors/behavior";
  48650. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48651. /**
  48652. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48653. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48654. */
  48655. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48656. /**
  48657. * Gets the name of the behavior.
  48658. */
  48659. get name(): string;
  48660. private _zoomStopsAnimation;
  48661. private _idleRotationSpeed;
  48662. private _idleRotationWaitTime;
  48663. private _idleRotationSpinupTime;
  48664. /**
  48665. * Sets the flag that indicates if user zooming should stop animation.
  48666. */
  48667. set zoomStopsAnimation(flag: boolean);
  48668. /**
  48669. * Gets the flag that indicates if user zooming should stop animation.
  48670. */
  48671. get zoomStopsAnimation(): boolean;
  48672. /**
  48673. * Sets the default speed at which the camera rotates around the model.
  48674. */
  48675. set idleRotationSpeed(speed: number);
  48676. /**
  48677. * Gets the default speed at which the camera rotates around the model.
  48678. */
  48679. get idleRotationSpeed(): number;
  48680. /**
  48681. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48682. */
  48683. set idleRotationWaitTime(time: number);
  48684. /**
  48685. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48686. */
  48687. get idleRotationWaitTime(): number;
  48688. /**
  48689. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48690. */
  48691. set idleRotationSpinupTime(time: number);
  48692. /**
  48693. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48694. */
  48695. get idleRotationSpinupTime(): number;
  48696. /**
  48697. * Gets a value indicating if the camera is currently rotating because of this behavior
  48698. */
  48699. get rotationInProgress(): boolean;
  48700. private _onPrePointerObservableObserver;
  48701. private _onAfterCheckInputsObserver;
  48702. private _attachedCamera;
  48703. private _isPointerDown;
  48704. private _lastFrameTime;
  48705. private _lastInteractionTime;
  48706. private _cameraRotationSpeed;
  48707. /**
  48708. * Initializes the behavior.
  48709. */
  48710. init(): void;
  48711. /**
  48712. * Attaches the behavior to its arc rotate camera.
  48713. * @param camera Defines the camera to attach the behavior to
  48714. */
  48715. attach(camera: ArcRotateCamera): void;
  48716. /**
  48717. * Detaches the behavior from its current arc rotate camera.
  48718. */
  48719. detach(): void;
  48720. /**
  48721. * Returns true if user is scrolling.
  48722. * @return true if user is scrolling.
  48723. */
  48724. private _userIsZooming;
  48725. private _lastFrameRadius;
  48726. private _shouldAnimationStopForInteraction;
  48727. /**
  48728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48729. */
  48730. private _applyUserInteraction;
  48731. private _userIsMoving;
  48732. }
  48733. }
  48734. declare module "babylonjs/Behaviors/Cameras/index" {
  48735. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48736. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48737. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48738. }
  48739. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48740. import { Mesh } from "babylonjs/Meshes/mesh";
  48741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48742. import { Behavior } from "babylonjs/Behaviors/behavior";
  48743. /**
  48744. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48745. */
  48746. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48747. private ui;
  48748. /**
  48749. * The name of the behavior
  48750. */
  48751. name: string;
  48752. /**
  48753. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48754. */
  48755. distanceAwayFromFace: number;
  48756. /**
  48757. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48758. */
  48759. distanceAwayFromBottomOfFace: number;
  48760. private _faceVectors;
  48761. private _target;
  48762. private _scene;
  48763. private _onRenderObserver;
  48764. private _tmpMatrix;
  48765. private _tmpVector;
  48766. /**
  48767. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48768. * @param ui The transform node that should be attched to the mesh
  48769. */
  48770. constructor(ui: TransformNode);
  48771. /**
  48772. * Initializes the behavior
  48773. */
  48774. init(): void;
  48775. private _closestFace;
  48776. private _zeroVector;
  48777. private _lookAtTmpMatrix;
  48778. private _lookAtToRef;
  48779. /**
  48780. * Attaches the AttachToBoxBehavior to the passed in mesh
  48781. * @param target The mesh that the specified node will be attached to
  48782. */
  48783. attach(target: Mesh): void;
  48784. /**
  48785. * Detaches the behavior from the mesh
  48786. */
  48787. detach(): void;
  48788. }
  48789. }
  48790. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48791. import { Behavior } from "babylonjs/Behaviors/behavior";
  48792. import { Mesh } from "babylonjs/Meshes/mesh";
  48793. /**
  48794. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48795. */
  48796. export class FadeInOutBehavior implements Behavior<Mesh> {
  48797. /**
  48798. * Time in milliseconds to delay before fading in (Default: 0)
  48799. */
  48800. delay: number;
  48801. /**
  48802. * Time in milliseconds for the mesh to fade in (Default: 300)
  48803. */
  48804. fadeInTime: number;
  48805. private _millisecondsPerFrame;
  48806. private _hovered;
  48807. private _hoverValue;
  48808. private _ownerNode;
  48809. /**
  48810. * Instatiates the FadeInOutBehavior
  48811. */
  48812. constructor();
  48813. /**
  48814. * The name of the behavior
  48815. */
  48816. get name(): string;
  48817. /**
  48818. * Initializes the behavior
  48819. */
  48820. init(): void;
  48821. /**
  48822. * Attaches the fade behavior on the passed in mesh
  48823. * @param ownerNode The mesh that will be faded in/out once attached
  48824. */
  48825. attach(ownerNode: Mesh): void;
  48826. /**
  48827. * Detaches the behavior from the mesh
  48828. */
  48829. detach(): void;
  48830. /**
  48831. * Triggers the mesh to begin fading in or out
  48832. * @param value if the object should fade in or out (true to fade in)
  48833. */
  48834. fadeIn(value: boolean): void;
  48835. private _update;
  48836. private _setAllVisibility;
  48837. }
  48838. }
  48839. declare module "babylonjs/Misc/pivotTools" {
  48840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48841. /**
  48842. * Class containing a set of static utilities functions for managing Pivots
  48843. * @hidden
  48844. */
  48845. export class PivotTools {
  48846. private static _PivotCached;
  48847. private static _OldPivotPoint;
  48848. private static _PivotTranslation;
  48849. private static _PivotTmpVector;
  48850. private static _PivotPostMultiplyPivotMatrix;
  48851. /** @hidden */
  48852. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48853. /** @hidden */
  48854. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48855. }
  48856. }
  48857. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48858. import { Scene } from "babylonjs/scene";
  48859. import { Vector4 } from "babylonjs/Maths/math.vector";
  48860. import { Mesh } from "babylonjs/Meshes/mesh";
  48861. import { Nullable } from "babylonjs/types";
  48862. import { Plane } from "babylonjs/Maths/math.plane";
  48863. /**
  48864. * Class containing static functions to help procedurally build meshes
  48865. */
  48866. export class PlaneBuilder {
  48867. /**
  48868. * Creates a plane mesh
  48869. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48870. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48871. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48875. * @param name defines the name of the mesh
  48876. * @param options defines the options used to create the mesh
  48877. * @param scene defines the hosting scene
  48878. * @returns the plane mesh
  48879. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48880. */
  48881. static CreatePlane(name: string, options: {
  48882. size?: number;
  48883. width?: number;
  48884. height?: number;
  48885. sideOrientation?: number;
  48886. frontUVs?: Vector4;
  48887. backUVs?: Vector4;
  48888. updatable?: boolean;
  48889. sourcePlane?: Plane;
  48890. }, scene?: Nullable<Scene>): Mesh;
  48891. }
  48892. }
  48893. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48894. import { Behavior } from "babylonjs/Behaviors/behavior";
  48895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48896. import { Observable } from "babylonjs/Misc/observable";
  48897. import { Vector3 } from "babylonjs/Maths/math.vector";
  48898. import { Ray } from "babylonjs/Culling/ray";
  48899. import "babylonjs/Meshes/Builders/planeBuilder";
  48900. /**
  48901. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48902. */
  48903. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48904. private static _AnyMouseID;
  48905. /**
  48906. * Abstract mesh the behavior is set on
  48907. */
  48908. attachedNode: AbstractMesh;
  48909. private _dragPlane;
  48910. private _scene;
  48911. private _pointerObserver;
  48912. private _beforeRenderObserver;
  48913. private static _planeScene;
  48914. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48915. /**
  48916. * 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)
  48917. */
  48918. maxDragAngle: number;
  48919. /**
  48920. * @hidden
  48921. */
  48922. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48923. /**
  48924. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48925. */
  48926. currentDraggingPointerID: number;
  48927. /**
  48928. * The last position where the pointer hit the drag plane in world space
  48929. */
  48930. lastDragPosition: Vector3;
  48931. /**
  48932. * If the behavior is currently in a dragging state
  48933. */
  48934. dragging: boolean;
  48935. /**
  48936. * 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)
  48937. */
  48938. dragDeltaRatio: number;
  48939. /**
  48940. * If the drag plane orientation should be updated during the dragging (Default: true)
  48941. */
  48942. updateDragPlane: boolean;
  48943. private _debugMode;
  48944. private _moving;
  48945. /**
  48946. * Fires each time the attached mesh is dragged with the pointer
  48947. * * delta between last drag position and current drag position in world space
  48948. * * dragDistance along the drag axis
  48949. * * dragPlaneNormal normal of the current drag plane used during the drag
  48950. * * dragPlanePoint in world space where the drag intersects the drag plane
  48951. */
  48952. onDragObservable: Observable<{
  48953. delta: Vector3;
  48954. dragPlanePoint: Vector3;
  48955. dragPlaneNormal: Vector3;
  48956. dragDistance: number;
  48957. pointerId: number;
  48958. }>;
  48959. /**
  48960. * Fires each time a drag begins (eg. mouse down on mesh)
  48961. */
  48962. onDragStartObservable: Observable<{
  48963. dragPlanePoint: Vector3;
  48964. pointerId: number;
  48965. }>;
  48966. /**
  48967. * Fires each time a drag ends (eg. mouse release after drag)
  48968. */
  48969. onDragEndObservable: Observable<{
  48970. dragPlanePoint: Vector3;
  48971. pointerId: number;
  48972. }>;
  48973. /**
  48974. * If the attached mesh should be moved when dragged
  48975. */
  48976. moveAttached: boolean;
  48977. /**
  48978. * If the drag behavior will react to drag events (Default: true)
  48979. */
  48980. enabled: boolean;
  48981. /**
  48982. * If pointer events should start and release the drag (Default: true)
  48983. */
  48984. startAndReleaseDragOnPointerEvents: boolean;
  48985. /**
  48986. * If camera controls should be detached during the drag
  48987. */
  48988. detachCameraControls: boolean;
  48989. /**
  48990. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48991. */
  48992. useObjectOrientationForDragging: boolean;
  48993. private _options;
  48994. /**
  48995. * Gets the options used by the behavior
  48996. */
  48997. get options(): {
  48998. dragAxis?: Vector3;
  48999. dragPlaneNormal?: Vector3;
  49000. };
  49001. /**
  49002. * Sets the options used by the behavior
  49003. */
  49004. set options(options: {
  49005. dragAxis?: Vector3;
  49006. dragPlaneNormal?: Vector3;
  49007. });
  49008. /**
  49009. * Creates a pointer drag behavior that can be attached to a mesh
  49010. * @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)
  49011. */
  49012. constructor(options?: {
  49013. dragAxis?: Vector3;
  49014. dragPlaneNormal?: Vector3;
  49015. });
  49016. /**
  49017. * Predicate to determine if it is valid to move the object to a new position when it is moved
  49018. */
  49019. validateDrag: (targetPosition: Vector3) => boolean;
  49020. /**
  49021. * The name of the behavior
  49022. */
  49023. get name(): string;
  49024. /**
  49025. * Initializes the behavior
  49026. */
  49027. init(): void;
  49028. private _tmpVector;
  49029. private _alternatePickedPoint;
  49030. private _worldDragAxis;
  49031. private _targetPosition;
  49032. private _attachedToElement;
  49033. /**
  49034. * Attaches the drag behavior the passed in mesh
  49035. * @param ownerNode The mesh that will be dragged around once attached
  49036. * @param predicate Predicate to use for pick filtering
  49037. */
  49038. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  49039. /**
  49040. * Force relase the drag action by code.
  49041. */
  49042. releaseDrag(): void;
  49043. private _startDragRay;
  49044. private _lastPointerRay;
  49045. /**
  49046. * Simulates the start of a pointer drag event on the behavior
  49047. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  49048. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  49049. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  49050. */
  49051. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49052. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49053. private _dragDelta;
  49054. protected _moveDrag(ray: Ray): void;
  49055. private _pickWithRayOnDragPlane;
  49056. private _pointA;
  49057. private _pointC;
  49058. private _localAxis;
  49059. private _lookAt;
  49060. private _updateDragPlanePosition;
  49061. /**
  49062. * Detaches the behavior from the mesh
  49063. */
  49064. detach(): void;
  49065. }
  49066. }
  49067. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49068. import { Mesh } from "babylonjs/Meshes/mesh";
  49069. import { Behavior } from "babylonjs/Behaviors/behavior";
  49070. /**
  49071. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49072. */
  49073. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49074. private _dragBehaviorA;
  49075. private _dragBehaviorB;
  49076. private _startDistance;
  49077. private _initialScale;
  49078. private _targetScale;
  49079. private _ownerNode;
  49080. private _sceneRenderObserver;
  49081. /**
  49082. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49083. */
  49084. constructor();
  49085. /**
  49086. * The name of the behavior
  49087. */
  49088. get name(): string;
  49089. /**
  49090. * Initializes the behavior
  49091. */
  49092. init(): void;
  49093. private _getCurrentDistance;
  49094. /**
  49095. * Attaches the scale behavior the passed in mesh
  49096. * @param ownerNode The mesh that will be scaled around once attached
  49097. */
  49098. attach(ownerNode: Mesh): void;
  49099. /**
  49100. * Detaches the behavior from the mesh
  49101. */
  49102. detach(): void;
  49103. }
  49104. }
  49105. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49106. import { Behavior } from "babylonjs/Behaviors/behavior";
  49107. import { Mesh } from "babylonjs/Meshes/mesh";
  49108. import { Observable } from "babylonjs/Misc/observable";
  49109. /**
  49110. * 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
  49111. */
  49112. export class SixDofDragBehavior implements Behavior<Mesh> {
  49113. private static _virtualScene;
  49114. private _ownerNode;
  49115. private _sceneRenderObserver;
  49116. private _scene;
  49117. private _targetPosition;
  49118. private _virtualOriginMesh;
  49119. private _virtualDragMesh;
  49120. private _pointerObserver;
  49121. private _moving;
  49122. private _startingOrientation;
  49123. private _attachedToElement;
  49124. /**
  49125. * 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)
  49126. */
  49127. private zDragFactor;
  49128. /**
  49129. * If the object should rotate to face the drag origin
  49130. */
  49131. rotateDraggedObject: boolean;
  49132. /**
  49133. * If the behavior is currently in a dragging state
  49134. */
  49135. dragging: boolean;
  49136. /**
  49137. * 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)
  49138. */
  49139. dragDeltaRatio: number;
  49140. /**
  49141. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49142. */
  49143. currentDraggingPointerID: number;
  49144. /**
  49145. * If camera controls should be detached during the drag
  49146. */
  49147. detachCameraControls: boolean;
  49148. /**
  49149. * Fires each time a drag starts
  49150. */
  49151. onDragStartObservable: Observable<{}>;
  49152. /**
  49153. * Fires each time a drag happens
  49154. */
  49155. onDragObservable: Observable<void>;
  49156. /**
  49157. * Fires each time a drag ends (eg. mouse release after drag)
  49158. */
  49159. onDragEndObservable: Observable<{}>;
  49160. /**
  49161. * 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
  49162. */
  49163. constructor();
  49164. /**
  49165. * The name of the behavior
  49166. */
  49167. get name(): string;
  49168. /**
  49169. * Initializes the behavior
  49170. */
  49171. init(): void;
  49172. /**
  49173. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49174. */
  49175. private get _pointerCamera();
  49176. /**
  49177. * Attaches the scale behavior the passed in mesh
  49178. * @param ownerNode The mesh that will be scaled around once attached
  49179. */
  49180. attach(ownerNode: Mesh): void;
  49181. /**
  49182. * Detaches the behavior from the mesh
  49183. */
  49184. detach(): void;
  49185. }
  49186. }
  49187. declare module "babylonjs/Behaviors/Meshes/index" {
  49188. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49189. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49190. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49191. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49192. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49193. }
  49194. declare module "babylonjs/Behaviors/index" {
  49195. export * from "babylonjs/Behaviors/behavior";
  49196. export * from "babylonjs/Behaviors/Cameras/index";
  49197. export * from "babylonjs/Behaviors/Meshes/index";
  49198. }
  49199. declare module "babylonjs/Bones/boneIKController" {
  49200. import { Bone } from "babylonjs/Bones/bone";
  49201. import { Vector3 } from "babylonjs/Maths/math.vector";
  49202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49203. import { Nullable } from "babylonjs/types";
  49204. /**
  49205. * Class used to apply inverse kinematics to bones
  49206. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49207. */
  49208. export class BoneIKController {
  49209. private static _tmpVecs;
  49210. private static _tmpQuat;
  49211. private static _tmpMats;
  49212. /**
  49213. * Gets or sets the target mesh
  49214. */
  49215. targetMesh: AbstractMesh;
  49216. /** Gets or sets the mesh used as pole */
  49217. poleTargetMesh: AbstractMesh;
  49218. /**
  49219. * Gets or sets the bone used as pole
  49220. */
  49221. poleTargetBone: Nullable<Bone>;
  49222. /**
  49223. * Gets or sets the target position
  49224. */
  49225. targetPosition: Vector3;
  49226. /**
  49227. * Gets or sets the pole target position
  49228. */
  49229. poleTargetPosition: Vector3;
  49230. /**
  49231. * Gets or sets the pole target local offset
  49232. */
  49233. poleTargetLocalOffset: Vector3;
  49234. /**
  49235. * Gets or sets the pole angle
  49236. */
  49237. poleAngle: number;
  49238. /**
  49239. * Gets or sets the mesh associated with the controller
  49240. */
  49241. mesh: AbstractMesh;
  49242. /**
  49243. * 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)
  49244. */
  49245. slerpAmount: number;
  49246. private _bone1Quat;
  49247. private _bone1Mat;
  49248. private _bone2Ang;
  49249. private _bone1;
  49250. private _bone2;
  49251. private _bone1Length;
  49252. private _bone2Length;
  49253. private _maxAngle;
  49254. private _maxReach;
  49255. private _rightHandedSystem;
  49256. private _bendAxis;
  49257. private _slerping;
  49258. private _adjustRoll;
  49259. /**
  49260. * Gets or sets maximum allowed angle
  49261. */
  49262. get maxAngle(): number;
  49263. set maxAngle(value: number);
  49264. /**
  49265. * Creates a new BoneIKController
  49266. * @param mesh defines the mesh to control
  49267. * @param bone defines the bone to control
  49268. * @param options defines options to set up the controller
  49269. */
  49270. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49271. targetMesh?: AbstractMesh;
  49272. poleTargetMesh?: AbstractMesh;
  49273. poleTargetBone?: Bone;
  49274. poleTargetLocalOffset?: Vector3;
  49275. poleAngle?: number;
  49276. bendAxis?: Vector3;
  49277. maxAngle?: number;
  49278. slerpAmount?: number;
  49279. });
  49280. private _setMaxAngle;
  49281. /**
  49282. * Force the controller to update the bones
  49283. */
  49284. update(): void;
  49285. }
  49286. }
  49287. declare module "babylonjs/Bones/boneLookController" {
  49288. import { Vector3 } from "babylonjs/Maths/math.vector";
  49289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49290. import { Bone } from "babylonjs/Bones/bone";
  49291. import { Space } from "babylonjs/Maths/math.axis";
  49292. /**
  49293. * Class used to make a bone look toward a point in space
  49294. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49295. */
  49296. export class BoneLookController {
  49297. private static _tmpVecs;
  49298. private static _tmpQuat;
  49299. private static _tmpMats;
  49300. /**
  49301. * The target Vector3 that the bone will look at
  49302. */
  49303. target: Vector3;
  49304. /**
  49305. * The mesh that the bone is attached to
  49306. */
  49307. mesh: AbstractMesh;
  49308. /**
  49309. * The bone that will be looking to the target
  49310. */
  49311. bone: Bone;
  49312. /**
  49313. * The up axis of the coordinate system that is used when the bone is rotated
  49314. */
  49315. upAxis: Vector3;
  49316. /**
  49317. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49318. */
  49319. upAxisSpace: Space;
  49320. /**
  49321. * Used to make an adjustment to the yaw of the bone
  49322. */
  49323. adjustYaw: number;
  49324. /**
  49325. * Used to make an adjustment to the pitch of the bone
  49326. */
  49327. adjustPitch: number;
  49328. /**
  49329. * Used to make an adjustment to the roll of the bone
  49330. */
  49331. adjustRoll: number;
  49332. /**
  49333. * 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)
  49334. */
  49335. slerpAmount: number;
  49336. private _minYaw;
  49337. private _maxYaw;
  49338. private _minPitch;
  49339. private _maxPitch;
  49340. private _minYawSin;
  49341. private _minYawCos;
  49342. private _maxYawSin;
  49343. private _maxYawCos;
  49344. private _midYawConstraint;
  49345. private _minPitchTan;
  49346. private _maxPitchTan;
  49347. private _boneQuat;
  49348. private _slerping;
  49349. private _transformYawPitch;
  49350. private _transformYawPitchInv;
  49351. private _firstFrameSkipped;
  49352. private _yawRange;
  49353. private _fowardAxis;
  49354. /**
  49355. * Gets or sets the minimum yaw angle that the bone can look to
  49356. */
  49357. get minYaw(): number;
  49358. set minYaw(value: number);
  49359. /**
  49360. * Gets or sets the maximum yaw angle that the bone can look to
  49361. */
  49362. get maxYaw(): number;
  49363. set maxYaw(value: number);
  49364. /**
  49365. * Gets or sets the minimum pitch angle that the bone can look to
  49366. */
  49367. get minPitch(): number;
  49368. set minPitch(value: number);
  49369. /**
  49370. * Gets or sets the maximum pitch angle that the bone can look to
  49371. */
  49372. get maxPitch(): number;
  49373. set maxPitch(value: number);
  49374. /**
  49375. * Create a BoneLookController
  49376. * @param mesh the mesh that the bone belongs to
  49377. * @param bone the bone that will be looking to the target
  49378. * @param target the target Vector3 to look at
  49379. * @param options optional settings:
  49380. * * maxYaw: the maximum angle the bone will yaw to
  49381. * * minYaw: the minimum angle the bone will yaw to
  49382. * * maxPitch: the maximum angle the bone will pitch to
  49383. * * minPitch: the minimum angle the bone will yaw to
  49384. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49385. * * upAxis: the up axis of the coordinate system
  49386. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49387. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49388. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49389. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49390. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49391. * * adjustRoll: used to make an adjustment to the roll of the bone
  49392. **/
  49393. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49394. maxYaw?: number;
  49395. minYaw?: number;
  49396. maxPitch?: number;
  49397. minPitch?: number;
  49398. slerpAmount?: number;
  49399. upAxis?: Vector3;
  49400. upAxisSpace?: Space;
  49401. yawAxis?: Vector3;
  49402. pitchAxis?: Vector3;
  49403. adjustYaw?: number;
  49404. adjustPitch?: number;
  49405. adjustRoll?: number;
  49406. });
  49407. /**
  49408. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49409. */
  49410. update(): void;
  49411. private _getAngleDiff;
  49412. private _getAngleBetween;
  49413. private _isAngleBetween;
  49414. }
  49415. }
  49416. declare module "babylonjs/Bones/index" {
  49417. export * from "babylonjs/Bones/bone";
  49418. export * from "babylonjs/Bones/boneIKController";
  49419. export * from "babylonjs/Bones/boneLookController";
  49420. export * from "babylonjs/Bones/skeleton";
  49421. }
  49422. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49423. import { Nullable } from "babylonjs/types";
  49424. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49425. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49426. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49427. /**
  49428. * Manage the gamepad inputs to control an arc rotate camera.
  49429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49430. */
  49431. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49432. /**
  49433. * Defines the camera the input is attached to.
  49434. */
  49435. camera: ArcRotateCamera;
  49436. /**
  49437. * Defines the gamepad the input is gathering event from.
  49438. */
  49439. gamepad: Nullable<Gamepad>;
  49440. /**
  49441. * Defines the gamepad rotation sensiblity.
  49442. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49443. */
  49444. gamepadRotationSensibility: number;
  49445. /**
  49446. * Defines the gamepad move sensiblity.
  49447. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49448. */
  49449. gamepadMoveSensibility: number;
  49450. private _yAxisScale;
  49451. /**
  49452. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49453. */
  49454. get invertYAxis(): boolean;
  49455. set invertYAxis(value: boolean);
  49456. private _onGamepadConnectedObserver;
  49457. private _onGamepadDisconnectedObserver;
  49458. /**
  49459. * Attach the input controls to a specific dom element to get the input from.
  49460. */
  49461. attachControl(): void;
  49462. /**
  49463. * Detach the current controls from the specified dom element.
  49464. */
  49465. detachControl(): void;
  49466. /**
  49467. * Update the current camera state depending on the inputs that have been used this frame.
  49468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49469. */
  49470. checkInputs(): void;
  49471. /**
  49472. * Gets the class name of the current intput.
  49473. * @returns the class name
  49474. */
  49475. getClassName(): string;
  49476. /**
  49477. * Get the friendly name associated with the input class.
  49478. * @returns the input friendly name
  49479. */
  49480. getSimpleName(): string;
  49481. }
  49482. }
  49483. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49486. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49487. interface ArcRotateCameraInputsManager {
  49488. /**
  49489. * Add orientation input support to the input manager.
  49490. * @returns the current input manager
  49491. */
  49492. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49493. }
  49494. }
  49495. /**
  49496. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49498. */
  49499. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49500. /**
  49501. * Defines the camera the input is attached to.
  49502. */
  49503. camera: ArcRotateCamera;
  49504. /**
  49505. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49506. */
  49507. alphaCorrection: number;
  49508. /**
  49509. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49510. */
  49511. gammaCorrection: number;
  49512. private _alpha;
  49513. private _gamma;
  49514. private _dirty;
  49515. private _deviceOrientationHandler;
  49516. /**
  49517. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49518. */
  49519. constructor();
  49520. /**
  49521. * Attach the input controls to a specific dom element to get the input from.
  49522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49523. */
  49524. attachControl(noPreventDefault?: boolean): void;
  49525. /** @hidden */
  49526. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49527. /**
  49528. * Update the current camera state depending on the inputs that have been used this frame.
  49529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49530. */
  49531. checkInputs(): void;
  49532. /**
  49533. * Detach the current controls from the specified dom element.
  49534. */
  49535. detachControl(): void;
  49536. /**
  49537. * Gets the class name of the current intput.
  49538. * @returns the class name
  49539. */
  49540. getClassName(): string;
  49541. /**
  49542. * Get the friendly name associated with the input class.
  49543. * @returns the input friendly name
  49544. */
  49545. getSimpleName(): string;
  49546. }
  49547. }
  49548. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49549. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49550. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49551. /**
  49552. * Listen to mouse events to control the camera.
  49553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49554. */
  49555. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49556. /**
  49557. * Defines the camera the input is attached to.
  49558. */
  49559. camera: FlyCamera;
  49560. /**
  49561. * Defines if touch is enabled. (Default is true.)
  49562. */
  49563. touchEnabled: boolean;
  49564. /**
  49565. * Defines the buttons associated with the input to handle camera rotation.
  49566. */
  49567. buttons: number[];
  49568. /**
  49569. * Assign buttons for Yaw control.
  49570. */
  49571. buttonsYaw: number[];
  49572. /**
  49573. * Assign buttons for Pitch control.
  49574. */
  49575. buttonsPitch: number[];
  49576. /**
  49577. * Assign buttons for Roll control.
  49578. */
  49579. buttonsRoll: number[];
  49580. /**
  49581. * Detect if any button is being pressed while mouse is moved.
  49582. * -1 = Mouse locked.
  49583. * 0 = Left button.
  49584. * 1 = Middle Button.
  49585. * 2 = Right Button.
  49586. */
  49587. activeButton: number;
  49588. /**
  49589. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49590. * Higher values reduce its sensitivity.
  49591. */
  49592. angularSensibility: number;
  49593. private _observer;
  49594. private _rollObserver;
  49595. private previousPosition;
  49596. private noPreventDefault;
  49597. private element;
  49598. /**
  49599. * Listen to mouse events to control the camera.
  49600. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49602. */
  49603. constructor(touchEnabled?: boolean);
  49604. /**
  49605. * Attach the mouse control to the HTML DOM element.
  49606. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49607. */
  49608. attachControl(noPreventDefault?: boolean): void;
  49609. /**
  49610. * Detach the current controls from the specified dom element.
  49611. */
  49612. detachControl(): void;
  49613. /**
  49614. * Gets the class name of the current input.
  49615. * @returns the class name.
  49616. */
  49617. getClassName(): string;
  49618. /**
  49619. * Get the friendly name associated with the input class.
  49620. * @returns the input's friendly name.
  49621. */
  49622. getSimpleName(): string;
  49623. private _pointerInput;
  49624. private _onMouseMove;
  49625. /**
  49626. * Rotate camera by mouse offset.
  49627. */
  49628. private rotateCamera;
  49629. }
  49630. }
  49631. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49632. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49633. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49634. /**
  49635. * Default Inputs manager for the FlyCamera.
  49636. * It groups all the default supported inputs for ease of use.
  49637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49638. */
  49639. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49640. /**
  49641. * Instantiates a new FlyCameraInputsManager.
  49642. * @param camera Defines the camera the inputs belong to.
  49643. */
  49644. constructor(camera: FlyCamera);
  49645. /**
  49646. * Add keyboard input support to the input manager.
  49647. * @returns the new FlyCameraKeyboardMoveInput().
  49648. */
  49649. addKeyboard(): FlyCameraInputsManager;
  49650. /**
  49651. * Add mouse input support to the input manager.
  49652. * @param touchEnabled Enable touch screen support.
  49653. * @returns the new FlyCameraMouseInput().
  49654. */
  49655. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49656. }
  49657. }
  49658. declare module "babylonjs/Cameras/flyCamera" {
  49659. import { Scene } from "babylonjs/scene";
  49660. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49662. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49663. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49664. /**
  49665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49666. * such as in a 3D Space Shooter or a Flight Simulator.
  49667. */
  49668. export class FlyCamera extends TargetCamera {
  49669. /**
  49670. * Define the collision ellipsoid of the camera.
  49671. * This is helpful for simulating a camera body, like a player's body.
  49672. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49673. */
  49674. ellipsoid: Vector3;
  49675. /**
  49676. * Define an offset for the position of the ellipsoid around the camera.
  49677. * This can be helpful if the camera is attached away from the player's body center,
  49678. * such as at its head.
  49679. */
  49680. ellipsoidOffset: Vector3;
  49681. /**
  49682. * Enable or disable collisions of the camera with the rest of the scene objects.
  49683. */
  49684. checkCollisions: boolean;
  49685. /**
  49686. * Enable or disable gravity on the camera.
  49687. */
  49688. applyGravity: boolean;
  49689. /**
  49690. * Define the current direction the camera is moving to.
  49691. */
  49692. cameraDirection: Vector3;
  49693. /**
  49694. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49695. * This overrides and empties cameraRotation.
  49696. */
  49697. rotationQuaternion: Quaternion;
  49698. /**
  49699. * Track Roll to maintain the wanted Rolling when looking around.
  49700. */
  49701. _trackRoll: number;
  49702. /**
  49703. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49704. */
  49705. rollCorrect: number;
  49706. /**
  49707. * Mimic a banked turn, Rolling the camera when Yawing.
  49708. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49709. */
  49710. bankedTurn: boolean;
  49711. /**
  49712. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49713. */
  49714. bankedTurnLimit: number;
  49715. /**
  49716. * Value of 0 disables the banked Roll.
  49717. * Value of 1 is equal to the Yaw angle in radians.
  49718. */
  49719. bankedTurnMultiplier: number;
  49720. /**
  49721. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49722. */
  49723. inputs: FlyCameraInputsManager;
  49724. /**
  49725. * Gets the input sensibility for mouse input.
  49726. * Higher values reduce sensitivity.
  49727. */
  49728. get angularSensibility(): number;
  49729. /**
  49730. * Sets the input sensibility for a mouse input.
  49731. * Higher values reduce sensitivity.
  49732. */
  49733. set angularSensibility(value: number);
  49734. /**
  49735. * Get the keys for camera movement forward.
  49736. */
  49737. get keysForward(): number[];
  49738. /**
  49739. * Set the keys for camera movement forward.
  49740. */
  49741. set keysForward(value: number[]);
  49742. /**
  49743. * Get the keys for camera movement backward.
  49744. */
  49745. get keysBackward(): number[];
  49746. set keysBackward(value: number[]);
  49747. /**
  49748. * Get the keys for camera movement up.
  49749. */
  49750. get keysUp(): number[];
  49751. /**
  49752. * Set the keys for camera movement up.
  49753. */
  49754. set keysUp(value: number[]);
  49755. /**
  49756. * Get the keys for camera movement down.
  49757. */
  49758. get keysDown(): number[];
  49759. /**
  49760. * Set the keys for camera movement down.
  49761. */
  49762. set keysDown(value: number[]);
  49763. /**
  49764. * Get the keys for camera movement left.
  49765. */
  49766. get keysLeft(): number[];
  49767. /**
  49768. * Set the keys for camera movement left.
  49769. */
  49770. set keysLeft(value: number[]);
  49771. /**
  49772. * Set the keys for camera movement right.
  49773. */
  49774. get keysRight(): number[];
  49775. /**
  49776. * Set the keys for camera movement right.
  49777. */
  49778. set keysRight(value: number[]);
  49779. /**
  49780. * Event raised when the camera collides with a mesh in the scene.
  49781. */
  49782. onCollide: (collidedMesh: AbstractMesh) => void;
  49783. private _collider;
  49784. private _needMoveForGravity;
  49785. private _oldPosition;
  49786. private _diffPosition;
  49787. private _newPosition;
  49788. /** @hidden */
  49789. _localDirection: Vector3;
  49790. /** @hidden */
  49791. _transformedDirection: Vector3;
  49792. /**
  49793. * Instantiates a FlyCamera.
  49794. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49795. * such as in a 3D Space Shooter or a Flight Simulator.
  49796. * @param name Define the name of the camera in the scene.
  49797. * @param position Define the starting position of the camera in the scene.
  49798. * @param scene Define the scene the camera belongs to.
  49799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49800. */
  49801. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49802. /**
  49803. * Attach the input controls to a specific dom element to get the input from.
  49804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49805. */
  49806. attachControl(noPreventDefault?: boolean): void;
  49807. /**
  49808. * Detach a control from the HTML DOM element.
  49809. * The camera will stop reacting to that input.
  49810. */
  49811. detachControl(): void;
  49812. private _collisionMask;
  49813. /**
  49814. * Get the mask that the camera ignores in collision events.
  49815. */
  49816. get collisionMask(): number;
  49817. /**
  49818. * Set the mask that the camera ignores in collision events.
  49819. */
  49820. set collisionMask(mask: number);
  49821. /** @hidden */
  49822. _collideWithWorld(displacement: Vector3): void;
  49823. /** @hidden */
  49824. private _onCollisionPositionChange;
  49825. /** @hidden */
  49826. _checkInputs(): void;
  49827. /** @hidden */
  49828. _decideIfNeedsToMove(): boolean;
  49829. /** @hidden */
  49830. _updatePosition(): void;
  49831. /**
  49832. * Restore the Roll to its target value at the rate specified.
  49833. * @param rate - Higher means slower restoring.
  49834. * @hidden
  49835. */
  49836. restoreRoll(rate: number): void;
  49837. /**
  49838. * Destroy the camera and release the current resources held by it.
  49839. */
  49840. dispose(): void;
  49841. /**
  49842. * Get the current object class name.
  49843. * @returns the class name.
  49844. */
  49845. getClassName(): string;
  49846. }
  49847. }
  49848. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49849. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49850. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49851. /**
  49852. * Listen to keyboard events to control the camera.
  49853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49854. */
  49855. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49856. /**
  49857. * Defines the camera the input is attached to.
  49858. */
  49859. camera: FlyCamera;
  49860. /**
  49861. * The list of keyboard keys used to control the forward move of the camera.
  49862. */
  49863. keysForward: number[];
  49864. /**
  49865. * The list of keyboard keys used to control the backward move of the camera.
  49866. */
  49867. keysBackward: number[];
  49868. /**
  49869. * The list of keyboard keys used to control the forward move of the camera.
  49870. */
  49871. keysUp: number[];
  49872. /**
  49873. * The list of keyboard keys used to control the backward move of the camera.
  49874. */
  49875. keysDown: number[];
  49876. /**
  49877. * The list of keyboard keys used to control the right strafe move of the camera.
  49878. */
  49879. keysRight: number[];
  49880. /**
  49881. * The list of keyboard keys used to control the left strafe move of the camera.
  49882. */
  49883. keysLeft: number[];
  49884. private _keys;
  49885. private _onCanvasBlurObserver;
  49886. private _onKeyboardObserver;
  49887. private _engine;
  49888. private _scene;
  49889. /**
  49890. * Attach the input controls to a specific dom element to get the input from.
  49891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49892. */
  49893. attachControl(noPreventDefault?: boolean): void;
  49894. /**
  49895. * Detach the current controls from the specified dom element.
  49896. */
  49897. detachControl(): void;
  49898. /**
  49899. * Gets the class name of the current intput.
  49900. * @returns the class name
  49901. */
  49902. getClassName(): string;
  49903. /** @hidden */
  49904. _onLostFocus(e: FocusEvent): void;
  49905. /**
  49906. * Get the friendly name associated with the input class.
  49907. * @returns the input friendly name
  49908. */
  49909. getSimpleName(): string;
  49910. /**
  49911. * Update the current camera state depending on the inputs that have been used this frame.
  49912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49913. */
  49914. checkInputs(): void;
  49915. }
  49916. }
  49917. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49918. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49919. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49920. /**
  49921. * Manage the mouse wheel inputs to control a follow camera.
  49922. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49923. */
  49924. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49925. /**
  49926. * Defines the camera the input is attached to.
  49927. */
  49928. camera: FollowCamera;
  49929. /**
  49930. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49931. */
  49932. axisControlRadius: boolean;
  49933. /**
  49934. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49935. */
  49936. axisControlHeight: boolean;
  49937. /**
  49938. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49939. */
  49940. axisControlRotation: boolean;
  49941. /**
  49942. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49943. * relation to mouseWheel events.
  49944. */
  49945. wheelPrecision: number;
  49946. /**
  49947. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49948. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49949. */
  49950. wheelDeltaPercentage: number;
  49951. private _wheel;
  49952. private _observer;
  49953. /**
  49954. * Attach the input controls to a specific dom element to get the input from.
  49955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49956. */
  49957. attachControl(noPreventDefault?: boolean): void;
  49958. /**
  49959. * Detach the current controls from the specified dom element.
  49960. */
  49961. detachControl(): void;
  49962. /**
  49963. * Gets the class name of the current intput.
  49964. * @returns the class name
  49965. */
  49966. getClassName(): string;
  49967. /**
  49968. * Get the friendly name associated with the input class.
  49969. * @returns the input friendly name
  49970. */
  49971. getSimpleName(): string;
  49972. }
  49973. }
  49974. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49975. import { Nullable } from "babylonjs/types";
  49976. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49977. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49978. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49979. /**
  49980. * Manage the pointers inputs to control an follow camera.
  49981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49982. */
  49983. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49984. /**
  49985. * Defines the camera the input is attached to.
  49986. */
  49987. camera: FollowCamera;
  49988. /**
  49989. * Gets the class name of the current input.
  49990. * @returns the class name
  49991. */
  49992. getClassName(): string;
  49993. /**
  49994. * Defines the pointer angular sensibility along the X axis or how fast is
  49995. * the camera rotating.
  49996. * A negative number will reverse the axis direction.
  49997. */
  49998. angularSensibilityX: number;
  49999. /**
  50000. * Defines the pointer angular sensibility along the Y axis or how fast is
  50001. * the camera rotating.
  50002. * A negative number will reverse the axis direction.
  50003. */
  50004. angularSensibilityY: number;
  50005. /**
  50006. * Defines the pointer pinch precision or how fast is the camera zooming.
  50007. * A negative number will reverse the axis direction.
  50008. */
  50009. pinchPrecision: number;
  50010. /**
  50011. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50012. * from 0.
  50013. * It defines the percentage of current camera.radius to use as delta when
  50014. * pinch zoom is used.
  50015. */
  50016. pinchDeltaPercentage: number;
  50017. /**
  50018. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50019. */
  50020. axisXControlRadius: boolean;
  50021. /**
  50022. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50023. */
  50024. axisXControlHeight: boolean;
  50025. /**
  50026. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50027. */
  50028. axisXControlRotation: boolean;
  50029. /**
  50030. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50031. */
  50032. axisYControlRadius: boolean;
  50033. /**
  50034. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50035. */
  50036. axisYControlHeight: boolean;
  50037. /**
  50038. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50039. */
  50040. axisYControlRotation: boolean;
  50041. /**
  50042. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50043. */
  50044. axisPinchControlRadius: boolean;
  50045. /**
  50046. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50047. */
  50048. axisPinchControlHeight: boolean;
  50049. /**
  50050. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50051. */
  50052. axisPinchControlRotation: boolean;
  50053. /**
  50054. * Log error messages if basic misconfiguration has occurred.
  50055. */
  50056. warningEnable: boolean;
  50057. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50059. private _warningCounter;
  50060. private _warning;
  50061. }
  50062. }
  50063. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50064. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50065. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50066. /**
  50067. * Default Inputs manager for the FollowCamera.
  50068. * It groups all the default supported inputs for ease of use.
  50069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50070. */
  50071. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50072. /**
  50073. * Instantiates a new FollowCameraInputsManager.
  50074. * @param camera Defines the camera the inputs belong to
  50075. */
  50076. constructor(camera: FollowCamera);
  50077. /**
  50078. * Add keyboard input support to the input manager.
  50079. * @returns the current input manager
  50080. */
  50081. addKeyboard(): FollowCameraInputsManager;
  50082. /**
  50083. * Add mouse wheel input support to the input manager.
  50084. * @returns the current input manager
  50085. */
  50086. addMouseWheel(): FollowCameraInputsManager;
  50087. /**
  50088. * Add pointers input support to the input manager.
  50089. * @returns the current input manager
  50090. */
  50091. addPointers(): FollowCameraInputsManager;
  50092. /**
  50093. * Add orientation input support to the input manager.
  50094. * @returns the current input manager
  50095. */
  50096. addVRDeviceOrientation(): FollowCameraInputsManager;
  50097. }
  50098. }
  50099. declare module "babylonjs/Cameras/followCamera" {
  50100. import { Nullable } from "babylonjs/types";
  50101. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50102. import { Scene } from "babylonjs/scene";
  50103. import { Vector3 } from "babylonjs/Maths/math.vector";
  50104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50105. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50106. /**
  50107. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50108. * an arc rotate version arcFollowCamera are available.
  50109. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50110. */
  50111. export class FollowCamera extends TargetCamera {
  50112. /**
  50113. * Distance the follow camera should follow an object at
  50114. */
  50115. radius: number;
  50116. /**
  50117. * Minimum allowed distance of the camera to the axis of rotation
  50118. * (The camera can not get closer).
  50119. * This can help limiting how the Camera is able to move in the scene.
  50120. */
  50121. lowerRadiusLimit: Nullable<number>;
  50122. /**
  50123. * Maximum allowed distance of the camera to the axis of rotation
  50124. * (The camera can not get further).
  50125. * This can help limiting how the Camera is able to move in the scene.
  50126. */
  50127. upperRadiusLimit: Nullable<number>;
  50128. /**
  50129. * Define a rotation offset between the camera and the object it follows
  50130. */
  50131. rotationOffset: number;
  50132. /**
  50133. * Minimum allowed angle to camera position relative to target object.
  50134. * This can help limiting how the Camera is able to move in the scene.
  50135. */
  50136. lowerRotationOffsetLimit: Nullable<number>;
  50137. /**
  50138. * Maximum allowed angle to camera position relative to target object.
  50139. * This can help limiting how the Camera is able to move in the scene.
  50140. */
  50141. upperRotationOffsetLimit: Nullable<number>;
  50142. /**
  50143. * Define a height offset between the camera and the object it follows.
  50144. * It can help following an object from the top (like a car chaing a plane)
  50145. */
  50146. heightOffset: number;
  50147. /**
  50148. * Minimum allowed height of camera position relative to target object.
  50149. * This can help limiting how the Camera is able to move in the scene.
  50150. */
  50151. lowerHeightOffsetLimit: Nullable<number>;
  50152. /**
  50153. * Maximum allowed height of camera position relative to target object.
  50154. * This can help limiting how the Camera is able to move in the scene.
  50155. */
  50156. upperHeightOffsetLimit: Nullable<number>;
  50157. /**
  50158. * Define how fast the camera can accelerate to follow it s target.
  50159. */
  50160. cameraAcceleration: number;
  50161. /**
  50162. * Define the speed limit of the camera following an object.
  50163. */
  50164. maxCameraSpeed: number;
  50165. /**
  50166. * Define the target of the camera.
  50167. */
  50168. lockedTarget: Nullable<AbstractMesh>;
  50169. /**
  50170. * Defines the input associated with the camera.
  50171. */
  50172. inputs: FollowCameraInputsManager;
  50173. /**
  50174. * Instantiates the follow camera.
  50175. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50176. * @param name Define the name of the camera in the scene
  50177. * @param position Define the position of the camera
  50178. * @param scene Define the scene the camera belong to
  50179. * @param lockedTarget Define the target of the camera
  50180. */
  50181. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50182. private _follow;
  50183. /**
  50184. * Attach the input controls to a specific dom element to get the input from.
  50185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50186. */
  50187. attachControl(noPreventDefault?: boolean): void;
  50188. /**
  50189. * Detach the current controls from the specified dom element.
  50190. */
  50191. detachControl(): void;
  50192. /** @hidden */
  50193. _checkInputs(): void;
  50194. private _checkLimits;
  50195. /**
  50196. * Gets the camera class name.
  50197. * @returns the class name
  50198. */
  50199. getClassName(): string;
  50200. }
  50201. /**
  50202. * Arc Rotate version of the follow camera.
  50203. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50204. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50205. */
  50206. export class ArcFollowCamera extends TargetCamera {
  50207. /** The longitudinal angle of the camera */
  50208. alpha: number;
  50209. /** The latitudinal angle of the camera */
  50210. beta: number;
  50211. /** The radius of the camera from its target */
  50212. radius: number;
  50213. private _cartesianCoordinates;
  50214. /** Define the camera target (the mesh it should follow) */
  50215. private _meshTarget;
  50216. /**
  50217. * Instantiates a new ArcFollowCamera
  50218. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50219. * @param name Define the name of the camera
  50220. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50221. * @param beta Define the rotation angle of the camera around the elevation axis
  50222. * @param radius Define the radius of the camera from its target point
  50223. * @param target Define the target of the camera
  50224. * @param scene Define the scene the camera belongs to
  50225. */
  50226. constructor(name: string,
  50227. /** The longitudinal angle of the camera */
  50228. alpha: number,
  50229. /** The latitudinal angle of the camera */
  50230. beta: number,
  50231. /** The radius of the camera from its target */
  50232. radius: number,
  50233. /** Define the camera target (the mesh it should follow) */
  50234. target: Nullable<AbstractMesh>, scene: Scene);
  50235. private _follow;
  50236. /** @hidden */
  50237. _checkInputs(): void;
  50238. /**
  50239. * Returns the class name of the object.
  50240. * It is mostly used internally for serialization purposes.
  50241. */
  50242. getClassName(): string;
  50243. }
  50244. }
  50245. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50247. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50248. /**
  50249. * Manage the keyboard inputs to control the movement of a follow camera.
  50250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50251. */
  50252. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50253. /**
  50254. * Defines the camera the input is attached to.
  50255. */
  50256. camera: FollowCamera;
  50257. /**
  50258. * Defines the list of key codes associated with the up action (increase heightOffset)
  50259. */
  50260. keysHeightOffsetIncr: number[];
  50261. /**
  50262. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50263. */
  50264. keysHeightOffsetDecr: number[];
  50265. /**
  50266. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50267. */
  50268. keysHeightOffsetModifierAlt: boolean;
  50269. /**
  50270. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50271. */
  50272. keysHeightOffsetModifierCtrl: boolean;
  50273. /**
  50274. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50275. */
  50276. keysHeightOffsetModifierShift: boolean;
  50277. /**
  50278. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50279. */
  50280. keysRotationOffsetIncr: number[];
  50281. /**
  50282. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50283. */
  50284. keysRotationOffsetDecr: number[];
  50285. /**
  50286. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50287. */
  50288. keysRotationOffsetModifierAlt: boolean;
  50289. /**
  50290. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50291. */
  50292. keysRotationOffsetModifierCtrl: boolean;
  50293. /**
  50294. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50295. */
  50296. keysRotationOffsetModifierShift: boolean;
  50297. /**
  50298. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50299. */
  50300. keysRadiusIncr: number[];
  50301. /**
  50302. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50303. */
  50304. keysRadiusDecr: number[];
  50305. /**
  50306. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50307. */
  50308. keysRadiusModifierAlt: boolean;
  50309. /**
  50310. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50311. */
  50312. keysRadiusModifierCtrl: boolean;
  50313. /**
  50314. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50315. */
  50316. keysRadiusModifierShift: boolean;
  50317. /**
  50318. * Defines the rate of change of heightOffset.
  50319. */
  50320. heightSensibility: number;
  50321. /**
  50322. * Defines the rate of change of rotationOffset.
  50323. */
  50324. rotationSensibility: number;
  50325. /**
  50326. * Defines the rate of change of radius.
  50327. */
  50328. radiusSensibility: number;
  50329. private _keys;
  50330. private _ctrlPressed;
  50331. private _altPressed;
  50332. private _shiftPressed;
  50333. private _onCanvasBlurObserver;
  50334. private _onKeyboardObserver;
  50335. private _engine;
  50336. private _scene;
  50337. /**
  50338. * Attach the input controls to a specific dom element to get the input from.
  50339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50340. */
  50341. attachControl(noPreventDefault?: boolean): void;
  50342. /**
  50343. * Detach the current controls from the specified dom element.
  50344. */
  50345. detachControl(): void;
  50346. /**
  50347. * Update the current camera state depending on the inputs that have been used this frame.
  50348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50349. */
  50350. checkInputs(): void;
  50351. /**
  50352. * Gets the class name of the current input.
  50353. * @returns the class name
  50354. */
  50355. getClassName(): string;
  50356. /**
  50357. * Get the friendly name associated with the input class.
  50358. * @returns the input friendly name
  50359. */
  50360. getSimpleName(): string;
  50361. /**
  50362. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50363. * allow modification of the heightOffset value.
  50364. */
  50365. private _modifierHeightOffset;
  50366. /**
  50367. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50368. * allow modification of the rotationOffset value.
  50369. */
  50370. private _modifierRotationOffset;
  50371. /**
  50372. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50373. * allow modification of the radius value.
  50374. */
  50375. private _modifierRadius;
  50376. }
  50377. }
  50378. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50379. import { Nullable } from "babylonjs/types";
  50380. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50381. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50382. import { Observable } from "babylonjs/Misc/observable";
  50383. module "babylonjs/Cameras/freeCameraInputsManager" {
  50384. interface FreeCameraInputsManager {
  50385. /**
  50386. * @hidden
  50387. */
  50388. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50389. /**
  50390. * Add orientation input support to the input manager.
  50391. * @returns the current input manager
  50392. */
  50393. addDeviceOrientation(): FreeCameraInputsManager;
  50394. }
  50395. }
  50396. /**
  50397. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50398. * Screen rotation is taken into account.
  50399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50400. */
  50401. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50402. private _camera;
  50403. private _screenOrientationAngle;
  50404. private _constantTranform;
  50405. private _screenQuaternion;
  50406. private _alpha;
  50407. private _beta;
  50408. private _gamma;
  50409. /**
  50410. * Can be used to detect if a device orientation sensor is available on a device
  50411. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50412. * @returns a promise that will resolve on orientation change
  50413. */
  50414. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50415. /**
  50416. * @hidden
  50417. */
  50418. _onDeviceOrientationChangedObservable: Observable<void>;
  50419. /**
  50420. * Instantiates a new input
  50421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50422. */
  50423. constructor();
  50424. /**
  50425. * Define the camera controlled by the input.
  50426. */
  50427. get camera(): FreeCamera;
  50428. set camera(camera: FreeCamera);
  50429. /**
  50430. * Attach the input controls to a specific dom element to get the input from.
  50431. */
  50432. attachControl(): void;
  50433. private _orientationChanged;
  50434. private _deviceOrientation;
  50435. /**
  50436. * Detach the current controls from the specified dom element.
  50437. */
  50438. detachControl(): void;
  50439. /**
  50440. * Update the current camera state depending on the inputs that have been used this frame.
  50441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50442. */
  50443. checkInputs(): void;
  50444. /**
  50445. * Gets the class name of the current intput.
  50446. * @returns the class name
  50447. */
  50448. getClassName(): string;
  50449. /**
  50450. * Get the friendly name associated with the input class.
  50451. * @returns the input friendly name
  50452. */
  50453. getSimpleName(): string;
  50454. }
  50455. }
  50456. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50457. import { Nullable } from "babylonjs/types";
  50458. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50459. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50460. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50461. /**
  50462. * Manage the gamepad inputs to control a free camera.
  50463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50464. */
  50465. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50466. /**
  50467. * Define the camera the input is attached to.
  50468. */
  50469. camera: FreeCamera;
  50470. /**
  50471. * Define the Gamepad controlling the input
  50472. */
  50473. gamepad: Nullable<Gamepad>;
  50474. /**
  50475. * Defines the gamepad rotation sensiblity.
  50476. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50477. */
  50478. gamepadAngularSensibility: number;
  50479. /**
  50480. * Defines the gamepad move sensiblity.
  50481. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50482. */
  50483. gamepadMoveSensibility: number;
  50484. private _yAxisScale;
  50485. /**
  50486. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50487. */
  50488. get invertYAxis(): boolean;
  50489. set invertYAxis(value: boolean);
  50490. private _onGamepadConnectedObserver;
  50491. private _onGamepadDisconnectedObserver;
  50492. private _cameraTransform;
  50493. private _deltaTransform;
  50494. private _vector3;
  50495. private _vector2;
  50496. /**
  50497. * Attach the input controls to a specific dom element to get the input from.
  50498. */
  50499. attachControl(): void;
  50500. /**
  50501. * Detach the current controls from the specified dom element.
  50502. */
  50503. detachControl(): void;
  50504. /**
  50505. * Update the current camera state depending on the inputs that have been used this frame.
  50506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50507. */
  50508. checkInputs(): void;
  50509. /**
  50510. * Gets the class name of the current intput.
  50511. * @returns the class name
  50512. */
  50513. getClassName(): string;
  50514. /**
  50515. * Get the friendly name associated with the input class.
  50516. * @returns the input friendly name
  50517. */
  50518. getSimpleName(): string;
  50519. }
  50520. }
  50521. declare module "babylonjs/Misc/virtualJoystick" {
  50522. import { Nullable } from "babylonjs/types";
  50523. import { Vector3 } from "babylonjs/Maths/math.vector";
  50524. /**
  50525. * Defines the potential axis of a Joystick
  50526. */
  50527. export enum JoystickAxis {
  50528. /** X axis */
  50529. X = 0,
  50530. /** Y axis */
  50531. Y = 1,
  50532. /** Z axis */
  50533. Z = 2
  50534. }
  50535. /**
  50536. * Represents the different customization options available
  50537. * for VirtualJoystick
  50538. */
  50539. interface VirtualJoystickCustomizations {
  50540. /**
  50541. * Size of the joystick's puck
  50542. */
  50543. puckSize: number;
  50544. /**
  50545. * Size of the joystick's container
  50546. */
  50547. containerSize: number;
  50548. /**
  50549. * Color of the joystick && puck
  50550. */
  50551. color: string;
  50552. /**
  50553. * Image URL for the joystick's puck
  50554. */
  50555. puckImage?: string;
  50556. /**
  50557. * Image URL for the joystick's container
  50558. */
  50559. containerImage?: string;
  50560. /**
  50561. * Defines the unmoving position of the joystick container
  50562. */
  50563. position?: {
  50564. x: number;
  50565. y: number;
  50566. };
  50567. /**
  50568. * Defines whether or not the joystick container is always visible
  50569. */
  50570. alwaysVisible: boolean;
  50571. /**
  50572. * Defines whether or not to limit the movement of the puck to the joystick's container
  50573. */
  50574. limitToContainer: boolean;
  50575. }
  50576. /**
  50577. * Class used to define virtual joystick (used in touch mode)
  50578. */
  50579. export class VirtualJoystick {
  50580. /**
  50581. * Gets or sets a boolean indicating that left and right values must be inverted
  50582. */
  50583. reverseLeftRight: boolean;
  50584. /**
  50585. * Gets or sets a boolean indicating that up and down values must be inverted
  50586. */
  50587. reverseUpDown: boolean;
  50588. /**
  50589. * Gets the offset value for the position (ie. the change of the position value)
  50590. */
  50591. deltaPosition: Vector3;
  50592. /**
  50593. * Gets a boolean indicating if the virtual joystick was pressed
  50594. */
  50595. pressed: boolean;
  50596. /**
  50597. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50598. */
  50599. static Canvas: Nullable<HTMLCanvasElement>;
  50600. /**
  50601. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50602. */
  50603. limitToContainer: boolean;
  50604. private static _globalJoystickIndex;
  50605. private static _alwaysVisibleSticks;
  50606. private static vjCanvasContext;
  50607. private static vjCanvasWidth;
  50608. private static vjCanvasHeight;
  50609. private static halfWidth;
  50610. private static _GetDefaultOptions;
  50611. private _action;
  50612. private _axisTargetedByLeftAndRight;
  50613. private _axisTargetedByUpAndDown;
  50614. private _joystickSensibility;
  50615. private _inversedSensibility;
  50616. private _joystickPointerID;
  50617. private _joystickColor;
  50618. private _joystickPointerPos;
  50619. private _joystickPreviousPointerPos;
  50620. private _joystickPointerStartPos;
  50621. private _deltaJoystickVector;
  50622. private _leftJoystick;
  50623. private _touches;
  50624. private _joystickPosition;
  50625. private _alwaysVisible;
  50626. private _puckImage;
  50627. private _containerImage;
  50628. private _joystickPuckSize;
  50629. private _joystickContainerSize;
  50630. private _clearPuckSize;
  50631. private _clearContainerSize;
  50632. private _clearPuckSizeOffset;
  50633. private _clearContainerSizeOffset;
  50634. private _onPointerDownHandlerRef;
  50635. private _onPointerMoveHandlerRef;
  50636. private _onPointerUpHandlerRef;
  50637. private _onResize;
  50638. /**
  50639. * Creates a new virtual joystick
  50640. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50641. * @param customizations Defines the options we want to customize the VirtualJoystick
  50642. */
  50643. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50644. /**
  50645. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50646. * @param newJoystickSensibility defines the new sensibility
  50647. */
  50648. setJoystickSensibility(newJoystickSensibility: number): void;
  50649. private _onPointerDown;
  50650. private _onPointerMove;
  50651. private _onPointerUp;
  50652. /**
  50653. * Change the color of the virtual joystick
  50654. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50655. */
  50656. setJoystickColor(newColor: string): void;
  50657. /**
  50658. * Size of the joystick's container
  50659. */
  50660. set containerSize(newSize: number);
  50661. get containerSize(): number;
  50662. /**
  50663. * Size of the joystick's puck
  50664. */
  50665. set puckSize(newSize: number);
  50666. get puckSize(): number;
  50667. /**
  50668. * Clears the set position of the joystick
  50669. */
  50670. clearPosition(): void;
  50671. /**
  50672. * Defines whether or not the joystick container is always visible
  50673. */
  50674. set alwaysVisible(value: boolean);
  50675. get alwaysVisible(): boolean;
  50676. /**
  50677. * Sets the constant position of the Joystick container
  50678. * @param x X axis coordinate
  50679. * @param y Y axis coordinate
  50680. */
  50681. setPosition(x: number, y: number): void;
  50682. /**
  50683. * Defines a callback to call when the joystick is touched
  50684. * @param action defines the callback
  50685. */
  50686. setActionOnTouch(action: () => any): void;
  50687. /**
  50688. * Defines which axis you'd like to control for left & right
  50689. * @param axis defines the axis to use
  50690. */
  50691. setAxisForLeftRight(axis: JoystickAxis): void;
  50692. /**
  50693. * Defines which axis you'd like to control for up & down
  50694. * @param axis defines the axis to use
  50695. */
  50696. setAxisForUpDown(axis: JoystickAxis): void;
  50697. /**
  50698. * Clears the canvas from the previous puck / container draw
  50699. */
  50700. private _clearPreviousDraw;
  50701. /**
  50702. * Loads `urlPath` to be used for the container's image
  50703. * @param urlPath defines the urlPath of an image to use
  50704. */
  50705. setContainerImage(urlPath: string): void;
  50706. /**
  50707. * Loads `urlPath` to be used for the puck's image
  50708. * @param urlPath defines the urlPath of an image to use
  50709. */
  50710. setPuckImage(urlPath: string): void;
  50711. /**
  50712. * Draws the Virtual Joystick's container
  50713. */
  50714. private _drawContainer;
  50715. /**
  50716. * Draws the Virtual Joystick's puck
  50717. */
  50718. private _drawPuck;
  50719. private _drawVirtualJoystick;
  50720. /**
  50721. * Release internal HTML canvas
  50722. */
  50723. releaseCanvas(): void;
  50724. }
  50725. }
  50726. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50727. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50730. module "babylonjs/Cameras/freeCameraInputsManager" {
  50731. interface FreeCameraInputsManager {
  50732. /**
  50733. * Add virtual joystick input support to the input manager.
  50734. * @returns the current input manager
  50735. */
  50736. addVirtualJoystick(): FreeCameraInputsManager;
  50737. }
  50738. }
  50739. /**
  50740. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50742. */
  50743. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50744. /**
  50745. * Defines the camera the input is attached to.
  50746. */
  50747. camera: FreeCamera;
  50748. private _leftjoystick;
  50749. private _rightjoystick;
  50750. /**
  50751. * Gets the left stick of the virtual joystick.
  50752. * @returns The virtual Joystick
  50753. */
  50754. getLeftJoystick(): VirtualJoystick;
  50755. /**
  50756. * Gets the right stick of the virtual joystick.
  50757. * @returns The virtual Joystick
  50758. */
  50759. getRightJoystick(): VirtualJoystick;
  50760. /**
  50761. * Update the current camera state depending on the inputs that have been used this frame.
  50762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50763. */
  50764. checkInputs(): void;
  50765. /**
  50766. * Attach the input controls to a specific dom element to get the input from.
  50767. */
  50768. attachControl(): void;
  50769. /**
  50770. * Detach the current controls from the specified dom element.
  50771. */
  50772. detachControl(): void;
  50773. /**
  50774. * Gets the class name of the current intput.
  50775. * @returns the class name
  50776. */
  50777. getClassName(): string;
  50778. /**
  50779. * Get the friendly name associated with the input class.
  50780. * @returns the input friendly name
  50781. */
  50782. getSimpleName(): string;
  50783. }
  50784. }
  50785. declare module "babylonjs/Cameras/Inputs/index" {
  50786. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50787. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50788. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50789. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50790. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50791. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50792. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50793. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50794. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50795. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50796. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50797. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50798. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50799. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50800. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50801. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50802. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50803. }
  50804. declare module "babylonjs/Cameras/touchCamera" {
  50805. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50806. import { Scene } from "babylonjs/scene";
  50807. import { Vector3 } from "babylonjs/Maths/math.vector";
  50808. /**
  50809. * This represents a FPS type of camera controlled by touch.
  50810. * This is like a universal camera minus the Gamepad controls.
  50811. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50812. */
  50813. export class TouchCamera extends FreeCamera {
  50814. /**
  50815. * Defines the touch sensibility for rotation.
  50816. * The higher the faster.
  50817. */
  50818. get touchAngularSensibility(): number;
  50819. set touchAngularSensibility(value: number);
  50820. /**
  50821. * Defines the touch sensibility for move.
  50822. * The higher the faster.
  50823. */
  50824. get touchMoveSensibility(): number;
  50825. set touchMoveSensibility(value: number);
  50826. /**
  50827. * Instantiates a new touch camera.
  50828. * This represents a FPS type of camera controlled by touch.
  50829. * This is like a universal camera minus the Gamepad controls.
  50830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50831. * @param name Define the name of the camera in the scene
  50832. * @param position Define the start position of the camera in the scene
  50833. * @param scene Define the scene the camera belongs to
  50834. */
  50835. constructor(name: string, position: Vector3, scene: Scene);
  50836. /**
  50837. * Gets the current object class name.
  50838. * @return the class name
  50839. */
  50840. getClassName(): string;
  50841. /** @hidden */
  50842. _setupInputs(): void;
  50843. }
  50844. }
  50845. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50846. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50847. import { Scene } from "babylonjs/scene";
  50848. import { Vector3 } from "babylonjs/Maths/math.vector";
  50849. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50850. import { Axis } from "babylonjs/Maths/math.axis";
  50851. /**
  50852. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50853. * being tilted forward or back and left or right.
  50854. */
  50855. export class DeviceOrientationCamera extends FreeCamera {
  50856. private _initialQuaternion;
  50857. private _quaternionCache;
  50858. private _tmpDragQuaternion;
  50859. private _disablePointerInputWhenUsingDeviceOrientation;
  50860. /**
  50861. * Creates a new device orientation camera
  50862. * @param name The name of the camera
  50863. * @param position The start position camera
  50864. * @param scene The scene the camera belongs to
  50865. */
  50866. constructor(name: string, position: Vector3, scene: Scene);
  50867. /**
  50868. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50869. */
  50870. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50871. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50872. private _dragFactor;
  50873. /**
  50874. * Enabled turning on the y axis when the orientation sensor is active
  50875. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50876. */
  50877. enableHorizontalDragging(dragFactor?: number): void;
  50878. /**
  50879. * Gets the current instance class name ("DeviceOrientationCamera").
  50880. * This helps avoiding instanceof at run time.
  50881. * @returns the class name
  50882. */
  50883. getClassName(): string;
  50884. /**
  50885. * @hidden
  50886. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50887. */
  50888. _checkInputs(): void;
  50889. /**
  50890. * Reset the camera to its default orientation on the specified axis only.
  50891. * @param axis The axis to reset
  50892. */
  50893. resetToCurrentRotation(axis?: Axis): void;
  50894. }
  50895. }
  50896. declare module "babylonjs/Gamepads/xboxGamepad" {
  50897. import { Observable } from "babylonjs/Misc/observable";
  50898. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50899. /**
  50900. * Defines supported buttons for XBox360 compatible gamepads
  50901. */
  50902. export enum Xbox360Button {
  50903. /** A */
  50904. A = 0,
  50905. /** B */
  50906. B = 1,
  50907. /** X */
  50908. X = 2,
  50909. /** Y */
  50910. Y = 3,
  50911. /** Left button */
  50912. LB = 4,
  50913. /** Right button */
  50914. RB = 5,
  50915. /** Back */
  50916. Back = 8,
  50917. /** Start */
  50918. Start = 9,
  50919. /** Left stick */
  50920. LeftStick = 10,
  50921. /** Right stick */
  50922. RightStick = 11
  50923. }
  50924. /** Defines values for XBox360 DPad */
  50925. export enum Xbox360Dpad {
  50926. /** Up */
  50927. Up = 12,
  50928. /** Down */
  50929. Down = 13,
  50930. /** Left */
  50931. Left = 14,
  50932. /** Right */
  50933. Right = 15
  50934. }
  50935. /**
  50936. * Defines a XBox360 gamepad
  50937. */
  50938. export class Xbox360Pad extends Gamepad {
  50939. private _leftTrigger;
  50940. private _rightTrigger;
  50941. private _onlefttriggerchanged;
  50942. private _onrighttriggerchanged;
  50943. private _onbuttondown;
  50944. private _onbuttonup;
  50945. private _ondpaddown;
  50946. private _ondpadup;
  50947. /** Observable raised when a button is pressed */
  50948. onButtonDownObservable: Observable<Xbox360Button>;
  50949. /** Observable raised when a button is released */
  50950. onButtonUpObservable: Observable<Xbox360Button>;
  50951. /** Observable raised when a pad is pressed */
  50952. onPadDownObservable: Observable<Xbox360Dpad>;
  50953. /** Observable raised when a pad is released */
  50954. onPadUpObservable: Observable<Xbox360Dpad>;
  50955. private _buttonA;
  50956. private _buttonB;
  50957. private _buttonX;
  50958. private _buttonY;
  50959. private _buttonBack;
  50960. private _buttonStart;
  50961. private _buttonLB;
  50962. private _buttonRB;
  50963. private _buttonLeftStick;
  50964. private _buttonRightStick;
  50965. private _dPadUp;
  50966. private _dPadDown;
  50967. private _dPadLeft;
  50968. private _dPadRight;
  50969. private _isXboxOnePad;
  50970. /**
  50971. * Creates a new XBox360 gamepad object
  50972. * @param id defines the id of this gamepad
  50973. * @param index defines its index
  50974. * @param gamepad defines the internal HTML gamepad object
  50975. * @param xboxOne defines if it is a XBox One gamepad
  50976. */
  50977. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50978. /**
  50979. * Defines the callback to call when left trigger is pressed
  50980. * @param callback defines the callback to use
  50981. */
  50982. onlefttriggerchanged(callback: (value: number) => void): void;
  50983. /**
  50984. * Defines the callback to call when right trigger is pressed
  50985. * @param callback defines the callback to use
  50986. */
  50987. onrighttriggerchanged(callback: (value: number) => void): void;
  50988. /**
  50989. * Gets the left trigger value
  50990. */
  50991. get leftTrigger(): number;
  50992. /**
  50993. * Sets the left trigger value
  50994. */
  50995. set leftTrigger(newValue: number);
  50996. /**
  50997. * Gets the right trigger value
  50998. */
  50999. get rightTrigger(): number;
  51000. /**
  51001. * Sets the right trigger value
  51002. */
  51003. set rightTrigger(newValue: number);
  51004. /**
  51005. * Defines the callback to call when a button is pressed
  51006. * @param callback defines the callback to use
  51007. */
  51008. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51009. /**
  51010. * Defines the callback to call when a button is released
  51011. * @param callback defines the callback to use
  51012. */
  51013. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51014. /**
  51015. * Defines the callback to call when a pad is pressed
  51016. * @param callback defines the callback to use
  51017. */
  51018. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51019. /**
  51020. * Defines the callback to call when a pad is released
  51021. * @param callback defines the callback to use
  51022. */
  51023. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51024. private _setButtonValue;
  51025. private _setDPadValue;
  51026. /**
  51027. * Gets the value of the `A` button
  51028. */
  51029. get buttonA(): number;
  51030. /**
  51031. * Sets the value of the `A` button
  51032. */
  51033. set buttonA(value: number);
  51034. /**
  51035. * Gets the value of the `B` button
  51036. */
  51037. get buttonB(): number;
  51038. /**
  51039. * Sets the value of the `B` button
  51040. */
  51041. set buttonB(value: number);
  51042. /**
  51043. * Gets the value of the `X` button
  51044. */
  51045. get buttonX(): number;
  51046. /**
  51047. * Sets the value of the `X` button
  51048. */
  51049. set buttonX(value: number);
  51050. /**
  51051. * Gets the value of the `Y` button
  51052. */
  51053. get buttonY(): number;
  51054. /**
  51055. * Sets the value of the `Y` button
  51056. */
  51057. set buttonY(value: number);
  51058. /**
  51059. * Gets the value of the `Start` button
  51060. */
  51061. get buttonStart(): number;
  51062. /**
  51063. * Sets the value of the `Start` button
  51064. */
  51065. set buttonStart(value: number);
  51066. /**
  51067. * Gets the value of the `Back` button
  51068. */
  51069. get buttonBack(): number;
  51070. /**
  51071. * Sets the value of the `Back` button
  51072. */
  51073. set buttonBack(value: number);
  51074. /**
  51075. * Gets the value of the `Left` button
  51076. */
  51077. get buttonLB(): number;
  51078. /**
  51079. * Sets the value of the `Left` button
  51080. */
  51081. set buttonLB(value: number);
  51082. /**
  51083. * Gets the value of the `Right` button
  51084. */
  51085. get buttonRB(): number;
  51086. /**
  51087. * Sets the value of the `Right` button
  51088. */
  51089. set buttonRB(value: number);
  51090. /**
  51091. * Gets the value of the Left joystick
  51092. */
  51093. get buttonLeftStick(): number;
  51094. /**
  51095. * Sets the value of the Left joystick
  51096. */
  51097. set buttonLeftStick(value: number);
  51098. /**
  51099. * Gets the value of the Right joystick
  51100. */
  51101. get buttonRightStick(): number;
  51102. /**
  51103. * Sets the value of the Right joystick
  51104. */
  51105. set buttonRightStick(value: number);
  51106. /**
  51107. * Gets the value of D-pad up
  51108. */
  51109. get dPadUp(): number;
  51110. /**
  51111. * Sets the value of D-pad up
  51112. */
  51113. set dPadUp(value: number);
  51114. /**
  51115. * Gets the value of D-pad down
  51116. */
  51117. get dPadDown(): number;
  51118. /**
  51119. * Sets the value of D-pad down
  51120. */
  51121. set dPadDown(value: number);
  51122. /**
  51123. * Gets the value of D-pad left
  51124. */
  51125. get dPadLeft(): number;
  51126. /**
  51127. * Sets the value of D-pad left
  51128. */
  51129. set dPadLeft(value: number);
  51130. /**
  51131. * Gets the value of D-pad right
  51132. */
  51133. get dPadRight(): number;
  51134. /**
  51135. * Sets the value of D-pad right
  51136. */
  51137. set dPadRight(value: number);
  51138. /**
  51139. * Force the gamepad to synchronize with device values
  51140. */
  51141. update(): void;
  51142. /**
  51143. * Disposes the gamepad
  51144. */
  51145. dispose(): void;
  51146. }
  51147. }
  51148. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51149. import { Observable } from "babylonjs/Misc/observable";
  51150. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51151. /**
  51152. * Defines supported buttons for DualShock compatible gamepads
  51153. */
  51154. export enum DualShockButton {
  51155. /** Cross */
  51156. Cross = 0,
  51157. /** Circle */
  51158. Circle = 1,
  51159. /** Square */
  51160. Square = 2,
  51161. /** Triangle */
  51162. Triangle = 3,
  51163. /** L1 */
  51164. L1 = 4,
  51165. /** R1 */
  51166. R1 = 5,
  51167. /** Share */
  51168. Share = 8,
  51169. /** Options */
  51170. Options = 9,
  51171. /** Left stick */
  51172. LeftStick = 10,
  51173. /** Right stick */
  51174. RightStick = 11
  51175. }
  51176. /** Defines values for DualShock DPad */
  51177. export enum DualShockDpad {
  51178. /** Up */
  51179. Up = 12,
  51180. /** Down */
  51181. Down = 13,
  51182. /** Left */
  51183. Left = 14,
  51184. /** Right */
  51185. Right = 15
  51186. }
  51187. /**
  51188. * Defines a DualShock gamepad
  51189. */
  51190. export class DualShockPad extends Gamepad {
  51191. private _leftTrigger;
  51192. private _rightTrigger;
  51193. private _onlefttriggerchanged;
  51194. private _onrighttriggerchanged;
  51195. private _onbuttondown;
  51196. private _onbuttonup;
  51197. private _ondpaddown;
  51198. private _ondpadup;
  51199. /** Observable raised when a button is pressed */
  51200. onButtonDownObservable: Observable<DualShockButton>;
  51201. /** Observable raised when a button is released */
  51202. onButtonUpObservable: Observable<DualShockButton>;
  51203. /** Observable raised when a pad is pressed */
  51204. onPadDownObservable: Observable<DualShockDpad>;
  51205. /** Observable raised when a pad is released */
  51206. onPadUpObservable: Observable<DualShockDpad>;
  51207. private _buttonCross;
  51208. private _buttonCircle;
  51209. private _buttonSquare;
  51210. private _buttonTriangle;
  51211. private _buttonShare;
  51212. private _buttonOptions;
  51213. private _buttonL1;
  51214. private _buttonR1;
  51215. private _buttonLeftStick;
  51216. private _buttonRightStick;
  51217. private _dPadUp;
  51218. private _dPadDown;
  51219. private _dPadLeft;
  51220. private _dPadRight;
  51221. /**
  51222. * Creates a new DualShock gamepad object
  51223. * @param id defines the id of this gamepad
  51224. * @param index defines its index
  51225. * @param gamepad defines the internal HTML gamepad object
  51226. */
  51227. constructor(id: string, index: number, gamepad: any);
  51228. /**
  51229. * Defines the callback to call when left trigger is pressed
  51230. * @param callback defines the callback to use
  51231. */
  51232. onlefttriggerchanged(callback: (value: number) => void): void;
  51233. /**
  51234. * Defines the callback to call when right trigger is pressed
  51235. * @param callback defines the callback to use
  51236. */
  51237. onrighttriggerchanged(callback: (value: number) => void): void;
  51238. /**
  51239. * Gets the left trigger value
  51240. */
  51241. get leftTrigger(): number;
  51242. /**
  51243. * Sets the left trigger value
  51244. */
  51245. set leftTrigger(newValue: number);
  51246. /**
  51247. * Gets the right trigger value
  51248. */
  51249. get rightTrigger(): number;
  51250. /**
  51251. * Sets the right trigger value
  51252. */
  51253. set rightTrigger(newValue: number);
  51254. /**
  51255. * Defines the callback to call when a button is pressed
  51256. * @param callback defines the callback to use
  51257. */
  51258. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51259. /**
  51260. * Defines the callback to call when a button is released
  51261. * @param callback defines the callback to use
  51262. */
  51263. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51264. /**
  51265. * Defines the callback to call when a pad is pressed
  51266. * @param callback defines the callback to use
  51267. */
  51268. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51269. /**
  51270. * Defines the callback to call when a pad is released
  51271. * @param callback defines the callback to use
  51272. */
  51273. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51274. private _setButtonValue;
  51275. private _setDPadValue;
  51276. /**
  51277. * Gets the value of the `Cross` button
  51278. */
  51279. get buttonCross(): number;
  51280. /**
  51281. * Sets the value of the `Cross` button
  51282. */
  51283. set buttonCross(value: number);
  51284. /**
  51285. * Gets the value of the `Circle` button
  51286. */
  51287. get buttonCircle(): number;
  51288. /**
  51289. * Sets the value of the `Circle` button
  51290. */
  51291. set buttonCircle(value: number);
  51292. /**
  51293. * Gets the value of the `Square` button
  51294. */
  51295. get buttonSquare(): number;
  51296. /**
  51297. * Sets the value of the `Square` button
  51298. */
  51299. set buttonSquare(value: number);
  51300. /**
  51301. * Gets the value of the `Triangle` button
  51302. */
  51303. get buttonTriangle(): number;
  51304. /**
  51305. * Sets the value of the `Triangle` button
  51306. */
  51307. set buttonTriangle(value: number);
  51308. /**
  51309. * Gets the value of the `Options` button
  51310. */
  51311. get buttonOptions(): number;
  51312. /**
  51313. * Sets the value of the `Options` button
  51314. */
  51315. set buttonOptions(value: number);
  51316. /**
  51317. * Gets the value of the `Share` button
  51318. */
  51319. get buttonShare(): number;
  51320. /**
  51321. * Sets the value of the `Share` button
  51322. */
  51323. set buttonShare(value: number);
  51324. /**
  51325. * Gets the value of the `L1` button
  51326. */
  51327. get buttonL1(): number;
  51328. /**
  51329. * Sets the value of the `L1` button
  51330. */
  51331. set buttonL1(value: number);
  51332. /**
  51333. * Gets the value of the `R1` button
  51334. */
  51335. get buttonR1(): number;
  51336. /**
  51337. * Sets the value of the `R1` button
  51338. */
  51339. set buttonR1(value: number);
  51340. /**
  51341. * Gets the value of the Left joystick
  51342. */
  51343. get buttonLeftStick(): number;
  51344. /**
  51345. * Sets the value of the Left joystick
  51346. */
  51347. set buttonLeftStick(value: number);
  51348. /**
  51349. * Gets the value of the Right joystick
  51350. */
  51351. get buttonRightStick(): number;
  51352. /**
  51353. * Sets the value of the Right joystick
  51354. */
  51355. set buttonRightStick(value: number);
  51356. /**
  51357. * Gets the value of D-pad up
  51358. */
  51359. get dPadUp(): number;
  51360. /**
  51361. * Sets the value of D-pad up
  51362. */
  51363. set dPadUp(value: number);
  51364. /**
  51365. * Gets the value of D-pad down
  51366. */
  51367. get dPadDown(): number;
  51368. /**
  51369. * Sets the value of D-pad down
  51370. */
  51371. set dPadDown(value: number);
  51372. /**
  51373. * Gets the value of D-pad left
  51374. */
  51375. get dPadLeft(): number;
  51376. /**
  51377. * Sets the value of D-pad left
  51378. */
  51379. set dPadLeft(value: number);
  51380. /**
  51381. * Gets the value of D-pad right
  51382. */
  51383. get dPadRight(): number;
  51384. /**
  51385. * Sets the value of D-pad right
  51386. */
  51387. set dPadRight(value: number);
  51388. /**
  51389. * Force the gamepad to synchronize with device values
  51390. */
  51391. update(): void;
  51392. /**
  51393. * Disposes the gamepad
  51394. */
  51395. dispose(): void;
  51396. }
  51397. }
  51398. declare module "babylonjs/Gamepads/gamepadManager" {
  51399. import { Observable } from "babylonjs/Misc/observable";
  51400. import { Nullable } from "babylonjs/types";
  51401. import { Scene } from "babylonjs/scene";
  51402. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51403. /**
  51404. * Manager for handling gamepads
  51405. */
  51406. export class GamepadManager {
  51407. private _scene?;
  51408. private _babylonGamepads;
  51409. private _oneGamepadConnected;
  51410. /** @hidden */
  51411. _isMonitoring: boolean;
  51412. private _gamepadEventSupported;
  51413. private _gamepadSupport?;
  51414. /**
  51415. * observable to be triggered when the gamepad controller has been connected
  51416. */
  51417. onGamepadConnectedObservable: Observable<Gamepad>;
  51418. /**
  51419. * observable to be triggered when the gamepad controller has been disconnected
  51420. */
  51421. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51422. private _onGamepadConnectedEvent;
  51423. private _onGamepadDisconnectedEvent;
  51424. /**
  51425. * Initializes the gamepad manager
  51426. * @param _scene BabylonJS scene
  51427. */
  51428. constructor(_scene?: Scene | undefined);
  51429. /**
  51430. * The gamepads in the game pad manager
  51431. */
  51432. get gamepads(): Gamepad[];
  51433. /**
  51434. * Get the gamepad controllers based on type
  51435. * @param type The type of gamepad controller
  51436. * @returns Nullable gamepad
  51437. */
  51438. getGamepadByType(type?: number): Nullable<Gamepad>;
  51439. /**
  51440. * Disposes the gamepad manager
  51441. */
  51442. dispose(): void;
  51443. private _addNewGamepad;
  51444. private _startMonitoringGamepads;
  51445. private _stopMonitoringGamepads;
  51446. /** @hidden */
  51447. _checkGamepadsStatus(): void;
  51448. private _updateGamepadObjects;
  51449. }
  51450. }
  51451. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51452. import { Nullable } from "babylonjs/types";
  51453. import { Scene } from "babylonjs/scene";
  51454. import { ISceneComponent } from "babylonjs/sceneComponent";
  51455. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51456. module "babylonjs/scene" {
  51457. interface Scene {
  51458. /** @hidden */
  51459. _gamepadManager: Nullable<GamepadManager>;
  51460. /**
  51461. * Gets the gamepad manager associated with the scene
  51462. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51463. */
  51464. gamepadManager: GamepadManager;
  51465. }
  51466. }
  51467. module "babylonjs/Cameras/freeCameraInputsManager" {
  51468. /**
  51469. * Interface representing a free camera inputs manager
  51470. */
  51471. interface FreeCameraInputsManager {
  51472. /**
  51473. * Adds gamepad input support to the FreeCameraInputsManager.
  51474. * @returns the FreeCameraInputsManager
  51475. */
  51476. addGamepad(): FreeCameraInputsManager;
  51477. }
  51478. }
  51479. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51480. /**
  51481. * Interface representing an arc rotate camera inputs manager
  51482. */
  51483. interface ArcRotateCameraInputsManager {
  51484. /**
  51485. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51486. * @returns the camera inputs manager
  51487. */
  51488. addGamepad(): ArcRotateCameraInputsManager;
  51489. }
  51490. }
  51491. /**
  51492. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51493. */
  51494. export class GamepadSystemSceneComponent implements ISceneComponent {
  51495. /**
  51496. * The component name helpfull to identify the component in the list of scene components.
  51497. */
  51498. readonly name: string;
  51499. /**
  51500. * The scene the component belongs to.
  51501. */
  51502. scene: Scene;
  51503. /**
  51504. * Creates a new instance of the component for the given scene
  51505. * @param scene Defines the scene to register the component in
  51506. */
  51507. constructor(scene: Scene);
  51508. /**
  51509. * Registers the component in a given scene
  51510. */
  51511. register(): void;
  51512. /**
  51513. * Rebuilds the elements related to this component in case of
  51514. * context lost for instance.
  51515. */
  51516. rebuild(): void;
  51517. /**
  51518. * Disposes the component and the associated ressources
  51519. */
  51520. dispose(): void;
  51521. private _beforeCameraUpdate;
  51522. }
  51523. }
  51524. declare module "babylonjs/Cameras/universalCamera" {
  51525. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51526. import { Scene } from "babylonjs/scene";
  51527. import { Vector3 } from "babylonjs/Maths/math.vector";
  51528. import "babylonjs/Gamepads/gamepadSceneComponent";
  51529. /**
  51530. * 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,
  51531. * which still works and will still be found in many Playgrounds.
  51532. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51533. */
  51534. export class UniversalCamera extends TouchCamera {
  51535. /**
  51536. * Defines the gamepad rotation sensiblity.
  51537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51538. */
  51539. get gamepadAngularSensibility(): number;
  51540. set gamepadAngularSensibility(value: number);
  51541. /**
  51542. * Defines the gamepad move sensiblity.
  51543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51544. */
  51545. get gamepadMoveSensibility(): number;
  51546. set gamepadMoveSensibility(value: number);
  51547. /**
  51548. * 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,
  51549. * which still works and will still be found in many Playgrounds.
  51550. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51551. * @param name Define the name of the camera in the scene
  51552. * @param position Define the start position of the camera in the scene
  51553. * @param scene Define the scene the camera belongs to
  51554. */
  51555. constructor(name: string, position: Vector3, scene: Scene);
  51556. /**
  51557. * Gets the current object class name.
  51558. * @return the class name
  51559. */
  51560. getClassName(): string;
  51561. }
  51562. }
  51563. declare module "babylonjs/Cameras/gamepadCamera" {
  51564. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51565. import { Scene } from "babylonjs/scene";
  51566. import { Vector3 } from "babylonjs/Maths/math.vector";
  51567. /**
  51568. * This represents a FPS type of camera. This is only here for back compat purpose.
  51569. * Please use the UniversalCamera instead as both are identical.
  51570. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51571. */
  51572. export class GamepadCamera extends UniversalCamera {
  51573. /**
  51574. * Instantiates a new Gamepad Camera
  51575. * This represents a FPS type of camera. This is only here for back compat purpose.
  51576. * Please use the UniversalCamera instead as both are identical.
  51577. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51578. * @param name Define the name of the camera in the scene
  51579. * @param position Define the start position of the camera in the scene
  51580. * @param scene Define the scene the camera belongs to
  51581. */
  51582. constructor(name: string, position: Vector3, scene: Scene);
  51583. /**
  51584. * Gets the current object class name.
  51585. * @return the class name
  51586. */
  51587. getClassName(): string;
  51588. }
  51589. }
  51590. declare module "babylonjs/Shaders/pass.fragment" {
  51591. /** @hidden */
  51592. export var passPixelShader: {
  51593. name: string;
  51594. shader: string;
  51595. };
  51596. }
  51597. declare module "babylonjs/Shaders/passCube.fragment" {
  51598. /** @hidden */
  51599. export var passCubePixelShader: {
  51600. name: string;
  51601. shader: string;
  51602. };
  51603. }
  51604. declare module "babylonjs/PostProcesses/passPostProcess" {
  51605. import { Nullable } from "babylonjs/types";
  51606. import { Camera } from "babylonjs/Cameras/camera";
  51607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51608. import { Engine } from "babylonjs/Engines/engine";
  51609. import "babylonjs/Shaders/pass.fragment";
  51610. import "babylonjs/Shaders/passCube.fragment";
  51611. import { Scene } from "babylonjs/scene";
  51612. /**
  51613. * PassPostProcess which produces an output the same as it's input
  51614. */
  51615. export class PassPostProcess extends PostProcess {
  51616. /**
  51617. * Gets a string identifying the name of the class
  51618. * @returns "PassPostProcess" string
  51619. */
  51620. getClassName(): string;
  51621. /**
  51622. * Creates the PassPostProcess
  51623. * @param name The name of the effect.
  51624. * @param options The required width/height ratio to downsize to before computing the render pass.
  51625. * @param camera The camera to apply the render pass to.
  51626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51627. * @param engine The engine which the post process will be applied. (default: current engine)
  51628. * @param reusable If the post process can be reused on the same frame. (default: false)
  51629. * @param textureType The type of texture to be used when performing the post processing.
  51630. * @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)
  51631. */
  51632. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51633. /** @hidden */
  51634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51635. }
  51636. /**
  51637. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51638. */
  51639. export class PassCubePostProcess extends PostProcess {
  51640. private _face;
  51641. /**
  51642. * Gets or sets the cube face to display.
  51643. * * 0 is +X
  51644. * * 1 is -X
  51645. * * 2 is +Y
  51646. * * 3 is -Y
  51647. * * 4 is +Z
  51648. * * 5 is -Z
  51649. */
  51650. get face(): number;
  51651. set face(value: number);
  51652. /**
  51653. * Gets a string identifying the name of the class
  51654. * @returns "PassCubePostProcess" string
  51655. */
  51656. getClassName(): string;
  51657. /**
  51658. * Creates the PassCubePostProcess
  51659. * @param name The name of the effect.
  51660. * @param options The required width/height ratio to downsize to before computing the render pass.
  51661. * @param camera The camera to apply the render pass to.
  51662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51663. * @param engine The engine which the post process will be applied. (default: current engine)
  51664. * @param reusable If the post process can be reused on the same frame. (default: false)
  51665. * @param textureType The type of texture to be used when performing the post processing.
  51666. * @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)
  51667. */
  51668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51669. /** @hidden */
  51670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51671. }
  51672. }
  51673. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51674. /** @hidden */
  51675. export var anaglyphPixelShader: {
  51676. name: string;
  51677. shader: string;
  51678. };
  51679. }
  51680. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51681. import { Engine } from "babylonjs/Engines/engine";
  51682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51683. import { Camera } from "babylonjs/Cameras/camera";
  51684. import "babylonjs/Shaders/anaglyph.fragment";
  51685. /**
  51686. * Postprocess used to generate anaglyphic rendering
  51687. */
  51688. export class AnaglyphPostProcess extends PostProcess {
  51689. private _passedProcess;
  51690. /**
  51691. * Gets a string identifying the name of the class
  51692. * @returns "AnaglyphPostProcess" string
  51693. */
  51694. getClassName(): string;
  51695. /**
  51696. * Creates a new AnaglyphPostProcess
  51697. * @param name defines postprocess name
  51698. * @param options defines creation options or target ratio scale
  51699. * @param rigCameras defines cameras using this postprocess
  51700. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51701. * @param engine defines hosting engine
  51702. * @param reusable defines if the postprocess will be reused multiple times per frame
  51703. */
  51704. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51705. }
  51706. }
  51707. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51708. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51709. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51710. import { Scene } from "babylonjs/scene";
  51711. import { Vector3 } from "babylonjs/Maths/math.vector";
  51712. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51713. /**
  51714. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51715. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51716. */
  51717. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51718. /**
  51719. * Creates a new AnaglyphArcRotateCamera
  51720. * @param name defines camera name
  51721. * @param alpha defines alpha angle (in radians)
  51722. * @param beta defines beta angle (in radians)
  51723. * @param radius defines radius
  51724. * @param target defines camera target
  51725. * @param interaxialDistance defines distance between each color axis
  51726. * @param scene defines the hosting scene
  51727. */
  51728. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51729. /**
  51730. * Gets camera class name
  51731. * @returns AnaglyphArcRotateCamera
  51732. */
  51733. getClassName(): string;
  51734. }
  51735. }
  51736. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51737. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51738. import { Scene } from "babylonjs/scene";
  51739. import { Vector3 } from "babylonjs/Maths/math.vector";
  51740. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51741. /**
  51742. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51743. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51744. */
  51745. export class AnaglyphFreeCamera extends FreeCamera {
  51746. /**
  51747. * Creates a new AnaglyphFreeCamera
  51748. * @param name defines camera name
  51749. * @param position defines initial position
  51750. * @param interaxialDistance defines distance between each color axis
  51751. * @param scene defines the hosting scene
  51752. */
  51753. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51754. /**
  51755. * Gets camera class name
  51756. * @returns AnaglyphFreeCamera
  51757. */
  51758. getClassName(): string;
  51759. }
  51760. }
  51761. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51762. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51763. import { Scene } from "babylonjs/scene";
  51764. import { Vector3 } from "babylonjs/Maths/math.vector";
  51765. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51766. /**
  51767. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51768. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51769. */
  51770. export class AnaglyphGamepadCamera extends GamepadCamera {
  51771. /**
  51772. * Creates a new AnaglyphGamepadCamera
  51773. * @param name defines camera name
  51774. * @param position defines initial position
  51775. * @param interaxialDistance defines distance between each color axis
  51776. * @param scene defines the hosting scene
  51777. */
  51778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51779. /**
  51780. * Gets camera class name
  51781. * @returns AnaglyphGamepadCamera
  51782. */
  51783. getClassName(): string;
  51784. }
  51785. }
  51786. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51787. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51788. import { Scene } from "babylonjs/scene";
  51789. import { Vector3 } from "babylonjs/Maths/math.vector";
  51790. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51791. /**
  51792. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51793. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51794. */
  51795. export class AnaglyphUniversalCamera extends UniversalCamera {
  51796. /**
  51797. * Creates a new AnaglyphUniversalCamera
  51798. * @param name defines camera name
  51799. * @param position defines initial position
  51800. * @param interaxialDistance defines distance between each color axis
  51801. * @param scene defines the hosting scene
  51802. */
  51803. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51804. /**
  51805. * Gets camera class name
  51806. * @returns AnaglyphUniversalCamera
  51807. */
  51808. getClassName(): string;
  51809. }
  51810. }
  51811. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51812. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51813. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51814. import { Scene } from "babylonjs/scene";
  51815. import { Vector3 } from "babylonjs/Maths/math.vector";
  51816. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51817. /**
  51818. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51819. * @see https://doc.babylonjs.com/features/cameras
  51820. */
  51821. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51822. /**
  51823. * Creates a new StereoscopicArcRotateCamera
  51824. * @param name defines camera name
  51825. * @param alpha defines alpha angle (in radians)
  51826. * @param beta defines beta angle (in radians)
  51827. * @param radius defines radius
  51828. * @param target defines camera target
  51829. * @param interaxialDistance defines distance between each color axis
  51830. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51831. * @param scene defines the hosting scene
  51832. */
  51833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51834. /**
  51835. * Gets camera class name
  51836. * @returns StereoscopicArcRotateCamera
  51837. */
  51838. getClassName(): string;
  51839. }
  51840. }
  51841. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51843. import { Scene } from "babylonjs/scene";
  51844. import { Vector3 } from "babylonjs/Maths/math.vector";
  51845. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51846. /**
  51847. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51848. * @see https://doc.babylonjs.com/features/cameras
  51849. */
  51850. export class StereoscopicFreeCamera extends FreeCamera {
  51851. /**
  51852. * Creates a new StereoscopicFreeCamera
  51853. * @param name defines camera name
  51854. * @param position defines initial position
  51855. * @param interaxialDistance defines distance between each color axis
  51856. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51857. * @param scene defines the hosting scene
  51858. */
  51859. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51860. /**
  51861. * Gets camera class name
  51862. * @returns StereoscopicFreeCamera
  51863. */
  51864. getClassName(): string;
  51865. }
  51866. }
  51867. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51868. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51869. import { Scene } from "babylonjs/scene";
  51870. import { Vector3 } from "babylonjs/Maths/math.vector";
  51871. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51872. /**
  51873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51874. * @see https://doc.babylonjs.com/features/cameras
  51875. */
  51876. export class StereoscopicGamepadCamera extends GamepadCamera {
  51877. /**
  51878. * Creates a new StereoscopicGamepadCamera
  51879. * @param name defines camera name
  51880. * @param position defines initial position
  51881. * @param interaxialDistance defines distance between each color axis
  51882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51883. * @param scene defines the hosting scene
  51884. */
  51885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51886. /**
  51887. * Gets camera class name
  51888. * @returns StereoscopicGamepadCamera
  51889. */
  51890. getClassName(): string;
  51891. }
  51892. }
  51893. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51894. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51895. import { Scene } from "babylonjs/scene";
  51896. import { Vector3 } from "babylonjs/Maths/math.vector";
  51897. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51898. /**
  51899. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51900. * @see https://doc.babylonjs.com/features/cameras
  51901. */
  51902. export class StereoscopicUniversalCamera extends UniversalCamera {
  51903. /**
  51904. * Creates a new StereoscopicUniversalCamera
  51905. * @param name defines camera name
  51906. * @param position defines initial position
  51907. * @param interaxialDistance defines distance between each color axis
  51908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51909. * @param scene defines the hosting scene
  51910. */
  51911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51912. /**
  51913. * Gets camera class name
  51914. * @returns StereoscopicUniversalCamera
  51915. */
  51916. getClassName(): string;
  51917. }
  51918. }
  51919. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51920. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51921. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51922. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51923. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51924. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51925. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51926. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51927. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51928. }
  51929. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51931. import { Scene } from "babylonjs/scene";
  51932. import { Vector3 } from "babylonjs/Maths/math.vector";
  51933. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51934. /**
  51935. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51936. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51937. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51938. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51939. */
  51940. export class VirtualJoysticksCamera extends FreeCamera {
  51941. /**
  51942. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51945. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51946. * @param name Define the name of the camera in the scene
  51947. * @param position Define the start position of the camera in the scene
  51948. * @param scene Define the scene the camera belongs to
  51949. */
  51950. constructor(name: string, position: Vector3, scene: Scene);
  51951. /**
  51952. * Gets the current object class name.
  51953. * @return the class name
  51954. */
  51955. getClassName(): string;
  51956. }
  51957. }
  51958. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51959. import { Matrix } from "babylonjs/Maths/math.vector";
  51960. /**
  51961. * This represents all the required metrics to create a VR camera.
  51962. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51963. */
  51964. export class VRCameraMetrics {
  51965. /**
  51966. * Define the horizontal resolution off the screen.
  51967. */
  51968. hResolution: number;
  51969. /**
  51970. * Define the vertical resolution off the screen.
  51971. */
  51972. vResolution: number;
  51973. /**
  51974. * Define the horizontal screen size.
  51975. */
  51976. hScreenSize: number;
  51977. /**
  51978. * Define the vertical screen size.
  51979. */
  51980. vScreenSize: number;
  51981. /**
  51982. * Define the vertical screen center position.
  51983. */
  51984. vScreenCenter: number;
  51985. /**
  51986. * Define the distance of the eyes to the screen.
  51987. */
  51988. eyeToScreenDistance: number;
  51989. /**
  51990. * Define the distance between both lenses
  51991. */
  51992. lensSeparationDistance: number;
  51993. /**
  51994. * Define the distance between both viewer's eyes.
  51995. */
  51996. interpupillaryDistance: number;
  51997. /**
  51998. * Define the distortion factor of the VR postprocess.
  51999. * Please, touch with care.
  52000. */
  52001. distortionK: number[];
  52002. /**
  52003. * Define the chromatic aberration correction factors for the VR post process.
  52004. */
  52005. chromaAbCorrection: number[];
  52006. /**
  52007. * Define the scale factor of the post process.
  52008. * The smaller the better but the slower.
  52009. */
  52010. postProcessScaleFactor: number;
  52011. /**
  52012. * Define an offset for the lens center.
  52013. */
  52014. lensCenterOffset: number;
  52015. /**
  52016. * Define if the current vr camera should compensate the distortion of the lense or not.
  52017. */
  52018. compensateDistortion: boolean;
  52019. /**
  52020. * Defines if multiview should be enabled when rendering (Default: false)
  52021. */
  52022. multiviewEnabled: boolean;
  52023. /**
  52024. * Gets the rendering aspect ratio based on the provided resolutions.
  52025. */
  52026. get aspectRatio(): number;
  52027. /**
  52028. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52029. */
  52030. get aspectRatioFov(): number;
  52031. /**
  52032. * @hidden
  52033. */
  52034. get leftHMatrix(): Matrix;
  52035. /**
  52036. * @hidden
  52037. */
  52038. get rightHMatrix(): Matrix;
  52039. /**
  52040. * @hidden
  52041. */
  52042. get leftPreViewMatrix(): Matrix;
  52043. /**
  52044. * @hidden
  52045. */
  52046. get rightPreViewMatrix(): Matrix;
  52047. /**
  52048. * Get the default VRMetrics based on the most generic setup.
  52049. * @returns the default vr metrics
  52050. */
  52051. static GetDefault(): VRCameraMetrics;
  52052. }
  52053. }
  52054. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52055. /** @hidden */
  52056. export var vrDistortionCorrectionPixelShader: {
  52057. name: string;
  52058. shader: string;
  52059. };
  52060. }
  52061. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52062. import { Camera } from "babylonjs/Cameras/camera";
  52063. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52065. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52066. /**
  52067. * VRDistortionCorrectionPostProcess used for mobile VR
  52068. */
  52069. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52070. private _isRightEye;
  52071. private _distortionFactors;
  52072. private _postProcessScaleFactor;
  52073. private _lensCenterOffset;
  52074. private _scaleIn;
  52075. private _scaleFactor;
  52076. private _lensCenter;
  52077. /**
  52078. * Gets a string identifying the name of the class
  52079. * @returns "VRDistortionCorrectionPostProcess" string
  52080. */
  52081. getClassName(): string;
  52082. /**
  52083. * Initializes the VRDistortionCorrectionPostProcess
  52084. * @param name The name of the effect.
  52085. * @param camera The camera to apply the render pass to.
  52086. * @param isRightEye If this is for the right eye distortion
  52087. * @param vrMetrics All the required metrics for the VR camera
  52088. */
  52089. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52090. }
  52091. }
  52092. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52093. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52094. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52095. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52096. import { Scene } from "babylonjs/scene";
  52097. import { Vector3 } from "babylonjs/Maths/math.vector";
  52098. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52099. import "babylonjs/Cameras/RigModes/vrRigMode";
  52100. /**
  52101. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52102. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52103. */
  52104. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52105. /**
  52106. * Creates a new VRDeviceOrientationArcRotateCamera
  52107. * @param name defines camera name
  52108. * @param alpha defines the camera rotation along the logitudinal axis
  52109. * @param beta defines the camera rotation along the latitudinal axis
  52110. * @param radius defines the camera distance from its target
  52111. * @param target defines the camera target
  52112. * @param scene defines the scene the camera belongs to
  52113. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52114. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52115. */
  52116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52117. /**
  52118. * Gets camera class name
  52119. * @returns VRDeviceOrientationArcRotateCamera
  52120. */
  52121. getClassName(): string;
  52122. }
  52123. }
  52124. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52125. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52126. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52127. import { Scene } from "babylonjs/scene";
  52128. import { Vector3 } from "babylonjs/Maths/math.vector";
  52129. import "babylonjs/Cameras/RigModes/vrRigMode";
  52130. /**
  52131. * Camera used to simulate VR rendering (based on FreeCamera)
  52132. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52133. */
  52134. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52135. /**
  52136. * Creates a new VRDeviceOrientationFreeCamera
  52137. * @param name defines camera name
  52138. * @param position defines the start position of the camera
  52139. * @param scene defines the scene the camera belongs to
  52140. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52141. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52142. */
  52143. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52144. /**
  52145. * Gets camera class name
  52146. * @returns VRDeviceOrientationFreeCamera
  52147. */
  52148. getClassName(): string;
  52149. }
  52150. }
  52151. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52152. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52153. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52154. import { Scene } from "babylonjs/scene";
  52155. import { Vector3 } from "babylonjs/Maths/math.vector";
  52156. import "babylonjs/Gamepads/gamepadSceneComponent";
  52157. /**
  52158. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52159. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52160. */
  52161. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52162. /**
  52163. * Creates a new VRDeviceOrientationGamepadCamera
  52164. * @param name defines camera name
  52165. * @param position defines the start position of the camera
  52166. * @param scene defines the scene the camera belongs to
  52167. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52168. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52169. */
  52170. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52171. /**
  52172. * Gets camera class name
  52173. * @returns VRDeviceOrientationGamepadCamera
  52174. */
  52175. getClassName(): string;
  52176. }
  52177. }
  52178. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52179. import { Scene } from "babylonjs/scene";
  52180. import { Texture } from "babylonjs/Materials/Textures/texture";
  52181. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52182. /**
  52183. * A class extending Texture allowing drawing on a texture
  52184. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52185. */
  52186. export class DynamicTexture extends Texture {
  52187. private _generateMipMaps;
  52188. private _canvas;
  52189. private _context;
  52190. /**
  52191. * Creates a DynamicTexture
  52192. * @param name defines the name of the texture
  52193. * @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
  52194. * @param scene defines the scene where you want the texture
  52195. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52196. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52197. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52198. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52199. */
  52200. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52201. /**
  52202. * Get the current class name of the texture useful for serialization or dynamic coding.
  52203. * @returns "DynamicTexture"
  52204. */
  52205. getClassName(): string;
  52206. /**
  52207. * Gets the current state of canRescale
  52208. */
  52209. get canRescale(): boolean;
  52210. private _recreate;
  52211. /**
  52212. * Scales the texture
  52213. * @param ratio the scale factor to apply to both width and height
  52214. */
  52215. scale(ratio: number): void;
  52216. /**
  52217. * Resizes the texture
  52218. * @param width the new width
  52219. * @param height the new height
  52220. */
  52221. scaleTo(width: number, height: number): void;
  52222. /**
  52223. * Gets the context of the canvas used by the texture
  52224. * @returns the canvas context of the dynamic texture
  52225. */
  52226. getContext(): CanvasRenderingContext2D;
  52227. /**
  52228. * Clears the texture
  52229. */
  52230. clear(): void;
  52231. /**
  52232. * Updates the texture
  52233. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52234. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52235. */
  52236. update(invertY?: boolean, premulAlpha?: boolean): void;
  52237. /**
  52238. * Draws text onto the texture
  52239. * @param text defines the text to be drawn
  52240. * @param x defines the placement of the text from the left
  52241. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52242. * @param font defines the font to be used with font-style, font-size, font-name
  52243. * @param color defines the color used for the text
  52244. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52245. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52246. * @param update defines whether texture is immediately update (default is true)
  52247. */
  52248. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52249. /**
  52250. * Clones the texture
  52251. * @returns the clone of the texture.
  52252. */
  52253. clone(): DynamicTexture;
  52254. /**
  52255. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52256. * @returns a serialized dynamic texture object
  52257. */
  52258. serialize(): any;
  52259. private _IsCanvasElement;
  52260. /** @hidden */
  52261. _rebuild(): void;
  52262. }
  52263. }
  52264. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52265. import { Scene } from "babylonjs/scene";
  52266. import { Color3 } from "babylonjs/Maths/math.color";
  52267. import { Mesh } from "babylonjs/Meshes/mesh";
  52268. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52269. import { Nullable } from "babylonjs/types";
  52270. /**
  52271. * Class containing static functions to help procedurally build meshes
  52272. */
  52273. export class GroundBuilder {
  52274. /**
  52275. * Creates a ground mesh
  52276. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52277. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52279. * @param name defines the name of the mesh
  52280. * @param options defines the options used to create the mesh
  52281. * @param scene defines the hosting scene
  52282. * @returns the ground mesh
  52283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52284. */
  52285. static CreateGround(name: string, options: {
  52286. width?: number;
  52287. height?: number;
  52288. subdivisions?: number;
  52289. subdivisionsX?: number;
  52290. subdivisionsY?: number;
  52291. updatable?: boolean;
  52292. }, scene: any): Mesh;
  52293. /**
  52294. * Creates a tiled ground mesh
  52295. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52296. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52297. * * 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
  52298. * * 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
  52299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52300. * @param name defines the name of the mesh
  52301. * @param options defines the options used to create the mesh
  52302. * @param scene defines the hosting scene
  52303. * @returns the tiled ground mesh
  52304. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52305. */
  52306. static CreateTiledGround(name: string, options: {
  52307. xmin: number;
  52308. zmin: number;
  52309. xmax: number;
  52310. zmax: number;
  52311. subdivisions?: {
  52312. w: number;
  52313. h: number;
  52314. };
  52315. precision?: {
  52316. w: number;
  52317. h: number;
  52318. };
  52319. updatable?: boolean;
  52320. }, scene?: Nullable<Scene>): Mesh;
  52321. /**
  52322. * Creates a ground mesh from a height map
  52323. * * The parameter `url` sets the URL of the height map image resource.
  52324. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52325. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52326. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52327. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52328. * * 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.
  52329. * * 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).
  52330. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52332. * @param name defines the name of the mesh
  52333. * @param url defines the url to the height map
  52334. * @param options defines the options used to create the mesh
  52335. * @param scene defines the hosting scene
  52336. * @returns the ground mesh
  52337. * @see https://doc.babylonjs.com/babylon101/height_map
  52338. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52339. */
  52340. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52341. width?: number;
  52342. height?: number;
  52343. subdivisions?: number;
  52344. minHeight?: number;
  52345. maxHeight?: number;
  52346. colorFilter?: Color3;
  52347. alphaFilter?: number;
  52348. updatable?: boolean;
  52349. onReady?: (mesh: GroundMesh) => void;
  52350. }, scene?: Nullable<Scene>): GroundMesh;
  52351. }
  52352. }
  52353. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52354. import { Vector4 } from "babylonjs/Maths/math.vector";
  52355. import { Mesh } from "babylonjs/Meshes/mesh";
  52356. /**
  52357. * Class containing static functions to help procedurally build meshes
  52358. */
  52359. export class TorusBuilder {
  52360. /**
  52361. * Creates a torus mesh
  52362. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52363. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52364. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52368. * @param name defines the name of the mesh
  52369. * @param options defines the options used to create the mesh
  52370. * @param scene defines the hosting scene
  52371. * @returns the torus mesh
  52372. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52373. */
  52374. static CreateTorus(name: string, options: {
  52375. diameter?: number;
  52376. thickness?: number;
  52377. tessellation?: number;
  52378. updatable?: boolean;
  52379. sideOrientation?: number;
  52380. frontUVs?: Vector4;
  52381. backUVs?: Vector4;
  52382. }, scene: any): Mesh;
  52383. }
  52384. }
  52385. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52386. import { Vector4 } from "babylonjs/Maths/math.vector";
  52387. import { Color4 } from "babylonjs/Maths/math.color";
  52388. import { Mesh } from "babylonjs/Meshes/mesh";
  52389. /**
  52390. * Class containing static functions to help procedurally build meshes
  52391. */
  52392. export class CylinderBuilder {
  52393. /**
  52394. * Creates a cylinder or a cone mesh
  52395. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52396. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52397. * * 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.
  52398. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52399. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52400. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52401. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52402. * * 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).
  52403. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52404. * * 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).
  52405. * * 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
  52406. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52407. * * 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
  52408. * * 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.
  52409. * * If `enclose` is false, a ring surface is one element.
  52410. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52411. * * 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
  52412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52415. * @param name defines the name of the mesh
  52416. * @param options defines the options used to create the mesh
  52417. * @param scene defines the hosting scene
  52418. * @returns the cylinder mesh
  52419. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52420. */
  52421. static CreateCylinder(name: string, options: {
  52422. height?: number;
  52423. diameterTop?: number;
  52424. diameterBottom?: number;
  52425. diameter?: number;
  52426. tessellation?: number;
  52427. subdivisions?: number;
  52428. arc?: number;
  52429. faceColors?: Color4[];
  52430. faceUV?: Vector4[];
  52431. updatable?: boolean;
  52432. hasRings?: boolean;
  52433. enclose?: boolean;
  52434. cap?: number;
  52435. sideOrientation?: number;
  52436. frontUVs?: Vector4;
  52437. backUVs?: Vector4;
  52438. }, scene: any): Mesh;
  52439. }
  52440. }
  52441. declare module "babylonjs/XR/webXRTypes" {
  52442. import { Nullable } from "babylonjs/types";
  52443. import { IDisposable } from "babylonjs/scene";
  52444. /**
  52445. * States of the webXR experience
  52446. */
  52447. export enum WebXRState {
  52448. /**
  52449. * Transitioning to being in XR mode
  52450. */
  52451. ENTERING_XR = 0,
  52452. /**
  52453. * Transitioning to non XR mode
  52454. */
  52455. EXITING_XR = 1,
  52456. /**
  52457. * In XR mode and presenting
  52458. */
  52459. IN_XR = 2,
  52460. /**
  52461. * Not entered XR mode
  52462. */
  52463. NOT_IN_XR = 3
  52464. }
  52465. /**
  52466. * The state of the XR camera's tracking
  52467. */
  52468. export enum WebXRTrackingState {
  52469. /**
  52470. * No transformation received, device is not being tracked
  52471. */
  52472. NOT_TRACKING = 0,
  52473. /**
  52474. * Tracking lost - using emulated position
  52475. */
  52476. TRACKING_LOST = 1,
  52477. /**
  52478. * Transformation tracking works normally
  52479. */
  52480. TRACKING = 2
  52481. }
  52482. /**
  52483. * Abstraction of the XR render target
  52484. */
  52485. export interface WebXRRenderTarget extends IDisposable {
  52486. /**
  52487. * xrpresent context of the canvas which can be used to display/mirror xr content
  52488. */
  52489. canvasContext: WebGLRenderingContext;
  52490. /**
  52491. * xr layer for the canvas
  52492. */
  52493. xrLayer: Nullable<XRWebGLLayer>;
  52494. /**
  52495. * Initializes the xr layer for the session
  52496. * @param xrSession xr session
  52497. * @returns a promise that will resolve once the XR Layer has been created
  52498. */
  52499. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52500. }
  52501. }
  52502. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52503. import { Nullable } from "babylonjs/types";
  52504. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52505. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52506. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. /**
  52509. * COnfiguration object for WebXR output canvas
  52510. */
  52511. export class WebXRManagedOutputCanvasOptions {
  52512. /**
  52513. * An optional canvas in case you wish to create it yourself and provide it here.
  52514. * If not provided, a new canvas will be created
  52515. */
  52516. canvasElement?: HTMLCanvasElement;
  52517. /**
  52518. * Options for this XR Layer output
  52519. */
  52520. canvasOptions?: XRWebGLLayerInit;
  52521. /**
  52522. * CSS styling for a newly created canvas (if not provided)
  52523. */
  52524. newCanvasCssStyle?: string;
  52525. /**
  52526. * Get the default values of the configuration object
  52527. * @param engine defines the engine to use (can be null)
  52528. * @returns default values of this configuration object
  52529. */
  52530. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52531. }
  52532. /**
  52533. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52534. */
  52535. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52536. private _options;
  52537. private _canvas;
  52538. private _engine;
  52539. private _originalCanvasSize;
  52540. /**
  52541. * Rendering context of the canvas which can be used to display/mirror xr content
  52542. */
  52543. canvasContext: WebGLRenderingContext;
  52544. /**
  52545. * xr layer for the canvas
  52546. */
  52547. xrLayer: Nullable<XRWebGLLayer>;
  52548. /**
  52549. * Obseervers registered here will be triggered when the xr layer was initialized
  52550. */
  52551. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52552. /**
  52553. * Initializes the canvas to be added/removed upon entering/exiting xr
  52554. * @param _xrSessionManager The XR Session manager
  52555. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52556. */
  52557. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52558. /**
  52559. * Disposes of the object
  52560. */
  52561. dispose(): void;
  52562. /**
  52563. * Initializes the xr layer for the session
  52564. * @param xrSession xr session
  52565. * @returns a promise that will resolve once the XR Layer has been created
  52566. */
  52567. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52568. private _addCanvas;
  52569. private _removeCanvas;
  52570. private _setCanvasSize;
  52571. private _setManagedOutputCanvas;
  52572. }
  52573. }
  52574. declare module "babylonjs/XR/webXRSessionManager" {
  52575. import { Observable } from "babylonjs/Misc/observable";
  52576. import { Nullable } from "babylonjs/types";
  52577. import { IDisposable, Scene } from "babylonjs/scene";
  52578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52579. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52580. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52581. /**
  52582. * Manages an XRSession to work with Babylon's engine
  52583. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52584. */
  52585. export class WebXRSessionManager implements IDisposable {
  52586. /** The scene which the session should be created for */
  52587. scene: Scene;
  52588. private _referenceSpace;
  52589. private _rttProvider;
  52590. private _sessionEnded;
  52591. private _xrNavigator;
  52592. private baseLayer;
  52593. /**
  52594. * The base reference space from which the session started. good if you want to reset your
  52595. * reference space
  52596. */
  52597. baseReferenceSpace: XRReferenceSpace;
  52598. /**
  52599. * Current XR frame
  52600. */
  52601. currentFrame: Nullable<XRFrame>;
  52602. /** WebXR timestamp updated every frame */
  52603. currentTimestamp: number;
  52604. /**
  52605. * Used just in case of a failure to initialize an immersive session.
  52606. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52607. */
  52608. defaultHeightCompensation: number;
  52609. /**
  52610. * Fires every time a new xrFrame arrives which can be used to update the camera
  52611. */
  52612. onXRFrameObservable: Observable<XRFrame>;
  52613. /**
  52614. * Fires when the reference space changed
  52615. */
  52616. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52617. /**
  52618. * Fires when the xr session is ended either by the device or manually done
  52619. */
  52620. onXRSessionEnded: Observable<any>;
  52621. /**
  52622. * Fires when the xr session is ended either by the device or manually done
  52623. */
  52624. onXRSessionInit: Observable<XRSession>;
  52625. /**
  52626. * Underlying xr session
  52627. */
  52628. session: XRSession;
  52629. /**
  52630. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52631. * or get the offset the player is currently at.
  52632. */
  52633. viewerReferenceSpace: XRReferenceSpace;
  52634. /**
  52635. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52636. * @param scene The scene which the session should be created for
  52637. */
  52638. constructor(
  52639. /** The scene which the session should be created for */
  52640. scene: Scene);
  52641. /**
  52642. * The current reference space used in this session. This reference space can constantly change!
  52643. * It is mainly used to offset the camera's position.
  52644. */
  52645. get referenceSpace(): XRReferenceSpace;
  52646. /**
  52647. * Set a new reference space and triggers the observable
  52648. */
  52649. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52650. /**
  52651. * Disposes of the session manager
  52652. */
  52653. dispose(): void;
  52654. /**
  52655. * Stops the xrSession and restores the render loop
  52656. * @returns Promise which resolves after it exits XR
  52657. */
  52658. exitXRAsync(): Promise<void>;
  52659. /**
  52660. * Gets the correct render target texture to be rendered this frame for this eye
  52661. * @param eye the eye for which to get the render target
  52662. * @returns the render target for the specified eye
  52663. */
  52664. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52665. /**
  52666. * Creates a WebXRRenderTarget object for the XR session
  52667. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52668. * @param options optional options to provide when creating a new render target
  52669. * @returns a WebXR render target to which the session can render
  52670. */
  52671. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52672. /**
  52673. * Initializes the manager
  52674. * After initialization enterXR can be called to start an XR session
  52675. * @returns Promise which resolves after it is initialized
  52676. */
  52677. initializeAsync(): Promise<void>;
  52678. /**
  52679. * Initializes an xr session
  52680. * @param xrSessionMode mode to initialize
  52681. * @param xrSessionInit defines optional and required values to pass to the session builder
  52682. * @returns a promise which will resolve once the session has been initialized
  52683. */
  52684. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52685. /**
  52686. * Checks if a session would be supported for the creation options specified
  52687. * @param sessionMode session mode to check if supported eg. immersive-vr
  52688. * @returns A Promise that resolves to true if supported and false if not
  52689. */
  52690. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52691. /**
  52692. * Resets the reference space to the one started the session
  52693. */
  52694. resetReferenceSpace(): void;
  52695. /**
  52696. * Starts rendering to the xr layer
  52697. */
  52698. runXRRenderLoop(): void;
  52699. /**
  52700. * Sets the reference space on the xr session
  52701. * @param referenceSpaceType space to set
  52702. * @returns a promise that will resolve once the reference space has been set
  52703. */
  52704. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52705. /**
  52706. * Updates the render state of the session
  52707. * @param state state to set
  52708. * @returns a promise that resolves once the render state has been updated
  52709. */
  52710. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52711. /**
  52712. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52713. * @param sessionMode defines the session to test
  52714. * @returns a promise with boolean as final value
  52715. */
  52716. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52717. private _createRenderTargetTexture;
  52718. }
  52719. }
  52720. declare module "babylonjs/XR/webXRCamera" {
  52721. import { Vector3 } from "babylonjs/Maths/math.vector";
  52722. import { Scene } from "babylonjs/scene";
  52723. import { Camera } from "babylonjs/Cameras/camera";
  52724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52725. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52726. import { Observable } from "babylonjs/Misc/observable";
  52727. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52728. /**
  52729. * WebXR Camera which holds the views for the xrSession
  52730. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52731. */
  52732. export class WebXRCamera extends FreeCamera {
  52733. private _xrSessionManager;
  52734. private _firstFrame;
  52735. private _referenceQuaternion;
  52736. private _referencedPosition;
  52737. private _xrInvPositionCache;
  52738. private _xrInvQuaternionCache;
  52739. private _trackingState;
  52740. /**
  52741. * Observable raised before camera teleportation
  52742. */
  52743. onBeforeCameraTeleport: Observable<Vector3>;
  52744. /**
  52745. * Observable raised after camera teleportation
  52746. */
  52747. onAfterCameraTeleport: Observable<Vector3>;
  52748. /**
  52749. * Notifies when the camera's tracking state has changed.
  52750. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52751. */
  52752. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52753. /**
  52754. * Should position compensation execute on first frame.
  52755. * This is used when copying the position from a native (non XR) camera
  52756. */
  52757. compensateOnFirstFrame: boolean;
  52758. /**
  52759. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52760. * @param name the name of the camera
  52761. * @param scene the scene to add the camera to
  52762. * @param _xrSessionManager a constructed xr session manager
  52763. */
  52764. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52765. /**
  52766. * Get the current XR tracking state of the camera
  52767. */
  52768. get trackingState(): WebXRTrackingState;
  52769. private _setTrackingState;
  52770. /**
  52771. * Return the user's height, unrelated to the current ground.
  52772. * This will be the y position of this camera, when ground level is 0.
  52773. */
  52774. get realWorldHeight(): number;
  52775. /** @hidden */
  52776. _updateForDualEyeDebugging(): void;
  52777. /**
  52778. * Sets this camera's transformation based on a non-vr camera
  52779. * @param otherCamera the non-vr camera to copy the transformation from
  52780. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52781. */
  52782. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52783. /**
  52784. * Gets the current instance class name ("WebXRCamera").
  52785. * @returns the class name
  52786. */
  52787. getClassName(): string;
  52788. private _rotate180;
  52789. private _updateFromXRSession;
  52790. private _updateNumberOfRigCameras;
  52791. private _updateReferenceSpace;
  52792. private _updateReferenceSpaceOffset;
  52793. }
  52794. }
  52795. declare module "babylonjs/XR/webXRFeaturesManager" {
  52796. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52797. import { IDisposable } from "babylonjs/scene";
  52798. /**
  52799. * Defining the interface required for a (webxr) feature
  52800. */
  52801. export interface IWebXRFeature extends IDisposable {
  52802. /**
  52803. * Is this feature attached
  52804. */
  52805. attached: boolean;
  52806. /**
  52807. * Should auto-attach be disabled?
  52808. */
  52809. disableAutoAttach: boolean;
  52810. /**
  52811. * Attach the feature to the session
  52812. * Will usually be called by the features manager
  52813. *
  52814. * @param force should attachment be forced (even when already attached)
  52815. * @returns true if successful.
  52816. */
  52817. attach(force?: boolean): boolean;
  52818. /**
  52819. * Detach the feature from the session
  52820. * Will usually be called by the features manager
  52821. *
  52822. * @returns true if successful.
  52823. */
  52824. detach(): boolean;
  52825. /**
  52826. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52827. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52828. *
  52829. * @returns whether or not the feature is compatible in this environment
  52830. */
  52831. isCompatible(): boolean;
  52832. /**
  52833. * Was this feature disposed;
  52834. */
  52835. isDisposed: boolean;
  52836. /**
  52837. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52838. */
  52839. xrNativeFeatureName?: string;
  52840. /**
  52841. * A list of (Babylon WebXR) features this feature depends on
  52842. */
  52843. dependsOn?: string[];
  52844. }
  52845. /**
  52846. * A list of the currently available features without referencing them
  52847. */
  52848. export class WebXRFeatureName {
  52849. /**
  52850. * The name of the anchor system feature
  52851. */
  52852. static readonly ANCHOR_SYSTEM: string;
  52853. /**
  52854. * The name of the background remover feature
  52855. */
  52856. static readonly BACKGROUND_REMOVER: string;
  52857. /**
  52858. * The name of the hit test feature
  52859. */
  52860. static readonly HIT_TEST: string;
  52861. /**
  52862. * physics impostors for xr controllers feature
  52863. */
  52864. static readonly PHYSICS_CONTROLLERS: string;
  52865. /**
  52866. * The name of the plane detection feature
  52867. */
  52868. static readonly PLANE_DETECTION: string;
  52869. /**
  52870. * The name of the pointer selection feature
  52871. */
  52872. static readonly POINTER_SELECTION: string;
  52873. /**
  52874. * The name of the teleportation feature
  52875. */
  52876. static readonly TELEPORTATION: string;
  52877. /**
  52878. * The name of the feature points feature.
  52879. */
  52880. static readonly FEATURE_POINTS: string;
  52881. /**
  52882. * The name of the hand tracking feature.
  52883. */
  52884. static readonly HAND_TRACKING: string;
  52885. }
  52886. /**
  52887. * Defining the constructor of a feature. Used to register the modules.
  52888. */
  52889. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52890. /**
  52891. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52892. * It is mainly used in AR sessions.
  52893. *
  52894. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52895. */
  52896. export class WebXRFeaturesManager implements IDisposable {
  52897. private _xrSessionManager;
  52898. private static readonly _AvailableFeatures;
  52899. private _features;
  52900. /**
  52901. * constructs a new features manages.
  52902. *
  52903. * @param _xrSessionManager an instance of WebXRSessionManager
  52904. */
  52905. constructor(_xrSessionManager: WebXRSessionManager);
  52906. /**
  52907. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52908. * Mainly used internally.
  52909. *
  52910. * @param featureName the name of the feature to register
  52911. * @param constructorFunction the function used to construct the module
  52912. * @param version the (babylon) version of the module
  52913. * @param stable is that a stable version of this module
  52914. */
  52915. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52916. /**
  52917. * Returns a constructor of a specific feature.
  52918. *
  52919. * @param featureName the name of the feature to construct
  52920. * @param version the version of the feature to load
  52921. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52922. * @param options optional options provided to the module.
  52923. * @returns a function that, when called, will return a new instance of this feature
  52924. */
  52925. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52926. /**
  52927. * Can be used to return the list of features currently registered
  52928. *
  52929. * @returns an Array of available features
  52930. */
  52931. static GetAvailableFeatures(): string[];
  52932. /**
  52933. * Gets the versions available for a specific feature
  52934. * @param featureName the name of the feature
  52935. * @returns an array with the available versions
  52936. */
  52937. static GetAvailableVersions(featureName: string): string[];
  52938. /**
  52939. * Return the latest unstable version of this feature
  52940. * @param featureName the name of the feature to search
  52941. * @returns the version number. if not found will return -1
  52942. */
  52943. static GetLatestVersionOfFeature(featureName: string): number;
  52944. /**
  52945. * Return the latest stable version of this feature
  52946. * @param featureName the name of the feature to search
  52947. * @returns the version number. if not found will return -1
  52948. */
  52949. static GetStableVersionOfFeature(featureName: string): number;
  52950. /**
  52951. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52952. * Can be used during a session to start a feature
  52953. * @param featureName the name of feature to attach
  52954. */
  52955. attachFeature(featureName: string): void;
  52956. /**
  52957. * Can be used inside a session or when the session ends to detach a specific feature
  52958. * @param featureName the name of the feature to detach
  52959. */
  52960. detachFeature(featureName: string): void;
  52961. /**
  52962. * Used to disable an already-enabled feature
  52963. * The feature will be disposed and will be recreated once enabled.
  52964. * @param featureName the feature to disable
  52965. * @returns true if disable was successful
  52966. */
  52967. disableFeature(featureName: string | {
  52968. Name: string;
  52969. }): boolean;
  52970. /**
  52971. * dispose this features manager
  52972. */
  52973. dispose(): void;
  52974. /**
  52975. * 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.
  52976. * 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.
  52977. *
  52978. * @param featureName the name of the feature to load or the class of the feature
  52979. * @param version optional version to load. if not provided the latest version will be enabled
  52980. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52981. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52982. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52983. * @returns a new constructed feature or throws an error if feature not found.
  52984. */
  52985. enableFeature(featureName: string | {
  52986. Name: string;
  52987. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52988. /**
  52989. * get the implementation of an enabled feature.
  52990. * @param featureName the name of the feature to load
  52991. * @returns the feature class, if found
  52992. */
  52993. getEnabledFeature(featureName: string): IWebXRFeature;
  52994. /**
  52995. * Get the list of enabled features
  52996. * @returns an array of enabled features
  52997. */
  52998. getEnabledFeatures(): string[];
  52999. /**
  53000. * This function will exten the session creation configuration object with enabled features.
  53001. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53002. * according to the defined "required" variable, provided during enableFeature call
  53003. * @param xrSessionInit the xr Session init object to extend
  53004. *
  53005. * @returns an extended XRSessionInit object
  53006. */
  53007. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  53008. }
  53009. }
  53010. declare module "babylonjs/XR/webXRExperienceHelper" {
  53011. import { Observable } from "babylonjs/Misc/observable";
  53012. import { IDisposable, Scene } from "babylonjs/scene";
  53013. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53014. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53015. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  53016. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  53017. /**
  53018. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53019. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53020. */
  53021. export class WebXRExperienceHelper implements IDisposable {
  53022. private scene;
  53023. private _nonVRCamera;
  53024. private _originalSceneAutoClear;
  53025. private _supported;
  53026. /**
  53027. * Camera used to render xr content
  53028. */
  53029. camera: WebXRCamera;
  53030. /** A features manager for this xr session */
  53031. featuresManager: WebXRFeaturesManager;
  53032. /**
  53033. * Observers registered here will be triggered after the camera's initial transformation is set
  53034. * This can be used to set a different ground level or an extra rotation.
  53035. *
  53036. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53037. * to the position set after this observable is done executing.
  53038. */
  53039. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53040. /**
  53041. * Fires when the state of the experience helper has changed
  53042. */
  53043. onStateChangedObservable: Observable<WebXRState>;
  53044. /** Session manager used to keep track of xr session */
  53045. sessionManager: WebXRSessionManager;
  53046. /**
  53047. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53048. */
  53049. state: WebXRState;
  53050. /**
  53051. * Creates a WebXRExperienceHelper
  53052. * @param scene The scene the helper should be created in
  53053. */
  53054. private constructor();
  53055. /**
  53056. * Creates the experience helper
  53057. * @param scene the scene to attach the experience helper to
  53058. * @returns a promise for the experience helper
  53059. */
  53060. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53061. /**
  53062. * Disposes of the experience helper
  53063. */
  53064. dispose(): void;
  53065. /**
  53066. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53067. * @param sessionMode options for the XR session
  53068. * @param referenceSpaceType frame of reference of the XR session
  53069. * @param renderTarget the output canvas that will be used to enter XR mode
  53070. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53071. * @returns promise that resolves after xr mode has entered
  53072. */
  53073. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53074. /**
  53075. * Exits XR mode and returns the scene to its original state
  53076. * @returns promise that resolves after xr mode has exited
  53077. */
  53078. exitXRAsync(): Promise<void>;
  53079. private _nonXRToXRCamera;
  53080. private _setState;
  53081. }
  53082. }
  53083. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53084. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53085. import { Observable } from "babylonjs/Misc/observable";
  53086. import { IDisposable } from "babylonjs/scene";
  53087. /**
  53088. * X-Y values for axes in WebXR
  53089. */
  53090. export interface IWebXRMotionControllerAxesValue {
  53091. /**
  53092. * The value of the x axis
  53093. */
  53094. x: number;
  53095. /**
  53096. * The value of the y-axis
  53097. */
  53098. y: number;
  53099. }
  53100. /**
  53101. * changed / previous values for the values of this component
  53102. */
  53103. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53104. /**
  53105. * current (this frame) value
  53106. */
  53107. current: T;
  53108. /**
  53109. * previous (last change) value
  53110. */
  53111. previous: T;
  53112. }
  53113. /**
  53114. * Represents changes in the component between current frame and last values recorded
  53115. */
  53116. export interface IWebXRMotionControllerComponentChanges {
  53117. /**
  53118. * will be populated with previous and current values if axes changed
  53119. */
  53120. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53121. /**
  53122. * will be populated with previous and current values if pressed changed
  53123. */
  53124. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53125. /**
  53126. * will be populated with previous and current values if touched changed
  53127. */
  53128. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53129. /**
  53130. * will be populated with previous and current values if value changed
  53131. */
  53132. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53133. }
  53134. /**
  53135. * This class represents a single component (for example button or thumbstick) of a motion controller
  53136. */
  53137. export class WebXRControllerComponent implements IDisposable {
  53138. /**
  53139. * the id of this component
  53140. */
  53141. id: string;
  53142. /**
  53143. * the type of the component
  53144. */
  53145. type: MotionControllerComponentType;
  53146. private _buttonIndex;
  53147. private _axesIndices;
  53148. private _axes;
  53149. private _changes;
  53150. private _currentValue;
  53151. private _hasChanges;
  53152. private _pressed;
  53153. private _touched;
  53154. /**
  53155. * button component type
  53156. */
  53157. static BUTTON_TYPE: MotionControllerComponentType;
  53158. /**
  53159. * squeeze component type
  53160. */
  53161. static SQUEEZE_TYPE: MotionControllerComponentType;
  53162. /**
  53163. * Thumbstick component type
  53164. */
  53165. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53166. /**
  53167. * Touchpad component type
  53168. */
  53169. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53170. /**
  53171. * trigger component type
  53172. */
  53173. static TRIGGER_TYPE: MotionControllerComponentType;
  53174. /**
  53175. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53176. * the axes data changes
  53177. */
  53178. onAxisValueChangedObservable: Observable<{
  53179. x: number;
  53180. y: number;
  53181. }>;
  53182. /**
  53183. * Observers registered here will be triggered when the state of a button changes
  53184. * State change is either pressed / touched / value
  53185. */
  53186. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53187. /**
  53188. * Creates a new component for a motion controller.
  53189. * It is created by the motion controller itself
  53190. *
  53191. * @param id the id of this component
  53192. * @param type the type of the component
  53193. * @param _buttonIndex index in the buttons array of the gamepad
  53194. * @param _axesIndices indices of the values in the axes array of the gamepad
  53195. */
  53196. constructor(
  53197. /**
  53198. * the id of this component
  53199. */
  53200. id: string,
  53201. /**
  53202. * the type of the component
  53203. */
  53204. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53205. /**
  53206. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53207. */
  53208. get axes(): IWebXRMotionControllerAxesValue;
  53209. /**
  53210. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53211. */
  53212. get changes(): IWebXRMotionControllerComponentChanges;
  53213. /**
  53214. * Return whether or not the component changed the last frame
  53215. */
  53216. get hasChanges(): boolean;
  53217. /**
  53218. * is the button currently pressed
  53219. */
  53220. get pressed(): boolean;
  53221. /**
  53222. * is the button currently touched
  53223. */
  53224. get touched(): boolean;
  53225. /**
  53226. * Get the current value of this component
  53227. */
  53228. get value(): number;
  53229. /**
  53230. * Dispose this component
  53231. */
  53232. dispose(): void;
  53233. /**
  53234. * Are there axes correlating to this component
  53235. * @return true is axes data is available
  53236. */
  53237. isAxes(): boolean;
  53238. /**
  53239. * Is this component a button (hence - pressable)
  53240. * @returns true if can be pressed
  53241. */
  53242. isButton(): boolean;
  53243. /**
  53244. * update this component using the gamepad object it is in. Called on every frame
  53245. * @param nativeController the native gamepad controller object
  53246. */
  53247. update(nativeController: IMinimalMotionControllerObject): void;
  53248. }
  53249. }
  53250. declare module "babylonjs/Loading/sceneLoader" {
  53251. import { Observable } from "babylonjs/Misc/observable";
  53252. import { Nullable } from "babylonjs/types";
  53253. import { Scene } from "babylonjs/scene";
  53254. import { Engine } from "babylonjs/Engines/engine";
  53255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53256. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53257. import { AssetContainer } from "babylonjs/assetContainer";
  53258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53259. import { Skeleton } from "babylonjs/Bones/skeleton";
  53260. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53261. import { WebRequest } from "babylonjs/Misc/webRequest";
  53262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53263. import { Geometry } from "babylonjs/Meshes/geometry";
  53264. import { Light } from "babylonjs/Lights/light";
  53265. /**
  53266. * Type used for the success callback of ImportMesh
  53267. */
  53268. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53269. /**
  53270. * Interface used for the result of ImportMeshAsync
  53271. */
  53272. export interface ISceneLoaderAsyncResult {
  53273. /**
  53274. * The array of loaded meshes
  53275. */
  53276. readonly meshes: AbstractMesh[];
  53277. /**
  53278. * The array of loaded particle systems
  53279. */
  53280. readonly particleSystems: IParticleSystem[];
  53281. /**
  53282. * The array of loaded skeletons
  53283. */
  53284. readonly skeletons: Skeleton[];
  53285. /**
  53286. * The array of loaded animation groups
  53287. */
  53288. readonly animationGroups: AnimationGroup[];
  53289. /**
  53290. * The array of loaded transform nodes
  53291. */
  53292. readonly transformNodes: TransformNode[];
  53293. /**
  53294. * The array of loaded geometries
  53295. */
  53296. readonly geometries: Geometry[];
  53297. /**
  53298. * The array of loaded lights
  53299. */
  53300. readonly lights: Light[];
  53301. }
  53302. /**
  53303. * Interface used to represent data loading progression
  53304. */
  53305. export interface ISceneLoaderProgressEvent {
  53306. /**
  53307. * Defines if data length to load can be evaluated
  53308. */
  53309. readonly lengthComputable: boolean;
  53310. /**
  53311. * Defines the loaded data length
  53312. */
  53313. readonly loaded: number;
  53314. /**
  53315. * Defines the data length to load
  53316. */
  53317. readonly total: number;
  53318. }
  53319. /**
  53320. * Interface used by SceneLoader plugins to define supported file extensions
  53321. */
  53322. export interface ISceneLoaderPluginExtensions {
  53323. /**
  53324. * Defines the list of supported extensions
  53325. */
  53326. [extension: string]: {
  53327. isBinary: boolean;
  53328. };
  53329. }
  53330. /**
  53331. * Interface used by SceneLoader plugin factory
  53332. */
  53333. export interface ISceneLoaderPluginFactory {
  53334. /**
  53335. * Defines the name of the factory
  53336. */
  53337. name: string;
  53338. /**
  53339. * Function called to create a new plugin
  53340. * @return the new plugin
  53341. */
  53342. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53343. /**
  53344. * The callback that returns true if the data can be directly loaded.
  53345. * @param data string containing the file data
  53346. * @returns if the data can be loaded directly
  53347. */
  53348. canDirectLoad?(data: string): boolean;
  53349. }
  53350. /**
  53351. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53352. */
  53353. export interface ISceneLoaderPluginBase {
  53354. /**
  53355. * The friendly name of this plugin.
  53356. */
  53357. name: string;
  53358. /**
  53359. * The file extensions supported by this plugin.
  53360. */
  53361. extensions: string | ISceneLoaderPluginExtensions;
  53362. /**
  53363. * The callback called when loading from a url.
  53364. * @param scene scene loading this url
  53365. * @param url url to load
  53366. * @param onSuccess callback called when the file successfully loads
  53367. * @param onProgress callback called while file is loading (if the server supports this mode)
  53368. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53369. * @param onError callback called when the file fails to load
  53370. * @returns a file request object
  53371. */
  53372. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53373. /**
  53374. * The callback called when loading from a file object.
  53375. * @param scene scene loading this file
  53376. * @param file defines the file to load
  53377. * @param onSuccess defines the callback to call when data is loaded
  53378. * @param onProgress defines the callback to call during loading process
  53379. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53380. * @param onError defines the callback to call when an error occurs
  53381. * @returns a file request object
  53382. */
  53383. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53384. /**
  53385. * The callback that returns true if the data can be directly loaded.
  53386. * @param data string containing the file data
  53387. * @returns if the data can be loaded directly
  53388. */
  53389. canDirectLoad?(data: string): boolean;
  53390. /**
  53391. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53392. * @param scene scene loading this data
  53393. * @param data string containing the data
  53394. * @returns data to pass to the plugin
  53395. */
  53396. directLoad?(scene: Scene, data: string): any;
  53397. /**
  53398. * The callback that allows custom handling of the root url based on the response url.
  53399. * @param rootUrl the original root url
  53400. * @param responseURL the response url if available
  53401. * @returns the new root url
  53402. */
  53403. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53404. }
  53405. /**
  53406. * Interface used to define a SceneLoader plugin
  53407. */
  53408. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53409. /**
  53410. * Import meshes into a scene.
  53411. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53412. * @param scene The scene to import into
  53413. * @param data The data to import
  53414. * @param rootUrl The root url for scene and resources
  53415. * @param meshes The meshes array to import into
  53416. * @param particleSystems The particle systems array to import into
  53417. * @param skeletons The skeletons array to import into
  53418. * @param onError The callback when import fails
  53419. * @returns True if successful or false otherwise
  53420. */
  53421. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53422. /**
  53423. * Load into a scene.
  53424. * @param scene The scene to load into
  53425. * @param data The data to import
  53426. * @param rootUrl The root url for scene and resources
  53427. * @param onError The callback when import fails
  53428. * @returns True if successful or false otherwise
  53429. */
  53430. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53431. /**
  53432. * Load into an asset container.
  53433. * @param scene The scene to load into
  53434. * @param data The data to import
  53435. * @param rootUrl The root url for scene and resources
  53436. * @param onError The callback when import fails
  53437. * @returns The loaded asset container
  53438. */
  53439. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53440. }
  53441. /**
  53442. * Interface used to define an async SceneLoader plugin
  53443. */
  53444. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53445. /**
  53446. * Import meshes into a scene.
  53447. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53448. * @param scene The scene to import into
  53449. * @param data The data to import
  53450. * @param rootUrl The root url for scene and resources
  53451. * @param onProgress The callback when the load progresses
  53452. * @param fileName Defines the name of the file to load
  53453. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  53454. */
  53455. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  53456. /**
  53457. * Load into a scene.
  53458. * @param scene The scene to load into
  53459. * @param data The data to import
  53460. * @param rootUrl The root url for scene and resources
  53461. * @param onProgress The callback when the load progresses
  53462. * @param fileName Defines the name of the file to load
  53463. * @returns Nothing
  53464. */
  53465. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53466. /**
  53467. * Load into an asset container.
  53468. * @param scene The scene to load into
  53469. * @param data The data to import
  53470. * @param rootUrl The root url for scene and resources
  53471. * @param onProgress The callback when the load progresses
  53472. * @param fileName Defines the name of the file to load
  53473. * @returns The loaded asset container
  53474. */
  53475. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53476. }
  53477. /**
  53478. * Mode that determines how to handle old animation groups before loading new ones.
  53479. */
  53480. export enum SceneLoaderAnimationGroupLoadingMode {
  53481. /**
  53482. * Reset all old animations to initial state then dispose them.
  53483. */
  53484. Clean = 0,
  53485. /**
  53486. * Stop all old animations.
  53487. */
  53488. Stop = 1,
  53489. /**
  53490. * Restart old animations from first frame.
  53491. */
  53492. Sync = 2,
  53493. /**
  53494. * Old animations remains untouched.
  53495. */
  53496. NoSync = 3
  53497. }
  53498. /**
  53499. * Defines a plugin registered by the SceneLoader
  53500. */
  53501. interface IRegisteredPlugin {
  53502. /**
  53503. * Defines the plugin to use
  53504. */
  53505. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53506. /**
  53507. * Defines if the plugin supports binary data
  53508. */
  53509. isBinary: boolean;
  53510. }
  53511. /**
  53512. * Class used to load scene from various file formats using registered plugins
  53513. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53514. */
  53515. export class SceneLoader {
  53516. /**
  53517. * No logging while loading
  53518. */
  53519. static readonly NO_LOGGING: number;
  53520. /**
  53521. * Minimal logging while loading
  53522. */
  53523. static readonly MINIMAL_LOGGING: number;
  53524. /**
  53525. * Summary logging while loading
  53526. */
  53527. static readonly SUMMARY_LOGGING: number;
  53528. /**
  53529. * Detailled logging while loading
  53530. */
  53531. static readonly DETAILED_LOGGING: number;
  53532. /**
  53533. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53534. */
  53535. static get ForceFullSceneLoadingForIncremental(): boolean;
  53536. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53537. /**
  53538. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53539. */
  53540. static get ShowLoadingScreen(): boolean;
  53541. static set ShowLoadingScreen(value: boolean);
  53542. /**
  53543. * Defines the current logging level (while loading the scene)
  53544. * @ignorenaming
  53545. */
  53546. static get loggingLevel(): number;
  53547. static set loggingLevel(value: number);
  53548. /**
  53549. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53550. */
  53551. static get CleanBoneMatrixWeights(): boolean;
  53552. static set CleanBoneMatrixWeights(value: boolean);
  53553. /**
  53554. * Event raised when a plugin is used to load a scene
  53555. */
  53556. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53557. private static _registeredPlugins;
  53558. private static _showingLoadingScreen;
  53559. /**
  53560. * Gets the default plugin (used to load Babylon files)
  53561. * @returns the .babylon plugin
  53562. */
  53563. static GetDefaultPlugin(): IRegisteredPlugin;
  53564. private static _GetPluginForExtension;
  53565. private static _GetPluginForDirectLoad;
  53566. private static _GetPluginForFilename;
  53567. private static _GetDirectLoad;
  53568. private static _LoadData;
  53569. private static _GetFileInfo;
  53570. /**
  53571. * Gets a plugin that can load the given extension
  53572. * @param extension defines the extension to load
  53573. * @returns a plugin or null if none works
  53574. */
  53575. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53576. /**
  53577. * Gets a boolean indicating that the given extension can be loaded
  53578. * @param extension defines the extension to load
  53579. * @returns true if the extension is supported
  53580. */
  53581. static IsPluginForExtensionAvailable(extension: string): boolean;
  53582. /**
  53583. * Adds a new plugin to the list of registered plugins
  53584. * @param plugin defines the plugin to add
  53585. */
  53586. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53587. /**
  53588. * Import meshes into a scene
  53589. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53590. * @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)
  53591. * @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)
  53592. * @param scene the instance of BABYLON.Scene to append to
  53593. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53594. * @param onProgress a callback with a progress event for each file being loaded
  53595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53596. * @param pluginExtension the extension used to determine the plugin
  53597. * @returns The loaded plugin
  53598. */
  53599. 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>;
  53600. /**
  53601. * Import meshes into a scene
  53602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53603. * @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)
  53604. * @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)
  53605. * @param scene the instance of BABYLON.Scene to append to
  53606. * @param onProgress a callback with a progress event for each file being loaded
  53607. * @param pluginExtension the extension used to determine the plugin
  53608. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53609. */
  53610. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  53611. /**
  53612. * Load a scene
  53613. * @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)
  53614. * @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)
  53615. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53616. * @param onSuccess a callback with the scene when import succeeds
  53617. * @param onProgress a callback with a progress event for each file being loaded
  53618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53619. * @param pluginExtension the extension used to determine the plugin
  53620. * @returns The loaded plugin
  53621. */
  53622. 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>;
  53623. /**
  53624. * Load a scene
  53625. * @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)
  53626. * @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)
  53627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53628. * @param onProgress a callback with a progress event for each file being loaded
  53629. * @param pluginExtension the extension used to determine the plugin
  53630. * @returns The loaded scene
  53631. */
  53632. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53633. /**
  53634. * Append a scene
  53635. * @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)
  53636. * @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)
  53637. * @param scene is the instance of BABYLON.Scene to append to
  53638. * @param onSuccess a callback with the scene when import succeeds
  53639. * @param onProgress a callback with a progress event for each file being loaded
  53640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53641. * @param pluginExtension the extension used to determine the plugin
  53642. * @returns The loaded plugin
  53643. */
  53644. 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>;
  53645. /**
  53646. * Append a scene
  53647. * @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)
  53648. * @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)
  53649. * @param scene is the instance of BABYLON.Scene to append to
  53650. * @param onProgress a callback with a progress event for each file being loaded
  53651. * @param pluginExtension the extension used to determine the plugin
  53652. * @returns The given scene
  53653. */
  53654. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53655. /**
  53656. * Load a scene into an asset container
  53657. * @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)
  53658. * @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)
  53659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53660. * @param onSuccess a callback with the scene when import succeeds
  53661. * @param onProgress a callback with a progress event for each file being loaded
  53662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53663. * @param pluginExtension the extension used to determine the plugin
  53664. * @returns The loaded plugin
  53665. */
  53666. 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>;
  53667. /**
  53668. * Load a scene into an asset container
  53669. * @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)
  53670. * @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)
  53671. * @param scene is the instance of Scene to append to
  53672. * @param onProgress a callback with a progress event for each file being loaded
  53673. * @param pluginExtension the extension used to determine the plugin
  53674. * @returns The loaded asset container
  53675. */
  53676. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53677. /**
  53678. * Import animations from a file into a scene
  53679. * @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)
  53680. * @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)
  53681. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53682. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53683. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53684. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53685. * @param onSuccess a callback with the scene when import succeeds
  53686. * @param onProgress a callback with a progress event for each file being loaded
  53687. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53688. * @param pluginExtension the extension used to determine the plugin
  53689. */
  53690. 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;
  53691. /**
  53692. * Import animations from a file into a scene
  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 or a File object (default: empty string)
  53695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53696. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53697. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53698. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53699. * @param onSuccess a callback with the scene when import succeeds
  53700. * @param onProgress a callback with a progress event for each file being loaded
  53701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53702. * @param pluginExtension the extension used to determine the plugin
  53703. * @returns the updated scene with imported animations
  53704. */
  53705. 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>;
  53706. }
  53707. }
  53708. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53709. import { IDisposable, Scene } from "babylonjs/scene";
  53710. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53711. import { Observable } from "babylonjs/Misc/observable";
  53712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53713. import { Nullable } from "babylonjs/types";
  53714. /**
  53715. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53716. */
  53717. export type MotionControllerHandedness = "none" | "left" | "right";
  53718. /**
  53719. * The type of components available in motion controllers.
  53720. * This is not the name of the component.
  53721. */
  53722. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53723. /**
  53724. * The state of a controller component
  53725. */
  53726. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53727. /**
  53728. * The schema of motion controller layout.
  53729. * No object will be initialized using this interface
  53730. * This is used just to define the profile.
  53731. */
  53732. export interface IMotionControllerLayout {
  53733. /**
  53734. * Path to load the assets. Usually relative to the base path
  53735. */
  53736. assetPath: string;
  53737. /**
  53738. * Available components (unsorted)
  53739. */
  53740. components: {
  53741. /**
  53742. * A map of component Ids
  53743. */
  53744. [componentId: string]: {
  53745. /**
  53746. * The type of input the component outputs
  53747. */
  53748. type: MotionControllerComponentType;
  53749. /**
  53750. * The indices of this component in the gamepad object
  53751. */
  53752. gamepadIndices: {
  53753. /**
  53754. * Index of button
  53755. */
  53756. button?: number;
  53757. /**
  53758. * If available, index of x-axis
  53759. */
  53760. xAxis?: number;
  53761. /**
  53762. * If available, index of y-axis
  53763. */
  53764. yAxis?: number;
  53765. };
  53766. /**
  53767. * The mesh's root node name
  53768. */
  53769. rootNodeName: string;
  53770. /**
  53771. * Animation definitions for this model
  53772. */
  53773. visualResponses: {
  53774. [stateKey: string]: {
  53775. /**
  53776. * What property will be animated
  53777. */
  53778. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53779. /**
  53780. * What states influence this visual response
  53781. */
  53782. states: MotionControllerComponentStateType[];
  53783. /**
  53784. * Type of animation - movement or visibility
  53785. */
  53786. valueNodeProperty: "transform" | "visibility";
  53787. /**
  53788. * Base node name to move. Its position will be calculated according to the min and max nodes
  53789. */
  53790. valueNodeName?: string;
  53791. /**
  53792. * Minimum movement node
  53793. */
  53794. minNodeName?: string;
  53795. /**
  53796. * Max movement node
  53797. */
  53798. maxNodeName?: string;
  53799. };
  53800. };
  53801. /**
  53802. * If touch enabled, what is the name of node to display user feedback
  53803. */
  53804. touchPointNodeName?: string;
  53805. };
  53806. };
  53807. /**
  53808. * Is it xr standard mapping or not
  53809. */
  53810. gamepadMapping: "" | "xr-standard";
  53811. /**
  53812. * Base root node of this entire model
  53813. */
  53814. rootNodeName: string;
  53815. /**
  53816. * Defines the main button component id
  53817. */
  53818. selectComponentId: string;
  53819. }
  53820. /**
  53821. * A definition for the layout map in the input profile
  53822. */
  53823. export interface IMotionControllerLayoutMap {
  53824. /**
  53825. * Layouts with handedness type as a key
  53826. */
  53827. [handedness: string]: IMotionControllerLayout;
  53828. }
  53829. /**
  53830. * The XR Input profile schema
  53831. * Profiles can be found here:
  53832. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53833. */
  53834. export interface IMotionControllerProfile {
  53835. /**
  53836. * fallback profiles for this profileId
  53837. */
  53838. fallbackProfileIds: string[];
  53839. /**
  53840. * The layout map, with handedness as key
  53841. */
  53842. layouts: IMotionControllerLayoutMap;
  53843. /**
  53844. * The id of this profile
  53845. * correlates to the profile(s) in the xrInput.profiles array
  53846. */
  53847. profileId: string;
  53848. }
  53849. /**
  53850. * A helper-interface for the 3 meshes needed for controller button animation
  53851. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53852. */
  53853. export interface IMotionControllerButtonMeshMap {
  53854. /**
  53855. * the mesh that defines the pressed value mesh position.
  53856. * This is used to find the max-position of this button
  53857. */
  53858. pressedMesh: AbstractMesh;
  53859. /**
  53860. * the mesh that defines the unpressed value mesh position.
  53861. * This is used to find the min (or initial) position of this button
  53862. */
  53863. unpressedMesh: AbstractMesh;
  53864. /**
  53865. * The mesh that will be changed when value changes
  53866. */
  53867. valueMesh: AbstractMesh;
  53868. }
  53869. /**
  53870. * A helper-interface for the 3 meshes needed for controller axis animation.
  53871. * This will be expanded when touchpad animations are fully supported
  53872. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53873. */
  53874. export interface IMotionControllerMeshMap {
  53875. /**
  53876. * the mesh that defines the maximum value mesh position.
  53877. */
  53878. maxMesh?: AbstractMesh;
  53879. /**
  53880. * the mesh that defines the minimum value mesh position.
  53881. */
  53882. minMesh?: AbstractMesh;
  53883. /**
  53884. * The mesh that will be changed when axis value changes
  53885. */
  53886. valueMesh?: AbstractMesh;
  53887. }
  53888. /**
  53889. * The elements needed for change-detection of the gamepad objects in motion controllers
  53890. */
  53891. export interface IMinimalMotionControllerObject {
  53892. /**
  53893. * Available axes of this controller
  53894. */
  53895. axes: number[];
  53896. /**
  53897. * An array of available buttons
  53898. */
  53899. buttons: Array<{
  53900. /**
  53901. * Value of the button/trigger
  53902. */
  53903. value: number;
  53904. /**
  53905. * If the button/trigger is currently touched
  53906. */
  53907. touched: boolean;
  53908. /**
  53909. * If the button/trigger is currently pressed
  53910. */
  53911. pressed: boolean;
  53912. }>;
  53913. /**
  53914. * EXPERIMENTAL haptic support.
  53915. */
  53916. hapticActuators?: Array<{
  53917. pulse: (value: number, duration: number) => Promise<boolean>;
  53918. }>;
  53919. }
  53920. /**
  53921. * An Abstract Motion controller
  53922. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53923. * Each component has an observable to check for changes in value and state
  53924. */
  53925. export abstract class WebXRAbstractMotionController implements IDisposable {
  53926. protected scene: Scene;
  53927. protected layout: IMotionControllerLayout;
  53928. /**
  53929. * The gamepad object correlating to this controller
  53930. */
  53931. gamepadObject: IMinimalMotionControllerObject;
  53932. /**
  53933. * handedness (left/right/none) of this controller
  53934. */
  53935. handedness: MotionControllerHandedness;
  53936. private _initComponent;
  53937. private _modelReady;
  53938. /**
  53939. * A map of components (WebXRControllerComponent) in this motion controller
  53940. * Components have a ComponentType and can also have both button and axis definitions
  53941. */
  53942. readonly components: {
  53943. [id: string]: WebXRControllerComponent;
  53944. };
  53945. /**
  53946. * Disable the model's animation. Can be set at any time.
  53947. */
  53948. disableAnimation: boolean;
  53949. /**
  53950. * Observers registered here will be triggered when the model of this controller is done loading
  53951. */
  53952. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53953. /**
  53954. * The profile id of this motion controller
  53955. */
  53956. abstract profileId: string;
  53957. /**
  53958. * The root mesh of the model. It is null if the model was not yet initialized
  53959. */
  53960. rootMesh: Nullable<AbstractMesh>;
  53961. /**
  53962. * constructs a new abstract motion controller
  53963. * @param scene the scene to which the model of the controller will be added
  53964. * @param layout The profile layout to load
  53965. * @param gamepadObject The gamepad object correlating to this controller
  53966. * @param handedness handedness (left/right/none) of this controller
  53967. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53968. */
  53969. constructor(scene: Scene, layout: IMotionControllerLayout,
  53970. /**
  53971. * The gamepad object correlating to this controller
  53972. */
  53973. gamepadObject: IMinimalMotionControllerObject,
  53974. /**
  53975. * handedness (left/right/none) of this controller
  53976. */
  53977. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53978. /**
  53979. * Dispose this controller, the model mesh and all its components
  53980. */
  53981. dispose(): void;
  53982. /**
  53983. * Returns all components of specific type
  53984. * @param type the type to search for
  53985. * @return an array of components with this type
  53986. */
  53987. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53988. /**
  53989. * get a component based an its component id as defined in layout.components
  53990. * @param id the id of the component
  53991. * @returns the component correlates to the id or undefined if not found
  53992. */
  53993. getComponent(id: string): WebXRControllerComponent;
  53994. /**
  53995. * Get the list of components available in this motion controller
  53996. * @returns an array of strings correlating to available components
  53997. */
  53998. getComponentIds(): string[];
  53999. /**
  54000. * Get the first component of specific type
  54001. * @param type type of component to find
  54002. * @return a controller component or null if not found
  54003. */
  54004. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54005. /**
  54006. * Get the main (Select) component of this controller as defined in the layout
  54007. * @returns the main component of this controller
  54008. */
  54009. getMainComponent(): WebXRControllerComponent;
  54010. /**
  54011. * Loads the model correlating to this controller
  54012. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54013. * @returns A promise fulfilled with the result of the model loading
  54014. */
  54015. loadModel(): Promise<boolean>;
  54016. /**
  54017. * Update this model using the current XRFrame
  54018. * @param xrFrame the current xr frame to use and update the model
  54019. */
  54020. updateFromXRFrame(xrFrame: XRFrame): void;
  54021. /**
  54022. * Backwards compatibility due to a deeply-integrated typo
  54023. */
  54024. get handness(): XREye;
  54025. /**
  54026. * Pulse (vibrate) this controller
  54027. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54028. * Consecutive calls to this function will cancel the last pulse call
  54029. *
  54030. * @param value the strength of the pulse in 0.0...1.0 range
  54031. * @param duration Duration of the pulse in milliseconds
  54032. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54033. * @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
  54034. */
  54035. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54036. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54037. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54038. /**
  54039. * Moves the axis on the controller mesh based on its current state
  54040. * @param axis the index of the axis
  54041. * @param axisValue the value of the axis which determines the meshes new position
  54042. * @hidden
  54043. */
  54044. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54045. /**
  54046. * Update the model itself with the current frame data
  54047. * @param xrFrame the frame to use for updating the model mesh
  54048. */
  54049. protected updateModel(xrFrame: XRFrame): void;
  54050. /**
  54051. * Get the filename and path for this controller's model
  54052. * @returns a map of filename and path
  54053. */
  54054. protected abstract _getFilenameAndPath(): {
  54055. filename: string;
  54056. path: string;
  54057. };
  54058. /**
  54059. * This function is called before the mesh is loaded. It checks for loading constraints.
  54060. * For example, this function can check if the GLB loader is available
  54061. * If this function returns false, the generic controller will be loaded instead
  54062. * @returns Is the client ready to load the mesh
  54063. */
  54064. protected abstract _getModelLoadingConstraints(): boolean;
  54065. /**
  54066. * This function will be called after the model was successfully loaded and can be used
  54067. * for mesh transformations before it is available for the user
  54068. * @param meshes the loaded meshes
  54069. */
  54070. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54071. /**
  54072. * Set the root mesh for this controller. Important for the WebXR controller class
  54073. * @param meshes the loaded meshes
  54074. */
  54075. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54076. /**
  54077. * A function executed each frame that updates the mesh (if needed)
  54078. * @param xrFrame the current xrFrame
  54079. */
  54080. protected abstract _updateModel(xrFrame: XRFrame): void;
  54081. private _getGenericFilenameAndPath;
  54082. private _getGenericParentMesh;
  54083. }
  54084. }
  54085. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54086. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54088. import { Scene } from "babylonjs/scene";
  54089. /**
  54090. * A generic trigger-only motion controller for WebXR
  54091. */
  54092. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54093. /**
  54094. * Static version of the profile id of this controller
  54095. */
  54096. static ProfileId: string;
  54097. profileId: string;
  54098. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54099. protected _getFilenameAndPath(): {
  54100. filename: string;
  54101. path: string;
  54102. };
  54103. protected _getModelLoadingConstraints(): boolean;
  54104. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54105. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54106. protected _updateModel(): void;
  54107. }
  54108. }
  54109. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54110. import { Vector4 } from "babylonjs/Maths/math.vector";
  54111. import { Mesh } from "babylonjs/Meshes/mesh";
  54112. import { Scene } from "babylonjs/scene";
  54113. import { Nullable } from "babylonjs/types";
  54114. /**
  54115. * Class containing static functions to help procedurally build meshes
  54116. */
  54117. export class SphereBuilder {
  54118. /**
  54119. * Creates a sphere mesh
  54120. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54121. * * 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`)
  54122. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54123. * * 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
  54124. * * 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)
  54125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54128. * @param name defines the name of the mesh
  54129. * @param options defines the options used to create the mesh
  54130. * @param scene defines the hosting scene
  54131. * @returns the sphere mesh
  54132. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54133. */
  54134. static CreateSphere(name: string, options: {
  54135. segments?: number;
  54136. diameter?: number;
  54137. diameterX?: number;
  54138. diameterY?: number;
  54139. diameterZ?: number;
  54140. arc?: number;
  54141. slice?: number;
  54142. sideOrientation?: number;
  54143. frontUVs?: Vector4;
  54144. backUVs?: Vector4;
  54145. updatable?: boolean;
  54146. }, scene?: Nullable<Scene>): Mesh;
  54147. }
  54148. }
  54149. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54151. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54152. import { Scene } from "babylonjs/scene";
  54153. /**
  54154. * A profiled motion controller has its profile loaded from an online repository.
  54155. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54156. */
  54157. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54158. private _repositoryUrl;
  54159. private _buttonMeshMapping;
  54160. private _touchDots;
  54161. /**
  54162. * The profile ID of this controller. Will be populated when the controller initializes.
  54163. */
  54164. profileId: string;
  54165. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54166. dispose(): void;
  54167. protected _getFilenameAndPath(): {
  54168. filename: string;
  54169. path: string;
  54170. };
  54171. protected _getModelLoadingConstraints(): boolean;
  54172. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54173. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54174. protected _updateModel(_xrFrame: XRFrame): void;
  54175. }
  54176. }
  54177. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54178. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54179. import { Scene } from "babylonjs/scene";
  54180. /**
  54181. * A construction function type to create a new controller based on an xrInput object
  54182. */
  54183. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54184. /**
  54185. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54186. *
  54187. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54188. * it should be replaced with auto-loaded controllers.
  54189. *
  54190. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54191. */
  54192. export class WebXRMotionControllerManager {
  54193. private static _AvailableControllers;
  54194. private static _Fallbacks;
  54195. private static _ProfileLoadingPromises;
  54196. private static _ProfilesList;
  54197. /**
  54198. * The base URL of the online controller repository. Can be changed at any time.
  54199. */
  54200. static BaseRepositoryUrl: string;
  54201. /**
  54202. * Which repository gets priority - local or online
  54203. */
  54204. static PrioritizeOnlineRepository: boolean;
  54205. /**
  54206. * Use the online repository, or use only locally-defined controllers
  54207. */
  54208. static UseOnlineRepository: boolean;
  54209. /**
  54210. * Clear the cache used for profile loading and reload when requested again
  54211. */
  54212. static ClearProfilesCache(): void;
  54213. /**
  54214. * Register the default fallbacks.
  54215. * This function is called automatically when this file is imported.
  54216. */
  54217. static DefaultFallbacks(): void;
  54218. /**
  54219. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54220. * @param profileId the profile to which a fallback needs to be found
  54221. * @return an array with corresponding fallback profiles
  54222. */
  54223. static FindFallbackWithProfileId(profileId: string): string[];
  54224. /**
  54225. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54226. * The order of search:
  54227. *
  54228. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54229. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54230. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54231. * 4) return the generic trigger controller if none were found
  54232. *
  54233. * @param xrInput the xrInput to which a new controller is initialized
  54234. * @param scene the scene to which the model will be added
  54235. * @param forceProfile force a certain profile for this controller
  54236. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54237. */
  54238. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54239. /**
  54240. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54241. *
  54242. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54243. *
  54244. * @param type the profile type to register
  54245. * @param constructFunction the function to be called when loading this profile
  54246. */
  54247. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54248. /**
  54249. * Register a fallback to a specific profile.
  54250. * @param profileId the profileId that will receive the fallbacks
  54251. * @param fallbacks A list of fallback profiles
  54252. */
  54253. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54254. /**
  54255. * Will update the list of profiles available in the repository
  54256. * @return a promise that resolves to a map of profiles available online
  54257. */
  54258. static UpdateProfilesList(): Promise<{
  54259. [profile: string]: string;
  54260. }>;
  54261. private static _LoadProfileFromRepository;
  54262. private static _LoadProfilesFromAvailableControllers;
  54263. }
  54264. }
  54265. declare module "babylonjs/XR/webXRInputSource" {
  54266. import { Observable } from "babylonjs/Misc/observable";
  54267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54268. import { Ray } from "babylonjs/Culling/ray";
  54269. import { Scene } from "babylonjs/scene";
  54270. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54271. /**
  54272. * Configuration options for the WebXR controller creation
  54273. */
  54274. export interface IWebXRControllerOptions {
  54275. /**
  54276. * Should the controller mesh be animated when a user interacts with it
  54277. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54278. */
  54279. disableMotionControllerAnimation?: boolean;
  54280. /**
  54281. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54282. */
  54283. doNotLoadControllerMesh?: boolean;
  54284. /**
  54285. * Force a specific controller type for this controller.
  54286. * This can be used when creating your own profile or when testing different controllers
  54287. */
  54288. forceControllerProfile?: string;
  54289. /**
  54290. * Defines a rendering group ID for meshes that will be loaded.
  54291. * This is for the default controllers only.
  54292. */
  54293. renderingGroupId?: number;
  54294. }
  54295. /**
  54296. * Represents an XR controller
  54297. */
  54298. export class WebXRInputSource {
  54299. private _scene;
  54300. /** The underlying input source for the controller */
  54301. inputSource: XRInputSource;
  54302. private _options;
  54303. private _tmpVector;
  54304. private _uniqueId;
  54305. private _disposed;
  54306. /**
  54307. * 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
  54308. */
  54309. grip?: AbstractMesh;
  54310. /**
  54311. * If available, this is the gamepad object related to this controller.
  54312. * Using this object it is possible to get click events and trackpad changes of the
  54313. * webxr controller that is currently being used.
  54314. */
  54315. motionController?: WebXRAbstractMotionController;
  54316. /**
  54317. * Event that fires when the controller is removed/disposed.
  54318. * The object provided as event data is this controller, after associated assets were disposed.
  54319. * uniqueId is still available.
  54320. */
  54321. onDisposeObservable: Observable<WebXRInputSource>;
  54322. /**
  54323. * Will be triggered when the mesh associated with the motion controller is done loading.
  54324. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54325. * A shortened version of controller -> motion controller -> on mesh loaded.
  54326. */
  54327. onMeshLoadedObservable: Observable<AbstractMesh>;
  54328. /**
  54329. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54330. */
  54331. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54332. /**
  54333. * Pointer which can be used to select objects or attach a visible laser to
  54334. */
  54335. pointer: AbstractMesh;
  54336. /**
  54337. * Creates the input source object
  54338. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54339. * @param _scene the scene which the controller should be associated to
  54340. * @param inputSource the underlying input source for the controller
  54341. * @param _options options for this controller creation
  54342. */
  54343. constructor(_scene: Scene,
  54344. /** The underlying input source for the controller */
  54345. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54346. /**
  54347. * Get this controllers unique id
  54348. */
  54349. get uniqueId(): string;
  54350. /**
  54351. * Disposes of the object
  54352. */
  54353. dispose(): void;
  54354. /**
  54355. * Gets a world space ray coming from the pointer or grip
  54356. * @param result the resulting ray
  54357. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54358. */
  54359. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54360. /**
  54361. * Updates the controller pose based on the given XRFrame
  54362. * @param xrFrame xr frame to update the pose with
  54363. * @param referenceSpace reference space to use
  54364. */
  54365. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54366. }
  54367. }
  54368. declare module "babylonjs/XR/webXRInput" {
  54369. import { Observable } from "babylonjs/Misc/observable";
  54370. import { IDisposable } from "babylonjs/scene";
  54371. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54372. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54373. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54374. /**
  54375. * The schema for initialization options of the XR Input class
  54376. */
  54377. export interface IWebXRInputOptions {
  54378. /**
  54379. * If set to true no model will be automatically loaded
  54380. */
  54381. doNotLoadControllerMeshes?: boolean;
  54382. /**
  54383. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54384. * If not found, the xr input profile data will be used.
  54385. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54386. */
  54387. forceInputProfile?: string;
  54388. /**
  54389. * Do not send a request to the controller repository to load the profile.
  54390. *
  54391. * Instead, use the controllers available in babylon itself.
  54392. */
  54393. disableOnlineControllerRepository?: boolean;
  54394. /**
  54395. * A custom URL for the controllers repository
  54396. */
  54397. customControllersRepositoryURL?: string;
  54398. /**
  54399. * Should the controller model's components not move according to the user input
  54400. */
  54401. disableControllerAnimation?: boolean;
  54402. /**
  54403. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54404. */
  54405. controllerOptions?: IWebXRControllerOptions;
  54406. }
  54407. /**
  54408. * XR input used to track XR inputs such as controllers/rays
  54409. */
  54410. export class WebXRInput implements IDisposable {
  54411. /**
  54412. * the xr session manager for this session
  54413. */
  54414. xrSessionManager: WebXRSessionManager;
  54415. /**
  54416. * the WebXR camera for this session. Mainly used for teleportation
  54417. */
  54418. xrCamera: WebXRCamera;
  54419. private readonly options;
  54420. /**
  54421. * XR controllers being tracked
  54422. */
  54423. controllers: Array<WebXRInputSource>;
  54424. private _frameObserver;
  54425. private _sessionEndedObserver;
  54426. private _sessionInitObserver;
  54427. /**
  54428. * Event when a controller has been connected/added
  54429. */
  54430. onControllerAddedObservable: Observable<WebXRInputSource>;
  54431. /**
  54432. * Event when a controller has been removed/disconnected
  54433. */
  54434. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54435. /**
  54436. * Initializes the WebXRInput
  54437. * @param xrSessionManager the xr session manager for this session
  54438. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54439. * @param options = initialization options for this xr input
  54440. */
  54441. constructor(
  54442. /**
  54443. * the xr session manager for this session
  54444. */
  54445. xrSessionManager: WebXRSessionManager,
  54446. /**
  54447. * the WebXR camera for this session. Mainly used for teleportation
  54448. */
  54449. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54450. private _onInputSourcesChange;
  54451. private _addAndRemoveControllers;
  54452. /**
  54453. * Disposes of the object
  54454. */
  54455. dispose(): void;
  54456. }
  54457. }
  54458. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54459. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54460. import { Observable, EventState } from "babylonjs/Misc/observable";
  54461. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54462. /**
  54463. * This is the base class for all WebXR features.
  54464. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54465. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54466. */
  54467. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54468. protected _xrSessionManager: WebXRSessionManager;
  54469. private _attached;
  54470. private _removeOnDetach;
  54471. /**
  54472. * Is this feature disposed?
  54473. */
  54474. isDisposed: boolean;
  54475. /**
  54476. * Should auto-attach be disabled?
  54477. */
  54478. disableAutoAttach: boolean;
  54479. /**
  54480. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54481. */
  54482. xrNativeFeatureName: string;
  54483. /**
  54484. * Construct a new (abstract) WebXR feature
  54485. * @param _xrSessionManager the xr session manager for this feature
  54486. */
  54487. constructor(_xrSessionManager: WebXRSessionManager);
  54488. /**
  54489. * Is this feature attached
  54490. */
  54491. get attached(): boolean;
  54492. /**
  54493. * attach this feature
  54494. *
  54495. * @param force should attachment be forced (even when already attached)
  54496. * @returns true if successful, false is failed or already attached
  54497. */
  54498. attach(force?: boolean): boolean;
  54499. /**
  54500. * detach this feature.
  54501. *
  54502. * @returns true if successful, false if failed or already detached
  54503. */
  54504. detach(): boolean;
  54505. /**
  54506. * Dispose this feature and all of the resources attached
  54507. */
  54508. dispose(): void;
  54509. /**
  54510. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54511. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54512. *
  54513. * @returns whether or not the feature is compatible in this environment
  54514. */
  54515. isCompatible(): boolean;
  54516. /**
  54517. * This is used to register callbacks that will automatically be removed when detach is called.
  54518. * @param observable the observable to which the observer will be attached
  54519. * @param callback the callback to register
  54520. */
  54521. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54522. /**
  54523. * Code in this function will be executed on each xrFrame received from the browser.
  54524. * This function will not execute after the feature is detached.
  54525. * @param _xrFrame the current frame
  54526. */
  54527. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54528. }
  54529. }
  54530. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54531. import { IDisposable, Scene } from "babylonjs/scene";
  54532. import { Nullable } from "babylonjs/types";
  54533. import { Observable } from "babylonjs/Misc/observable";
  54534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54535. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54536. import { Camera } from "babylonjs/Cameras/camera";
  54537. /**
  54538. * Renders a layer on top of an existing scene
  54539. */
  54540. export class UtilityLayerRenderer implements IDisposable {
  54541. /** the original scene that will be rendered on top of */
  54542. originalScene: Scene;
  54543. private _pointerCaptures;
  54544. private _lastPointerEvents;
  54545. private static _DefaultUtilityLayer;
  54546. private static _DefaultKeepDepthUtilityLayer;
  54547. private _sharedGizmoLight;
  54548. private _renderCamera;
  54549. /**
  54550. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54551. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54552. * @returns the camera that is used when rendering the utility layer
  54553. */
  54554. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54555. /**
  54556. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54557. * @param cam the camera that should be used when rendering the utility layer
  54558. */
  54559. setRenderCamera(cam: Nullable<Camera>): void;
  54560. /**
  54561. * @hidden
  54562. * Light which used by gizmos to get light shading
  54563. */
  54564. _getSharedGizmoLight(): HemisphericLight;
  54565. /**
  54566. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54567. */
  54568. pickUtilitySceneFirst: boolean;
  54569. /**
  54570. * 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)
  54571. */
  54572. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54573. /**
  54574. * 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)
  54575. */
  54576. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54577. /**
  54578. * The scene that is rendered on top of the original scene
  54579. */
  54580. utilityLayerScene: Scene;
  54581. /**
  54582. * If the utility layer should automatically be rendered on top of existing scene
  54583. */
  54584. shouldRender: boolean;
  54585. /**
  54586. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54587. */
  54588. onlyCheckPointerDownEvents: boolean;
  54589. /**
  54590. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54591. */
  54592. processAllEvents: boolean;
  54593. /**
  54594. * Observable raised when the pointer move from the utility layer scene to the main scene
  54595. */
  54596. onPointerOutObservable: Observable<number>;
  54597. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54598. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54599. private _afterRenderObserver;
  54600. private _sceneDisposeObserver;
  54601. private _originalPointerObserver;
  54602. /**
  54603. * Instantiates a UtilityLayerRenderer
  54604. * @param originalScene the original scene that will be rendered on top of
  54605. * @param handleEvents boolean indicating if the utility layer should handle events
  54606. */
  54607. constructor(
  54608. /** the original scene that will be rendered on top of */
  54609. originalScene: Scene, handleEvents?: boolean);
  54610. private _notifyObservers;
  54611. /**
  54612. * Renders the utility layers scene on top of the original scene
  54613. */
  54614. render(): void;
  54615. /**
  54616. * Disposes of the renderer
  54617. */
  54618. dispose(): void;
  54619. private _updateCamera;
  54620. }
  54621. }
  54622. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54623. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54625. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54626. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54627. import { Scene } from "babylonjs/scene";
  54628. import { Nullable } from "babylonjs/types";
  54629. import { Color3 } from "babylonjs/Maths/math.color";
  54630. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54631. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54632. /**
  54633. * Options interface for the pointer selection module
  54634. */
  54635. export interface IWebXRControllerPointerSelectionOptions {
  54636. /**
  54637. * if provided, this scene will be used to render meshes.
  54638. */
  54639. customUtilityLayerScene?: Scene;
  54640. /**
  54641. * 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)
  54642. * If not disabled, the last picked point will be used to execute a pointer up event
  54643. * If disabled, pointer up event will be triggered right after the pointer down event.
  54644. * Used in screen and gaze target ray mode only
  54645. */
  54646. disablePointerUpOnTouchOut: boolean;
  54647. /**
  54648. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54649. */
  54650. forceGazeMode: boolean;
  54651. /**
  54652. * 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
  54653. * to start a new countdown to the pointer down event.
  54654. * Defaults to 1.
  54655. */
  54656. gazeModePointerMovedFactor?: number;
  54657. /**
  54658. * Different button type to use instead of the main component
  54659. */
  54660. overrideButtonId?: string;
  54661. /**
  54662. * use this rendering group id for the meshes (optional)
  54663. */
  54664. renderingGroupId?: number;
  54665. /**
  54666. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54667. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54668. * 3000 means 3 seconds between pointing at something and selecting it
  54669. */
  54670. timeToSelect?: number;
  54671. /**
  54672. * Should meshes created here be added to a utility layer or the main scene
  54673. */
  54674. useUtilityLayer?: boolean;
  54675. /**
  54676. * Optional WebXR camera to be used for gaze selection
  54677. */
  54678. gazeCamera?: WebXRCamera;
  54679. /**
  54680. * the xr input to use with this pointer selection
  54681. */
  54682. xrInput: WebXRInput;
  54683. /**
  54684. * Should the scene pointerX and pointerY update be disabled
  54685. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54686. * Disable in VR, if not needed.
  54687. * The first rig camera (left eye) will be used to calculate the projection
  54688. */
  54689. disableScenePointerVectorUpdate: boolean;
  54690. /**
  54691. * Enable pointer selection on all controllers instead of switching between them
  54692. */
  54693. enablePointerSelectionOnAllControllers?: boolean;
  54694. /**
  54695. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54696. * If switch is enabled, it will still allow the user to switch between the different controllers
  54697. */
  54698. preferredHandedness?: XRHandedness;
  54699. /**
  54700. * Disable switching the pointer selection from one controller to the other.
  54701. * 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
  54702. */
  54703. disableSwitchOnClick?: boolean;
  54704. /**
  54705. * The maximum distance of the pointer selection feature. Defaults to 100.
  54706. */
  54707. maxPointerDistance?: number;
  54708. }
  54709. /**
  54710. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54711. */
  54712. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54713. private readonly _options;
  54714. private static _idCounter;
  54715. private _attachController;
  54716. private _controllers;
  54717. private _scene;
  54718. private _tmpVectorForPickCompare;
  54719. private _attachedController;
  54720. /**
  54721. * The module's name
  54722. */
  54723. static readonly Name: string;
  54724. /**
  54725. * The (Babylon) version of this module.
  54726. * This is an integer representing the implementation version.
  54727. * This number does not correspond to the WebXR specs version
  54728. */
  54729. static readonly Version: number;
  54730. /**
  54731. * Disable lighting on the laser pointer (so it will always be visible)
  54732. */
  54733. disablePointerLighting: boolean;
  54734. /**
  54735. * Disable lighting on the selection mesh (so it will always be visible)
  54736. */
  54737. disableSelectionMeshLighting: boolean;
  54738. /**
  54739. * Should the laser pointer be displayed
  54740. */
  54741. displayLaserPointer: boolean;
  54742. /**
  54743. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54744. */
  54745. displaySelectionMesh: boolean;
  54746. /**
  54747. * This color will be set to the laser pointer when selection is triggered
  54748. */
  54749. laserPointerPickedColor: Color3;
  54750. /**
  54751. * Default color of the laser pointer
  54752. */
  54753. laserPointerDefaultColor: Color3;
  54754. /**
  54755. * default color of the selection ring
  54756. */
  54757. selectionMeshDefaultColor: Color3;
  54758. /**
  54759. * This color will be applied to the selection ring when selection is triggered
  54760. */
  54761. selectionMeshPickedColor: Color3;
  54762. /**
  54763. * Optional filter to be used for ray selection. This predicate shares behavior with
  54764. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54765. */
  54766. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54767. /**
  54768. * constructs a new background remover module
  54769. * @param _xrSessionManager the session manager for this module
  54770. * @param _options read-only options to be used in this module
  54771. */
  54772. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54773. /**
  54774. * attach this feature
  54775. * Will usually be called by the features manager
  54776. *
  54777. * @returns true if successful.
  54778. */
  54779. attach(): boolean;
  54780. /**
  54781. * detach this feature.
  54782. * Will usually be called by the features manager
  54783. *
  54784. * @returns true if successful.
  54785. */
  54786. detach(): boolean;
  54787. /**
  54788. * Will get the mesh under a specific pointer.
  54789. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54790. * @param controllerId the controllerId to check
  54791. * @returns The mesh under pointer or null if no mesh is under the pointer
  54792. */
  54793. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54794. /**
  54795. * Get the xr controller that correlates to the pointer id in the pointer event
  54796. *
  54797. * @param id the pointer id to search for
  54798. * @returns the controller that correlates to this id or null if not found
  54799. */
  54800. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54801. private _identityMatrix;
  54802. private _screenCoordinatesRef;
  54803. private _viewportRef;
  54804. protected _onXRFrame(_xrFrame: XRFrame): void;
  54805. private _attachGazeMode;
  54806. private _attachScreenRayMode;
  54807. private _attachTrackedPointerRayMode;
  54808. private _convertNormalToDirectionOfRay;
  54809. private _detachController;
  54810. private _generateNewMeshPair;
  54811. private _pickingMoved;
  54812. private _updatePointerDistance;
  54813. /** @hidden */
  54814. get lasterPointerDefaultColor(): Color3;
  54815. }
  54816. }
  54817. declare module "babylonjs/XR/webXREnterExitUI" {
  54818. import { Nullable } from "babylonjs/types";
  54819. import { Observable } from "babylonjs/Misc/observable";
  54820. import { IDisposable, Scene } from "babylonjs/scene";
  54821. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54822. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54823. /**
  54824. * Button which can be used to enter a different mode of XR
  54825. */
  54826. export class WebXREnterExitUIButton {
  54827. /** button element */
  54828. element: HTMLElement;
  54829. /** XR initialization options for the button */
  54830. sessionMode: XRSessionMode;
  54831. /** Reference space type */
  54832. referenceSpaceType: XRReferenceSpaceType;
  54833. /**
  54834. * Creates a WebXREnterExitUIButton
  54835. * @param element button element
  54836. * @param sessionMode XR initialization session mode
  54837. * @param referenceSpaceType the type of reference space to be used
  54838. */
  54839. constructor(
  54840. /** button element */
  54841. element: HTMLElement,
  54842. /** XR initialization options for the button */
  54843. sessionMode: XRSessionMode,
  54844. /** Reference space type */
  54845. referenceSpaceType: XRReferenceSpaceType);
  54846. /**
  54847. * Extendable function which can be used to update the button's visuals when the state changes
  54848. * @param activeButton the current active button in the UI
  54849. */
  54850. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54851. }
  54852. /**
  54853. * Options to create the webXR UI
  54854. */
  54855. export class WebXREnterExitUIOptions {
  54856. /**
  54857. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54858. */
  54859. customButtons?: Array<WebXREnterExitUIButton>;
  54860. /**
  54861. * A reference space type to use when creating the default button.
  54862. * Default is local-floor
  54863. */
  54864. referenceSpaceType?: XRReferenceSpaceType;
  54865. /**
  54866. * Context to enter xr with
  54867. */
  54868. renderTarget?: Nullable<WebXRRenderTarget>;
  54869. /**
  54870. * A session mode to use when creating the default button.
  54871. * Default is immersive-vr
  54872. */
  54873. sessionMode?: XRSessionMode;
  54874. /**
  54875. * A list of optional features to init the session with
  54876. */
  54877. optionalFeatures?: string[];
  54878. /**
  54879. * A list of optional features to init the session with
  54880. */
  54881. requiredFeatures?: string[];
  54882. /**
  54883. * If defined, this function will be executed if the UI encounters an error when entering XR
  54884. */
  54885. onError?: (error: any) => void;
  54886. }
  54887. /**
  54888. * UI to allow the user to enter/exit XR mode
  54889. */
  54890. export class WebXREnterExitUI implements IDisposable {
  54891. private scene;
  54892. /** version of the options passed to this UI */
  54893. options: WebXREnterExitUIOptions;
  54894. private _activeButton;
  54895. private _buttons;
  54896. /**
  54897. * The HTML Div Element to which buttons are added.
  54898. */
  54899. readonly overlay: HTMLDivElement;
  54900. /**
  54901. * Fired every time the active button is changed.
  54902. *
  54903. * When xr is entered via a button that launches xr that button will be the callback parameter
  54904. *
  54905. * When exiting xr the callback parameter will be null)
  54906. */
  54907. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54908. /**
  54909. *
  54910. * @param scene babylon scene object to use
  54911. * @param options (read-only) version of the options passed to this UI
  54912. */
  54913. private constructor();
  54914. /**
  54915. * Creates UI to allow the user to enter/exit XR mode
  54916. * @param scene the scene to add the ui to
  54917. * @param helper the xr experience helper to enter/exit xr with
  54918. * @param options options to configure the UI
  54919. * @returns the created ui
  54920. */
  54921. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54922. /**
  54923. * Disposes of the XR UI component
  54924. */
  54925. dispose(): void;
  54926. private _updateButtons;
  54927. }
  54928. }
  54929. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54930. import { Vector3 } from "babylonjs/Maths/math.vector";
  54931. import { Color4 } from "babylonjs/Maths/math.color";
  54932. import { Nullable } from "babylonjs/types";
  54933. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54934. import { Scene } from "babylonjs/scene";
  54935. /**
  54936. * Class containing static functions to help procedurally build meshes
  54937. */
  54938. export class LinesBuilder {
  54939. /**
  54940. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54941. * * 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
  54942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54943. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54944. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54945. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54946. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54947. * * 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
  54948. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54951. * @param name defines the name of the new line system
  54952. * @param options defines the options used to create the line system
  54953. * @param scene defines the hosting scene
  54954. * @returns a new line system mesh
  54955. */
  54956. static CreateLineSystem(name: string, options: {
  54957. lines: Vector3[][];
  54958. updatable?: boolean;
  54959. instance?: Nullable<LinesMesh>;
  54960. colors?: Nullable<Color4[][]>;
  54961. useVertexAlpha?: boolean;
  54962. }, scene: Nullable<Scene>): LinesMesh;
  54963. /**
  54964. * Creates a line mesh
  54965. * 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
  54966. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54967. * * The parameter `points` is an array successive Vector3
  54968. * * 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
  54969. * * The optional parameter `colors` is 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 alpha blending (faster)
  54971. * * When updating an instance, remember that only point positions can change, not the number of points
  54972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54974. * @param name defines the name of the new line system
  54975. * @param options defines the options used to create the line system
  54976. * @param scene defines the hosting scene
  54977. * @returns a new line mesh
  54978. */
  54979. static CreateLines(name: string, options: {
  54980. points: Vector3[];
  54981. updatable?: boolean;
  54982. instance?: Nullable<LinesMesh>;
  54983. colors?: Color4[];
  54984. useVertexAlpha?: boolean;
  54985. }, scene?: Nullable<Scene>): LinesMesh;
  54986. /**
  54987. * Creates a dashed line mesh
  54988. * * 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
  54989. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54990. * * The parameter `points` is an array successive Vector3
  54991. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54992. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54993. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54994. * * 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
  54995. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54996. * * When updating an instance, remember that only point positions can change, not the number of points
  54997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54998. * @param name defines the name of the mesh
  54999. * @param options defines the options used to create the mesh
  55000. * @param scene defines the hosting scene
  55001. * @returns the dashed line mesh
  55002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55003. */
  55004. static CreateDashedLines(name: string, options: {
  55005. points: Vector3[];
  55006. dashSize?: number;
  55007. gapSize?: number;
  55008. dashNb?: number;
  55009. updatable?: boolean;
  55010. instance?: LinesMesh;
  55011. useVertexAlpha?: boolean;
  55012. }, scene?: Nullable<Scene>): LinesMesh;
  55013. }
  55014. }
  55015. declare module "babylonjs/Misc/timer" {
  55016. import { Observable, Observer } from "babylonjs/Misc/observable";
  55017. import { Nullable } from "babylonjs/types";
  55018. import { IDisposable } from "babylonjs/scene";
  55019. /**
  55020. * Construction options for a timer
  55021. */
  55022. export interface ITimerOptions<T> {
  55023. /**
  55024. * Time-to-end
  55025. */
  55026. timeout: number;
  55027. /**
  55028. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55029. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55030. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55031. */
  55032. contextObservable: Observable<T>;
  55033. /**
  55034. * Optional parameters when adding an observer to the observable
  55035. */
  55036. observableParameters?: {
  55037. mask?: number;
  55038. insertFirst?: boolean;
  55039. scope?: any;
  55040. };
  55041. /**
  55042. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55043. */
  55044. breakCondition?: (data?: ITimerData<T>) => boolean;
  55045. /**
  55046. * Will be triggered when the time condition has met
  55047. */
  55048. onEnded?: (data: ITimerData<any>) => void;
  55049. /**
  55050. * Will be triggered when the break condition has met (prematurely ended)
  55051. */
  55052. onAborted?: (data: ITimerData<any>) => void;
  55053. /**
  55054. * Optional function to execute on each tick (or count)
  55055. */
  55056. onTick?: (data: ITimerData<any>) => void;
  55057. }
  55058. /**
  55059. * An interface defining the data sent by the timer
  55060. */
  55061. export interface ITimerData<T> {
  55062. /**
  55063. * When did it start
  55064. */
  55065. startTime: number;
  55066. /**
  55067. * Time now
  55068. */
  55069. currentTime: number;
  55070. /**
  55071. * Time passed since started
  55072. */
  55073. deltaTime: number;
  55074. /**
  55075. * How much is completed, in [0.0...1.0].
  55076. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55077. */
  55078. completeRate: number;
  55079. /**
  55080. * What the registered observable sent in the last count
  55081. */
  55082. payload: T;
  55083. }
  55084. /**
  55085. * The current state of the timer
  55086. */
  55087. export enum TimerState {
  55088. /**
  55089. * Timer initialized, not yet started
  55090. */
  55091. INIT = 0,
  55092. /**
  55093. * Timer started and counting
  55094. */
  55095. STARTED = 1,
  55096. /**
  55097. * Timer ended (whether aborted or time reached)
  55098. */
  55099. ENDED = 2
  55100. }
  55101. /**
  55102. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55103. *
  55104. * @param options options with which to initialize this timer
  55105. */
  55106. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55107. /**
  55108. * An advanced implementation of a timer class
  55109. */
  55110. export class AdvancedTimer<T = any> implements IDisposable {
  55111. /**
  55112. * Will notify each time the timer calculates the remaining time
  55113. */
  55114. onEachCountObservable: Observable<ITimerData<T>>;
  55115. /**
  55116. * Will trigger when the timer was aborted due to the break condition
  55117. */
  55118. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55119. /**
  55120. * Will trigger when the timer ended successfully
  55121. */
  55122. onTimerEndedObservable: Observable<ITimerData<T>>;
  55123. /**
  55124. * Will trigger when the timer state has changed
  55125. */
  55126. onStateChangedObservable: Observable<TimerState>;
  55127. private _observer;
  55128. private _contextObservable;
  55129. private _observableParameters;
  55130. private _startTime;
  55131. private _timer;
  55132. private _state;
  55133. private _breakCondition;
  55134. private _timeToEnd;
  55135. private _breakOnNextTick;
  55136. /**
  55137. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55138. * @param options construction options for this advanced timer
  55139. */
  55140. constructor(options: ITimerOptions<T>);
  55141. /**
  55142. * set a breaking condition for this timer. Default is to never break during count
  55143. * @param predicate the new break condition. Returns true to break, false otherwise
  55144. */
  55145. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55146. /**
  55147. * Reset ALL associated observables in this advanced timer
  55148. */
  55149. clearObservables(): void;
  55150. /**
  55151. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55152. *
  55153. * @param timeToEnd how much time to measure until timer ended
  55154. */
  55155. start(timeToEnd?: number): void;
  55156. /**
  55157. * Will force a stop on the next tick.
  55158. */
  55159. stop(): void;
  55160. /**
  55161. * Dispose this timer, clearing all resources
  55162. */
  55163. dispose(): void;
  55164. private _setState;
  55165. private _tick;
  55166. private _stop;
  55167. }
  55168. }
  55169. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55170. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55171. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55172. import { Nullable } from "babylonjs/types";
  55173. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55175. import { Vector3 } from "babylonjs/Maths/math.vector";
  55176. import { Material } from "babylonjs/Materials/material";
  55177. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55178. import { Scene } from "babylonjs/scene";
  55179. /**
  55180. * The options container for the teleportation module
  55181. */
  55182. export interface IWebXRTeleportationOptions {
  55183. /**
  55184. * if provided, this scene will be used to render meshes.
  55185. */
  55186. customUtilityLayerScene?: Scene;
  55187. /**
  55188. * Values to configure the default target mesh
  55189. */
  55190. defaultTargetMeshOptions?: {
  55191. /**
  55192. * Fill color of the teleportation area
  55193. */
  55194. teleportationFillColor?: string;
  55195. /**
  55196. * Border color for the teleportation area
  55197. */
  55198. teleportationBorderColor?: string;
  55199. /**
  55200. * Disable the mesh's animation sequence
  55201. */
  55202. disableAnimation?: boolean;
  55203. /**
  55204. * Disable lighting on the material or the ring and arrow
  55205. */
  55206. disableLighting?: boolean;
  55207. /**
  55208. * Override the default material of the torus and arrow
  55209. */
  55210. torusArrowMaterial?: Material;
  55211. };
  55212. /**
  55213. * A list of meshes to use as floor meshes.
  55214. * Meshes can be added and removed after initializing the feature using the
  55215. * addFloorMesh and removeFloorMesh functions
  55216. * If empty, rotation will still work
  55217. */
  55218. floorMeshes?: AbstractMesh[];
  55219. /**
  55220. * use this rendering group id for the meshes (optional)
  55221. */
  55222. renderingGroupId?: number;
  55223. /**
  55224. * Should teleportation move only to snap points
  55225. */
  55226. snapPointsOnly?: boolean;
  55227. /**
  55228. * An array of points to which the teleportation will snap to.
  55229. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55230. */
  55231. snapPositions?: Vector3[];
  55232. /**
  55233. * How close should the teleportation ray be in order to snap to position.
  55234. * Default to 0.8 units (meters)
  55235. */
  55236. snapToPositionRadius?: number;
  55237. /**
  55238. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55239. * If you want to support rotation, make sure your mesh has a direction indicator.
  55240. *
  55241. * When left untouched, the default mesh will be initialized.
  55242. */
  55243. teleportationTargetMesh?: AbstractMesh;
  55244. /**
  55245. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55246. */
  55247. timeToTeleport?: number;
  55248. /**
  55249. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55250. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55251. */
  55252. useMainComponentOnly?: boolean;
  55253. /**
  55254. * Should meshes created here be added to a utility layer or the main scene
  55255. */
  55256. useUtilityLayer?: boolean;
  55257. /**
  55258. * Babylon XR Input class for controller
  55259. */
  55260. xrInput: WebXRInput;
  55261. /**
  55262. * Meshes that the teleportation ray cannot go through
  55263. */
  55264. pickBlockerMeshes?: AbstractMesh[];
  55265. /**
  55266. * Should teleport work only on a specific hand?
  55267. */
  55268. forceHandedness?: XRHandedness;
  55269. /**
  55270. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55271. */
  55272. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55273. }
  55274. /**
  55275. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55276. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55277. * the input of the attached controllers.
  55278. */
  55279. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55280. private _options;
  55281. private _controllers;
  55282. private _currentTeleportationControllerId;
  55283. private _floorMeshes;
  55284. private _quadraticBezierCurve;
  55285. private _selectionFeature;
  55286. private _snapToPositions;
  55287. private _snappedToPoint;
  55288. private _teleportationRingMaterial?;
  55289. private _tmpRay;
  55290. private _tmpVector;
  55291. private _tmpQuaternion;
  55292. /**
  55293. * The module's name
  55294. */
  55295. static readonly Name: string;
  55296. /**
  55297. * The (Babylon) version of this module.
  55298. * This is an integer representing the implementation version.
  55299. * This number does not correspond to the webxr specs version
  55300. */
  55301. static readonly Version: number;
  55302. /**
  55303. * Is movement backwards enabled
  55304. */
  55305. backwardsMovementEnabled: boolean;
  55306. /**
  55307. * Distance to travel when moving backwards
  55308. */
  55309. backwardsTeleportationDistance: number;
  55310. /**
  55311. * The distance from the user to the inspection point in the direction of the controller
  55312. * A higher number will allow the user to move further
  55313. * defaults to 5 (meters, in xr units)
  55314. */
  55315. parabolicCheckRadius: number;
  55316. /**
  55317. * Should the module support parabolic ray on top of direct ray
  55318. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55319. * Very helpful when moving between floors / different heights
  55320. */
  55321. parabolicRayEnabled: boolean;
  55322. /**
  55323. * The second type of ray - straight line.
  55324. * Should it be enabled or should the parabolic line be the only one.
  55325. */
  55326. straightRayEnabled: boolean;
  55327. /**
  55328. * How much rotation should be applied when rotating right and left
  55329. */
  55330. rotationAngle: number;
  55331. private _rotationEnabled;
  55332. /**
  55333. * Is rotation enabled when moving forward?
  55334. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55335. */
  55336. get rotationEnabled(): boolean;
  55337. /**
  55338. * Sets wether rotation is enabled or not
  55339. * @param enabled is rotation enabled when teleportation is shown
  55340. */
  55341. set rotationEnabled(enabled: boolean);
  55342. /**
  55343. * Exposes the currently set teleportation target mesh.
  55344. */
  55345. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55346. /**
  55347. * constructs a new anchor system
  55348. * @param _xrSessionManager an instance of WebXRSessionManager
  55349. * @param _options configuration object for this feature
  55350. */
  55351. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55352. /**
  55353. * Get the snapPointsOnly flag
  55354. */
  55355. get snapPointsOnly(): boolean;
  55356. /**
  55357. * Sets the snapPointsOnly flag
  55358. * @param snapToPoints should teleportation be exclusively to snap points
  55359. */
  55360. set snapPointsOnly(snapToPoints: boolean);
  55361. /**
  55362. * Add a new mesh to the floor meshes array
  55363. * @param mesh the mesh to use as floor mesh
  55364. */
  55365. addFloorMesh(mesh: AbstractMesh): void;
  55366. /**
  55367. * Add a new snap-to point to fix teleportation to this position
  55368. * @param newSnapPoint The new Snap-To point
  55369. */
  55370. addSnapPoint(newSnapPoint: Vector3): void;
  55371. attach(): boolean;
  55372. detach(): boolean;
  55373. dispose(): void;
  55374. /**
  55375. * Remove a mesh from the floor meshes array
  55376. * @param mesh the mesh to remove
  55377. */
  55378. removeFloorMesh(mesh: AbstractMesh): void;
  55379. /**
  55380. * Remove a mesh from the floor meshes array using its name
  55381. * @param name the mesh name to remove
  55382. */
  55383. removeFloorMeshByName(name: string): void;
  55384. /**
  55385. * 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
  55386. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55387. * @returns was the point found and removed or not
  55388. */
  55389. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55390. /**
  55391. * This function sets a selection feature that will be disabled when
  55392. * the forward ray is shown and will be reattached when hidden.
  55393. * This is used to remove the selection rays when moving.
  55394. * @param selectionFeature the feature to disable when forward movement is enabled
  55395. */
  55396. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55397. protected _onXRFrame(_xrFrame: XRFrame): void;
  55398. private _attachController;
  55399. private _createDefaultTargetMesh;
  55400. private _detachController;
  55401. private _findClosestSnapPointWithRadius;
  55402. private _setTargetMeshPosition;
  55403. private _setTargetMeshVisibility;
  55404. private _showParabolicPath;
  55405. private _teleportForward;
  55406. }
  55407. }
  55408. declare module "babylonjs/XR/webXRDefaultExperience" {
  55409. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55410. import { Scene } from "babylonjs/scene";
  55411. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55412. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55413. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55414. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55416. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55417. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55418. /**
  55419. * Options for the default xr helper
  55420. */
  55421. export class WebXRDefaultExperienceOptions {
  55422. /**
  55423. * Enable or disable default UI to enter XR
  55424. */
  55425. disableDefaultUI?: boolean;
  55426. /**
  55427. * Should teleportation not initialize. defaults to false.
  55428. */
  55429. disableTeleportation?: boolean;
  55430. /**
  55431. * Floor meshes that will be used for teleport
  55432. */
  55433. floorMeshes?: Array<AbstractMesh>;
  55434. /**
  55435. * If set to true, the first frame will not be used to reset position
  55436. * The first frame is mainly used when copying transformation from the old camera
  55437. * Mainly used in AR
  55438. */
  55439. ignoreNativeCameraTransformation?: boolean;
  55440. /**
  55441. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55442. */
  55443. inputOptions?: IWebXRInputOptions;
  55444. /**
  55445. * optional configuration for the output canvas
  55446. */
  55447. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55448. /**
  55449. * optional UI options. This can be used among other to change session mode and reference space type
  55450. */
  55451. uiOptions?: WebXREnterExitUIOptions;
  55452. /**
  55453. * When loading teleportation and pointer select, use stable versions instead of latest.
  55454. */
  55455. useStablePlugins?: boolean;
  55456. /**
  55457. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55458. */
  55459. renderingGroupId?: number;
  55460. /**
  55461. * A list of optional features to init the session with
  55462. * If set to true, all features we support will be added
  55463. */
  55464. optionalFeatures?: boolean | string[];
  55465. }
  55466. /**
  55467. * Default experience which provides a similar setup to the previous webVRExperience
  55468. */
  55469. export class WebXRDefaultExperience {
  55470. /**
  55471. * Base experience
  55472. */
  55473. baseExperience: WebXRExperienceHelper;
  55474. /**
  55475. * Enables ui for entering/exiting xr
  55476. */
  55477. enterExitUI: WebXREnterExitUI;
  55478. /**
  55479. * Input experience extension
  55480. */
  55481. input: WebXRInput;
  55482. /**
  55483. * Enables laser pointer and selection
  55484. */
  55485. pointerSelection: WebXRControllerPointerSelection;
  55486. /**
  55487. * Default target xr should render to
  55488. */
  55489. renderTarget: WebXRRenderTarget;
  55490. /**
  55491. * Enables teleportation
  55492. */
  55493. teleportation: WebXRMotionControllerTeleportation;
  55494. private constructor();
  55495. /**
  55496. * Creates the default xr experience
  55497. * @param scene scene
  55498. * @param options options for basic configuration
  55499. * @returns resulting WebXRDefaultExperience
  55500. */
  55501. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55502. /**
  55503. * DIsposes of the experience helper
  55504. */
  55505. dispose(): void;
  55506. }
  55507. }
  55508. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55509. import { Observable } from "babylonjs/Misc/observable";
  55510. import { Nullable } from "babylonjs/types";
  55511. import { Camera } from "babylonjs/Cameras/camera";
  55512. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55513. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55514. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55515. import { Scene } from "babylonjs/scene";
  55516. import { Vector3 } from "babylonjs/Maths/math.vector";
  55517. import { Color3 } from "babylonjs/Maths/math.color";
  55518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55520. import { Mesh } from "babylonjs/Meshes/mesh";
  55521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55522. import { EasingFunction } from "babylonjs/Animations/easing";
  55523. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55524. import "babylonjs/Meshes/Builders/groundBuilder";
  55525. import "babylonjs/Meshes/Builders/torusBuilder";
  55526. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55527. import "babylonjs/Gamepads/gamepadSceneComponent";
  55528. import "babylonjs/Animations/animatable";
  55529. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55530. /**
  55531. * Options to modify the vr teleportation behavior.
  55532. */
  55533. export interface VRTeleportationOptions {
  55534. /**
  55535. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55536. */
  55537. floorMeshName?: string;
  55538. /**
  55539. * A list of meshes to be used as the teleportation floor. (default: empty)
  55540. */
  55541. floorMeshes?: Mesh[];
  55542. /**
  55543. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55544. */
  55545. teleportationMode?: number;
  55546. /**
  55547. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55548. */
  55549. teleportationTime?: number;
  55550. /**
  55551. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55552. */
  55553. teleportationSpeed?: number;
  55554. /**
  55555. * The easing function used in the animation or null for Linear. (default CircleEase)
  55556. */
  55557. easingFunction?: EasingFunction;
  55558. }
  55559. /**
  55560. * Options to modify the vr experience helper's behavior.
  55561. */
  55562. export interface VRExperienceHelperOptions extends WebVROptions {
  55563. /**
  55564. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55565. */
  55566. createDeviceOrientationCamera?: boolean;
  55567. /**
  55568. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55569. */
  55570. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55571. /**
  55572. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55573. */
  55574. laserToggle?: boolean;
  55575. /**
  55576. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55577. */
  55578. floorMeshes?: Mesh[];
  55579. /**
  55580. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55581. */
  55582. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55583. /**
  55584. * Defines if WebXR should be used instead of WebVR (if available)
  55585. */
  55586. useXR?: boolean;
  55587. }
  55588. /**
  55589. * Event containing information after VR has been entered
  55590. */
  55591. export class OnAfterEnteringVRObservableEvent {
  55592. /**
  55593. * If entering vr was successful
  55594. */
  55595. success: boolean;
  55596. }
  55597. /**
  55598. * Helps to quickly add VR support to an existing scene.
  55599. * See https://doc.babylonjs.com/how_to/webvr_helper
  55600. */
  55601. export class VRExperienceHelper {
  55602. /** Options to modify the vr experience helper's behavior. */
  55603. webVROptions: VRExperienceHelperOptions;
  55604. private _scene;
  55605. private _position;
  55606. private _btnVR;
  55607. private _btnVRDisplayed;
  55608. private _webVRsupported;
  55609. private _webVRready;
  55610. private _webVRrequesting;
  55611. private _webVRpresenting;
  55612. private _hasEnteredVR;
  55613. private _fullscreenVRpresenting;
  55614. private _inputElement;
  55615. private _webVRCamera;
  55616. private _vrDeviceOrientationCamera;
  55617. private _deviceOrientationCamera;
  55618. private _existingCamera;
  55619. private _onKeyDown;
  55620. private _onVrDisplayPresentChange;
  55621. private _onVRDisplayChanged;
  55622. private _onVRRequestPresentStart;
  55623. private _onVRRequestPresentComplete;
  55624. /**
  55625. * 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)
  55626. */
  55627. enableGazeEvenWhenNoPointerLock: boolean;
  55628. /**
  55629. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55630. */
  55631. exitVROnDoubleTap: boolean;
  55632. /**
  55633. * Observable raised right before entering VR.
  55634. */
  55635. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55636. /**
  55637. * Observable raised when entering VR has completed.
  55638. */
  55639. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55640. /**
  55641. * Observable raised when exiting VR.
  55642. */
  55643. onExitingVRObservable: Observable<VRExperienceHelper>;
  55644. /**
  55645. * Observable raised when controller mesh is loaded.
  55646. */
  55647. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55648. /** Return this.onEnteringVRObservable
  55649. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55650. */
  55651. get onEnteringVR(): Observable<VRExperienceHelper>;
  55652. /** Return this.onExitingVRObservable
  55653. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55654. */
  55655. get onExitingVR(): Observable<VRExperienceHelper>;
  55656. /** Return this.onControllerMeshLoadedObservable
  55657. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55658. */
  55659. get onControllerMeshLoaded(): Observable<WebVRController>;
  55660. private _rayLength;
  55661. private _useCustomVRButton;
  55662. private _teleportationRequested;
  55663. private _teleportActive;
  55664. private _floorMeshName;
  55665. private _floorMeshesCollection;
  55666. private _teleportationMode;
  55667. private _teleportationTime;
  55668. private _teleportationSpeed;
  55669. private _teleportationEasing;
  55670. private _rotationAllowed;
  55671. private _teleportBackwardsVector;
  55672. private _teleportationTarget;
  55673. private _isDefaultTeleportationTarget;
  55674. private _postProcessMove;
  55675. private _teleportationFillColor;
  55676. private _teleportationBorderColor;
  55677. private _rotationAngle;
  55678. private _haloCenter;
  55679. private _cameraGazer;
  55680. private _padSensibilityUp;
  55681. private _padSensibilityDown;
  55682. private _leftController;
  55683. private _rightController;
  55684. private _gazeColor;
  55685. private _laserColor;
  55686. private _pickedLaserColor;
  55687. private _pickedGazeColor;
  55688. /**
  55689. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55690. */
  55691. onNewMeshSelected: Observable<AbstractMesh>;
  55692. /**
  55693. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55694. * This observable will provide the mesh and the controller used to select the mesh
  55695. */
  55696. onMeshSelectedWithController: Observable<{
  55697. mesh: AbstractMesh;
  55698. controller: WebVRController;
  55699. }>;
  55700. /**
  55701. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55702. */
  55703. onNewMeshPicked: Observable<PickingInfo>;
  55704. private _circleEase;
  55705. /**
  55706. * Observable raised before camera teleportation
  55707. */
  55708. onBeforeCameraTeleport: Observable<Vector3>;
  55709. /**
  55710. * Observable raised after camera teleportation
  55711. */
  55712. onAfterCameraTeleport: Observable<Vector3>;
  55713. /**
  55714. * Observable raised when current selected mesh gets unselected
  55715. */
  55716. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55717. private _raySelectionPredicate;
  55718. /**
  55719. * To be optionaly changed by user to define custom ray selection
  55720. */
  55721. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55722. /**
  55723. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55724. */
  55725. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55726. /**
  55727. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55728. */
  55729. teleportationEnabled: boolean;
  55730. private _defaultHeight;
  55731. private _teleportationInitialized;
  55732. private _interactionsEnabled;
  55733. private _interactionsRequested;
  55734. private _displayGaze;
  55735. private _displayLaserPointer;
  55736. /**
  55737. * The mesh used to display where the user is going to teleport.
  55738. */
  55739. get teleportationTarget(): Mesh;
  55740. /**
  55741. * Sets the mesh to be used to display where the user is going to teleport.
  55742. */
  55743. set teleportationTarget(value: Mesh);
  55744. /**
  55745. * 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
  55746. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55747. * See https://doc.babylonjs.com/resources/baking_transformations
  55748. */
  55749. get gazeTrackerMesh(): Mesh;
  55750. set gazeTrackerMesh(value: Mesh);
  55751. /**
  55752. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55753. */
  55754. updateGazeTrackerScale: boolean;
  55755. /**
  55756. * If the gaze trackers color should be updated when selecting meshes
  55757. */
  55758. updateGazeTrackerColor: boolean;
  55759. /**
  55760. * If the controller laser color should be updated when selecting meshes
  55761. */
  55762. updateControllerLaserColor: boolean;
  55763. /**
  55764. * The gaze tracking mesh corresponding to the left controller
  55765. */
  55766. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55767. /**
  55768. * The gaze tracking mesh corresponding to the right controller
  55769. */
  55770. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55771. /**
  55772. * If the ray of the gaze should be displayed.
  55773. */
  55774. get displayGaze(): boolean;
  55775. /**
  55776. * Sets if the ray of the gaze should be displayed.
  55777. */
  55778. set displayGaze(value: boolean);
  55779. /**
  55780. * If the ray of the LaserPointer should be displayed.
  55781. */
  55782. get displayLaserPointer(): boolean;
  55783. /**
  55784. * Sets if the ray of the LaserPointer should be displayed.
  55785. */
  55786. set displayLaserPointer(value: boolean);
  55787. /**
  55788. * The deviceOrientationCamera used as the camera when not in VR.
  55789. */
  55790. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55791. /**
  55792. * Based on the current WebVR support, returns the current VR camera used.
  55793. */
  55794. get currentVRCamera(): Nullable<Camera>;
  55795. /**
  55796. * The webVRCamera which is used when in VR.
  55797. */
  55798. get webVRCamera(): WebVRFreeCamera;
  55799. /**
  55800. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55801. */
  55802. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55803. /**
  55804. * The html button that is used to trigger entering into VR.
  55805. */
  55806. get vrButton(): Nullable<HTMLButtonElement>;
  55807. private get _teleportationRequestInitiated();
  55808. /**
  55809. * Defines whether or not Pointer lock should be requested when switching to
  55810. * full screen.
  55811. */
  55812. requestPointerLockOnFullScreen: boolean;
  55813. /**
  55814. * If asking to force XR, this will be populated with the default xr experience
  55815. */
  55816. xr: WebXRDefaultExperience;
  55817. /**
  55818. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55819. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55820. */
  55821. xrTestDone: boolean;
  55822. /**
  55823. * Instantiates a VRExperienceHelper.
  55824. * Helps to quickly add VR support to an existing scene.
  55825. * @param scene The scene the VRExperienceHelper belongs to.
  55826. * @param webVROptions Options to modify the vr experience helper's behavior.
  55827. */
  55828. constructor(scene: Scene,
  55829. /** Options to modify the vr experience helper's behavior. */
  55830. webVROptions?: VRExperienceHelperOptions);
  55831. private completeVRInit;
  55832. private _onDefaultMeshLoaded;
  55833. private _onResize;
  55834. private _onFullscreenChange;
  55835. /**
  55836. * Gets a value indicating if we are currently in VR mode.
  55837. */
  55838. get isInVRMode(): boolean;
  55839. private onVrDisplayPresentChange;
  55840. private onVRDisplayChanged;
  55841. private moveButtonToBottomRight;
  55842. private displayVRButton;
  55843. private updateButtonVisibility;
  55844. private _cachedAngularSensibility;
  55845. /**
  55846. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55847. * Otherwise, will use the fullscreen API.
  55848. */
  55849. enterVR(): void;
  55850. /**
  55851. * Attempt to exit VR, or fullscreen.
  55852. */
  55853. exitVR(): void;
  55854. /**
  55855. * The position of the vr experience helper.
  55856. */
  55857. get position(): Vector3;
  55858. /**
  55859. * Sets the position of the vr experience helper.
  55860. */
  55861. set position(value: Vector3);
  55862. /**
  55863. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55864. */
  55865. enableInteractions(): void;
  55866. private get _noControllerIsActive();
  55867. private beforeRender;
  55868. private _isTeleportationFloor;
  55869. /**
  55870. * Adds a floor mesh to be used for teleportation.
  55871. * @param floorMesh the mesh to be used for teleportation.
  55872. */
  55873. addFloorMesh(floorMesh: Mesh): void;
  55874. /**
  55875. * Removes a floor mesh from being used for teleportation.
  55876. * @param floorMesh the mesh to be removed.
  55877. */
  55878. removeFloorMesh(floorMesh: Mesh): void;
  55879. /**
  55880. * Enables interactions and teleportation using the VR controllers and gaze.
  55881. * @param vrTeleportationOptions options to modify teleportation behavior.
  55882. */
  55883. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55884. private _onNewGamepadConnected;
  55885. private _tryEnableInteractionOnController;
  55886. private _onNewGamepadDisconnected;
  55887. private _enableInteractionOnController;
  55888. private _checkTeleportWithRay;
  55889. private _checkRotate;
  55890. private _checkTeleportBackwards;
  55891. private _enableTeleportationOnController;
  55892. private _createTeleportationCircles;
  55893. private _displayTeleportationTarget;
  55894. private _hideTeleportationTarget;
  55895. private _rotateCamera;
  55896. private _moveTeleportationSelectorTo;
  55897. private _workingVector;
  55898. private _workingQuaternion;
  55899. private _workingMatrix;
  55900. /**
  55901. * Time Constant Teleportation Mode
  55902. */
  55903. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55904. /**
  55905. * Speed Constant Teleportation Mode
  55906. */
  55907. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55908. /**
  55909. * Teleports the users feet to the desired location
  55910. * @param location The location where the user's feet should be placed
  55911. */
  55912. teleportCamera(location: Vector3): void;
  55913. private _convertNormalToDirectionOfRay;
  55914. private _castRayAndSelectObject;
  55915. private _notifySelectedMeshUnselected;
  55916. /**
  55917. * Permanently set new colors for the laser pointer
  55918. * @param color the new laser color
  55919. * @param pickedColor the new laser color when picked mesh detected
  55920. */
  55921. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55922. /**
  55923. * Set lighting enabled / disabled on the laser pointer of both controllers
  55924. * @param enabled should the lighting be enabled on the laser pointer
  55925. */
  55926. setLaserLightingState(enabled?: boolean): void;
  55927. /**
  55928. * Permanently set new colors for the gaze pointer
  55929. * @param color the new gaze color
  55930. * @param pickedColor the new gaze color when picked mesh detected
  55931. */
  55932. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55933. /**
  55934. * Sets the color of the laser ray from the vr controllers.
  55935. * @param color new color for the ray.
  55936. */
  55937. changeLaserColor(color: Color3): void;
  55938. /**
  55939. * Sets the color of the ray from the vr headsets gaze.
  55940. * @param color new color for the ray.
  55941. */
  55942. changeGazeColor(color: Color3): void;
  55943. /**
  55944. * Exits VR and disposes of the vr experience helper
  55945. */
  55946. dispose(): void;
  55947. /**
  55948. * Gets the name of the VRExperienceHelper class
  55949. * @returns "VRExperienceHelper"
  55950. */
  55951. getClassName(): string;
  55952. }
  55953. }
  55954. declare module "babylonjs/Cameras/VR/index" {
  55955. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55956. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55957. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55958. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55959. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55960. export * from "babylonjs/Cameras/VR/webVRCamera";
  55961. }
  55962. declare module "babylonjs/Cameras/RigModes/index" {
  55963. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55964. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55965. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55966. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55967. }
  55968. declare module "babylonjs/Cameras/index" {
  55969. export * from "babylonjs/Cameras/Inputs/index";
  55970. export * from "babylonjs/Cameras/cameraInputsManager";
  55971. export * from "babylonjs/Cameras/camera";
  55972. export * from "babylonjs/Cameras/targetCamera";
  55973. export * from "babylonjs/Cameras/freeCamera";
  55974. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55975. export * from "babylonjs/Cameras/touchCamera";
  55976. export * from "babylonjs/Cameras/arcRotateCamera";
  55977. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55978. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55979. export * from "babylonjs/Cameras/flyCamera";
  55980. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55981. export * from "babylonjs/Cameras/followCamera";
  55982. export * from "babylonjs/Cameras/followCameraInputsManager";
  55983. export * from "babylonjs/Cameras/gamepadCamera";
  55984. export * from "babylonjs/Cameras/Stereoscopic/index";
  55985. export * from "babylonjs/Cameras/universalCamera";
  55986. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55987. export * from "babylonjs/Cameras/VR/index";
  55988. export * from "babylonjs/Cameras/RigModes/index";
  55989. }
  55990. declare module "babylonjs/Collisions/index" {
  55991. export * from "babylonjs/Collisions/collider";
  55992. export * from "babylonjs/Collisions/collisionCoordinator";
  55993. export * from "babylonjs/Collisions/pickingInfo";
  55994. export * from "babylonjs/Collisions/intersectionInfo";
  55995. export * from "babylonjs/Collisions/meshCollisionData";
  55996. }
  55997. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55998. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55999. import { Vector3 } from "babylonjs/Maths/math.vector";
  56000. import { Ray } from "babylonjs/Culling/ray";
  56001. import { Plane } from "babylonjs/Maths/math.plane";
  56002. /**
  56003. * Contains an array of blocks representing the octree
  56004. */
  56005. export interface IOctreeContainer<T> {
  56006. /**
  56007. * Blocks within the octree
  56008. */
  56009. blocks: Array<OctreeBlock<T>>;
  56010. }
  56011. /**
  56012. * Class used to store a cell in an octree
  56013. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56014. */
  56015. export class OctreeBlock<T> {
  56016. /**
  56017. * Gets the content of the current block
  56018. */
  56019. entries: T[];
  56020. /**
  56021. * Gets the list of block children
  56022. */
  56023. blocks: Array<OctreeBlock<T>>;
  56024. private _depth;
  56025. private _maxDepth;
  56026. private _capacity;
  56027. private _minPoint;
  56028. private _maxPoint;
  56029. private _boundingVectors;
  56030. private _creationFunc;
  56031. /**
  56032. * Creates a new block
  56033. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56034. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56035. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56036. * @param depth defines the current depth of this block in the octree
  56037. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56038. * @param creationFunc defines a callback to call when an element is added to the block
  56039. */
  56040. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56041. /**
  56042. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56043. */
  56044. get capacity(): number;
  56045. /**
  56046. * Gets the minimum vector (in world space) of the block's bounding box
  56047. */
  56048. get minPoint(): Vector3;
  56049. /**
  56050. * Gets the maximum vector (in world space) of the block's bounding box
  56051. */
  56052. get maxPoint(): Vector3;
  56053. /**
  56054. * Add a new element to this block
  56055. * @param entry defines the element to add
  56056. */
  56057. addEntry(entry: T): void;
  56058. /**
  56059. * Remove an element from this block
  56060. * @param entry defines the element to remove
  56061. */
  56062. removeEntry(entry: T): void;
  56063. /**
  56064. * Add an array of elements to this block
  56065. * @param entries defines the array of elements to add
  56066. */
  56067. addEntries(entries: T[]): void;
  56068. /**
  56069. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56070. * @param frustumPlanes defines the frustum planes to test
  56071. * @param selection defines the array to store current content if selection is positive
  56072. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56073. */
  56074. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56075. /**
  56076. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56077. * @param sphereCenter defines the bounding sphere center
  56078. * @param sphereRadius defines the bounding sphere radius
  56079. * @param selection defines the array to store current content if selection is positive
  56080. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56081. */
  56082. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56083. /**
  56084. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56085. * @param ray defines the ray to test with
  56086. * @param selection defines the array to store current content if selection is positive
  56087. */
  56088. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56089. /**
  56090. * Subdivide the content into child blocks (this block will then be empty)
  56091. */
  56092. createInnerBlocks(): void;
  56093. /**
  56094. * @hidden
  56095. */
  56096. 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;
  56097. }
  56098. }
  56099. declare module "babylonjs/Culling/Octrees/octree" {
  56100. import { SmartArray } from "babylonjs/Misc/smartArray";
  56101. import { Vector3 } from "babylonjs/Maths/math.vector";
  56102. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56104. import { Ray } from "babylonjs/Culling/ray";
  56105. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  56106. import { Plane } from "babylonjs/Maths/math.plane";
  56107. /**
  56108. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56109. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56110. */
  56111. export class Octree<T> {
  56112. /** 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.) */
  56113. maxDepth: number;
  56114. /**
  56115. * Blocks within the octree containing objects
  56116. */
  56117. blocks: Array<OctreeBlock<T>>;
  56118. /**
  56119. * Content stored in the octree
  56120. */
  56121. dynamicContent: T[];
  56122. private _maxBlockCapacity;
  56123. private _selectionContent;
  56124. private _creationFunc;
  56125. /**
  56126. * Creates a octree
  56127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56128. * @param creationFunc function to be used to instatiate the octree
  56129. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56130. * @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.)
  56131. */
  56132. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56133. /** 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.) */
  56134. maxDepth?: number);
  56135. /**
  56136. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56137. * @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);
  56138. * @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);
  56139. * @param entries meshes to be added to the octree blocks
  56140. */
  56141. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56142. /**
  56143. * Adds a mesh to the octree
  56144. * @param entry Mesh to add to the octree
  56145. */
  56146. addMesh(entry: T): void;
  56147. /**
  56148. * Remove an element from the octree
  56149. * @param entry defines the element to remove
  56150. */
  56151. removeMesh(entry: T): void;
  56152. /**
  56153. * Selects an array of meshes within the frustum
  56154. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56155. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56156. * @returns array of meshes within the frustum
  56157. */
  56158. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56159. /**
  56160. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56161. * @param sphereCenter defines the bounding sphere center
  56162. * @param sphereRadius defines the bounding sphere radius
  56163. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56164. * @returns an array of objects that intersect the sphere
  56165. */
  56166. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56167. /**
  56168. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56169. * @param ray defines the ray to test with
  56170. * @returns array of intersected objects
  56171. */
  56172. intersectsRay(ray: Ray): SmartArray<T>;
  56173. /**
  56174. * Adds a mesh into the octree block if it intersects the block
  56175. */
  56176. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56177. /**
  56178. * Adds a submesh into the octree block if it intersects the block
  56179. */
  56180. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56181. }
  56182. }
  56183. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56184. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56185. import { Scene } from "babylonjs/scene";
  56186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56188. import { Ray } from "babylonjs/Culling/ray";
  56189. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56190. import { Collider } from "babylonjs/Collisions/collider";
  56191. module "babylonjs/scene" {
  56192. interface Scene {
  56193. /**
  56194. * @hidden
  56195. * Backing Filed
  56196. */
  56197. _selectionOctree: Octree<AbstractMesh>;
  56198. /**
  56199. * Gets the octree used to boost mesh selection (picking)
  56200. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56201. */
  56202. selectionOctree: Octree<AbstractMesh>;
  56203. /**
  56204. * Creates or updates the octree used to boost selection (picking)
  56205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56206. * @param maxCapacity defines the maximum capacity per leaf
  56207. * @param maxDepth defines the maximum depth of the octree
  56208. * @returns an octree of AbstractMesh
  56209. */
  56210. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56211. }
  56212. }
  56213. module "babylonjs/Meshes/abstractMesh" {
  56214. interface AbstractMesh {
  56215. /**
  56216. * @hidden
  56217. * Backing Field
  56218. */
  56219. _submeshesOctree: Octree<SubMesh>;
  56220. /**
  56221. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56222. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56223. * @param maxCapacity defines the maximum size of each block (64 by default)
  56224. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56225. * @returns the new octree
  56226. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56228. */
  56229. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56230. }
  56231. }
  56232. /**
  56233. * Defines the octree scene component responsible to manage any octrees
  56234. * in a given scene.
  56235. */
  56236. export class OctreeSceneComponent {
  56237. /**
  56238. * The component name help to identify the component in the list of scene components.
  56239. */
  56240. readonly name: string;
  56241. /**
  56242. * The scene the component belongs to.
  56243. */
  56244. scene: Scene;
  56245. /**
  56246. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56247. */
  56248. readonly checksIsEnabled: boolean;
  56249. /**
  56250. * Creates a new instance of the component for the given scene
  56251. * @param scene Defines the scene to register the component in
  56252. */
  56253. constructor(scene: Scene);
  56254. /**
  56255. * Registers the component in a given scene
  56256. */
  56257. register(): void;
  56258. /**
  56259. * Return the list of active meshes
  56260. * @returns the list of active meshes
  56261. */
  56262. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56263. /**
  56264. * Return the list of active sub meshes
  56265. * @param mesh The mesh to get the candidates sub meshes from
  56266. * @returns the list of active sub meshes
  56267. */
  56268. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56269. private _tempRay;
  56270. /**
  56271. * Return the list of sub meshes intersecting with a given local ray
  56272. * @param mesh defines the mesh to find the submesh for
  56273. * @param localRay defines the ray in local space
  56274. * @returns the list of intersecting sub meshes
  56275. */
  56276. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56277. /**
  56278. * Return the list of sub meshes colliding with a collider
  56279. * @param mesh defines the mesh to find the submesh for
  56280. * @param collider defines the collider to evaluate the collision against
  56281. * @returns the list of colliding sub meshes
  56282. */
  56283. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56284. /**
  56285. * Rebuilds the elements related to this component in case of
  56286. * context lost for instance.
  56287. */
  56288. rebuild(): void;
  56289. /**
  56290. * Disposes the component and the associated ressources.
  56291. */
  56292. dispose(): void;
  56293. }
  56294. }
  56295. declare module "babylonjs/Culling/Octrees/index" {
  56296. export * from "babylonjs/Culling/Octrees/octree";
  56297. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56298. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56299. }
  56300. declare module "babylonjs/Culling/index" {
  56301. export * from "babylonjs/Culling/boundingBox";
  56302. export * from "babylonjs/Culling/boundingInfo";
  56303. export * from "babylonjs/Culling/boundingSphere";
  56304. export * from "babylonjs/Culling/Octrees/index";
  56305. export * from "babylonjs/Culling/ray";
  56306. }
  56307. declare module "babylonjs/Gizmos/gizmo" {
  56308. import { Observer } from "babylonjs/Misc/observable";
  56309. import { Nullable } from "babylonjs/types";
  56310. import { IDisposable } from "babylonjs/scene";
  56311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56312. import { Mesh } from "babylonjs/Meshes/mesh";
  56313. import { Node } from "babylonjs/node";
  56314. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56315. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56316. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56317. /**
  56318. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56319. */
  56320. export interface GizmoAxisCache {
  56321. /** Mesh used to runder the Gizmo */
  56322. gizmoMeshes: Mesh[];
  56323. /** Mesh used to detect user interaction with Gizmo */
  56324. colliderMeshes: Mesh[];
  56325. /** Material used to inicate color of gizmo mesh */
  56326. material: StandardMaterial;
  56327. /** Material used to inicate hover state of the Gizmo */
  56328. hoverMaterial: StandardMaterial;
  56329. /** Material used to inicate disabled state of the Gizmo */
  56330. disableMaterial: StandardMaterial;
  56331. /** Used to indicate Active state of the Gizmo */
  56332. active: boolean;
  56333. }
  56334. /**
  56335. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56336. */
  56337. export class Gizmo implements IDisposable {
  56338. /** The utility layer the gizmo will be added to */
  56339. gizmoLayer: UtilityLayerRenderer;
  56340. /**
  56341. * The root mesh of the gizmo
  56342. */
  56343. _rootMesh: Mesh;
  56344. private _attachedMesh;
  56345. private _attachedNode;
  56346. /**
  56347. * Ratio for the scale of the gizmo (Default: 1)
  56348. */
  56349. protected _scaleRatio: number;
  56350. /**
  56351. * boolean updated by pointermove when a gizmo mesh is hovered
  56352. */
  56353. protected _isHovered: boolean;
  56354. /**
  56355. * Ratio for the scale of the gizmo (Default: 1)
  56356. */
  56357. set scaleRatio(value: number);
  56358. get scaleRatio(): number;
  56359. /**
  56360. * True when the mouse pointer is hovered a gizmo mesh
  56361. */
  56362. get isHovered(): boolean;
  56363. /**
  56364. * If a custom mesh has been set (Default: false)
  56365. */
  56366. protected _customMeshSet: boolean;
  56367. /**
  56368. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56369. * * When set, interactions will be enabled
  56370. */
  56371. get attachedMesh(): Nullable<AbstractMesh>;
  56372. set attachedMesh(value: Nullable<AbstractMesh>);
  56373. /**
  56374. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56375. * * When set, interactions will be enabled
  56376. */
  56377. get attachedNode(): Nullable<Node>;
  56378. set attachedNode(value: Nullable<Node>);
  56379. /**
  56380. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56381. * @param mesh The mesh to replace the default mesh of the gizmo
  56382. */
  56383. setCustomMesh(mesh: Mesh): void;
  56384. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56385. /**
  56386. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56387. */
  56388. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56389. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56390. /**
  56391. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56392. */
  56393. updateGizmoPositionToMatchAttachedMesh: boolean;
  56394. /**
  56395. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56396. */
  56397. updateScale: boolean;
  56398. protected _interactionsEnabled: boolean;
  56399. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56400. private _beforeRenderObserver;
  56401. private _tempQuaternion;
  56402. private _tempVector;
  56403. private _tempVector2;
  56404. private _tempMatrix1;
  56405. private _tempMatrix2;
  56406. private _rightHandtoLeftHandMatrix;
  56407. /**
  56408. * Creates a gizmo
  56409. * @param gizmoLayer The utility layer the gizmo will be added to
  56410. */
  56411. constructor(
  56412. /** The utility layer the gizmo will be added to */
  56413. gizmoLayer?: UtilityLayerRenderer);
  56414. /**
  56415. * Updates the gizmo to match the attached mesh's position/rotation
  56416. */
  56417. protected _update(): void;
  56418. /**
  56419. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56420. * @param value Node, TransformNode or mesh
  56421. */
  56422. protected _matrixChanged(): void;
  56423. /**
  56424. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56425. * @param gizmoLayer The utility layer the gizmo will be added to
  56426. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56427. * @returns {Observer<PointerInfo>} pointerObserver
  56428. */
  56429. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56430. /**
  56431. * Disposes of the gizmo
  56432. */
  56433. dispose(): void;
  56434. }
  56435. }
  56436. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56437. import { Observable } from "babylonjs/Misc/observable";
  56438. import { Nullable } from "babylonjs/types";
  56439. import { Vector3 } from "babylonjs/Maths/math.vector";
  56440. import { Color3 } from "babylonjs/Maths/math.color";
  56441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56442. import { Node } from "babylonjs/node";
  56443. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56444. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56446. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56447. import { Scene } from "babylonjs/scene";
  56448. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56449. /**
  56450. * Single plane drag gizmo
  56451. */
  56452. export class PlaneDragGizmo extends Gizmo {
  56453. /**
  56454. * Drag behavior responsible for the gizmos dragging interactions
  56455. */
  56456. dragBehavior: PointerDragBehavior;
  56457. private _pointerObserver;
  56458. /**
  56459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56460. */
  56461. snapDistance: number;
  56462. /**
  56463. * Event that fires each time the gizmo snaps to a new location.
  56464. * * snapDistance is the the change in distance
  56465. */
  56466. onSnapObservable: Observable<{
  56467. snapDistance: number;
  56468. }>;
  56469. private _gizmoMesh;
  56470. private _coloredMaterial;
  56471. private _hoverMaterial;
  56472. private _disableMaterial;
  56473. private _isEnabled;
  56474. private _parent;
  56475. private _dragging;
  56476. /** @hidden */
  56477. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56478. /**
  56479. * Creates a PlaneDragGizmo
  56480. * @param gizmoLayer The utility layer the gizmo will be added to
  56481. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56482. * @param color The color of the gizmo
  56483. */
  56484. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56485. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56486. /**
  56487. * If the gizmo is enabled
  56488. */
  56489. set isEnabled(value: boolean);
  56490. get isEnabled(): boolean;
  56491. /**
  56492. * Disposes of the gizmo
  56493. */
  56494. dispose(): void;
  56495. }
  56496. }
  56497. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56498. import { Observable } from "babylonjs/Misc/observable";
  56499. import { Nullable } from "babylonjs/types";
  56500. import { Vector3 } from "babylonjs/Maths/math.vector";
  56501. import { Color3 } from "babylonjs/Maths/math.color";
  56502. import "babylonjs/Meshes/Builders/linesBuilder";
  56503. import { Node } from "babylonjs/node";
  56504. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56505. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56506. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56507. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56508. /**
  56509. * Single plane rotation gizmo
  56510. */
  56511. export class PlaneRotationGizmo extends Gizmo {
  56512. /**
  56513. * Drag behavior responsible for the gizmos dragging interactions
  56514. */
  56515. dragBehavior: PointerDragBehavior;
  56516. private _pointerObserver;
  56517. /**
  56518. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56519. */
  56520. snapDistance: number;
  56521. /**
  56522. * Event that fires each time the gizmo snaps to a new location.
  56523. * * snapDistance is the the change in distance
  56524. */
  56525. onSnapObservable: Observable<{
  56526. snapDistance: number;
  56527. }>;
  56528. private _isEnabled;
  56529. private _parent;
  56530. private _coloredMaterial;
  56531. private _hoverMaterial;
  56532. private _disableMaterial;
  56533. private _gizmoMesh;
  56534. private _rotationCircle;
  56535. private _dragging;
  56536. private static _CircleConstants;
  56537. /**
  56538. * Creates a PlaneRotationGizmo
  56539. * @param gizmoLayer The utility layer the gizmo will be added to
  56540. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56541. * @param color The color of the gizmo
  56542. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56543. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56544. * @param thickness display gizmo axis thickness
  56545. */
  56546. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56547. /** Create Geometry for Gizmo */
  56548. private _createGizmoMesh;
  56549. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56550. private setupRotationCircle;
  56551. private updateRotationPath;
  56552. private updateRotationCircle;
  56553. /**
  56554. * If the gizmo is enabled
  56555. */
  56556. set isEnabled(value: boolean);
  56557. get isEnabled(): boolean;
  56558. /**
  56559. * Disposes of the gizmo
  56560. */
  56561. dispose(): void;
  56562. }
  56563. }
  56564. declare module "babylonjs/Gizmos/rotationGizmo" {
  56565. import { Observable } from "babylonjs/Misc/observable";
  56566. import { Nullable } from "babylonjs/types";
  56567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56568. import { Mesh } from "babylonjs/Meshes/mesh";
  56569. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56570. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56572. import { Node } from "babylonjs/node";
  56573. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56574. /**
  56575. * Gizmo that enables rotating a mesh along 3 axis
  56576. */
  56577. export class RotationGizmo extends Gizmo {
  56578. /**
  56579. * Internal gizmo used for interactions on the x axis
  56580. */
  56581. xGizmo: PlaneRotationGizmo;
  56582. /**
  56583. * Internal gizmo used for interactions on the y axis
  56584. */
  56585. yGizmo: PlaneRotationGizmo;
  56586. /**
  56587. * Internal gizmo used for interactions on the z axis
  56588. */
  56589. zGizmo: PlaneRotationGizmo;
  56590. /** Fires an event when any of it's sub gizmos are dragged */
  56591. onDragStartObservable: Observable<unknown>;
  56592. /** Fires an event when any of it's sub gizmos are released from dragging */
  56593. onDragEndObservable: Observable<unknown>;
  56594. private _meshAttached;
  56595. private _nodeAttached;
  56596. private _observables;
  56597. /** Node Caching for quick lookup */
  56598. private _gizmoAxisCache;
  56599. get attachedMesh(): Nullable<AbstractMesh>;
  56600. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56601. get attachedNode(): Nullable<Node>;
  56602. set attachedNode(node: Nullable<Node>);
  56603. protected _checkBillboardTransform(): void;
  56604. /**
  56605. * True when the mouse pointer is hovering a gizmo mesh
  56606. */
  56607. get isHovered(): boolean;
  56608. /**
  56609. * Creates a RotationGizmo
  56610. * @param gizmoLayer The utility layer the gizmo will be added to
  56611. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56612. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56613. * @param thickness display gizmo axis thickness
  56614. */
  56615. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56616. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56617. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56618. /**
  56619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56620. */
  56621. set snapDistance(value: number);
  56622. get snapDistance(): number;
  56623. /**
  56624. * Ratio for the scale of the gizmo (Default: 1)
  56625. */
  56626. set scaleRatio(value: number);
  56627. get scaleRatio(): number;
  56628. /**
  56629. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56630. * @param mesh Axis gizmo mesh
  56631. * @param cache Gizmo axis definition used for reactive gizmo UI
  56632. */
  56633. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56634. /**
  56635. * Disposes of the gizmo
  56636. */
  56637. dispose(): void;
  56638. /**
  56639. * CustomMeshes are not supported by this gizmo
  56640. * @param mesh The mesh to replace the default mesh of the gizmo
  56641. */
  56642. setCustomMesh(mesh: Mesh): void;
  56643. }
  56644. }
  56645. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56646. import { Scene } from "babylonjs/scene";
  56647. import { Vector4 } from "babylonjs/Maths/math.vector";
  56648. import { Color4 } from "babylonjs/Maths/math.color";
  56649. import { Mesh } from "babylonjs/Meshes/mesh";
  56650. import { Nullable } from "babylonjs/types";
  56651. /**
  56652. * Class containing static functions to help procedurally build meshes
  56653. */
  56654. export class PolyhedronBuilder {
  56655. /**
  56656. * Creates a polyhedron mesh
  56657. * * 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
  56658. * * The parameter `size` (positive float, default 1) sets the polygon size
  56659. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56660. * * 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`
  56661. * * 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
  56662. * * 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)`)
  56663. * * 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
  56664. * * 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
  56665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56668. * @param name defines the name of the mesh
  56669. * @param options defines the options used to create the mesh
  56670. * @param scene defines the hosting scene
  56671. * @returns the polyhedron mesh
  56672. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56673. */
  56674. static CreatePolyhedron(name: string, options: {
  56675. type?: number;
  56676. size?: number;
  56677. sizeX?: number;
  56678. sizeY?: number;
  56679. sizeZ?: number;
  56680. custom?: any;
  56681. faceUV?: Vector4[];
  56682. faceColors?: Color4[];
  56683. flat?: boolean;
  56684. updatable?: boolean;
  56685. sideOrientation?: number;
  56686. frontUVs?: Vector4;
  56687. backUVs?: Vector4;
  56688. }, scene?: Nullable<Scene>): Mesh;
  56689. }
  56690. }
  56691. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56692. import { Nullable } from "babylonjs/types";
  56693. import { Scene } from "babylonjs/scene";
  56694. import { Vector4 } from "babylonjs/Maths/math.vector";
  56695. import { Color4 } from "babylonjs/Maths/math.color";
  56696. import { Mesh } from "babylonjs/Meshes/mesh";
  56697. /**
  56698. * Class containing static functions to help procedurally build meshes
  56699. */
  56700. export class BoxBuilder {
  56701. /**
  56702. * Creates a box mesh
  56703. * * The parameter `size` sets the size (float) of each box side (default 1)
  56704. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56705. * * 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)
  56706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56710. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56711. * @param name defines the name of the mesh
  56712. * @param options defines the options used to create the mesh
  56713. * @param scene defines the hosting scene
  56714. * @returns the box mesh
  56715. */
  56716. static CreateBox(name: string, options: {
  56717. size?: number;
  56718. width?: number;
  56719. height?: number;
  56720. depth?: number;
  56721. faceUV?: Vector4[];
  56722. faceColors?: Color4[];
  56723. sideOrientation?: number;
  56724. frontUVs?: Vector4;
  56725. backUVs?: Vector4;
  56726. wrap?: boolean;
  56727. topBaseAt?: number;
  56728. bottomBaseAt?: number;
  56729. updatable?: boolean;
  56730. }, scene?: Nullable<Scene>): Mesh;
  56731. }
  56732. }
  56733. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56734. import { Observable } from "babylonjs/Misc/observable";
  56735. import { Nullable } from "babylonjs/types";
  56736. import { Vector3 } from "babylonjs/Maths/math.vector";
  56737. import { Node } from "babylonjs/node";
  56738. import { Mesh } from "babylonjs/Meshes/mesh";
  56739. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56740. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56741. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56742. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56743. import { Color3 } from "babylonjs/Maths/math.color";
  56744. /**
  56745. * Single axis scale gizmo
  56746. */
  56747. export class AxisScaleGizmo extends Gizmo {
  56748. /**
  56749. * Drag behavior responsible for the gizmos dragging interactions
  56750. */
  56751. dragBehavior: PointerDragBehavior;
  56752. private _pointerObserver;
  56753. /**
  56754. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56755. */
  56756. snapDistance: number;
  56757. /**
  56758. * Event that fires each time the gizmo snaps to a new location.
  56759. * * snapDistance is the the change in distance
  56760. */
  56761. onSnapObservable: Observable<{
  56762. snapDistance: number;
  56763. }>;
  56764. /**
  56765. * If the scaling operation should be done on all axis (default: false)
  56766. */
  56767. uniformScaling: boolean;
  56768. /**
  56769. * Custom sensitivity value for the drag strength
  56770. */
  56771. sensitivity: number;
  56772. private _isEnabled;
  56773. private _parent;
  56774. private _gizmoMesh;
  56775. private _coloredMaterial;
  56776. private _hoverMaterial;
  56777. private _disableMaterial;
  56778. private _dragging;
  56779. private _tmpVector;
  56780. private _tmpMatrix;
  56781. private _tmpMatrix2;
  56782. /**
  56783. * Creates an AxisScaleGizmo
  56784. * @param gizmoLayer The utility layer the gizmo will be added to
  56785. * @param dragAxis The axis which the gizmo will be able to scale on
  56786. * @param color The color of the gizmo
  56787. * @param thickness display gizmo axis thickness
  56788. */
  56789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56790. /** Create Geometry for Gizmo */
  56791. private _createGizmoMesh;
  56792. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56793. /**
  56794. * If the gizmo is enabled
  56795. */
  56796. set isEnabled(value: boolean);
  56797. get isEnabled(): boolean;
  56798. /**
  56799. * Disposes of the gizmo
  56800. */
  56801. dispose(): void;
  56802. /**
  56803. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56804. * @param mesh The mesh to replace the default mesh of the gizmo
  56805. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56806. */
  56807. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56808. }
  56809. }
  56810. declare module "babylonjs/Gizmos/scaleGizmo" {
  56811. import { Observable } from "babylonjs/Misc/observable";
  56812. import { Nullable } from "babylonjs/types";
  56813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56814. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56815. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56817. import { Mesh } from "babylonjs/Meshes/mesh";
  56818. import { Node } from "babylonjs/node";
  56819. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56820. /**
  56821. * Gizmo that enables scaling a mesh along 3 axis
  56822. */
  56823. export class ScaleGizmo extends Gizmo {
  56824. /**
  56825. * Internal gizmo used for interactions on the x axis
  56826. */
  56827. xGizmo: AxisScaleGizmo;
  56828. /**
  56829. * Internal gizmo used for interactions on the y axis
  56830. */
  56831. yGizmo: AxisScaleGizmo;
  56832. /**
  56833. * Internal gizmo used for interactions on the z axis
  56834. */
  56835. zGizmo: AxisScaleGizmo;
  56836. /**
  56837. * Internal gizmo used to scale all axis equally
  56838. */
  56839. uniformScaleGizmo: AxisScaleGizmo;
  56840. private _meshAttached;
  56841. private _nodeAttached;
  56842. private _snapDistance;
  56843. private _uniformScalingMesh;
  56844. private _octahedron;
  56845. private _sensitivity;
  56846. private _coloredMaterial;
  56847. private _hoverMaterial;
  56848. private _disableMaterial;
  56849. private _observables;
  56850. /** Node Caching for quick lookup */
  56851. private _gizmoAxisCache;
  56852. /** Fires an event when any of it's sub gizmos are dragged */
  56853. onDragStartObservable: Observable<unknown>;
  56854. /** Fires an event when any of it's sub gizmos are released from dragging */
  56855. onDragEndObservable: Observable<unknown>;
  56856. get attachedMesh(): Nullable<AbstractMesh>;
  56857. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56858. get attachedNode(): Nullable<Node>;
  56859. set attachedNode(node: Nullable<Node>);
  56860. /**
  56861. * True when the mouse pointer is hovering a gizmo mesh
  56862. */
  56863. get isHovered(): boolean;
  56864. /**
  56865. * Creates a ScaleGizmo
  56866. * @param gizmoLayer The utility layer the gizmo will be added to
  56867. * @param thickness display gizmo axis thickness
  56868. */
  56869. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56870. /** Create Geometry for Gizmo */
  56871. private _createUniformScaleMesh;
  56872. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56873. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56874. /**
  56875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56876. */
  56877. set snapDistance(value: number);
  56878. get snapDistance(): number;
  56879. /**
  56880. * Ratio for the scale of the gizmo (Default: 1)
  56881. */
  56882. set scaleRatio(value: number);
  56883. get scaleRatio(): number;
  56884. /**
  56885. * Sensitivity factor for dragging (Default: 1)
  56886. */
  56887. set sensitivity(value: number);
  56888. get sensitivity(): number;
  56889. /**
  56890. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56891. * @param mesh Axis gizmo mesh
  56892. * @param cache Gizmo axis definition used for reactive gizmo UI
  56893. */
  56894. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56895. /**
  56896. * Disposes of the gizmo
  56897. */
  56898. dispose(): void;
  56899. }
  56900. }
  56901. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56902. import { Observable } from "babylonjs/Misc/observable";
  56903. import { Nullable } from "babylonjs/types";
  56904. import { Vector3 } from "babylonjs/Maths/math.vector";
  56905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56906. import { Mesh } from "babylonjs/Meshes/mesh";
  56907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56909. import { Color3 } from "babylonjs/Maths/math.color";
  56910. import "babylonjs/Meshes/Builders/boxBuilder";
  56911. /**
  56912. * Bounding box gizmo
  56913. */
  56914. export class BoundingBoxGizmo extends Gizmo {
  56915. private _lineBoundingBox;
  56916. private _rotateSpheresParent;
  56917. private _scaleBoxesParent;
  56918. private _boundingDimensions;
  56919. private _renderObserver;
  56920. private _pointerObserver;
  56921. private _scaleDragSpeed;
  56922. private _tmpQuaternion;
  56923. private _tmpVector;
  56924. private _tmpRotationMatrix;
  56925. /**
  56926. * 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)
  56927. */
  56928. ignoreChildren: boolean;
  56929. /**
  56930. * 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)
  56931. */
  56932. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56933. /**
  56934. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56935. */
  56936. rotationSphereSize: number;
  56937. /**
  56938. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56939. */
  56940. scaleBoxSize: number;
  56941. /**
  56942. * 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)
  56943. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56944. */
  56945. fixedDragMeshScreenSize: boolean;
  56946. /**
  56947. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  56948. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56949. */
  56950. fixedDragMeshBoundsSize: boolean;
  56951. /**
  56952. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56953. */
  56954. fixedDragMeshScreenSizeDistanceFactor: number;
  56955. /**
  56956. * Fired when a rotation sphere or scale box is dragged
  56957. */
  56958. onDragStartObservable: Observable<{}>;
  56959. /**
  56960. * Fired when a scale box is dragged
  56961. */
  56962. onScaleBoxDragObservable: Observable<{}>;
  56963. /**
  56964. * Fired when a scale box drag is ended
  56965. */
  56966. onScaleBoxDragEndObservable: Observable<{}>;
  56967. /**
  56968. * Fired when a rotation sphere is dragged
  56969. */
  56970. onRotationSphereDragObservable: Observable<{}>;
  56971. /**
  56972. * Fired when a rotation sphere drag is ended
  56973. */
  56974. onRotationSphereDragEndObservable: Observable<{}>;
  56975. /**
  56976. * 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)
  56977. */
  56978. scalePivot: Nullable<Vector3>;
  56979. /**
  56980. * Mesh used as a pivot to rotate the attached node
  56981. */
  56982. private _anchorMesh;
  56983. private _existingMeshScale;
  56984. private _dragMesh;
  56985. private pointerDragBehavior;
  56986. private coloredMaterial;
  56987. private hoverColoredMaterial;
  56988. /**
  56989. * Sets the color of the bounding box gizmo
  56990. * @param color the color to set
  56991. */
  56992. setColor(color: Color3): void;
  56993. /**
  56994. * Creates an BoundingBoxGizmo
  56995. * @param gizmoLayer The utility layer the gizmo will be added to
  56996. * @param color The color of the gizmo
  56997. */
  56998. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56999. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57000. private _selectNode;
  57001. /**
  57002. * Updates the bounding box information for the Gizmo
  57003. */
  57004. updateBoundingBox(): void;
  57005. private _updateRotationSpheres;
  57006. private _updateScaleBoxes;
  57007. /**
  57008. * Enables rotation on the specified axis and disables rotation on the others
  57009. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57010. */
  57011. setEnabledRotationAxis(axis: string): void;
  57012. /**
  57013. * Enables/disables scaling
  57014. * @param enable if scaling should be enabled
  57015. * @param homogeneousScaling defines if scaling should only be homogeneous
  57016. */
  57017. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57018. private _updateDummy;
  57019. /**
  57020. * Enables a pointer drag behavior on the bounding box of the gizmo
  57021. */
  57022. enableDragBehavior(): void;
  57023. /**
  57024. * Disposes of the gizmo
  57025. */
  57026. dispose(): void;
  57027. /**
  57028. * 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)
  57029. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57030. * @returns the bounding box mesh with the passed in mesh as a child
  57031. */
  57032. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57033. /**
  57034. * CustomMeshes are not supported by this gizmo
  57035. * @param mesh The mesh to replace the default mesh of the gizmo
  57036. */
  57037. setCustomMesh(mesh: Mesh): void;
  57038. }
  57039. }
  57040. declare module "babylonjs/Gizmos/gizmoManager" {
  57041. import { Observable } from "babylonjs/Misc/observable";
  57042. import { Nullable } from "babylonjs/types";
  57043. import { Scene, IDisposable } from "babylonjs/scene";
  57044. import { Node } from "babylonjs/node";
  57045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57046. import { Mesh } from "babylonjs/Meshes/mesh";
  57047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57048. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  57049. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57050. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  57051. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57052. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  57053. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  57054. /**
  57055. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57056. */
  57057. export class GizmoManager implements IDisposable {
  57058. private scene;
  57059. /**
  57060. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57061. */
  57062. gizmos: {
  57063. positionGizmo: Nullable<PositionGizmo>;
  57064. rotationGizmo: Nullable<RotationGizmo>;
  57065. scaleGizmo: Nullable<ScaleGizmo>;
  57066. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57067. };
  57068. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57069. clearGizmoOnEmptyPointerEvent: boolean;
  57070. /** Fires an event when the manager is attached to a mesh */
  57071. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57072. /** Fires an event when the manager is attached to a node */
  57073. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57074. private _gizmosEnabled;
  57075. private _pointerObservers;
  57076. private _attachedMesh;
  57077. private _attachedNode;
  57078. private _boundingBoxColor;
  57079. private _defaultUtilityLayer;
  57080. private _defaultKeepDepthUtilityLayer;
  57081. private _thickness;
  57082. /** Node Caching for quick lookup */
  57083. private _gizmoAxisCache;
  57084. /**
  57085. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57086. */
  57087. boundingBoxDragBehavior: SixDofDragBehavior;
  57088. /**
  57089. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57090. */
  57091. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57092. /**
  57093. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57094. */
  57095. attachableNodes: Nullable<Array<Node>>;
  57096. /**
  57097. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57098. */
  57099. usePointerToAttachGizmos: boolean;
  57100. /**
  57101. * Utility layer that the bounding box gizmo belongs to
  57102. */
  57103. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57104. /**
  57105. * Utility layer that all gizmos besides bounding box belong to
  57106. */
  57107. get utilityLayer(): UtilityLayerRenderer;
  57108. /**
  57109. * True when the mouse pointer is hovering a gizmo mesh
  57110. */
  57111. get isHovered(): boolean;
  57112. /**
  57113. * Instatiates a gizmo manager
  57114. * @param scene the scene to overlay the gizmos on top of
  57115. * @param thickness display gizmo axis thickness
  57116. * @param utilityLayer the layer where gizmos are rendered
  57117. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57118. */
  57119. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57120. /**
  57121. * Subscribes to pointer down events, for attaching and detaching mesh
  57122. * @param scene The sceme layer the observer will be added to
  57123. */
  57124. private _attachToMeshPointerObserver;
  57125. /**
  57126. * Attaches a set of gizmos to the specified mesh
  57127. * @param mesh The mesh the gizmo's should be attached to
  57128. */
  57129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57130. /**
  57131. * Attaches a set of gizmos to the specified node
  57132. * @param node The node the gizmo's should be attached to
  57133. */
  57134. attachToNode(node: Nullable<Node>): void;
  57135. /**
  57136. * If the position gizmo is enabled
  57137. */
  57138. set positionGizmoEnabled(value: boolean);
  57139. get positionGizmoEnabled(): boolean;
  57140. /**
  57141. * If the rotation gizmo is enabled
  57142. */
  57143. set rotationGizmoEnabled(value: boolean);
  57144. get rotationGizmoEnabled(): boolean;
  57145. /**
  57146. * If the scale gizmo is enabled
  57147. */
  57148. set scaleGizmoEnabled(value: boolean);
  57149. get scaleGizmoEnabled(): boolean;
  57150. /**
  57151. * If the boundingBox gizmo is enabled
  57152. */
  57153. set boundingBoxGizmoEnabled(value: boolean);
  57154. get boundingBoxGizmoEnabled(): boolean;
  57155. /**
  57156. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57157. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57158. */
  57159. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57160. /**
  57161. * Disposes of the gizmo manager
  57162. */
  57163. dispose(): void;
  57164. }
  57165. }
  57166. declare module "babylonjs/Gizmos/positionGizmo" {
  57167. import { Observable } from "babylonjs/Misc/observable";
  57168. import { Nullable } from "babylonjs/types";
  57169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57170. import { Node } from "babylonjs/node";
  57171. import { Mesh } from "babylonjs/Meshes/mesh";
  57172. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57173. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57174. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57176. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57177. /**
  57178. * Gizmo that enables dragging a mesh along 3 axis
  57179. */
  57180. export class PositionGizmo extends Gizmo {
  57181. /**
  57182. * Internal gizmo used for interactions on the x axis
  57183. */
  57184. xGizmo: AxisDragGizmo;
  57185. /**
  57186. * Internal gizmo used for interactions on the y axis
  57187. */
  57188. yGizmo: AxisDragGizmo;
  57189. /**
  57190. * Internal gizmo used for interactions on the z axis
  57191. */
  57192. zGizmo: AxisDragGizmo;
  57193. /**
  57194. * Internal gizmo used for interactions on the yz plane
  57195. */
  57196. xPlaneGizmo: PlaneDragGizmo;
  57197. /**
  57198. * Internal gizmo used for interactions on the xz plane
  57199. */
  57200. yPlaneGizmo: PlaneDragGizmo;
  57201. /**
  57202. * Internal gizmo used for interactions on the xy plane
  57203. */
  57204. zPlaneGizmo: PlaneDragGizmo;
  57205. /**
  57206. * private variables
  57207. */
  57208. private _meshAttached;
  57209. private _nodeAttached;
  57210. private _snapDistance;
  57211. private _observables;
  57212. /** Node Caching for quick lookup */
  57213. private _gizmoAxisCache;
  57214. /** Fires an event when any of it's sub gizmos are dragged */
  57215. onDragStartObservable: Observable<unknown>;
  57216. /** Fires an event when any of it's sub gizmos are released from dragging */
  57217. onDragEndObservable: Observable<unknown>;
  57218. /**
  57219. * If set to true, planar drag is enabled
  57220. */
  57221. private _planarGizmoEnabled;
  57222. get attachedMesh(): Nullable<AbstractMesh>;
  57223. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57224. get attachedNode(): Nullable<Node>;
  57225. set attachedNode(node: Nullable<Node>);
  57226. /**
  57227. * True when the mouse pointer is hovering a gizmo mesh
  57228. */
  57229. get isHovered(): boolean;
  57230. /**
  57231. * Creates a PositionGizmo
  57232. * @param gizmoLayer The utility layer the gizmo will be added to
  57233. @param thickness display gizmo axis thickness
  57234. */
  57235. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57236. /**
  57237. * If the planar drag gizmo is enabled
  57238. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57239. */
  57240. set planarGizmoEnabled(value: boolean);
  57241. get planarGizmoEnabled(): boolean;
  57242. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57243. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57244. /**
  57245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57246. */
  57247. set snapDistance(value: number);
  57248. get snapDistance(): number;
  57249. /**
  57250. * Ratio for the scale of the gizmo (Default: 1)
  57251. */
  57252. set scaleRatio(value: number);
  57253. get scaleRatio(): number;
  57254. /**
  57255. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57256. * @param mesh Axis gizmo mesh
  57257. * @param cache Gizmo axis definition used for reactive gizmo UI
  57258. */
  57259. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57260. /**
  57261. * Disposes of the gizmo
  57262. */
  57263. dispose(): void;
  57264. /**
  57265. * CustomMeshes are not supported by this gizmo
  57266. * @param mesh The mesh to replace the default mesh of the gizmo
  57267. */
  57268. setCustomMesh(mesh: Mesh): void;
  57269. }
  57270. }
  57271. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57272. import { Observable } from "babylonjs/Misc/observable";
  57273. import { Nullable } from "babylonjs/types";
  57274. import { Vector3 } from "babylonjs/Maths/math.vector";
  57275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57276. import { Node } from "babylonjs/node";
  57277. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57278. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57280. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57281. import { Scene } from "babylonjs/scene";
  57282. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57283. import { Color3 } from "babylonjs/Maths/math.color";
  57284. /**
  57285. * Single axis drag gizmo
  57286. */
  57287. export class AxisDragGizmo extends Gizmo {
  57288. /**
  57289. * Drag behavior responsible for the gizmos dragging interactions
  57290. */
  57291. dragBehavior: PointerDragBehavior;
  57292. private _pointerObserver;
  57293. /**
  57294. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57295. */
  57296. snapDistance: number;
  57297. /**
  57298. * Event that fires each time the gizmo snaps to a new location.
  57299. * * snapDistance is the the change in distance
  57300. */
  57301. onSnapObservable: Observable<{
  57302. snapDistance: number;
  57303. }>;
  57304. private _isEnabled;
  57305. private _parent;
  57306. private _gizmoMesh;
  57307. private _coloredMaterial;
  57308. private _hoverMaterial;
  57309. private _disableMaterial;
  57310. private _dragging;
  57311. /** @hidden */
  57312. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57313. /** @hidden */
  57314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57315. /**
  57316. * Creates an AxisDragGizmo
  57317. * @param gizmoLayer The utility layer the gizmo will be added to
  57318. * @param dragAxis The axis which the gizmo will be able to drag on
  57319. * @param color The color of the gizmo
  57320. * @param thickness display gizmo axis thickness
  57321. */
  57322. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57324. /**
  57325. * If the gizmo is enabled
  57326. */
  57327. set isEnabled(value: boolean);
  57328. get isEnabled(): boolean;
  57329. /**
  57330. * Disposes of the gizmo
  57331. */
  57332. dispose(): void;
  57333. }
  57334. }
  57335. declare module "babylonjs/Debug/axesViewer" {
  57336. import { Vector3 } from "babylonjs/Maths/math.vector";
  57337. import { Nullable } from "babylonjs/types";
  57338. import { Scene } from "babylonjs/scene";
  57339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57340. /**
  57341. * The Axes viewer will show 3 axes in a specific point in space
  57342. */
  57343. export class AxesViewer {
  57344. private _xAxis;
  57345. private _yAxis;
  57346. private _zAxis;
  57347. private _scaleLinesFactor;
  57348. private _instanced;
  57349. /**
  57350. * Gets the hosting scene
  57351. */
  57352. scene: Nullable<Scene>;
  57353. /**
  57354. * Gets or sets a number used to scale line length
  57355. */
  57356. scaleLines: number;
  57357. /** Gets the node hierarchy used to render x-axis */
  57358. get xAxis(): TransformNode;
  57359. /** Gets the node hierarchy used to render y-axis */
  57360. get yAxis(): TransformNode;
  57361. /** Gets the node hierarchy used to render z-axis */
  57362. get zAxis(): TransformNode;
  57363. /**
  57364. * Creates a new AxesViewer
  57365. * @param scene defines the hosting scene
  57366. * @param scaleLines defines a number used to scale line length (1 by default)
  57367. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57368. * @param xAxis defines the node hierarchy used to render the x-axis
  57369. * @param yAxis defines the node hierarchy used to render the y-axis
  57370. * @param zAxis defines the node hierarchy used to render the z-axis
  57371. */
  57372. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57373. /**
  57374. * Force the viewer to update
  57375. * @param position defines the position of the viewer
  57376. * @param xaxis defines the x axis of the viewer
  57377. * @param yaxis defines the y axis of the viewer
  57378. * @param zaxis defines the z axis of the viewer
  57379. */
  57380. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57381. /**
  57382. * Creates an instance of this axes viewer.
  57383. * @returns a new axes viewer with instanced meshes
  57384. */
  57385. createInstance(): AxesViewer;
  57386. /** Releases resources */
  57387. dispose(): void;
  57388. private static _SetRenderingGroupId;
  57389. }
  57390. }
  57391. declare module "babylonjs/Debug/boneAxesViewer" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57394. import { Vector3 } from "babylonjs/Maths/math.vector";
  57395. import { Mesh } from "babylonjs/Meshes/mesh";
  57396. import { Bone } from "babylonjs/Bones/bone";
  57397. import { Scene } from "babylonjs/scene";
  57398. /**
  57399. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57400. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57401. */
  57402. export class BoneAxesViewer extends AxesViewer {
  57403. /**
  57404. * Gets or sets the target mesh where to display the axes viewer
  57405. */
  57406. mesh: Nullable<Mesh>;
  57407. /**
  57408. * Gets or sets the target bone where to display the axes viewer
  57409. */
  57410. bone: Nullable<Bone>;
  57411. /** Gets current position */
  57412. pos: Vector3;
  57413. /** Gets direction of X axis */
  57414. xaxis: Vector3;
  57415. /** Gets direction of Y axis */
  57416. yaxis: Vector3;
  57417. /** Gets direction of Z axis */
  57418. zaxis: Vector3;
  57419. /**
  57420. * Creates a new BoneAxesViewer
  57421. * @param scene defines the hosting scene
  57422. * @param bone defines the target bone
  57423. * @param mesh defines the target mesh
  57424. * @param scaleLines defines a scaling factor for line length (1 by default)
  57425. */
  57426. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57427. /**
  57428. * Force the viewer to update
  57429. */
  57430. update(): void;
  57431. /** Releases resources */
  57432. dispose(): void;
  57433. }
  57434. }
  57435. declare module "babylonjs/Debug/debugLayer" {
  57436. import { Scene } from "babylonjs/scene";
  57437. /**
  57438. * Interface used to define scene explorer extensibility option
  57439. */
  57440. export interface IExplorerExtensibilityOption {
  57441. /**
  57442. * Define the option label
  57443. */
  57444. label: string;
  57445. /**
  57446. * Defines the action to execute on click
  57447. */
  57448. action: (entity: any) => void;
  57449. }
  57450. /**
  57451. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57452. */
  57453. export interface IExplorerExtensibilityGroup {
  57454. /**
  57455. * Defines a predicate to test if a given type mut be extended
  57456. */
  57457. predicate: (entity: any) => boolean;
  57458. /**
  57459. * Gets the list of options added to a type
  57460. */
  57461. entries: IExplorerExtensibilityOption[];
  57462. }
  57463. /**
  57464. * Interface used to define the options to use to create the Inspector
  57465. */
  57466. export interface IInspectorOptions {
  57467. /**
  57468. * Display in overlay mode (default: false)
  57469. */
  57470. overlay?: boolean;
  57471. /**
  57472. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57473. */
  57474. globalRoot?: HTMLElement;
  57475. /**
  57476. * Display the Scene explorer
  57477. */
  57478. showExplorer?: boolean;
  57479. /**
  57480. * Display the property inspector
  57481. */
  57482. showInspector?: boolean;
  57483. /**
  57484. * Display in embed mode (both panes on the right)
  57485. */
  57486. embedMode?: boolean;
  57487. /**
  57488. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57489. */
  57490. handleResize?: boolean;
  57491. /**
  57492. * Allow the panes to popup (default: true)
  57493. */
  57494. enablePopup?: boolean;
  57495. /**
  57496. * Allow the panes to be closed by users (default: true)
  57497. */
  57498. enableClose?: boolean;
  57499. /**
  57500. * Optional list of extensibility entries
  57501. */
  57502. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57503. /**
  57504. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57505. */
  57506. inspectorURL?: string;
  57507. /**
  57508. * Optional initial tab (default to DebugLayerTab.Properties)
  57509. */
  57510. initialTab?: DebugLayerTab;
  57511. }
  57512. module "babylonjs/scene" {
  57513. interface Scene {
  57514. /**
  57515. * @hidden
  57516. * Backing field
  57517. */
  57518. _debugLayer: DebugLayer;
  57519. /**
  57520. * Gets the debug layer (aka Inspector) associated with the scene
  57521. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57522. */
  57523. debugLayer: DebugLayer;
  57524. }
  57525. }
  57526. /**
  57527. * Enum of inspector action tab
  57528. */
  57529. export enum DebugLayerTab {
  57530. /**
  57531. * Properties tag (default)
  57532. */
  57533. Properties = 0,
  57534. /**
  57535. * Debug tab
  57536. */
  57537. Debug = 1,
  57538. /**
  57539. * Statistics tab
  57540. */
  57541. Statistics = 2,
  57542. /**
  57543. * Tools tab
  57544. */
  57545. Tools = 3,
  57546. /**
  57547. * Settings tab
  57548. */
  57549. Settings = 4
  57550. }
  57551. /**
  57552. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57553. * what is happening in your scene
  57554. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57555. */
  57556. export class DebugLayer {
  57557. /**
  57558. * Define the url to get the inspector script from.
  57559. * By default it uses the babylonjs CDN.
  57560. * @ignoreNaming
  57561. */
  57562. static InspectorURL: string;
  57563. private _scene;
  57564. private BJSINSPECTOR;
  57565. private _onPropertyChangedObservable?;
  57566. /**
  57567. * Observable triggered when a property is changed through the inspector.
  57568. */
  57569. get onPropertyChangedObservable(): any;
  57570. /**
  57571. * Instantiates a new debug layer.
  57572. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57573. * what is happening in your scene
  57574. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57575. * @param scene Defines the scene to inspect
  57576. */
  57577. constructor(scene: Scene);
  57578. /** Creates the inspector window. */
  57579. private _createInspector;
  57580. /**
  57581. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57582. * @param entity defines the entity to select
  57583. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57584. */
  57585. select(entity: any, lineContainerTitles?: string | string[]): void;
  57586. /** Get the inspector from bundle or global */
  57587. private _getGlobalInspector;
  57588. /**
  57589. * Get if the inspector is visible or not.
  57590. * @returns true if visible otherwise, false
  57591. */
  57592. isVisible(): boolean;
  57593. /**
  57594. * Hide the inspector and close its window.
  57595. */
  57596. hide(): void;
  57597. /**
  57598. * Update the scene in the inspector
  57599. */
  57600. setAsActiveScene(): void;
  57601. /**
  57602. * Launch the debugLayer.
  57603. * @param config Define the configuration of the inspector
  57604. * @return a promise fulfilled when the debug layer is visible
  57605. */
  57606. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57607. }
  57608. }
  57609. declare module "babylonjs/Debug/physicsViewer" {
  57610. import { Nullable } from "babylonjs/types";
  57611. import { Scene } from "babylonjs/scene";
  57612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57613. import { Mesh } from "babylonjs/Meshes/mesh";
  57614. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57615. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57616. /**
  57617. * Used to show the physics impostor around the specific mesh
  57618. */
  57619. export class PhysicsViewer {
  57620. /** @hidden */
  57621. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57622. /** @hidden */
  57623. protected _meshes: Array<Nullable<AbstractMesh>>;
  57624. /** @hidden */
  57625. protected _scene: Nullable<Scene>;
  57626. /** @hidden */
  57627. protected _numMeshes: number;
  57628. /** @hidden */
  57629. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57630. private _renderFunction;
  57631. private _utilityLayer;
  57632. private _debugBoxMesh;
  57633. private _debugSphereMesh;
  57634. private _debugCylinderMesh;
  57635. private _debugMaterial;
  57636. private _debugMeshMeshes;
  57637. /**
  57638. * Creates a new PhysicsViewer
  57639. * @param scene defines the hosting scene
  57640. */
  57641. constructor(scene: Scene);
  57642. /** @hidden */
  57643. protected _updateDebugMeshes(): void;
  57644. /**
  57645. * Renders a specified physic impostor
  57646. * @param impostor defines the impostor to render
  57647. * @param targetMesh defines the mesh represented by the impostor
  57648. * @returns the new debug mesh used to render the impostor
  57649. */
  57650. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57651. /**
  57652. * Hides a specified physic impostor
  57653. * @param impostor defines the impostor to hide
  57654. */
  57655. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57656. private _getDebugMaterial;
  57657. private _getDebugBoxMesh;
  57658. private _getDebugSphereMesh;
  57659. private _getDebugCylinderMesh;
  57660. private _getDebugMeshMesh;
  57661. private _getDebugMesh;
  57662. /** Releases all resources */
  57663. dispose(): void;
  57664. }
  57665. }
  57666. declare module "babylonjs/Debug/rayHelper" {
  57667. import { Nullable } from "babylonjs/types";
  57668. import { Ray } from "babylonjs/Culling/ray";
  57669. import { Vector3 } from "babylonjs/Maths/math.vector";
  57670. import { Color3 } from "babylonjs/Maths/math.color";
  57671. import { Scene } from "babylonjs/scene";
  57672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57673. import "babylonjs/Meshes/Builders/linesBuilder";
  57674. /**
  57675. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57676. * in order to better appreciate the issue one might have.
  57677. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57678. */
  57679. export class RayHelper {
  57680. /**
  57681. * Defines the ray we are currently tryin to visualize.
  57682. */
  57683. ray: Nullable<Ray>;
  57684. private _renderPoints;
  57685. private _renderLine;
  57686. private _renderFunction;
  57687. private _scene;
  57688. private _onAfterRenderObserver;
  57689. private _onAfterStepObserver;
  57690. private _attachedToMesh;
  57691. private _meshSpaceDirection;
  57692. private _meshSpaceOrigin;
  57693. /**
  57694. * Helper function to create a colored helper in a scene in one line.
  57695. * @param ray Defines the ray we are currently tryin to visualize
  57696. * @param scene Defines the scene the ray is used in
  57697. * @param color Defines the color we want to see the ray in
  57698. * @returns The newly created ray helper.
  57699. */
  57700. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57701. /**
  57702. * Instantiate a new ray helper.
  57703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57704. * in order to better appreciate the issue one might have.
  57705. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57706. * @param ray Defines the ray we are currently tryin to visualize
  57707. */
  57708. constructor(ray: Ray);
  57709. /**
  57710. * Shows the ray we are willing to debug.
  57711. * @param scene Defines the scene the ray needs to be rendered in
  57712. * @param color Defines the color the ray needs to be rendered in
  57713. */
  57714. show(scene: Scene, color?: Color3): void;
  57715. /**
  57716. * Hides the ray we are debugging.
  57717. */
  57718. hide(): void;
  57719. private _render;
  57720. /**
  57721. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57722. * @param mesh Defines the mesh we want the helper attached to
  57723. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57724. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57725. * @param length Defines the length of the ray
  57726. */
  57727. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57728. /**
  57729. * Detach the ray helper from the mesh it has previously been attached to.
  57730. */
  57731. detachFromMesh(): void;
  57732. private _updateToMesh;
  57733. /**
  57734. * Dispose the helper and release its associated resources.
  57735. */
  57736. dispose(): void;
  57737. }
  57738. }
  57739. declare module "babylonjs/Debug/ISkeletonViewer" {
  57740. import { Skeleton } from "babylonjs/Bones/skeleton";
  57741. import { Color3 } from "babylonjs/Maths/math.color";
  57742. /**
  57743. * Defines the options associated with the creation of a SkeletonViewer.
  57744. */
  57745. export interface ISkeletonViewerOptions {
  57746. /** Should the system pause animations before building the Viewer? */
  57747. pauseAnimations: boolean;
  57748. /** Should the system return the skeleton to rest before building? */
  57749. returnToRest: boolean;
  57750. /** public Display Mode of the Viewer */
  57751. displayMode: number;
  57752. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57753. displayOptions: ISkeletonViewerDisplayOptions;
  57754. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57755. computeBonesUsingShaders: boolean;
  57756. /** Flag ignore non weighted bones */
  57757. useAllBones: boolean;
  57758. }
  57759. /**
  57760. * Defines how to display the various bone meshes for the viewer.
  57761. */
  57762. export interface ISkeletonViewerDisplayOptions {
  57763. /** How far down to start tapering the bone spurs */
  57764. midStep?: number;
  57765. /** How big is the midStep? */
  57766. midStepFactor?: number;
  57767. /** Base for the Sphere Size */
  57768. sphereBaseSize?: number;
  57769. /** The ratio of the sphere to the longest bone in units */
  57770. sphereScaleUnit?: number;
  57771. /** Ratio for the Sphere Size */
  57772. sphereFactor?: number;
  57773. /** Whether a spur should attach its far end to the child bone position */
  57774. spurFollowsChild?: boolean;
  57775. /** Whether to show local axes or not */
  57776. showLocalAxes?: boolean;
  57777. /** Length of each local axis */
  57778. localAxesSize?: number;
  57779. }
  57780. /**
  57781. * Defines the constructor options for the BoneWeight Shader.
  57782. */
  57783. export interface IBoneWeightShaderOptions {
  57784. /** Skeleton to Map */
  57785. skeleton: Skeleton;
  57786. /** Colors for Uninfluenced bones */
  57787. colorBase?: Color3;
  57788. /** Colors for 0.0-0.25 Weight bones */
  57789. colorZero?: Color3;
  57790. /** Color for 0.25-0.5 Weight Influence */
  57791. colorQuarter?: Color3;
  57792. /** Color for 0.5-0.75 Weight Influence */
  57793. colorHalf?: Color3;
  57794. /** Color for 0.75-1 Weight Influence */
  57795. colorFull?: Color3;
  57796. /** Color for Zero Weight Influence */
  57797. targetBoneIndex?: number;
  57798. }
  57799. /**
  57800. * Simple structure of the gradient steps for the Color Map.
  57801. */
  57802. export interface ISkeletonMapShaderColorMapKnot {
  57803. /** Color of the Knot */
  57804. color: Color3;
  57805. /** Location of the Knot */
  57806. location: number;
  57807. }
  57808. /**
  57809. * Defines the constructor options for the SkeletonMap Shader.
  57810. */
  57811. export interface ISkeletonMapShaderOptions {
  57812. /** Skeleton to Map */
  57813. skeleton: Skeleton;
  57814. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57815. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57816. }
  57817. }
  57818. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57819. import { Nullable } from "babylonjs/types";
  57820. import { Scene } from "babylonjs/scene";
  57821. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57822. import { Color4 } from "babylonjs/Maths/math.color";
  57823. import { Mesh } from "babylonjs/Meshes/mesh";
  57824. /**
  57825. * Class containing static functions to help procedurally build meshes
  57826. */
  57827. export class RibbonBuilder {
  57828. /**
  57829. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57830. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57831. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57832. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57833. * * 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
  57834. * * 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
  57835. * * 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
  57836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57839. * * 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
  57840. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57841. * * 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
  57842. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57844. * @param name defines the name of the mesh
  57845. * @param options defines the options used to create the mesh
  57846. * @param scene defines the hosting scene
  57847. * @returns the ribbon mesh
  57848. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57850. */
  57851. static CreateRibbon(name: string, options: {
  57852. pathArray: Vector3[][];
  57853. closeArray?: boolean;
  57854. closePath?: boolean;
  57855. offset?: number;
  57856. updatable?: boolean;
  57857. sideOrientation?: number;
  57858. frontUVs?: Vector4;
  57859. backUVs?: Vector4;
  57860. instance?: Mesh;
  57861. invertUV?: boolean;
  57862. uvs?: Vector2[];
  57863. colors?: Color4[];
  57864. }, scene?: Nullable<Scene>): Mesh;
  57865. }
  57866. }
  57867. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57868. import { Nullable } from "babylonjs/types";
  57869. import { Scene } from "babylonjs/scene";
  57870. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57871. import { Mesh } from "babylonjs/Meshes/mesh";
  57872. /**
  57873. * Class containing static functions to help procedurally build meshes
  57874. */
  57875. export class ShapeBuilder {
  57876. /**
  57877. * 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.
  57878. * * 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.
  57879. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57880. * * 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.
  57881. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57882. * * 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
  57883. * * 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
  57884. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57889. * @param name defines the name of the mesh
  57890. * @param options defines the options used to create the mesh
  57891. * @param scene defines the hosting scene
  57892. * @returns the extruded shape mesh
  57893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57895. */
  57896. static ExtrudeShape(name: string, options: {
  57897. shape: Vector3[];
  57898. path: Vector3[];
  57899. scale?: number;
  57900. rotation?: number;
  57901. cap?: number;
  57902. updatable?: boolean;
  57903. sideOrientation?: number;
  57904. frontUVs?: Vector4;
  57905. backUVs?: Vector4;
  57906. instance?: Mesh;
  57907. invertUV?: boolean;
  57908. }, scene?: Nullable<Scene>): Mesh;
  57909. /**
  57910. * Creates an custom extruded shape mesh.
  57911. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57912. * * 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.
  57913. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57914. * * 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
  57915. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57916. * * 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
  57917. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57918. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57919. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57920. * * 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
  57921. * * 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
  57922. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57927. * @param name defines the name of the mesh
  57928. * @param options defines the options used to create the mesh
  57929. * @param scene defines the hosting scene
  57930. * @returns the custom extruded shape mesh
  57931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57934. */
  57935. static ExtrudeShapeCustom(name: string, options: {
  57936. shape: Vector3[];
  57937. path: Vector3[];
  57938. scaleFunction?: any;
  57939. rotationFunction?: any;
  57940. ribbonCloseArray?: boolean;
  57941. ribbonClosePath?: boolean;
  57942. cap?: number;
  57943. updatable?: boolean;
  57944. sideOrientation?: number;
  57945. frontUVs?: Vector4;
  57946. backUVs?: Vector4;
  57947. instance?: Mesh;
  57948. invertUV?: boolean;
  57949. }, scene?: Nullable<Scene>): Mesh;
  57950. private static _ExtrudeShapeGeneric;
  57951. }
  57952. }
  57953. declare module "babylonjs/Debug/skeletonViewer" {
  57954. import { Color3 } from "babylonjs/Maths/math.color";
  57955. import { Scene } from "babylonjs/scene";
  57956. import { Nullable } from "babylonjs/types";
  57957. import { Skeleton } from "babylonjs/Bones/skeleton";
  57958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57959. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57961. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57962. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57963. /**
  57964. * Class used to render a debug view of a given skeleton
  57965. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57966. */
  57967. export class SkeletonViewer {
  57968. /** defines the skeleton to render */
  57969. skeleton: Skeleton;
  57970. /** defines the mesh attached to the skeleton */
  57971. mesh: AbstractMesh;
  57972. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57973. autoUpdateBonesMatrices: boolean;
  57974. /** defines the rendering group id to use with the viewer */
  57975. renderingGroupId: number;
  57976. /** is the options for the viewer */
  57977. options: Partial<ISkeletonViewerOptions>;
  57978. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  57979. static readonly DISPLAY_LINES: number;
  57980. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  57981. static readonly DISPLAY_SPHERES: number;
  57982. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  57983. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  57984. /** public static method to create a BoneWeight Shader
  57985. * @param options The constructor options
  57986. * @param scene The scene that the shader is scoped to
  57987. * @returns The created ShaderMaterial
  57988. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  57989. */
  57990. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  57991. /** public static method to create a BoneWeight Shader
  57992. * @param options The constructor options
  57993. * @param scene The scene that the shader is scoped to
  57994. * @returns The created ShaderMaterial
  57995. */
  57996. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  57997. /** private static method to create a BoneWeight Shader
  57998. * @param size The size of the buffer to create (usually the bone count)
  57999. * @param colorMap The gradient data to generate
  58000. * @param scene The scene that the shader is scoped to
  58001. * @returns an Array of floats from the color gradient values
  58002. */
  58003. private static _CreateBoneMapColorBuffer;
  58004. /** If SkeletonViewer scene scope. */
  58005. private _scene;
  58006. /** Gets or sets the color used to render the skeleton */
  58007. color: Color3;
  58008. /** Array of the points of the skeleton fo the line view. */
  58009. private _debugLines;
  58010. /** The SkeletonViewers Mesh. */
  58011. private _debugMesh;
  58012. /** The local axes Meshes. */
  58013. private _localAxes;
  58014. /** If SkeletonViewer is enabled. */
  58015. private _isEnabled;
  58016. /** If SkeletonViewer is ready. */
  58017. private _ready;
  58018. /** SkeletonViewer render observable. */
  58019. private _obs;
  58020. /** The Utility Layer to render the gizmos in. */
  58021. private _utilityLayer;
  58022. private _boneIndices;
  58023. /** Gets the Scene. */
  58024. get scene(): Scene;
  58025. /** Gets the utilityLayer. */
  58026. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58027. /** Checks Ready Status. */
  58028. get isReady(): Boolean;
  58029. /** Sets Ready Status. */
  58030. set ready(value: boolean);
  58031. /** Gets the debugMesh */
  58032. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58033. /** Sets the debugMesh */
  58034. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58035. /** Gets the displayMode */
  58036. get displayMode(): number;
  58037. /** Sets the displayMode */
  58038. set displayMode(value: number);
  58039. /**
  58040. * Creates a new SkeletonViewer
  58041. * @param skeleton defines the skeleton to render
  58042. * @param mesh defines the mesh attached to the skeleton
  58043. * @param scene defines the hosting scene
  58044. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58045. * @param renderingGroupId defines the rendering group id to use with the viewer
  58046. * @param options All of the extra constructor options for the SkeletonViewer
  58047. */
  58048. constructor(
  58049. /** defines the skeleton to render */
  58050. skeleton: Skeleton,
  58051. /** defines the mesh attached to the skeleton */
  58052. mesh: AbstractMesh,
  58053. /** The Scene scope*/
  58054. scene: Scene,
  58055. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58056. autoUpdateBonesMatrices?: boolean,
  58057. /** defines the rendering group id to use with the viewer */
  58058. renderingGroupId?: number,
  58059. /** is the options for the viewer */
  58060. options?: Partial<ISkeletonViewerOptions>);
  58061. /** The Dynamic bindings for the update functions */
  58062. private _bindObs;
  58063. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58064. update(): void;
  58065. /** Gets or sets a boolean indicating if the viewer is enabled */
  58066. set isEnabled(value: boolean);
  58067. get isEnabled(): boolean;
  58068. private _getBonePosition;
  58069. private _getLinesForBonesWithLength;
  58070. private _getLinesForBonesNoLength;
  58071. /** function to revert the mesh and scene back to the initial state. */
  58072. private _revert;
  58073. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58074. private _getAbsoluteBindPoseToRef;
  58075. /** function to build and bind sphere joint points and spur bone representations. */
  58076. private _buildSpheresAndSpurs;
  58077. private _buildLocalAxes;
  58078. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58079. private _displayLinesUpdate;
  58080. /** Changes the displayMode of the skeleton viewer
  58081. * @param mode The displayMode numerical value
  58082. */
  58083. changeDisplayMode(mode: number): void;
  58084. /** Sets a display option of the skeleton viewer
  58085. *
  58086. * | Option | Type | Default | Description |
  58087. * | ---------------- | ------- | ------- | ----------- |
  58088. * | 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`. |
  58089. * | 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`. |
  58090. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58091. * | 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`. |
  58092. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58093. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58094. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58095. *
  58096. * @param option String of the option name
  58097. * @param value The numerical option value
  58098. */
  58099. changeDisplayOptions(option: string, value: number): void;
  58100. /** Release associated resources */
  58101. dispose(): void;
  58102. }
  58103. }
  58104. declare module "babylonjs/Debug/index" {
  58105. export * from "babylonjs/Debug/axesViewer";
  58106. export * from "babylonjs/Debug/boneAxesViewer";
  58107. export * from "babylonjs/Debug/debugLayer";
  58108. export * from "babylonjs/Debug/physicsViewer";
  58109. export * from "babylonjs/Debug/rayHelper";
  58110. export * from "babylonjs/Debug/skeletonViewer";
  58111. export * from "babylonjs/Debug/ISkeletonViewer";
  58112. }
  58113. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  58114. /**
  58115. * Enum for Device Types
  58116. */
  58117. export enum DeviceType {
  58118. /** Generic */
  58119. Generic = 0,
  58120. /** Keyboard */
  58121. Keyboard = 1,
  58122. /** Mouse */
  58123. Mouse = 2,
  58124. /** Touch Pointers */
  58125. Touch = 3,
  58126. /** PS4 Dual Shock */
  58127. DualShock = 4,
  58128. /** Xbox */
  58129. Xbox = 5,
  58130. /** Switch Controller */
  58131. Switch = 6
  58132. }
  58133. /**
  58134. * Enum for All Pointers (Touch/Mouse)
  58135. */
  58136. export enum PointerInput {
  58137. /** Horizontal Axis */
  58138. Horizontal = 0,
  58139. /** Vertical Axis */
  58140. Vertical = 1,
  58141. /** Left Click or Touch */
  58142. LeftClick = 2,
  58143. /** Middle Click */
  58144. MiddleClick = 3,
  58145. /** Right Click */
  58146. RightClick = 4,
  58147. /** Browser Back */
  58148. BrowserBack = 5,
  58149. /** Browser Forward */
  58150. BrowserForward = 6
  58151. }
  58152. /**
  58153. * Enum for Dual Shock Gamepad
  58154. */
  58155. export enum DualShockInput {
  58156. /** Cross */
  58157. Cross = 0,
  58158. /** Circle */
  58159. Circle = 1,
  58160. /** Square */
  58161. Square = 2,
  58162. /** Triangle */
  58163. Triangle = 3,
  58164. /** L1 */
  58165. L1 = 4,
  58166. /** R1 */
  58167. R1 = 5,
  58168. /** L2 */
  58169. L2 = 6,
  58170. /** R2 */
  58171. R2 = 7,
  58172. /** Share */
  58173. Share = 8,
  58174. /** Options */
  58175. Options = 9,
  58176. /** L3 */
  58177. L3 = 10,
  58178. /** R3 */
  58179. R3 = 11,
  58180. /** DPadUp */
  58181. DPadUp = 12,
  58182. /** DPadDown */
  58183. DPadDown = 13,
  58184. /** DPadLeft */
  58185. DPadLeft = 14,
  58186. /** DRight */
  58187. DPadRight = 15,
  58188. /** Home */
  58189. Home = 16,
  58190. /** TouchPad */
  58191. TouchPad = 17,
  58192. /** LStickXAxis */
  58193. LStickXAxis = 18,
  58194. /** LStickYAxis */
  58195. LStickYAxis = 19,
  58196. /** RStickXAxis */
  58197. RStickXAxis = 20,
  58198. /** RStickYAxis */
  58199. RStickYAxis = 21
  58200. }
  58201. /**
  58202. * Enum for Xbox Gamepad
  58203. */
  58204. export enum XboxInput {
  58205. /** A */
  58206. A = 0,
  58207. /** B */
  58208. B = 1,
  58209. /** X */
  58210. X = 2,
  58211. /** Y */
  58212. Y = 3,
  58213. /** LB */
  58214. LB = 4,
  58215. /** RB */
  58216. RB = 5,
  58217. /** LT */
  58218. LT = 6,
  58219. /** RT */
  58220. RT = 7,
  58221. /** Back */
  58222. Back = 8,
  58223. /** Start */
  58224. Start = 9,
  58225. /** LS */
  58226. LS = 10,
  58227. /** RS */
  58228. RS = 11,
  58229. /** DPadUp */
  58230. DPadUp = 12,
  58231. /** DPadDown */
  58232. DPadDown = 13,
  58233. /** DPadLeft */
  58234. DPadLeft = 14,
  58235. /** DRight */
  58236. DPadRight = 15,
  58237. /** Home */
  58238. Home = 16,
  58239. /** LStickXAxis */
  58240. LStickXAxis = 17,
  58241. /** LStickYAxis */
  58242. LStickYAxis = 18,
  58243. /** RStickXAxis */
  58244. RStickXAxis = 19,
  58245. /** RStickYAxis */
  58246. RStickYAxis = 20
  58247. }
  58248. /**
  58249. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58250. */
  58251. export enum SwitchInput {
  58252. /** B */
  58253. B = 0,
  58254. /** A */
  58255. A = 1,
  58256. /** Y */
  58257. Y = 2,
  58258. /** X */
  58259. X = 3,
  58260. /** L */
  58261. L = 4,
  58262. /** R */
  58263. R = 5,
  58264. /** ZL */
  58265. ZL = 6,
  58266. /** ZR */
  58267. ZR = 7,
  58268. /** Minus */
  58269. Minus = 8,
  58270. /** Plus */
  58271. Plus = 9,
  58272. /** LS */
  58273. LS = 10,
  58274. /** RS */
  58275. RS = 11,
  58276. /** DPadUp */
  58277. DPadUp = 12,
  58278. /** DPadDown */
  58279. DPadDown = 13,
  58280. /** DPadLeft */
  58281. DPadLeft = 14,
  58282. /** DRight */
  58283. DPadRight = 15,
  58284. /** Home */
  58285. Home = 16,
  58286. /** Capture */
  58287. Capture = 17,
  58288. /** LStickXAxis */
  58289. LStickXAxis = 18,
  58290. /** LStickYAxis */
  58291. LStickYAxis = 19,
  58292. /** RStickXAxis */
  58293. RStickXAxis = 20,
  58294. /** RStickYAxis */
  58295. RStickYAxis = 21
  58296. }
  58297. }
  58298. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58299. import { Engine } from "babylonjs/Engines/engine";
  58300. import { IDisposable } from "babylonjs/scene";
  58301. import { Nullable } from "babylonjs/types";
  58302. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58303. /**
  58304. * This class will take all inputs from Keyboard, Pointer, and
  58305. * any Gamepads and provide a polling system that all devices
  58306. * will use. This class assumes that there will only be one
  58307. * pointer device and one keyboard.
  58308. */
  58309. export class DeviceInputSystem implements IDisposable {
  58310. /**
  58311. * Returns onDeviceConnected callback property
  58312. * @returns Callback with function to execute when a device is connected
  58313. */
  58314. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58315. /**
  58316. * Sets callback function when a device is connected and executes against all connected devices
  58317. * @param callback Function to execute when a device is connected
  58318. */
  58319. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58320. /**
  58321. * Callback to be triggered when a device is disconnected
  58322. */
  58323. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58324. /**
  58325. * Callback to be triggered when event driven input is updated
  58326. */
  58327. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58328. private _inputs;
  58329. private _gamepads;
  58330. private _keyboardActive;
  58331. private _pointerActive;
  58332. private _elementToAttachTo;
  58333. private _keyboardDownEvent;
  58334. private _keyboardUpEvent;
  58335. private _pointerMoveEvent;
  58336. private _pointerDownEvent;
  58337. private _pointerUpEvent;
  58338. private _gamepadConnectedEvent;
  58339. private _gamepadDisconnectedEvent;
  58340. private _onDeviceConnected;
  58341. private static _MAX_KEYCODES;
  58342. private static _MAX_POINTER_INPUTS;
  58343. private constructor();
  58344. /**
  58345. * Creates a new DeviceInputSystem instance
  58346. * @param engine Engine to pull input element from
  58347. * @returns The new instance
  58348. */
  58349. static Create(engine: Engine): DeviceInputSystem;
  58350. /**
  58351. * Checks for current device input value, given an id and input index
  58352. * @param deviceName Id of connected device
  58353. * @param inputIndex Index of device input
  58354. * @returns Current value of input
  58355. */
  58356. /**
  58357. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58358. * @param deviceType Enum specifiying device type
  58359. * @param deviceSlot "Slot" or index that device is referenced in
  58360. * @param inputIndex Id of input to be checked
  58361. * @returns Current value of input
  58362. */
  58363. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58364. /**
  58365. * Dispose of all the eventlisteners
  58366. */
  58367. dispose(): void;
  58368. /**
  58369. * Checks for existing connections to devices and register them, if necessary
  58370. * Currently handles gamepads and mouse
  58371. */
  58372. private _checkForConnectedDevices;
  58373. /**
  58374. * Add a gamepad to the DeviceInputSystem
  58375. * @param gamepad A single DOM Gamepad object
  58376. */
  58377. private _addGamePad;
  58378. /**
  58379. * Add pointer device to DeviceInputSystem
  58380. * @param deviceType Type of Pointer to add
  58381. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58382. * @param currentX Current X at point of adding
  58383. * @param currentY Current Y at point of adding
  58384. */
  58385. private _addPointerDevice;
  58386. /**
  58387. * Add device and inputs to device array
  58388. * @param deviceType Enum specifiying device type
  58389. * @param deviceSlot "Slot" or index that device is referenced in
  58390. * @param numberOfInputs Number of input entries to create for given device
  58391. */
  58392. private _registerDevice;
  58393. /**
  58394. * Given a specific device name, remove that device from the device map
  58395. * @param deviceType Enum specifiying device type
  58396. * @param deviceSlot "Slot" or index that device is referenced in
  58397. */
  58398. private _unregisterDevice;
  58399. /**
  58400. * Handle all actions that come from keyboard interaction
  58401. */
  58402. private _handleKeyActions;
  58403. /**
  58404. * Handle all actions that come from pointer interaction
  58405. */
  58406. private _handlePointerActions;
  58407. /**
  58408. * Handle all actions that come from gamepad interaction
  58409. */
  58410. private _handleGamepadActions;
  58411. /**
  58412. * Update all non-event based devices with each frame
  58413. * @param deviceType Enum specifiying device type
  58414. * @param deviceSlot "Slot" or index that device is referenced in
  58415. * @param inputIndex Id of input to be checked
  58416. */
  58417. private _updateDevice;
  58418. /**
  58419. * Gets DeviceType from the device name
  58420. * @param deviceName Name of Device from DeviceInputSystem
  58421. * @returns DeviceType enum value
  58422. */
  58423. private _getGamepadDeviceType;
  58424. }
  58425. }
  58426. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58427. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58428. /**
  58429. * Type to handle enforcement of inputs
  58430. */
  58431. 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;
  58432. }
  58433. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58434. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58435. import { Engine } from "babylonjs/Engines/engine";
  58436. import { IDisposable } from "babylonjs/scene";
  58437. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58438. import { Nullable } from "babylonjs/types";
  58439. import { Observable } from "babylonjs/Misc/observable";
  58440. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58441. /**
  58442. * Class that handles all input for a specific device
  58443. */
  58444. export class DeviceSource<T extends DeviceType> {
  58445. /** Type of device */
  58446. readonly deviceType: DeviceType;
  58447. /** "Slot" or index that device is referenced in */
  58448. readonly deviceSlot: number;
  58449. /**
  58450. * Observable to handle device input changes per device
  58451. */
  58452. readonly onInputChangedObservable: Observable<{
  58453. inputIndex: DeviceInput<T>;
  58454. previousState: Nullable<number>;
  58455. currentState: Nullable<number>;
  58456. }>;
  58457. private readonly _deviceInputSystem;
  58458. /**
  58459. * Default Constructor
  58460. * @param deviceInputSystem Reference to DeviceInputSystem
  58461. * @param deviceType Type of device
  58462. * @param deviceSlot "Slot" or index that device is referenced in
  58463. */
  58464. constructor(deviceInputSystem: DeviceInputSystem,
  58465. /** Type of device */
  58466. deviceType: DeviceType,
  58467. /** "Slot" or index that device is referenced in */
  58468. deviceSlot?: number);
  58469. /**
  58470. * Get input for specific input
  58471. * @param inputIndex index of specific input on device
  58472. * @returns Input value from DeviceInputSystem
  58473. */
  58474. getInput(inputIndex: DeviceInput<T>): number;
  58475. }
  58476. /**
  58477. * Class to keep track of devices
  58478. */
  58479. export class DeviceSourceManager implements IDisposable {
  58480. /**
  58481. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58482. */
  58483. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58484. /**
  58485. * Observable to be triggered when after a device is disconnected
  58486. */
  58487. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58488. private readonly _devices;
  58489. private readonly _firstDevice;
  58490. private readonly _deviceInputSystem;
  58491. /**
  58492. * Default Constructor
  58493. * @param engine engine to pull input element from
  58494. */
  58495. constructor(engine: Engine);
  58496. /**
  58497. * Gets a DeviceSource, given a type and slot
  58498. * @param deviceType Enum specifying device type
  58499. * @param deviceSlot "Slot" or index that device is referenced in
  58500. * @returns DeviceSource object
  58501. */
  58502. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58503. /**
  58504. * Gets an array of DeviceSource objects for a given device type
  58505. * @param deviceType Enum specifying device type
  58506. * @returns Array of DeviceSource objects
  58507. */
  58508. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58509. /**
  58510. * Returns a read-only list of all available devices
  58511. * @returns Read-only array with active devices
  58512. */
  58513. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58514. /**
  58515. * Dispose of DeviceInputSystem and other parts
  58516. */
  58517. dispose(): void;
  58518. /**
  58519. * Function to add device name to device list
  58520. * @param deviceType Enum specifying device type
  58521. * @param deviceSlot "Slot" or index that device is referenced in
  58522. */
  58523. private _addDevice;
  58524. /**
  58525. * Function to remove device name to device list
  58526. * @param deviceType Enum specifying device type
  58527. * @param deviceSlot "Slot" or index that device is referenced in
  58528. */
  58529. private _removeDevice;
  58530. /**
  58531. * Updates array storing first connected device of each type
  58532. * @param type Type of Device
  58533. */
  58534. private _updateFirstDevices;
  58535. }
  58536. }
  58537. declare module "babylonjs/DeviceInput/index" {
  58538. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58539. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58540. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58541. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58542. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58543. }
  58544. declare module "babylonjs/Engines/nullEngine" {
  58545. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58546. import { Engine } from "babylonjs/Engines/engine";
  58547. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58548. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58550. import { Effect } from "babylonjs/Materials/effect";
  58551. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58553. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58554. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58555. /**
  58556. * Options to create the null engine
  58557. */
  58558. export class NullEngineOptions {
  58559. /**
  58560. * Render width (Default: 512)
  58561. */
  58562. renderWidth: number;
  58563. /**
  58564. * Render height (Default: 256)
  58565. */
  58566. renderHeight: number;
  58567. /**
  58568. * Texture size (Default: 512)
  58569. */
  58570. textureSize: number;
  58571. /**
  58572. * If delta time between frames should be constant
  58573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58574. */
  58575. deterministicLockstep: boolean;
  58576. /**
  58577. * Maximum about of steps between frames (Default: 4)
  58578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58579. */
  58580. lockstepMaxSteps: number;
  58581. /**
  58582. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58583. */
  58584. useHighPrecisionMatrix?: boolean;
  58585. }
  58586. /**
  58587. * The null engine class provides support for headless version of babylon.js.
  58588. * This can be used in server side scenario or for testing purposes
  58589. */
  58590. export class NullEngine extends Engine {
  58591. private _options;
  58592. /**
  58593. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58595. * @returns true if engine is in deterministic lock step mode
  58596. */
  58597. isDeterministicLockStep(): boolean;
  58598. /**
  58599. * Gets the max steps when engine is running in deterministic lock step
  58600. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58601. * @returns the max steps
  58602. */
  58603. getLockstepMaxSteps(): number;
  58604. /**
  58605. * Gets the current hardware scaling level.
  58606. * By default the hardware scaling level is computed from the window device ratio.
  58607. * 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.
  58608. * @returns a number indicating the current hardware scaling level
  58609. */
  58610. getHardwareScalingLevel(): number;
  58611. constructor(options?: NullEngineOptions);
  58612. /**
  58613. * Creates a vertex buffer
  58614. * @param vertices the data for the vertex buffer
  58615. * @returns the new WebGL static buffer
  58616. */
  58617. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58618. /**
  58619. * Creates a new index buffer
  58620. * @param indices defines the content of the index buffer
  58621. * @param updatable defines if the index buffer must be updatable
  58622. * @returns a new webGL buffer
  58623. */
  58624. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58625. /**
  58626. * Clear the current render buffer or the current render target (if any is set up)
  58627. * @param color defines the color to use
  58628. * @param backBuffer defines if the back buffer must be cleared
  58629. * @param depth defines if the depth buffer must be cleared
  58630. * @param stencil defines if the stencil buffer must be cleared
  58631. */
  58632. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58633. /**
  58634. * Gets the current render width
  58635. * @param useScreen defines if screen size must be used (or the current render target if any)
  58636. * @returns a number defining the current render width
  58637. */
  58638. getRenderWidth(useScreen?: boolean): number;
  58639. /**
  58640. * Gets the current render height
  58641. * @param useScreen defines if screen size must be used (or the current render target if any)
  58642. * @returns a number defining the current render height
  58643. */
  58644. getRenderHeight(useScreen?: boolean): number;
  58645. /**
  58646. * Set the WebGL's viewport
  58647. * @param viewport defines the viewport element to be used
  58648. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58649. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58650. */
  58651. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58652. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58653. /**
  58654. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58655. * @param pipelineContext defines the pipeline context to use
  58656. * @param uniformsNames defines the list of uniform names
  58657. * @returns an array of webGL uniform locations
  58658. */
  58659. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58660. /**
  58661. * Gets the lsit of active attributes for a given webGL program
  58662. * @param pipelineContext defines the pipeline context to use
  58663. * @param attributesNames defines the list of attribute names to get
  58664. * @returns an array of indices indicating the offset of each attribute
  58665. */
  58666. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58667. /**
  58668. * Binds an effect to the webGL context
  58669. * @param effect defines the effect to bind
  58670. */
  58671. bindSamplers(effect: Effect): void;
  58672. /**
  58673. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58674. * @param effect defines the effect to activate
  58675. */
  58676. enableEffect(effect: Effect): void;
  58677. /**
  58678. * Set various states to the webGL context
  58679. * @param culling defines backface culling state
  58680. * @param zOffset defines the value to apply to zOffset (0 by default)
  58681. * @param force defines if states must be applied even if cache is up to date
  58682. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58683. */
  58684. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58685. /**
  58686. * Set the value of an uniform to an array of int32
  58687. * @param uniform defines the webGL uniform location where to store the value
  58688. * @param array defines the array of int32 to store
  58689. * @returns true if value was set
  58690. */
  58691. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58692. /**
  58693. * Set the value of an uniform to an array of int32 (stored as vec2)
  58694. * @param uniform defines the webGL uniform location where to store the value
  58695. * @param array defines the array of int32 to store
  58696. * @returns true if value was set
  58697. */
  58698. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58699. /**
  58700. * Set the value of an uniform to an array of int32 (stored as vec3)
  58701. * @param uniform defines the webGL uniform location where to store the value
  58702. * @param array defines the array of int32 to store
  58703. * @returns true if value was set
  58704. */
  58705. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58706. /**
  58707. * Set the value of an uniform to an array of int32 (stored as vec4)
  58708. * @param uniform defines the webGL uniform location where to store the value
  58709. * @param array defines the array of int32 to store
  58710. * @returns true if value was set
  58711. */
  58712. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58713. /**
  58714. * Set the value of an uniform to an array of float32
  58715. * @param uniform defines the webGL uniform location where to store the value
  58716. * @param array defines the array of float32 to store
  58717. * @returns true if value was set
  58718. */
  58719. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58720. /**
  58721. * Set the value of an uniform to an array of float32 (stored as vec2)
  58722. * @param uniform defines the webGL uniform location where to store the value
  58723. * @param array defines the array of float32 to store
  58724. * @returns true if value was set
  58725. */
  58726. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58727. /**
  58728. * Set the value of an uniform to an array of float32 (stored as vec3)
  58729. * @param uniform defines the webGL uniform location where to store the value
  58730. * @param array defines the array of float32 to store
  58731. * @returns true if value was set
  58732. */
  58733. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58734. /**
  58735. * Set the value of an uniform to an array of float32 (stored as vec4)
  58736. * @param uniform defines the webGL uniform location where to store the value
  58737. * @param array defines the array of float32 to store
  58738. * @returns true if value was set
  58739. */
  58740. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58741. /**
  58742. * Set the value of an uniform to an array of number
  58743. * @param uniform defines the webGL uniform location where to store the value
  58744. * @param array defines the array of number to store
  58745. * @returns true if value was set
  58746. */
  58747. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58748. /**
  58749. * Set the value of an uniform to an array of number (stored as vec2)
  58750. * @param uniform defines the webGL uniform location where to store the value
  58751. * @param array defines the array of number to store
  58752. * @returns true if value was set
  58753. */
  58754. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58755. /**
  58756. * Set the value of an uniform to an array of number (stored as vec3)
  58757. * @param uniform defines the webGL uniform location where to store the value
  58758. * @param array defines the array of number to store
  58759. * @returns true if value was set
  58760. */
  58761. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58762. /**
  58763. * Set the value of an uniform to an array of number (stored as vec4)
  58764. * @param uniform defines the webGL uniform location where to store the value
  58765. * @param array defines the array of number to store
  58766. * @returns true if value was set
  58767. */
  58768. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58769. /**
  58770. * Set the value of an uniform to an array of float32 (stored as matrices)
  58771. * @param uniform defines the webGL uniform location where to store the value
  58772. * @param matrices defines the array of float32 to store
  58773. * @returns true if value was set
  58774. */
  58775. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58776. /**
  58777. * Set the value of an uniform to a matrix (3x3)
  58778. * @param uniform defines the webGL uniform location where to store the value
  58779. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58780. * @returns true if value was set
  58781. */
  58782. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58783. /**
  58784. * Set the value of an uniform to a matrix (2x2)
  58785. * @param uniform defines the webGL uniform location where to store the value
  58786. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58787. * @returns true if value was set
  58788. */
  58789. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58790. /**
  58791. * Set the value of an uniform to a number (float)
  58792. * @param uniform defines the webGL uniform location where to store the value
  58793. * @param value defines the float number to store
  58794. * @returns true if value was set
  58795. */
  58796. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58797. /**
  58798. * Set the value of an uniform to a vec2
  58799. * @param uniform defines the webGL uniform location where to store the value
  58800. * @param x defines the 1st component of the value
  58801. * @param y defines the 2nd component of the value
  58802. * @returns true if value was set
  58803. */
  58804. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58805. /**
  58806. * Set the value of an uniform to a vec3
  58807. * @param uniform defines the webGL uniform location where to store the value
  58808. * @param x defines the 1st component of the value
  58809. * @param y defines the 2nd component of the value
  58810. * @param z defines the 3rd component of the value
  58811. * @returns true if value was set
  58812. */
  58813. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58814. /**
  58815. * Set the value of an uniform to a boolean
  58816. * @param uniform defines the webGL uniform location where to store the value
  58817. * @param bool defines the boolean to store
  58818. * @returns true if value was set
  58819. */
  58820. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58821. /**
  58822. * Set the value of an uniform to a vec4
  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. * @param z defines the 3rd component of the value
  58827. * @param w defines the 4th component of the value
  58828. * @returns true if value was set
  58829. */
  58830. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58831. /**
  58832. * Sets the current alpha mode
  58833. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58834. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58835. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58836. */
  58837. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58838. /**
  58839. * Bind webGl buffers directly to the webGL context
  58840. * @param vertexBuffers defines the vertex buffer to bind
  58841. * @param indexBuffer defines the index buffer to bind
  58842. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58843. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58844. * @param effect defines the effect associated with the vertex buffer
  58845. */
  58846. bindBuffers(vertexBuffers: {
  58847. [key: string]: VertexBuffer;
  58848. }, indexBuffer: DataBuffer, effect: Effect): void;
  58849. /**
  58850. * Force the entire cache to be cleared
  58851. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58852. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58853. */
  58854. wipeCaches(bruteForce?: boolean): void;
  58855. /**
  58856. * Send a draw order
  58857. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58858. * @param indexStart defines the starting index
  58859. * @param indexCount defines the number of index to draw
  58860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58861. */
  58862. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58863. /**
  58864. * Draw a list of indexed primitives
  58865. * @param fillMode defines the primitive to use
  58866. * @param indexStart defines the starting index
  58867. * @param indexCount defines the number of index to draw
  58868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58869. */
  58870. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58871. /**
  58872. * Draw a list of unindexed primitives
  58873. * @param fillMode defines the primitive to use
  58874. * @param verticesStart defines the index of first vertex to draw
  58875. * @param verticesCount defines the count of vertices to draw
  58876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58877. */
  58878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58879. /** @hidden */
  58880. _createTexture(): WebGLTexture;
  58881. /** @hidden */
  58882. _releaseTexture(texture: InternalTexture): void;
  58883. /**
  58884. * Usually called from Texture.ts.
  58885. * Passed information to create a WebGLTexture
  58886. * @param urlArg defines a value which contains one of the following:
  58887. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58888. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58889. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58890. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58891. * @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)
  58892. * @param scene needed for loading to the correct scene
  58893. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58894. * @param onLoad optional callback to be called upon successful completion
  58895. * @param onError optional callback to be called upon failure
  58896. * @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
  58897. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58898. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58899. * @param forcedExtension defines the extension to use to pick the right loader
  58900. * @param mimeType defines an optional mime type
  58901. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58902. */
  58903. 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;
  58904. /**
  58905. * Creates a new render target texture
  58906. * @param size defines the size of the texture
  58907. * @param options defines the options used to create the texture
  58908. * @returns a new render target texture stored in an InternalTexture
  58909. */
  58910. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58911. /**
  58912. * Update the sampling mode of a given texture
  58913. * @param samplingMode defines the required sampling mode
  58914. * @param texture defines the texture to update
  58915. */
  58916. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58917. /**
  58918. * Binds the frame buffer to the specified texture.
  58919. * @param texture The texture to render to or null for the default canvas
  58920. * @param faceIndex The face of the texture to render to in case of cube texture
  58921. * @param requiredWidth The width of the target to render to
  58922. * @param requiredHeight The height of the target to render to
  58923. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58924. * @param lodLevel defines le lod level to bind to the frame buffer
  58925. */
  58926. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58927. /**
  58928. * Unbind the current render target texture from the webGL context
  58929. * @param texture defines the render target texture to unbind
  58930. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58931. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58932. */
  58933. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58934. /**
  58935. * Creates a dynamic vertex buffer
  58936. * @param vertices the data for the dynamic vertex buffer
  58937. * @returns the new WebGL dynamic buffer
  58938. */
  58939. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58940. /**
  58941. * Update the content of a dynamic texture
  58942. * @param texture defines the texture to update
  58943. * @param canvas defines the canvas containing the source
  58944. * @param invertY defines if data must be stored with Y axis inverted
  58945. * @param premulAlpha defines if alpha is stored as premultiplied
  58946. * @param format defines the format of the data
  58947. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58948. */
  58949. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58950. /**
  58951. * Gets a boolean indicating if all created effects are ready
  58952. * @returns true if all effects are ready
  58953. */
  58954. areAllEffectsReady(): boolean;
  58955. /**
  58956. * @hidden
  58957. * Get the current error code of the webGL context
  58958. * @returns the error code
  58959. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58960. */
  58961. getError(): number;
  58962. /** @hidden */
  58963. _getUnpackAlignement(): number;
  58964. /** @hidden */
  58965. _unpackFlipY(value: boolean): void;
  58966. /**
  58967. * Update a dynamic index buffer
  58968. * @param indexBuffer defines the target index buffer
  58969. * @param indices defines the data to update
  58970. * @param offset defines the offset in the target index buffer where update should start
  58971. */
  58972. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58973. /**
  58974. * Updates a dynamic vertex buffer.
  58975. * @param vertexBuffer the vertex buffer to update
  58976. * @param vertices the data used to update the vertex buffer
  58977. * @param byteOffset the byte offset of the data (optional)
  58978. * @param byteLength the byte length of the data (optional)
  58979. */
  58980. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  58981. /** @hidden */
  58982. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  58983. /** @hidden */
  58984. _bindTexture(channel: number, texture: InternalTexture): void;
  58985. protected _deleteBuffer(buffer: WebGLBuffer): void;
  58986. /**
  58987. * 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
  58988. */
  58989. releaseEffects(): void;
  58990. displayLoadingUI(): void;
  58991. hideLoadingUI(): void;
  58992. /** @hidden */
  58993. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58994. /** @hidden */
  58995. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58996. /** @hidden */
  58997. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58998. /** @hidden */
  58999. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59000. }
  59001. }
  59002. declare module "babylonjs/Instrumentation/timeToken" {
  59003. import { Nullable } from "babylonjs/types";
  59004. /**
  59005. * @hidden
  59006. **/
  59007. export class _TimeToken {
  59008. _startTimeQuery: Nullable<WebGLQuery>;
  59009. _endTimeQuery: Nullable<WebGLQuery>;
  59010. _timeElapsedQuery: Nullable<WebGLQuery>;
  59011. _timeElapsedQueryEnded: boolean;
  59012. }
  59013. }
  59014. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  59015. import { Nullable, int } from "babylonjs/types";
  59016. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  59017. /** @hidden */
  59018. export class _OcclusionDataStorage {
  59019. /** @hidden */
  59020. occlusionInternalRetryCounter: number;
  59021. /** @hidden */
  59022. isOcclusionQueryInProgress: boolean;
  59023. /** @hidden */
  59024. isOccluded: boolean;
  59025. /** @hidden */
  59026. occlusionRetryCount: number;
  59027. /** @hidden */
  59028. occlusionType: number;
  59029. /** @hidden */
  59030. occlusionQueryAlgorithmType: number;
  59031. }
  59032. module "babylonjs/Engines/engine" {
  59033. interface Engine {
  59034. /**
  59035. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59036. * @return the new query
  59037. */
  59038. createQuery(): WebGLQuery;
  59039. /**
  59040. * Delete and release a webGL query
  59041. * @param query defines the query to delete
  59042. * @return the current engine
  59043. */
  59044. deleteQuery(query: WebGLQuery): Engine;
  59045. /**
  59046. * Check if a given query has resolved and got its value
  59047. * @param query defines the query to check
  59048. * @returns true if the query got its value
  59049. */
  59050. isQueryResultAvailable(query: WebGLQuery): boolean;
  59051. /**
  59052. * Gets the value of a given query
  59053. * @param query defines the query to check
  59054. * @returns the value of the query
  59055. */
  59056. getQueryResult(query: WebGLQuery): number;
  59057. /**
  59058. * Initiates an occlusion query
  59059. * @param algorithmType defines the algorithm to use
  59060. * @param query defines the query to use
  59061. * @returns the current engine
  59062. * @see https://doc.babylonjs.com/features/occlusionquery
  59063. */
  59064. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59065. /**
  59066. * Ends an occlusion query
  59067. * @see https://doc.babylonjs.com/features/occlusionquery
  59068. * @param algorithmType defines the algorithm to use
  59069. * @returns the current engine
  59070. */
  59071. endOcclusionQuery(algorithmType: number): Engine;
  59072. /**
  59073. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59074. * Please note that only one query can be issued at a time
  59075. * @returns a time token used to track the time span
  59076. */
  59077. startTimeQuery(): Nullable<_TimeToken>;
  59078. /**
  59079. * Ends a time query
  59080. * @param token defines the token used to measure the time span
  59081. * @returns the time spent (in ns)
  59082. */
  59083. endTimeQuery(token: _TimeToken): int;
  59084. /** @hidden */
  59085. _currentNonTimestampToken: Nullable<_TimeToken>;
  59086. /** @hidden */
  59087. _createTimeQuery(): WebGLQuery;
  59088. /** @hidden */
  59089. _deleteTimeQuery(query: WebGLQuery): void;
  59090. /** @hidden */
  59091. _getGlAlgorithmType(algorithmType: number): number;
  59092. /** @hidden */
  59093. _getTimeQueryResult(query: WebGLQuery): any;
  59094. /** @hidden */
  59095. _getTimeQueryAvailability(query: WebGLQuery): any;
  59096. }
  59097. }
  59098. module "babylonjs/Meshes/abstractMesh" {
  59099. interface AbstractMesh {
  59100. /**
  59101. * Backing filed
  59102. * @hidden
  59103. */
  59104. __occlusionDataStorage: _OcclusionDataStorage;
  59105. /**
  59106. * Access property
  59107. * @hidden
  59108. */
  59109. _occlusionDataStorage: _OcclusionDataStorage;
  59110. /**
  59111. * 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.
  59112. * The default value is -1 which means don't break the query and wait till the result
  59113. * @see https://doc.babylonjs.com/features/occlusionquery
  59114. */
  59115. occlusionRetryCount: number;
  59116. /**
  59117. * 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:
  59118. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59119. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59120. * * 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.
  59121. * @see https://doc.babylonjs.com/features/occlusionquery
  59122. */
  59123. occlusionType: number;
  59124. /**
  59125. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59126. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59127. * * 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.
  59128. * @see https://doc.babylonjs.com/features/occlusionquery
  59129. */
  59130. occlusionQueryAlgorithmType: number;
  59131. /**
  59132. * 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
  59133. * @see https://doc.babylonjs.com/features/occlusionquery
  59134. */
  59135. isOccluded: boolean;
  59136. /**
  59137. * Flag to check the progress status of the query
  59138. * @see https://doc.babylonjs.com/features/occlusionquery
  59139. */
  59140. isOcclusionQueryInProgress: boolean;
  59141. }
  59142. }
  59143. }
  59144. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59147. /** @hidden */
  59148. export var _forceTransformFeedbackToBundle: boolean;
  59149. module "babylonjs/Engines/engine" {
  59150. interface Engine {
  59151. /**
  59152. * Creates a webGL transform feedback object
  59153. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59154. * @returns the webGL transform feedback object
  59155. */
  59156. createTransformFeedback(): WebGLTransformFeedback;
  59157. /**
  59158. * Delete a webGL transform feedback object
  59159. * @param value defines the webGL transform feedback object to delete
  59160. */
  59161. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59162. /**
  59163. * Bind a webGL transform feedback object to the webgl context
  59164. * @param value defines the webGL transform feedback object to bind
  59165. */
  59166. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59167. /**
  59168. * Begins a transform feedback operation
  59169. * @param usePoints defines if points or triangles must be used
  59170. */
  59171. beginTransformFeedback(usePoints: boolean): void;
  59172. /**
  59173. * Ends a transform feedback operation
  59174. */
  59175. endTransformFeedback(): void;
  59176. /**
  59177. * Specify the varyings to use with transform feedback
  59178. * @param program defines the associated webGL program
  59179. * @param value defines the list of strings representing the varying names
  59180. */
  59181. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59182. /**
  59183. * Bind a webGL buffer for a transform feedback operation
  59184. * @param value defines the webGL buffer to bind
  59185. */
  59186. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59187. }
  59188. }
  59189. }
  59190. declare module "babylonjs/Engines/Extensions/engine.views" {
  59191. import { Camera } from "babylonjs/Cameras/camera";
  59192. import { Nullable } from "babylonjs/types";
  59193. /**
  59194. * Class used to define an additional view for the engine
  59195. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59196. */
  59197. export class EngineView {
  59198. /** Defines the canvas where to render the view */
  59199. target: HTMLCanvasElement;
  59200. /** Defines an optional camera used to render the view (will use active camera else) */
  59201. camera?: Camera;
  59202. }
  59203. module "babylonjs/Engines/engine" {
  59204. interface Engine {
  59205. /**
  59206. * Gets or sets the HTML element to use for attaching events
  59207. */
  59208. inputElement: Nullable<HTMLElement>;
  59209. /**
  59210. * Gets the current engine view
  59211. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59212. */
  59213. activeView: Nullable<EngineView>;
  59214. /** Gets or sets the list of views */
  59215. views: EngineView[];
  59216. /**
  59217. * Register a new child canvas
  59218. * @param canvas defines the canvas to register
  59219. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59220. * @returns the associated view
  59221. */
  59222. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59223. /**
  59224. * Remove a registered child canvas
  59225. * @param canvas defines the canvas to remove
  59226. * @returns the current engine
  59227. */
  59228. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59229. }
  59230. }
  59231. }
  59232. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59233. import { Nullable } from "babylonjs/types";
  59234. module "babylonjs/Engines/engine" {
  59235. interface Engine {
  59236. /** @hidden */
  59237. _excludedCompressedTextures: string[];
  59238. /** @hidden */
  59239. _textureFormatInUse: string;
  59240. /**
  59241. * Gets the list of texture formats supported
  59242. */
  59243. readonly texturesSupported: Array<string>;
  59244. /**
  59245. * Gets the texture format in use
  59246. */
  59247. readonly textureFormatInUse: Nullable<string>;
  59248. /**
  59249. * Set the compressed texture extensions or file names to skip.
  59250. *
  59251. * @param skippedFiles defines the list of those texture files you want to skip
  59252. * Example: [".dds", ".env", "myfile.png"]
  59253. */
  59254. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59255. /**
  59256. * Set the compressed texture format to use, based on the formats you have, and the formats
  59257. * supported by the hardware / browser.
  59258. *
  59259. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59260. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59261. * to API arguments needed to compressed textures. This puts the burden on the container
  59262. * generator to house the arcane code for determining these for current & future formats.
  59263. *
  59264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59266. *
  59267. * Note: The result of this call is not taken into account when a texture is base64.
  59268. *
  59269. * @param formatsAvailable defines the list of those format families you have created
  59270. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59271. *
  59272. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59273. * @returns The extension selected.
  59274. */
  59275. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59276. }
  59277. }
  59278. }
  59279. declare module "babylonjs/Engines/Extensions/index" {
  59280. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59281. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59282. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59283. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59284. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59285. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59286. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59287. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59288. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59289. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59290. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59291. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59292. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59293. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59294. export * from "babylonjs/Engines/Extensions/engine.views";
  59295. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59296. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59297. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59298. }
  59299. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59301. /** @hidden */
  59302. export var rgbdEncodePixelShader: {
  59303. name: string;
  59304. shader: string;
  59305. };
  59306. }
  59307. declare module "babylonjs/Misc/environmentTextureTools" {
  59308. import { Nullable } from "babylonjs/types";
  59309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59312. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59313. import "babylonjs/Engines/Extensions/engine.readTexture";
  59314. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59315. import "babylonjs/Shaders/rgbdEncode.fragment";
  59316. import "babylonjs/Shaders/rgbdDecode.fragment";
  59317. /**
  59318. * Raw texture data and descriptor sufficient for WebGL texture upload
  59319. */
  59320. export interface EnvironmentTextureInfo {
  59321. /**
  59322. * Version of the environment map
  59323. */
  59324. version: number;
  59325. /**
  59326. * Width of image
  59327. */
  59328. width: number;
  59329. /**
  59330. * Irradiance information stored in the file.
  59331. */
  59332. irradiance: any;
  59333. /**
  59334. * Specular information stored in the file.
  59335. */
  59336. specular: any;
  59337. }
  59338. /**
  59339. * Defines One Image in the file. It requires only the position in the file
  59340. * as well as the length.
  59341. */
  59342. interface BufferImageData {
  59343. /**
  59344. * Length of the image data.
  59345. */
  59346. length: number;
  59347. /**
  59348. * Position of the data from the null terminator delimiting the end of the JSON.
  59349. */
  59350. position: number;
  59351. }
  59352. /**
  59353. * Defines the specular data enclosed in the file.
  59354. * This corresponds to the version 1 of the data.
  59355. */
  59356. export interface EnvironmentTextureSpecularInfoV1 {
  59357. /**
  59358. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59359. */
  59360. specularDataPosition?: number;
  59361. /**
  59362. * This contains all the images data needed to reconstruct the cubemap.
  59363. */
  59364. mipmaps: Array<BufferImageData>;
  59365. /**
  59366. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59367. */
  59368. lodGenerationScale: number;
  59369. }
  59370. /**
  59371. * Sets of helpers addressing the serialization and deserialization of environment texture
  59372. * stored in a BabylonJS env file.
  59373. * Those files are usually stored as .env files.
  59374. */
  59375. export class EnvironmentTextureTools {
  59376. /**
  59377. * Magic number identifying the env file.
  59378. */
  59379. private static _MagicBytes;
  59380. /**
  59381. * Gets the environment info from an env file.
  59382. * @param data The array buffer containing the .env bytes.
  59383. * @returns the environment file info (the json header) if successfully parsed.
  59384. */
  59385. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59386. /**
  59387. * Creates an environment texture from a loaded cube texture.
  59388. * @param texture defines the cube texture to convert in env file
  59389. * @return a promise containing the environment data if succesfull.
  59390. */
  59391. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59392. /**
  59393. * Creates a JSON representation of the spherical data.
  59394. * @param texture defines the texture containing the polynomials
  59395. * @return the JSON representation of the spherical info
  59396. */
  59397. private static _CreateEnvTextureIrradiance;
  59398. /**
  59399. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59400. * @param data the image data
  59401. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59402. * @return the views described by info providing access to the underlying buffer
  59403. */
  59404. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59405. /**
  59406. * Uploads the texture info contained in the env file to the GPU.
  59407. * @param texture defines the internal texture to upload to
  59408. * @param data defines the data to load
  59409. * @param info defines the texture info retrieved through the GetEnvInfo method
  59410. * @returns a promise
  59411. */
  59412. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59413. private static _OnImageReadyAsync;
  59414. /**
  59415. * Uploads the levels of image data to the GPU.
  59416. * @param texture defines the internal texture to upload to
  59417. * @param imageData defines the array buffer views of image data [mipmap][face]
  59418. * @returns a promise
  59419. */
  59420. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59421. /**
  59422. * Uploads spherical polynomials information to the texture.
  59423. * @param texture defines the texture we are trying to upload the information to
  59424. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59425. */
  59426. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59427. /** @hidden */
  59428. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59429. }
  59430. }
  59431. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59432. /**
  59433. * Class used to inline functions in shader code
  59434. */
  59435. export class ShaderCodeInliner {
  59436. private static readonly _RegexpFindFunctionNameAndType;
  59437. private _sourceCode;
  59438. private _functionDescr;
  59439. private _numMaxIterations;
  59440. /** Gets or sets the token used to mark the functions to inline */
  59441. inlineToken: string;
  59442. /** Gets or sets the debug mode */
  59443. debug: boolean;
  59444. /** Gets the code after the inlining process */
  59445. get code(): string;
  59446. /**
  59447. * Initializes the inliner
  59448. * @param sourceCode shader code source to inline
  59449. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59450. */
  59451. constructor(sourceCode: string, numMaxIterations?: number);
  59452. /**
  59453. * Start the processing of the shader code
  59454. */
  59455. processCode(): void;
  59456. private _collectFunctions;
  59457. private _processInlining;
  59458. private _extractBetweenMarkers;
  59459. private _skipWhitespaces;
  59460. private _removeComments;
  59461. private _replaceFunctionCallsByCode;
  59462. private _findBackward;
  59463. private _escapeRegExp;
  59464. private _replaceNames;
  59465. }
  59466. }
  59467. declare module "babylonjs/Engines/nativeEngine" {
  59468. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59469. import { Engine } from "babylonjs/Engines/engine";
  59470. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59473. import { Effect } from "babylonjs/Materials/effect";
  59474. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59475. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59476. import { IColor4Like } from "babylonjs/Maths/math.like";
  59477. import { Scene } from "babylonjs/scene";
  59478. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59479. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59480. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59481. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59482. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59483. /**
  59484. * Container for accessors for natively-stored mesh data buffers.
  59485. */
  59486. class NativeDataBuffer extends DataBuffer {
  59487. /**
  59488. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59489. */
  59490. nativeIndexBuffer?: any;
  59491. /**
  59492. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59493. */
  59494. nativeVertexBuffer?: any;
  59495. }
  59496. /** @hidden */
  59497. class NativeTexture extends InternalTexture {
  59498. getInternalTexture(): InternalTexture;
  59499. getViewCount(): number;
  59500. }
  59501. /** @hidden */
  59502. export class NativeEngine extends Engine {
  59503. private readonly _native;
  59504. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59505. private readonly INVALID_HANDLE;
  59506. private _boundBuffersVertexArray;
  59507. private _currentDepthTest;
  59508. getHardwareScalingLevel(): number;
  59509. constructor();
  59510. dispose(): void;
  59511. /**
  59512. * Can be used to override the current requestAnimationFrame requester.
  59513. * @hidden
  59514. */
  59515. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59516. /**
  59517. * Override default engine behavior.
  59518. * @param color
  59519. * @param backBuffer
  59520. * @param depth
  59521. * @param stencil
  59522. */
  59523. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59524. /**
  59525. * Gets host document
  59526. * @returns the host document object
  59527. */
  59528. getHostDocument(): Nullable<Document>;
  59529. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59530. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59531. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59532. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59533. [key: string]: VertexBuffer;
  59534. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59535. bindBuffers(vertexBuffers: {
  59536. [key: string]: VertexBuffer;
  59537. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59538. recordVertexArrayObject(vertexBuffers: {
  59539. [key: string]: VertexBuffer;
  59540. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59541. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59542. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59543. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59544. /**
  59545. * Draw a list of indexed primitives
  59546. * @param fillMode defines the primitive to use
  59547. * @param indexStart defines the starting index
  59548. * @param indexCount defines the number of index to draw
  59549. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59550. */
  59551. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59552. /**
  59553. * Draw a list of unindexed primitives
  59554. * @param fillMode defines the primitive to use
  59555. * @param verticesStart defines the index of first vertex to draw
  59556. * @param verticesCount defines the count of vertices to draw
  59557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59558. */
  59559. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59560. createPipelineContext(): IPipelineContext;
  59561. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59562. /** @hidden */
  59563. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59564. /** @hidden */
  59565. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59566. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59567. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59568. protected _setProgram(program: WebGLProgram): void;
  59569. _releaseEffect(effect: Effect): void;
  59570. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59571. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59572. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59573. bindSamplers(effect: Effect): void;
  59574. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59575. getRenderWidth(useScreen?: boolean): number;
  59576. getRenderHeight(useScreen?: boolean): number;
  59577. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59578. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59579. /**
  59580. * Set the z offset to apply to current rendering
  59581. * @param value defines the offset to apply
  59582. */
  59583. setZOffset(value: number): void;
  59584. /**
  59585. * Gets the current value of the zOffset
  59586. * @returns the current zOffset state
  59587. */
  59588. getZOffset(): number;
  59589. /**
  59590. * Enable or disable depth buffering
  59591. * @param enable defines the state to set
  59592. */
  59593. setDepthBuffer(enable: boolean): void;
  59594. /**
  59595. * Gets a boolean indicating if depth writing is enabled
  59596. * @returns the current depth writing state
  59597. */
  59598. getDepthWrite(): boolean;
  59599. setDepthFunctionToGreater(): void;
  59600. setDepthFunctionToGreaterOrEqual(): void;
  59601. setDepthFunctionToLess(): void;
  59602. setDepthFunctionToLessOrEqual(): void;
  59603. /**
  59604. * Enable or disable depth writing
  59605. * @param enable defines the state to set
  59606. */
  59607. setDepthWrite(enable: boolean): void;
  59608. /**
  59609. * Enable or disable color writing
  59610. * @param enable defines the state to set
  59611. */
  59612. setColorWrite(enable: boolean): void;
  59613. /**
  59614. * Gets a boolean indicating if color writing is enabled
  59615. * @returns the current color writing state
  59616. */
  59617. getColorWrite(): boolean;
  59618. /**
  59619. * Sets alpha constants used by some alpha blending modes
  59620. * @param r defines the red component
  59621. * @param g defines the green component
  59622. * @param b defines the blue component
  59623. * @param a defines the alpha component
  59624. */
  59625. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59626. /**
  59627. * Sets the current alpha mode
  59628. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59629. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59630. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59631. */
  59632. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59633. /**
  59634. * Gets the current alpha mode
  59635. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59636. * @returns the current alpha mode
  59637. */
  59638. getAlphaMode(): number;
  59639. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59640. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59641. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59642. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59643. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59644. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59645. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59646. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59647. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59648. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59649. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59650. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59651. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59652. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59653. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59654. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59655. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59656. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59657. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59658. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59659. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59660. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59661. wipeCaches(bruteForce?: boolean): void;
  59662. _createTexture(): WebGLTexture;
  59663. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59664. /**
  59665. * Update the content of a dynamic texture
  59666. * @param texture defines the texture to update
  59667. * @param canvas defines the canvas containing the source
  59668. * @param invertY defines if data must be stored with Y axis inverted
  59669. * @param premulAlpha defines if alpha is stored as premultiplied
  59670. * @param format defines the format of the data
  59671. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59672. */
  59673. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59674. /**
  59675. * Usually called from Texture.ts.
  59676. * Passed information to create a WebGLTexture
  59677. * @param url defines a value which contains one of the following:
  59678. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59679. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59680. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59682. * @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)
  59683. * @param scene needed for loading to the correct scene
  59684. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59685. * @param onLoad optional callback to be called upon successful completion
  59686. * @param onError optional callback to be called upon failure
  59687. * @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
  59688. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59689. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59690. * @param forcedExtension defines the extension to use to pick the right loader
  59691. * @param mimeType defines an optional mime type
  59692. * @param loaderOptions options to be passed to the loader
  59693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59694. */
  59695. 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;
  59696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59697. _releaseFramebufferObjects(texture: InternalTexture): void;
  59698. /**
  59699. * Creates a cube texture
  59700. * @param rootUrl defines the url where the files to load is located
  59701. * @param scene defines the current scene
  59702. * @param files defines the list of files to load (1 per face)
  59703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59704. * @param onLoad defines an optional callback raised when the texture is loaded
  59705. * @param onError defines an optional callback raised if there is an issue to load the texture
  59706. * @param format defines the format of the data
  59707. * @param forcedExtension defines the extension to use to pick the right loader
  59708. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59711. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59712. * @returns the cube texture as an InternalTexture
  59713. */
  59714. 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;
  59715. createRenderTargetTexture(size: number | {
  59716. width: number;
  59717. height: number;
  59718. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59719. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59720. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59721. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59723. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59724. /**
  59725. * Updates a dynamic vertex buffer.
  59726. * @param vertexBuffer the vertex buffer to update
  59727. * @param data the data used to update the vertex buffer
  59728. * @param byteOffset the byte offset of the data (optional)
  59729. * @param byteLength the byte length of the data (optional)
  59730. */
  59731. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59732. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59733. private _updateAnisotropicLevel;
  59734. private _getAddressMode;
  59735. /** @hidden */
  59736. _bindTexture(channel: number, texture: InternalTexture): void;
  59737. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59738. releaseEffects(): void;
  59739. /** @hidden */
  59740. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59741. /** @hidden */
  59742. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59743. /** @hidden */
  59744. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59745. /** @hidden */
  59746. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59747. private _getNativeSamplingMode;
  59748. private _getNativeTextureFormat;
  59749. private _getNativeAlphaMode;
  59750. private _getNativeAttribType;
  59751. }
  59752. }
  59753. declare module "babylonjs/Engines/index" {
  59754. export * from "babylonjs/Engines/constants";
  59755. export * from "babylonjs/Engines/engineCapabilities";
  59756. export * from "babylonjs/Engines/instancingAttributeInfo";
  59757. export * from "babylonjs/Engines/thinEngine";
  59758. export * from "babylonjs/Engines/engine";
  59759. export * from "babylonjs/Engines/engineStore";
  59760. export * from "babylonjs/Engines/nullEngine";
  59761. export * from "babylonjs/Engines/Extensions/index";
  59762. export * from "babylonjs/Engines/IPipelineContext";
  59763. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59764. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59765. export * from "babylonjs/Engines/nativeEngine";
  59766. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59767. export * from "babylonjs/Engines/performanceConfigurator";
  59768. }
  59769. declare module "babylonjs/Events/clipboardEvents" {
  59770. /**
  59771. * Gather the list of clipboard event types as constants.
  59772. */
  59773. export class ClipboardEventTypes {
  59774. /**
  59775. * The clipboard event is fired when a copy command is active (pressed).
  59776. */
  59777. static readonly COPY: number;
  59778. /**
  59779. * The clipboard event is fired when a cut command is active (pressed).
  59780. */
  59781. static readonly CUT: number;
  59782. /**
  59783. * The clipboard event is fired when a paste command is active (pressed).
  59784. */
  59785. static readonly PASTE: number;
  59786. }
  59787. /**
  59788. * This class is used to store clipboard related info for the onClipboardObservable event.
  59789. */
  59790. export class ClipboardInfo {
  59791. /**
  59792. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59793. */
  59794. type: number;
  59795. /**
  59796. * Defines the related dom event
  59797. */
  59798. event: ClipboardEvent;
  59799. /**
  59800. *Creates an instance of ClipboardInfo.
  59801. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59802. * @param event Defines the related dom event
  59803. */
  59804. constructor(
  59805. /**
  59806. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59807. */
  59808. type: number,
  59809. /**
  59810. * Defines the related dom event
  59811. */
  59812. event: ClipboardEvent);
  59813. /**
  59814. * Get the clipboard event's type from the keycode.
  59815. * @param keyCode Defines the keyCode for the current keyboard event.
  59816. * @return {number}
  59817. */
  59818. static GetTypeFromCharacter(keyCode: number): number;
  59819. }
  59820. }
  59821. declare module "babylonjs/Events/index" {
  59822. export * from "babylonjs/Events/keyboardEvents";
  59823. export * from "babylonjs/Events/pointerEvents";
  59824. export * from "babylonjs/Events/clipboardEvents";
  59825. }
  59826. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59827. import { Scene } from "babylonjs/scene";
  59828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59829. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59830. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59831. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59832. /**
  59833. * Google Daydream controller
  59834. */
  59835. export class DaydreamController extends WebVRController {
  59836. /**
  59837. * Base Url for the controller model.
  59838. */
  59839. static MODEL_BASE_URL: string;
  59840. /**
  59841. * File name for the controller model.
  59842. */
  59843. static MODEL_FILENAME: string;
  59844. /**
  59845. * Gamepad Id prefix used to identify Daydream Controller.
  59846. */
  59847. static readonly GAMEPAD_ID_PREFIX: string;
  59848. /**
  59849. * Creates a new DaydreamController from a gamepad
  59850. * @param vrGamepad the gamepad that the controller should be created from
  59851. */
  59852. constructor(vrGamepad: any);
  59853. /**
  59854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59855. * @param scene scene in which to add meshes
  59856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59857. */
  59858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59859. /**
  59860. * Called once for each button that changed state since the last frame
  59861. * @param buttonIdx Which button index changed
  59862. * @param state New state of the button
  59863. * @param changes Which properties on the state changed since last frame
  59864. */
  59865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59866. }
  59867. }
  59868. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59869. import { Scene } from "babylonjs/scene";
  59870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59871. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59872. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59873. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59874. /**
  59875. * Gear VR Controller
  59876. */
  59877. export class GearVRController extends WebVRController {
  59878. /**
  59879. * Base Url for the controller model.
  59880. */
  59881. static MODEL_BASE_URL: string;
  59882. /**
  59883. * File name for the controller model.
  59884. */
  59885. static MODEL_FILENAME: string;
  59886. /**
  59887. * Gamepad Id prefix used to identify this controller.
  59888. */
  59889. static readonly GAMEPAD_ID_PREFIX: string;
  59890. private readonly _buttonIndexToObservableNameMap;
  59891. /**
  59892. * Creates a new GearVRController from a gamepad
  59893. * @param vrGamepad the gamepad that the controller should be created from
  59894. */
  59895. constructor(vrGamepad: any);
  59896. /**
  59897. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59898. * @param scene scene in which to add meshes
  59899. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59900. */
  59901. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59902. /**
  59903. * Called once for each button that changed state since the last frame
  59904. * @param buttonIdx Which button index changed
  59905. * @param state New state of the button
  59906. * @param changes Which properties on the state changed since last frame
  59907. */
  59908. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59909. }
  59910. }
  59911. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59912. import { Scene } from "babylonjs/scene";
  59913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59914. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59915. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59916. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59917. /**
  59918. * Generic Controller
  59919. */
  59920. export class GenericController extends WebVRController {
  59921. /**
  59922. * Base Url for the controller model.
  59923. */
  59924. static readonly MODEL_BASE_URL: string;
  59925. /**
  59926. * File name for the controller model.
  59927. */
  59928. static readonly MODEL_FILENAME: string;
  59929. /**
  59930. * Creates a new GenericController from a gamepad
  59931. * @param vrGamepad the gamepad that the controller should be created from
  59932. */
  59933. constructor(vrGamepad: any);
  59934. /**
  59935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59936. * @param scene scene in which to add meshes
  59937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59938. */
  59939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59940. /**
  59941. * Called once for each button that changed state since the last frame
  59942. * @param buttonIdx Which button index changed
  59943. * @param state New state of the button
  59944. * @param changes Which properties on the state changed since last frame
  59945. */
  59946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59947. }
  59948. }
  59949. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59950. import { Observable } from "babylonjs/Misc/observable";
  59951. import { Scene } from "babylonjs/scene";
  59952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59953. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59954. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59955. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59956. /**
  59957. * Oculus Touch Controller
  59958. */
  59959. export class OculusTouchController extends WebVRController {
  59960. /**
  59961. * Base Url for the controller model.
  59962. */
  59963. static MODEL_BASE_URL: string;
  59964. /**
  59965. * File name for the left controller model.
  59966. */
  59967. static MODEL_LEFT_FILENAME: string;
  59968. /**
  59969. * File name for the right controller model.
  59970. */
  59971. static MODEL_RIGHT_FILENAME: string;
  59972. /**
  59973. * Base Url for the Quest controller model.
  59974. */
  59975. static QUEST_MODEL_BASE_URL: string;
  59976. /**
  59977. * @hidden
  59978. * If the controllers are running on a device that needs the updated Quest controller models
  59979. */
  59980. static _IsQuest: boolean;
  59981. /**
  59982. * Fired when the secondary trigger on this controller is modified
  59983. */
  59984. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  59985. /**
  59986. * Fired when the thumb rest on this controller is modified
  59987. */
  59988. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  59989. /**
  59990. * Creates a new OculusTouchController from a gamepad
  59991. * @param vrGamepad the gamepad that the controller should be created from
  59992. */
  59993. constructor(vrGamepad: any);
  59994. /**
  59995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59996. * @param scene scene in which to add meshes
  59997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59998. */
  59999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60000. /**
  60001. * Fired when the A button on this controller is modified
  60002. */
  60003. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60004. /**
  60005. * Fired when the B button on this controller is modified
  60006. */
  60007. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60008. /**
  60009. * Fired when the X button on this controller is modified
  60010. */
  60011. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60012. /**
  60013. * Fired when the Y button on this controller is modified
  60014. */
  60015. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60016. /**
  60017. * Called once for each button that changed state since the last frame
  60018. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60019. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60020. * 2) secondary trigger (same)
  60021. * 3) A (right) X (left), touch, pressed = value
  60022. * 4) B / Y
  60023. * 5) thumb rest
  60024. * @param buttonIdx Which button index changed
  60025. * @param state New state of the button
  60026. * @param changes Which properties on the state changed since last frame
  60027. */
  60028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60029. }
  60030. }
  60031. declare module "babylonjs/Gamepads/Controllers/viveController" {
  60032. import { Scene } from "babylonjs/scene";
  60033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60035. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60036. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60037. import { Observable } from "babylonjs/Misc/observable";
  60038. /**
  60039. * Vive Controller
  60040. */
  60041. export class ViveController extends WebVRController {
  60042. /**
  60043. * Base Url for the controller model.
  60044. */
  60045. static MODEL_BASE_URL: string;
  60046. /**
  60047. * File name for the controller model.
  60048. */
  60049. static MODEL_FILENAME: string;
  60050. /**
  60051. * Creates a new ViveController from a gamepad
  60052. * @param vrGamepad the gamepad that the controller should be created from
  60053. */
  60054. constructor(vrGamepad: any);
  60055. /**
  60056. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60057. * @param scene scene in which to add meshes
  60058. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60059. */
  60060. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60061. /**
  60062. * Fired when the left button on this controller is modified
  60063. */
  60064. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60065. /**
  60066. * Fired when the right button on this controller is modified
  60067. */
  60068. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60069. /**
  60070. * Fired when the menu button on this controller is modified
  60071. */
  60072. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60073. /**
  60074. * Called once for each button that changed state since the last frame
  60075. * Vive mapping:
  60076. * 0: touchpad
  60077. * 1: trigger
  60078. * 2: left AND right buttons
  60079. * 3: menu button
  60080. * @param buttonIdx Which button index changed
  60081. * @param state New state of the button
  60082. * @param changes Which properties on the state changed since last frame
  60083. */
  60084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60085. }
  60086. }
  60087. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  60088. import { Observable } from "babylonjs/Misc/observable";
  60089. import { Scene } from "babylonjs/scene";
  60090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60091. import { Ray } from "babylonjs/Culling/ray";
  60092. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60093. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60094. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60095. /**
  60096. * Defines the WindowsMotionController object that the state of the windows motion controller
  60097. */
  60098. export class WindowsMotionController extends WebVRController {
  60099. /**
  60100. * The base url used to load the left and right controller models
  60101. */
  60102. static MODEL_BASE_URL: string;
  60103. /**
  60104. * The name of the left controller model file
  60105. */
  60106. static MODEL_LEFT_FILENAME: string;
  60107. /**
  60108. * The name of the right controller model file
  60109. */
  60110. static MODEL_RIGHT_FILENAME: string;
  60111. /**
  60112. * The controller name prefix for this controller type
  60113. */
  60114. static readonly GAMEPAD_ID_PREFIX: string;
  60115. /**
  60116. * The controller id pattern for this controller type
  60117. */
  60118. private static readonly GAMEPAD_ID_PATTERN;
  60119. private _loadedMeshInfo;
  60120. protected readonly _mapping: {
  60121. buttons: string[];
  60122. buttonMeshNames: {
  60123. trigger: string;
  60124. menu: string;
  60125. grip: string;
  60126. thumbstick: string;
  60127. trackpad: string;
  60128. };
  60129. buttonObservableNames: {
  60130. trigger: string;
  60131. menu: string;
  60132. grip: string;
  60133. thumbstick: string;
  60134. trackpad: string;
  60135. };
  60136. axisMeshNames: string[];
  60137. pointingPoseMeshName: string;
  60138. };
  60139. /**
  60140. * Fired when the trackpad on this controller is clicked
  60141. */
  60142. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60143. /**
  60144. * Fired when the trackpad on this controller is modified
  60145. */
  60146. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60147. /**
  60148. * The current x and y values of this controller's trackpad
  60149. */
  60150. trackpad: StickValues;
  60151. /**
  60152. * Creates a new WindowsMotionController from a gamepad
  60153. * @param vrGamepad the gamepad that the controller should be created from
  60154. */
  60155. constructor(vrGamepad: any);
  60156. /**
  60157. * Fired when the trigger on this controller is modified
  60158. */
  60159. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60160. /**
  60161. * Fired when the menu button on this controller is modified
  60162. */
  60163. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60164. /**
  60165. * Fired when the grip button on this controller is modified
  60166. */
  60167. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60168. /**
  60169. * Fired when the thumbstick button on this controller is modified
  60170. */
  60171. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60172. /**
  60173. * Fired when the touchpad button on this controller is modified
  60174. */
  60175. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60176. /**
  60177. * Fired when the touchpad values on this controller are modified
  60178. */
  60179. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60180. protected _updateTrackpad(): void;
  60181. /**
  60182. * Called once per frame by the engine.
  60183. */
  60184. update(): void;
  60185. /**
  60186. * Called once for each button that changed state since the last frame
  60187. * @param buttonIdx Which button index changed
  60188. * @param state New state of the button
  60189. * @param changes Which properties on the state changed since last frame
  60190. */
  60191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60192. /**
  60193. * Moves the buttons on the controller mesh based on their current state
  60194. * @param buttonName the name of the button to move
  60195. * @param buttonValue the value of the button which determines the buttons new position
  60196. */
  60197. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60198. /**
  60199. * Moves the axis on the controller mesh based on its current state
  60200. * @param axis the index of the axis
  60201. * @param axisValue the value of the axis which determines the meshes new position
  60202. * @hidden
  60203. */
  60204. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60205. /**
  60206. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60207. * @param scene scene in which to add meshes
  60208. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60209. */
  60210. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60211. /**
  60212. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60213. * can be transformed by button presses and axes values, based on this._mapping.
  60214. *
  60215. * @param scene scene in which the meshes exist
  60216. * @param meshes list of meshes that make up the controller model to process
  60217. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60218. */
  60219. private processModel;
  60220. private createMeshInfo;
  60221. /**
  60222. * Gets the ray of the controller in the direction the controller is pointing
  60223. * @param length the length the resulting ray should be
  60224. * @returns a ray in the direction the controller is pointing
  60225. */
  60226. getForwardRay(length?: number): Ray;
  60227. /**
  60228. * Disposes of the controller
  60229. */
  60230. dispose(): void;
  60231. }
  60232. /**
  60233. * This class represents a new windows motion controller in XR.
  60234. */
  60235. export class XRWindowsMotionController extends WindowsMotionController {
  60236. /**
  60237. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60238. */
  60239. protected readonly _mapping: {
  60240. buttons: string[];
  60241. buttonMeshNames: {
  60242. trigger: string;
  60243. menu: string;
  60244. grip: string;
  60245. thumbstick: string;
  60246. trackpad: string;
  60247. };
  60248. buttonObservableNames: {
  60249. trigger: string;
  60250. menu: string;
  60251. grip: string;
  60252. thumbstick: string;
  60253. trackpad: string;
  60254. };
  60255. axisMeshNames: string[];
  60256. pointingPoseMeshName: string;
  60257. };
  60258. /**
  60259. * Construct a new XR-Based windows motion controller
  60260. *
  60261. * @param gamepadInfo the gamepad object from the browser
  60262. */
  60263. constructor(gamepadInfo: any);
  60264. /**
  60265. * holds the thumbstick values (X,Y)
  60266. */
  60267. thumbstickValues: StickValues;
  60268. /**
  60269. * Fired when the thumbstick on this controller is clicked
  60270. */
  60271. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60272. /**
  60273. * Fired when the thumbstick on this controller is modified
  60274. */
  60275. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60276. /**
  60277. * Fired when the touchpad button on this controller is modified
  60278. */
  60279. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60280. /**
  60281. * Fired when the touchpad values on this controller are modified
  60282. */
  60283. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60284. /**
  60285. * Fired when the thumbstick button on this controller is modified
  60286. * here to prevent breaking changes
  60287. */
  60288. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60289. /**
  60290. * updating the thumbstick(!) and not the trackpad.
  60291. * This is named this way due to the difference between WebVR and XR and to avoid
  60292. * changing the parent class.
  60293. */
  60294. protected _updateTrackpad(): void;
  60295. /**
  60296. * Disposes the class with joy
  60297. */
  60298. dispose(): void;
  60299. }
  60300. }
  60301. declare module "babylonjs/Gamepads/Controllers/index" {
  60302. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60303. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60304. export * from "babylonjs/Gamepads/Controllers/genericController";
  60305. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60306. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60307. export * from "babylonjs/Gamepads/Controllers/viveController";
  60308. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60309. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60310. }
  60311. declare module "babylonjs/Gamepads/index" {
  60312. export * from "babylonjs/Gamepads/Controllers/index";
  60313. export * from "babylonjs/Gamepads/gamepad";
  60314. export * from "babylonjs/Gamepads/gamepadManager";
  60315. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60316. export * from "babylonjs/Gamepads/xboxGamepad";
  60317. export * from "babylonjs/Gamepads/dualShockGamepad";
  60318. }
  60319. declare module "babylonjs/Lights/directionalLight" {
  60320. import { Camera } from "babylonjs/Cameras/camera";
  60321. import { Scene } from "babylonjs/scene";
  60322. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60324. import { Light } from "babylonjs/Lights/light";
  60325. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60326. import { Effect } from "babylonjs/Materials/effect";
  60327. /**
  60328. * A directional light is defined by a direction (what a surprise!).
  60329. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60330. * 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.
  60331. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60332. */
  60333. export class DirectionalLight extends ShadowLight {
  60334. private _shadowFrustumSize;
  60335. /**
  60336. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60337. */
  60338. get shadowFrustumSize(): number;
  60339. /**
  60340. * Specifies a fix frustum size for the shadow generation.
  60341. */
  60342. set shadowFrustumSize(value: number);
  60343. private _shadowOrthoScale;
  60344. /**
  60345. * Gets the shadow projection scale against the optimal computed one.
  60346. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60347. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60348. */
  60349. get shadowOrthoScale(): number;
  60350. /**
  60351. * Sets the shadow projection scale against the optimal computed one.
  60352. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60353. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60354. */
  60355. set shadowOrthoScale(value: number);
  60356. /**
  60357. * Automatically compute the projection matrix to best fit (including all the casters)
  60358. * on each frame.
  60359. */
  60360. autoUpdateExtends: boolean;
  60361. /**
  60362. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60363. * on each frame. autoUpdateExtends must be set to true for this to work
  60364. */
  60365. autoCalcShadowZBounds: boolean;
  60366. private _orthoLeft;
  60367. private _orthoRight;
  60368. private _orthoTop;
  60369. private _orthoBottom;
  60370. /**
  60371. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60372. * The directional light is emitted from everywhere in the given direction.
  60373. * It can cast shadows.
  60374. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60375. * @param name The friendly name of the light
  60376. * @param direction The direction of the light
  60377. * @param scene The scene the light belongs to
  60378. */
  60379. constructor(name: string, direction: Vector3, scene: Scene);
  60380. /**
  60381. * Returns the string "DirectionalLight".
  60382. * @return The class name
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Returns the integer 1.
  60387. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60388. */
  60389. getTypeID(): number;
  60390. /**
  60391. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60392. * Returns the DirectionalLight Shadow projection matrix.
  60393. */
  60394. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60395. /**
  60396. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60397. * Returns the DirectionalLight Shadow projection matrix.
  60398. */
  60399. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60400. /**
  60401. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60402. * Returns the DirectionalLight Shadow projection matrix.
  60403. */
  60404. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60405. protected _buildUniformLayout(): void;
  60406. /**
  60407. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60408. * @param effect The effect to update
  60409. * @param lightIndex The index of the light in the effect to update
  60410. * @returns The directional light
  60411. */
  60412. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60413. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60414. /**
  60415. * Gets the minZ used for shadow according to both the scene and the light.
  60416. *
  60417. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60418. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60419. * @param activeCamera The camera we are returning the min for
  60420. * @returns the depth min z
  60421. */
  60422. getDepthMinZ(activeCamera: Camera): number;
  60423. /**
  60424. * Gets the maxZ used for shadow according to both the scene and the light.
  60425. *
  60426. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60427. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60428. * @param activeCamera The camera we are returning the max for
  60429. * @returns the depth max z
  60430. */
  60431. getDepthMaxZ(activeCamera: Camera): number;
  60432. /**
  60433. * Prepares the list of defines specific to the light type.
  60434. * @param defines the list of defines
  60435. * @param lightIndex defines the index of the light for the effect
  60436. */
  60437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60438. }
  60439. }
  60440. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60441. import { Mesh } from "babylonjs/Meshes/mesh";
  60442. /**
  60443. * Class containing static functions to help procedurally build meshes
  60444. */
  60445. export class HemisphereBuilder {
  60446. /**
  60447. * Creates a hemisphere mesh
  60448. * @param name defines the name of the mesh
  60449. * @param options defines the options used to create the mesh
  60450. * @param scene defines the hosting scene
  60451. * @returns the hemisphere mesh
  60452. */
  60453. static CreateHemisphere(name: string, options: {
  60454. segments?: number;
  60455. diameter?: number;
  60456. sideOrientation?: number;
  60457. }, scene: any): Mesh;
  60458. }
  60459. }
  60460. declare module "babylonjs/Lights/spotLight" {
  60461. import { Nullable } from "babylonjs/types";
  60462. import { Scene } from "babylonjs/scene";
  60463. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60465. import { Effect } from "babylonjs/Materials/effect";
  60466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60467. import { Light } from "babylonjs/Lights/light";
  60468. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60469. /**
  60470. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60471. * These values define a cone of light starting from the position, emitting toward the direction.
  60472. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60473. * and the exponent defines the speed of the decay of the light with distance (reach).
  60474. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60475. */
  60476. export class SpotLight extends ShadowLight {
  60477. private _angle;
  60478. private _innerAngle;
  60479. private _cosHalfAngle;
  60480. private _lightAngleScale;
  60481. private _lightAngleOffset;
  60482. /**
  60483. * Gets the cone angle of the spot light in Radians.
  60484. */
  60485. get angle(): number;
  60486. /**
  60487. * Sets the cone angle of the spot light in Radians.
  60488. */
  60489. set angle(value: number);
  60490. /**
  60491. * Only used in gltf falloff mode, this defines the angle where
  60492. * the directional falloff will start before cutting at angle which could be seen
  60493. * as outer angle.
  60494. */
  60495. get innerAngle(): number;
  60496. /**
  60497. * Only used in gltf falloff mode, this defines the angle where
  60498. * the directional falloff will start before cutting at angle which could be seen
  60499. * as outer angle.
  60500. */
  60501. set innerAngle(value: number);
  60502. private _shadowAngleScale;
  60503. /**
  60504. * Allows scaling the angle of the light for shadow generation only.
  60505. */
  60506. get shadowAngleScale(): number;
  60507. /**
  60508. * Allows scaling the angle of the light for shadow generation only.
  60509. */
  60510. set shadowAngleScale(value: number);
  60511. /**
  60512. * The light decay speed with the distance from the emission spot.
  60513. */
  60514. exponent: number;
  60515. private _projectionTextureMatrix;
  60516. /**
  60517. * Allows reading the projecton texture
  60518. */
  60519. get projectionTextureMatrix(): Matrix;
  60520. protected _projectionTextureLightNear: number;
  60521. /**
  60522. * Gets the near clip of the Spotlight for texture projection.
  60523. */
  60524. get projectionTextureLightNear(): number;
  60525. /**
  60526. * Sets the near clip of the Spotlight for texture projection.
  60527. */
  60528. set projectionTextureLightNear(value: number);
  60529. protected _projectionTextureLightFar: number;
  60530. /**
  60531. * Gets the far clip of the Spotlight for texture projection.
  60532. */
  60533. get projectionTextureLightFar(): number;
  60534. /**
  60535. * Sets the far clip of the Spotlight for texture projection.
  60536. */
  60537. set projectionTextureLightFar(value: number);
  60538. protected _projectionTextureUpDirection: Vector3;
  60539. /**
  60540. * Gets the Up vector of the Spotlight for texture projection.
  60541. */
  60542. get projectionTextureUpDirection(): Vector3;
  60543. /**
  60544. * Sets the Up vector of the Spotlight for texture projection.
  60545. */
  60546. set projectionTextureUpDirection(value: Vector3);
  60547. private _projectionTexture;
  60548. /**
  60549. * Gets the projection texture of the light.
  60550. */
  60551. get projectionTexture(): Nullable<BaseTexture>;
  60552. /**
  60553. * Sets the projection texture of the light.
  60554. */
  60555. set projectionTexture(value: Nullable<BaseTexture>);
  60556. private static _IsProceduralTexture;
  60557. private static _IsTexture;
  60558. private _projectionTextureViewLightDirty;
  60559. private _projectionTextureProjectionLightDirty;
  60560. private _projectionTextureDirty;
  60561. private _projectionTextureViewTargetVector;
  60562. private _projectionTextureViewLightMatrix;
  60563. private _projectionTextureProjectionLightMatrix;
  60564. private _projectionTextureScalingMatrix;
  60565. /**
  60566. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60567. * It can cast shadows.
  60568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60569. * @param name The light friendly name
  60570. * @param position The position of the spot light in the scene
  60571. * @param direction The direction of the light in the scene
  60572. * @param angle The cone angle of the light in Radians
  60573. * @param exponent The light decay speed with the distance from the emission spot
  60574. * @param scene The scene the lights belongs to
  60575. */
  60576. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60577. /**
  60578. * Returns the string "SpotLight".
  60579. * @returns the class name
  60580. */
  60581. getClassName(): string;
  60582. /**
  60583. * Returns the integer 2.
  60584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60585. */
  60586. getTypeID(): number;
  60587. /**
  60588. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60589. */
  60590. protected _setDirection(value: Vector3): void;
  60591. /**
  60592. * Overrides the position setter to recompute the projection texture view light Matrix.
  60593. */
  60594. protected _setPosition(value: Vector3): void;
  60595. /**
  60596. * 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.
  60597. * Returns the SpotLight.
  60598. */
  60599. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60600. protected _computeProjectionTextureViewLightMatrix(): void;
  60601. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60602. /**
  60603. * Main function for light texture projection matrix computing.
  60604. */
  60605. protected _computeProjectionTextureMatrix(): void;
  60606. protected _buildUniformLayout(): void;
  60607. private _computeAngleValues;
  60608. /**
  60609. * Sets the passed Effect "effect" with the Light textures.
  60610. * @param effect The effect to update
  60611. * @param lightIndex The index of the light in the effect to update
  60612. * @returns The light
  60613. */
  60614. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60615. /**
  60616. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60617. * @param effect The effect to update
  60618. * @param lightIndex The index of the light in the effect to update
  60619. * @returns The spot light
  60620. */
  60621. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60622. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60623. /**
  60624. * Disposes the light and the associated resources.
  60625. */
  60626. dispose(): void;
  60627. /**
  60628. * Prepares the list of defines specific to the light type.
  60629. * @param defines the list of defines
  60630. * @param lightIndex defines the index of the light for the effect
  60631. */
  60632. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60633. }
  60634. }
  60635. declare module "babylonjs/Gizmos/lightGizmo" {
  60636. import { Nullable } from "babylonjs/types";
  60637. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60638. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60639. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60640. import { Light } from "babylonjs/Lights/light";
  60641. import { Observable } from "babylonjs/Misc/observable";
  60642. /**
  60643. * Gizmo that enables viewing a light
  60644. */
  60645. export class LightGizmo extends Gizmo {
  60646. private _lightMesh;
  60647. private _material;
  60648. private _cachedPosition;
  60649. private _cachedForward;
  60650. private _attachedMeshParent;
  60651. private _pointerObserver;
  60652. /**
  60653. * Event that fires each time the gizmo is clicked
  60654. */
  60655. onClickedObservable: Observable<Light>;
  60656. /**
  60657. * Creates a LightGizmo
  60658. * @param gizmoLayer The utility layer the gizmo will be added to
  60659. */
  60660. constructor(gizmoLayer?: UtilityLayerRenderer);
  60661. private _light;
  60662. /**
  60663. * The light that the gizmo is attached to
  60664. */
  60665. set light(light: Nullable<Light>);
  60666. get light(): Nullable<Light>;
  60667. /**
  60668. * Gets the material used to render the light gizmo
  60669. */
  60670. get material(): StandardMaterial;
  60671. /**
  60672. * @hidden
  60673. * Updates the gizmo to match the attached mesh's position/rotation
  60674. */
  60675. protected _update(): void;
  60676. private static _Scale;
  60677. /**
  60678. * Creates the lines for a light mesh
  60679. */
  60680. private static _CreateLightLines;
  60681. /**
  60682. * Disposes of the light gizmo
  60683. */
  60684. dispose(): void;
  60685. private static _CreateHemisphericLightMesh;
  60686. private static _CreatePointLightMesh;
  60687. private static _CreateSpotLightMesh;
  60688. private static _CreateDirectionalLightMesh;
  60689. }
  60690. }
  60691. declare module "babylonjs/Gizmos/cameraGizmo" {
  60692. import { Nullable } from "babylonjs/types";
  60693. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60695. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60696. import { Camera } from "babylonjs/Cameras/camera";
  60697. import { Observable } from "babylonjs/Misc/observable";
  60698. /**
  60699. * Gizmo that enables viewing a camera
  60700. */
  60701. export class CameraGizmo extends Gizmo {
  60702. private _cameraMesh;
  60703. private _cameraLinesMesh;
  60704. private _material;
  60705. private _pointerObserver;
  60706. /**
  60707. * Event that fires each time the gizmo is clicked
  60708. */
  60709. onClickedObservable: Observable<Camera>;
  60710. /**
  60711. * Creates a CameraGizmo
  60712. * @param gizmoLayer The utility layer the gizmo will be added to
  60713. */
  60714. constructor(gizmoLayer?: UtilityLayerRenderer);
  60715. private _camera;
  60716. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60717. get displayFrustum(): boolean;
  60718. set displayFrustum(value: boolean);
  60719. /**
  60720. * The camera that the gizmo is attached to
  60721. */
  60722. set camera(camera: Nullable<Camera>);
  60723. get camera(): Nullable<Camera>;
  60724. /**
  60725. * Gets the material used to render the camera gizmo
  60726. */
  60727. get material(): StandardMaterial;
  60728. /**
  60729. * @hidden
  60730. * Updates the gizmo to match the attached mesh's position/rotation
  60731. */
  60732. protected _update(): void;
  60733. private static _Scale;
  60734. private _invProjection;
  60735. /**
  60736. * Disposes of the camera gizmo
  60737. */
  60738. dispose(): void;
  60739. private static _CreateCameraMesh;
  60740. private static _CreateCameraFrustum;
  60741. }
  60742. }
  60743. declare module "babylonjs/Gizmos/index" {
  60744. export * from "babylonjs/Gizmos/axisDragGizmo";
  60745. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60746. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60747. export * from "babylonjs/Gizmos/gizmo";
  60748. export * from "babylonjs/Gizmos/gizmoManager";
  60749. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60750. export * from "babylonjs/Gizmos/positionGizmo";
  60751. export * from "babylonjs/Gizmos/rotationGizmo";
  60752. export * from "babylonjs/Gizmos/scaleGizmo";
  60753. export * from "babylonjs/Gizmos/lightGizmo";
  60754. export * from "babylonjs/Gizmos/cameraGizmo";
  60755. export * from "babylonjs/Gizmos/planeDragGizmo";
  60756. }
  60757. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60758. /** @hidden */
  60759. export var backgroundFragmentDeclaration: {
  60760. name: string;
  60761. shader: string;
  60762. };
  60763. }
  60764. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60765. /** @hidden */
  60766. export var backgroundUboDeclaration: {
  60767. name: string;
  60768. shader: string;
  60769. };
  60770. }
  60771. declare module "babylonjs/Shaders/background.fragment" {
  60772. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60773. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60774. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60776. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60777. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60779. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60780. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60781. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60783. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60785. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60786. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60787. /** @hidden */
  60788. export var backgroundPixelShader: {
  60789. name: string;
  60790. shader: string;
  60791. };
  60792. }
  60793. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60794. /** @hidden */
  60795. export var backgroundVertexDeclaration: {
  60796. name: string;
  60797. shader: string;
  60798. };
  60799. }
  60800. declare module "babylonjs/Shaders/background.vertex" {
  60801. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60803. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60804. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60805. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60806. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60807. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60808. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60809. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60810. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60811. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60812. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60813. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60814. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60815. /** @hidden */
  60816. export var backgroundVertexShader: {
  60817. name: string;
  60818. shader: string;
  60819. };
  60820. }
  60821. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60822. import { Nullable, int, float } from "babylonjs/types";
  60823. import { Scene } from "babylonjs/scene";
  60824. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60827. import { Mesh } from "babylonjs/Meshes/mesh";
  60828. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60829. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60830. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60832. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60833. import { Color3 } from "babylonjs/Maths/math.color";
  60834. import "babylonjs/Shaders/background.fragment";
  60835. import "babylonjs/Shaders/background.vertex";
  60836. /**
  60837. * Background material used to create an efficient environement around your scene.
  60838. */
  60839. export class BackgroundMaterial extends PushMaterial {
  60840. /**
  60841. * Standard reflectance value at parallel view angle.
  60842. */
  60843. static StandardReflectance0: number;
  60844. /**
  60845. * Standard reflectance value at grazing angle.
  60846. */
  60847. static StandardReflectance90: number;
  60848. protected _primaryColor: Color3;
  60849. /**
  60850. * Key light Color (multiply against the environement texture)
  60851. */
  60852. primaryColor: Color3;
  60853. protected __perceptualColor: Nullable<Color3>;
  60854. /**
  60855. * Experimental Internal Use Only.
  60856. *
  60857. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60858. * This acts as a helper to set the primary color to a more "human friendly" value.
  60859. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60860. * output color as close as possible from the chosen value.
  60861. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60862. * part of lighting setup.)
  60863. */
  60864. get _perceptualColor(): Nullable<Color3>;
  60865. set _perceptualColor(value: Nullable<Color3>);
  60866. protected _primaryColorShadowLevel: float;
  60867. /**
  60868. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60869. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60870. */
  60871. get primaryColorShadowLevel(): float;
  60872. set primaryColorShadowLevel(value: float);
  60873. protected _primaryColorHighlightLevel: float;
  60874. /**
  60875. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60876. * The primary color is used at the level chosen to define what the white area would look.
  60877. */
  60878. get primaryColorHighlightLevel(): float;
  60879. set primaryColorHighlightLevel(value: float);
  60880. protected _reflectionTexture: Nullable<BaseTexture>;
  60881. /**
  60882. * Reflection Texture used in the material.
  60883. * Should be author in a specific way for the best result (refer to the documentation).
  60884. */
  60885. reflectionTexture: Nullable<BaseTexture>;
  60886. protected _reflectionBlur: float;
  60887. /**
  60888. * Reflection Texture level of blur.
  60889. *
  60890. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60891. * texture twice.
  60892. */
  60893. reflectionBlur: float;
  60894. protected _diffuseTexture: Nullable<BaseTexture>;
  60895. /**
  60896. * Diffuse Texture used in the material.
  60897. * Should be author in a specific way for the best result (refer to the documentation).
  60898. */
  60899. diffuseTexture: Nullable<BaseTexture>;
  60900. protected _shadowLights: Nullable<IShadowLight[]>;
  60901. /**
  60902. * Specify the list of lights casting shadow on the material.
  60903. * All scene shadow lights will be included if null.
  60904. */
  60905. shadowLights: Nullable<IShadowLight[]>;
  60906. protected _shadowLevel: float;
  60907. /**
  60908. * Helps adjusting the shadow to a softer level if required.
  60909. * 0 means black shadows and 1 means no shadows.
  60910. */
  60911. shadowLevel: float;
  60912. protected _sceneCenter: Vector3;
  60913. /**
  60914. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60915. * It is usually zero but might be interesting to modify according to your setup.
  60916. */
  60917. sceneCenter: Vector3;
  60918. protected _opacityFresnel: boolean;
  60919. /**
  60920. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60921. * This helps ensuring a nice transition when the camera goes under the ground.
  60922. */
  60923. opacityFresnel: boolean;
  60924. protected _reflectionFresnel: boolean;
  60925. /**
  60926. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60927. * This helps adding a mirror texture on the ground.
  60928. */
  60929. reflectionFresnel: boolean;
  60930. protected _reflectionFalloffDistance: number;
  60931. /**
  60932. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60933. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60934. */
  60935. reflectionFalloffDistance: number;
  60936. protected _reflectionAmount: number;
  60937. /**
  60938. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60939. */
  60940. reflectionAmount: number;
  60941. protected _reflectionReflectance0: number;
  60942. /**
  60943. * This specifies the weight of the reflection at grazing angle.
  60944. */
  60945. reflectionReflectance0: number;
  60946. protected _reflectionReflectance90: number;
  60947. /**
  60948. * This specifies the weight of the reflection at a perpendicular point of view.
  60949. */
  60950. reflectionReflectance90: number;
  60951. /**
  60952. * Sets the reflection reflectance fresnel values according to the default standard
  60953. * empirically know to work well :-)
  60954. */
  60955. set reflectionStandardFresnelWeight(value: number);
  60956. protected _useRGBColor: boolean;
  60957. /**
  60958. * Helps to directly use the maps channels instead of their level.
  60959. */
  60960. useRGBColor: boolean;
  60961. protected _enableNoise: boolean;
  60962. /**
  60963. * This helps reducing the banding effect that could occur on the background.
  60964. */
  60965. enableNoise: boolean;
  60966. /**
  60967. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60968. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60969. * Recommended to be keep at 1.0 except for special cases.
  60970. */
  60971. get fovMultiplier(): number;
  60972. set fovMultiplier(value: number);
  60973. private _fovMultiplier;
  60974. /**
  60975. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60976. */
  60977. useEquirectangularFOV: boolean;
  60978. private _maxSimultaneousLights;
  60979. /**
  60980. * Number of Simultaneous lights allowed on the material.
  60981. */
  60982. maxSimultaneousLights: int;
  60983. private _shadowOnly;
  60984. /**
  60985. * Make the material only render shadows
  60986. */
  60987. shadowOnly: boolean;
  60988. /**
  60989. * Default configuration related to image processing available in the Background Material.
  60990. */
  60991. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60992. /**
  60993. * Keep track of the image processing observer to allow dispose and replace.
  60994. */
  60995. private _imageProcessingObserver;
  60996. /**
  60997. * Attaches a new image processing configuration to the PBR Material.
  60998. * @param configuration (if null the scene configuration will be use)
  60999. */
  61000. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61001. /**
  61002. * Gets the image processing configuration used either in this material.
  61003. */
  61004. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61005. /**
  61006. * Sets the Default image processing configuration used either in the this material.
  61007. *
  61008. * If sets to null, the scene one is in use.
  61009. */
  61010. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61011. /**
  61012. * Gets wether the color curves effect is enabled.
  61013. */
  61014. get cameraColorCurvesEnabled(): boolean;
  61015. /**
  61016. * Sets wether the color curves effect is enabled.
  61017. */
  61018. set cameraColorCurvesEnabled(value: boolean);
  61019. /**
  61020. * Gets wether the color grading effect is enabled.
  61021. */
  61022. get cameraColorGradingEnabled(): boolean;
  61023. /**
  61024. * Gets wether the color grading effect is enabled.
  61025. */
  61026. set cameraColorGradingEnabled(value: boolean);
  61027. /**
  61028. * Gets wether tonemapping is enabled or not.
  61029. */
  61030. get cameraToneMappingEnabled(): boolean;
  61031. /**
  61032. * Sets wether tonemapping is enabled or not
  61033. */
  61034. set cameraToneMappingEnabled(value: boolean);
  61035. /**
  61036. * The camera exposure used on this material.
  61037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61038. * This corresponds to a photographic exposure.
  61039. */
  61040. get cameraExposure(): float;
  61041. /**
  61042. * The camera exposure used on this material.
  61043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61044. * This corresponds to a photographic exposure.
  61045. */
  61046. set cameraExposure(value: float);
  61047. /**
  61048. * Gets The camera contrast used on this material.
  61049. */
  61050. get cameraContrast(): float;
  61051. /**
  61052. * Sets The camera contrast used on this material.
  61053. */
  61054. set cameraContrast(value: float);
  61055. /**
  61056. * Gets the Color Grading 2D Lookup Texture.
  61057. */
  61058. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61059. /**
  61060. * Sets the Color Grading 2D Lookup Texture.
  61061. */
  61062. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61063. /**
  61064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61066. * 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;
  61067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61068. */
  61069. get cameraColorCurves(): Nullable<ColorCurves>;
  61070. /**
  61071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61073. * 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;
  61074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61075. */
  61076. set cameraColorCurves(value: Nullable<ColorCurves>);
  61077. /**
  61078. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61079. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61080. */
  61081. switchToBGR: boolean;
  61082. private _renderTargets;
  61083. private _reflectionControls;
  61084. private _white;
  61085. private _primaryShadowColor;
  61086. private _primaryHighlightColor;
  61087. /**
  61088. * Instantiates a Background Material in the given scene
  61089. * @param name The friendly name of the material
  61090. * @param scene The scene to add the material to
  61091. */
  61092. constructor(name: string, scene: Scene);
  61093. /**
  61094. * Gets a boolean indicating that current material needs to register RTT
  61095. */
  61096. get hasRenderTargetTextures(): boolean;
  61097. /**
  61098. * The entire material has been created in order to prevent overdraw.
  61099. * @returns false
  61100. */
  61101. needAlphaTesting(): boolean;
  61102. /**
  61103. * The entire material has been created in order to prevent overdraw.
  61104. * @returns true if blending is enable
  61105. */
  61106. needAlphaBlending(): boolean;
  61107. /**
  61108. * Checks wether the material is ready to be rendered for a given mesh.
  61109. * @param mesh The mesh to render
  61110. * @param subMesh The submesh to check against
  61111. * @param useInstances Specify wether or not the material is used with instances
  61112. * @returns true if all the dependencies are ready (Textures, Effects...)
  61113. */
  61114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61115. /**
  61116. * Compute the primary color according to the chosen perceptual color.
  61117. */
  61118. private _computePrimaryColorFromPerceptualColor;
  61119. /**
  61120. * Compute the highlights and shadow colors according to their chosen levels.
  61121. */
  61122. private _computePrimaryColors;
  61123. /**
  61124. * Build the uniform buffer used in the material.
  61125. */
  61126. buildUniformLayout(): void;
  61127. /**
  61128. * Unbind the material.
  61129. */
  61130. unbind(): void;
  61131. /**
  61132. * Bind only the world matrix to the material.
  61133. * @param world The world matrix to bind.
  61134. */
  61135. bindOnlyWorldMatrix(world: Matrix): void;
  61136. /**
  61137. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61138. * @param world The world matrix to bind.
  61139. * @param subMesh The submesh to bind for.
  61140. */
  61141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61142. /**
  61143. * Checks to see if a texture is used in the material.
  61144. * @param texture - Base texture to use.
  61145. * @returns - Boolean specifying if a texture is used in the material.
  61146. */
  61147. hasTexture(texture: BaseTexture): boolean;
  61148. /**
  61149. * Dispose the material.
  61150. * @param forceDisposeEffect Force disposal of the associated effect.
  61151. * @param forceDisposeTextures Force disposal of the associated textures.
  61152. */
  61153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61154. /**
  61155. * Clones the material.
  61156. * @param name The cloned name.
  61157. * @returns The cloned material.
  61158. */
  61159. clone(name: string): BackgroundMaterial;
  61160. /**
  61161. * Serializes the current material to its JSON representation.
  61162. * @returns The JSON representation.
  61163. */
  61164. serialize(): any;
  61165. /**
  61166. * Gets the class name of the material
  61167. * @returns "BackgroundMaterial"
  61168. */
  61169. getClassName(): string;
  61170. /**
  61171. * Parse a JSON input to create back a background material.
  61172. * @param source The JSON data to parse
  61173. * @param scene The scene to create the parsed material in
  61174. * @param rootUrl The root url of the assets the material depends upon
  61175. * @returns the instantiated BackgroundMaterial.
  61176. */
  61177. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61178. }
  61179. }
  61180. declare module "babylonjs/Helpers/environmentHelper" {
  61181. import { Observable } from "babylonjs/Misc/observable";
  61182. import { Nullable } from "babylonjs/types";
  61183. import { Scene } from "babylonjs/scene";
  61184. import { Vector3 } from "babylonjs/Maths/math.vector";
  61185. import { Color3 } from "babylonjs/Maths/math.color";
  61186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61187. import { Mesh } from "babylonjs/Meshes/mesh";
  61188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61189. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61190. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61191. import "babylonjs/Meshes/Builders/planeBuilder";
  61192. import "babylonjs/Meshes/Builders/boxBuilder";
  61193. /**
  61194. * Represents the different options available during the creation of
  61195. * a Environment helper.
  61196. *
  61197. * This can control the default ground, skybox and image processing setup of your scene.
  61198. */
  61199. export interface IEnvironmentHelperOptions {
  61200. /**
  61201. * Specifies whether or not to create a ground.
  61202. * True by default.
  61203. */
  61204. createGround: boolean;
  61205. /**
  61206. * Specifies the ground size.
  61207. * 15 by default.
  61208. */
  61209. groundSize: number;
  61210. /**
  61211. * The texture used on the ground for the main color.
  61212. * Comes from the BabylonJS CDN by default.
  61213. *
  61214. * Remarks: Can be either a texture or a url.
  61215. */
  61216. groundTexture: string | BaseTexture;
  61217. /**
  61218. * The color mixed in the ground texture by default.
  61219. * BabylonJS clearColor by default.
  61220. */
  61221. groundColor: Color3;
  61222. /**
  61223. * Specifies the ground opacity.
  61224. * 1 by default.
  61225. */
  61226. groundOpacity: number;
  61227. /**
  61228. * Enables the ground to receive shadows.
  61229. * True by default.
  61230. */
  61231. enableGroundShadow: boolean;
  61232. /**
  61233. * Helps preventing the shadow to be fully black on the ground.
  61234. * 0.5 by default.
  61235. */
  61236. groundShadowLevel: number;
  61237. /**
  61238. * Creates a mirror texture attach to the ground.
  61239. * false by default.
  61240. */
  61241. enableGroundMirror: boolean;
  61242. /**
  61243. * Specifies the ground mirror size ratio.
  61244. * 0.3 by default as the default kernel is 64.
  61245. */
  61246. groundMirrorSizeRatio: number;
  61247. /**
  61248. * Specifies the ground mirror blur kernel size.
  61249. * 64 by default.
  61250. */
  61251. groundMirrorBlurKernel: number;
  61252. /**
  61253. * Specifies the ground mirror visibility amount.
  61254. * 1 by default
  61255. */
  61256. groundMirrorAmount: number;
  61257. /**
  61258. * Specifies the ground mirror reflectance weight.
  61259. * This uses the standard weight of the background material to setup the fresnel effect
  61260. * of the mirror.
  61261. * 1 by default.
  61262. */
  61263. groundMirrorFresnelWeight: number;
  61264. /**
  61265. * Specifies the ground mirror Falloff distance.
  61266. * This can helps reducing the size of the reflection.
  61267. * 0 by Default.
  61268. */
  61269. groundMirrorFallOffDistance: number;
  61270. /**
  61271. * Specifies the ground mirror texture type.
  61272. * Unsigned Int by Default.
  61273. */
  61274. groundMirrorTextureType: number;
  61275. /**
  61276. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61277. * the shown objects.
  61278. */
  61279. groundYBias: number;
  61280. /**
  61281. * Specifies whether or not to create a skybox.
  61282. * True by default.
  61283. */
  61284. createSkybox: boolean;
  61285. /**
  61286. * Specifies the skybox size.
  61287. * 20 by default.
  61288. */
  61289. skyboxSize: number;
  61290. /**
  61291. * The texture used on the skybox for the main color.
  61292. * Comes from the BabylonJS CDN by default.
  61293. *
  61294. * Remarks: Can be either a texture or a url.
  61295. */
  61296. skyboxTexture: string | BaseTexture;
  61297. /**
  61298. * The color mixed in the skybox texture by default.
  61299. * BabylonJS clearColor by default.
  61300. */
  61301. skyboxColor: Color3;
  61302. /**
  61303. * The background rotation around the Y axis of the scene.
  61304. * This helps aligning the key lights of your scene with the background.
  61305. * 0 by default.
  61306. */
  61307. backgroundYRotation: number;
  61308. /**
  61309. * Compute automatically the size of the elements to best fit with the scene.
  61310. */
  61311. sizeAuto: boolean;
  61312. /**
  61313. * Default position of the rootMesh if autoSize is not true.
  61314. */
  61315. rootPosition: Vector3;
  61316. /**
  61317. * Sets up the image processing in the scene.
  61318. * true by default.
  61319. */
  61320. setupImageProcessing: boolean;
  61321. /**
  61322. * The texture used as your environment texture in the scene.
  61323. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61324. *
  61325. * Remarks: Can be either a texture or a url.
  61326. */
  61327. environmentTexture: string | BaseTexture;
  61328. /**
  61329. * The value of the exposure to apply to the scene.
  61330. * 0.6 by default if setupImageProcessing is true.
  61331. */
  61332. cameraExposure: number;
  61333. /**
  61334. * The value of the contrast to apply to the scene.
  61335. * 1.6 by default if setupImageProcessing is true.
  61336. */
  61337. cameraContrast: number;
  61338. /**
  61339. * Specifies whether or not tonemapping should be enabled in the scene.
  61340. * true by default if setupImageProcessing is true.
  61341. */
  61342. toneMappingEnabled: boolean;
  61343. }
  61344. /**
  61345. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61346. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61347. * It also helps with the default setup of your imageProcessing configuration.
  61348. */
  61349. export class EnvironmentHelper {
  61350. /**
  61351. * Default ground texture URL.
  61352. */
  61353. private static _groundTextureCDNUrl;
  61354. /**
  61355. * Default skybox texture URL.
  61356. */
  61357. private static _skyboxTextureCDNUrl;
  61358. /**
  61359. * Default environment texture URL.
  61360. */
  61361. private static _environmentTextureCDNUrl;
  61362. /**
  61363. * Creates the default options for the helper.
  61364. */
  61365. private static _getDefaultOptions;
  61366. private _rootMesh;
  61367. /**
  61368. * Gets the root mesh created by the helper.
  61369. */
  61370. get rootMesh(): Mesh;
  61371. private _skybox;
  61372. /**
  61373. * Gets the skybox created by the helper.
  61374. */
  61375. get skybox(): Nullable<Mesh>;
  61376. private _skyboxTexture;
  61377. /**
  61378. * Gets the skybox texture created by the helper.
  61379. */
  61380. get skyboxTexture(): Nullable<BaseTexture>;
  61381. private _skyboxMaterial;
  61382. /**
  61383. * Gets the skybox material created by the helper.
  61384. */
  61385. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61386. private _ground;
  61387. /**
  61388. * Gets the ground mesh created by the helper.
  61389. */
  61390. get ground(): Nullable<Mesh>;
  61391. private _groundTexture;
  61392. /**
  61393. * Gets the ground texture created by the helper.
  61394. */
  61395. get groundTexture(): Nullable<BaseTexture>;
  61396. private _groundMirror;
  61397. /**
  61398. * Gets the ground mirror created by the helper.
  61399. */
  61400. get groundMirror(): Nullable<MirrorTexture>;
  61401. /**
  61402. * Gets the ground mirror render list to helps pushing the meshes
  61403. * you wish in the ground reflection.
  61404. */
  61405. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61406. private _groundMaterial;
  61407. /**
  61408. * Gets the ground material created by the helper.
  61409. */
  61410. get groundMaterial(): Nullable<BackgroundMaterial>;
  61411. /**
  61412. * Stores the creation options.
  61413. */
  61414. private readonly _scene;
  61415. private _options;
  61416. /**
  61417. * This observable will be notified with any error during the creation of the environment,
  61418. * mainly texture creation errors.
  61419. */
  61420. onErrorObservable: Observable<{
  61421. message?: string;
  61422. exception?: any;
  61423. }>;
  61424. /**
  61425. * constructor
  61426. * @param options Defines the options we want to customize the helper
  61427. * @param scene The scene to add the material to
  61428. */
  61429. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61430. /**
  61431. * Updates the background according to the new options
  61432. * @param options
  61433. */
  61434. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61435. /**
  61436. * Sets the primary color of all the available elements.
  61437. * @param color the main color to affect to the ground and the background
  61438. */
  61439. setMainColor(color: Color3): void;
  61440. /**
  61441. * Setup the image processing according to the specified options.
  61442. */
  61443. private _setupImageProcessing;
  61444. /**
  61445. * Setup the environment texture according to the specified options.
  61446. */
  61447. private _setupEnvironmentTexture;
  61448. /**
  61449. * Setup the background according to the specified options.
  61450. */
  61451. private _setupBackground;
  61452. /**
  61453. * Get the scene sizes according to the setup.
  61454. */
  61455. private _getSceneSize;
  61456. /**
  61457. * Setup the ground according to the specified options.
  61458. */
  61459. private _setupGround;
  61460. /**
  61461. * Setup the ground material according to the specified options.
  61462. */
  61463. private _setupGroundMaterial;
  61464. /**
  61465. * Setup the ground diffuse texture according to the specified options.
  61466. */
  61467. private _setupGroundDiffuseTexture;
  61468. /**
  61469. * Setup the ground mirror texture according to the specified options.
  61470. */
  61471. private _setupGroundMirrorTexture;
  61472. /**
  61473. * Setup the ground to receive the mirror texture.
  61474. */
  61475. private _setupMirrorInGroundMaterial;
  61476. /**
  61477. * Setup the skybox according to the specified options.
  61478. */
  61479. private _setupSkybox;
  61480. /**
  61481. * Setup the skybox material according to the specified options.
  61482. */
  61483. private _setupSkyboxMaterial;
  61484. /**
  61485. * Setup the skybox reflection texture according to the specified options.
  61486. */
  61487. private _setupSkyboxReflectionTexture;
  61488. private _errorHandler;
  61489. /**
  61490. * Dispose all the elements created by the Helper.
  61491. */
  61492. dispose(): void;
  61493. }
  61494. }
  61495. declare module "babylonjs/Helpers/textureDome" {
  61496. import { Scene } from "babylonjs/scene";
  61497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61498. import { Mesh } from "babylonjs/Meshes/mesh";
  61499. import { Texture } from "babylonjs/Materials/Textures/texture";
  61500. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61501. import "babylonjs/Meshes/Builders/sphereBuilder";
  61502. import { Nullable } from "babylonjs/types";
  61503. import { Observable } from "babylonjs/Misc/observable";
  61504. /**
  61505. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61506. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61507. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61508. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61509. */
  61510. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61511. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61512. /**
  61513. * Define the source as a Monoscopic panoramic 360/180.
  61514. */
  61515. static readonly MODE_MONOSCOPIC: number;
  61516. /**
  61517. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61518. */
  61519. static readonly MODE_TOPBOTTOM: number;
  61520. /**
  61521. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61522. */
  61523. static readonly MODE_SIDEBYSIDE: number;
  61524. private _halfDome;
  61525. private _crossEye;
  61526. protected _useDirectMapping: boolean;
  61527. /**
  61528. * The texture being displayed on the sphere
  61529. */
  61530. protected _texture: T;
  61531. /**
  61532. * Gets the texture being displayed on the sphere
  61533. */
  61534. get texture(): T;
  61535. /**
  61536. * Sets the texture being displayed on the sphere
  61537. */
  61538. set texture(newTexture: T);
  61539. /**
  61540. * The skybox material
  61541. */
  61542. protected _material: BackgroundMaterial;
  61543. /**
  61544. * The surface used for the dome
  61545. */
  61546. protected _mesh: Mesh;
  61547. /**
  61548. * Gets the mesh used for the dome.
  61549. */
  61550. get mesh(): Mesh;
  61551. /**
  61552. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61553. */
  61554. private _halfDomeMask;
  61555. /**
  61556. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61557. * Also see the options.resolution property.
  61558. */
  61559. get fovMultiplier(): number;
  61560. set fovMultiplier(value: number);
  61561. protected _textureMode: number;
  61562. /**
  61563. * Gets or set the current texture mode for the texture. It can be:
  61564. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61565. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61566. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61567. */
  61568. get textureMode(): number;
  61569. /**
  61570. * Sets the current texture mode for the texture. It can be:
  61571. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61572. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61573. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61574. */
  61575. set textureMode(value: number);
  61576. /**
  61577. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61578. */
  61579. get halfDome(): boolean;
  61580. /**
  61581. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61582. */
  61583. set halfDome(enabled: boolean);
  61584. /**
  61585. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61586. */
  61587. set crossEye(enabled: boolean);
  61588. /**
  61589. * Is it a cross-eye texture?
  61590. */
  61591. get crossEye(): boolean;
  61592. /**
  61593. * The background material of this dome.
  61594. */
  61595. get material(): BackgroundMaterial;
  61596. /**
  61597. * Oberserver used in Stereoscopic VR Mode.
  61598. */
  61599. private _onBeforeCameraRenderObserver;
  61600. /**
  61601. * Observable raised when an error occured while loading the 360 image
  61602. */
  61603. onLoadErrorObservable: Observable<string>;
  61604. /**
  61605. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61606. * @param name Element's name, child elements will append suffixes for their own names.
  61607. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61608. * @param options An object containing optional or exposed sub element properties
  61609. */
  61610. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61611. resolution?: number;
  61612. clickToPlay?: boolean;
  61613. autoPlay?: boolean;
  61614. loop?: boolean;
  61615. size?: number;
  61616. poster?: string;
  61617. faceForward?: boolean;
  61618. useDirectMapping?: boolean;
  61619. halfDomeMode?: boolean;
  61620. crossEyeMode?: boolean;
  61621. generateMipMaps?: boolean;
  61622. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61623. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61624. protected _changeTextureMode(value: number): void;
  61625. /**
  61626. * Releases resources associated with this node.
  61627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61629. */
  61630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61631. }
  61632. }
  61633. declare module "babylonjs/Helpers/photoDome" {
  61634. import { Scene } from "babylonjs/scene";
  61635. import { Texture } from "babylonjs/Materials/Textures/texture";
  61636. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61637. /**
  61638. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61639. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61640. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61641. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61642. */
  61643. export class PhotoDome extends TextureDome<Texture> {
  61644. /**
  61645. * Define the image as a Monoscopic panoramic 360 image.
  61646. */
  61647. static readonly MODE_MONOSCOPIC: number;
  61648. /**
  61649. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61650. */
  61651. static readonly MODE_TOPBOTTOM: number;
  61652. /**
  61653. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61654. */
  61655. static readonly MODE_SIDEBYSIDE: number;
  61656. /**
  61657. * Gets or sets the texture being displayed on the sphere
  61658. */
  61659. get photoTexture(): Texture;
  61660. /**
  61661. * sets the texture being displayed on the sphere
  61662. */
  61663. set photoTexture(value: Texture);
  61664. /**
  61665. * Gets the current video mode for the video. It can be:
  61666. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61667. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61668. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61669. */
  61670. get imageMode(): number;
  61671. /**
  61672. * Sets the current video mode for the video. It can be:
  61673. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61674. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61675. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61676. */
  61677. set imageMode(value: number);
  61678. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61679. }
  61680. }
  61681. declare module "babylonjs/Misc/dds" {
  61682. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61684. import { Nullable } from "babylonjs/types";
  61685. import { Scene } from "babylonjs/scene";
  61686. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61687. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61688. /**
  61689. * Direct draw surface info
  61690. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61691. */
  61692. export interface DDSInfo {
  61693. /**
  61694. * Width of the texture
  61695. */
  61696. width: number;
  61697. /**
  61698. * Width of the texture
  61699. */
  61700. height: number;
  61701. /**
  61702. * Number of Mipmaps for the texture
  61703. * @see https://en.wikipedia.org/wiki/Mipmap
  61704. */
  61705. mipmapCount: number;
  61706. /**
  61707. * If the textures format is a known fourCC format
  61708. * @see https://www.fourcc.org/
  61709. */
  61710. isFourCC: boolean;
  61711. /**
  61712. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61713. */
  61714. isRGB: boolean;
  61715. /**
  61716. * If the texture is a lumincance format
  61717. */
  61718. isLuminance: boolean;
  61719. /**
  61720. * If this is a cube texture
  61721. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61722. */
  61723. isCube: boolean;
  61724. /**
  61725. * If the texture is a compressed format eg. FOURCC_DXT1
  61726. */
  61727. isCompressed: boolean;
  61728. /**
  61729. * The dxgiFormat of the texture
  61730. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61731. */
  61732. dxgiFormat: number;
  61733. /**
  61734. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61735. */
  61736. textureType: number;
  61737. /**
  61738. * Sphericle polynomial created for the dds texture
  61739. */
  61740. sphericalPolynomial?: SphericalPolynomial;
  61741. }
  61742. /**
  61743. * Class used to provide DDS decompression tools
  61744. */
  61745. export class DDSTools {
  61746. /**
  61747. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61748. */
  61749. static StoreLODInAlphaChannel: boolean;
  61750. /**
  61751. * Gets DDS information from an array buffer
  61752. * @param data defines the array buffer view to read data from
  61753. * @returns the DDS information
  61754. */
  61755. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61756. private static _FloatView;
  61757. private static _Int32View;
  61758. private static _ToHalfFloat;
  61759. private static _FromHalfFloat;
  61760. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61761. private static _GetHalfFloatRGBAArrayBuffer;
  61762. private static _GetFloatRGBAArrayBuffer;
  61763. private static _GetFloatAsUIntRGBAArrayBuffer;
  61764. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61765. private static _GetRGBAArrayBuffer;
  61766. private static _ExtractLongWordOrder;
  61767. private static _GetRGBArrayBuffer;
  61768. private static _GetLuminanceArrayBuffer;
  61769. /**
  61770. * Uploads DDS Levels to a Babylon Texture
  61771. * @hidden
  61772. */
  61773. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61774. }
  61775. module "babylonjs/Engines/thinEngine" {
  61776. interface ThinEngine {
  61777. /**
  61778. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61779. * @param rootUrl defines the url where the file to load is located
  61780. * @param scene defines the current scene
  61781. * @param lodScale defines scale to apply to the mip map selection
  61782. * @param lodOffset defines offset to apply to the mip map selection
  61783. * @param onLoad defines an optional callback raised when the texture is loaded
  61784. * @param onError defines an optional callback raised if there is an issue to load the texture
  61785. * @param format defines the format of the data
  61786. * @param forcedExtension defines the extension to use to pick the right loader
  61787. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61788. * @returns the cube texture as an InternalTexture
  61789. */
  61790. 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;
  61791. }
  61792. }
  61793. }
  61794. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61795. import { Nullable } from "babylonjs/types";
  61796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61797. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61798. /**
  61799. * Implementation of the DDS Texture Loader.
  61800. * @hidden
  61801. */
  61802. export class _DDSTextureLoader implements IInternalTextureLoader {
  61803. /**
  61804. * Defines wether the loader supports cascade loading the different faces.
  61805. */
  61806. readonly supportCascades: boolean;
  61807. /**
  61808. * This returns if the loader support the current file information.
  61809. * @param extension defines the file extension of the file being loaded
  61810. * @returns true if the loader can load the specified file
  61811. */
  61812. canLoad(extension: string): boolean;
  61813. /**
  61814. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61815. * @param data contains the texture data
  61816. * @param texture defines the BabylonJS internal texture
  61817. * @param createPolynomials will be true if polynomials have been requested
  61818. * @param onLoad defines the callback to trigger once the texture is ready
  61819. * @param onError defines the callback to trigger in case of error
  61820. */
  61821. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61822. /**
  61823. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61824. * @param data contains the texture data
  61825. * @param texture defines the BabylonJS internal texture
  61826. * @param callback defines the method to call once ready to upload
  61827. */
  61828. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61829. }
  61830. }
  61831. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61832. import { Nullable } from "babylonjs/types";
  61833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61834. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61835. /**
  61836. * Implementation of the ENV Texture Loader.
  61837. * @hidden
  61838. */
  61839. export class _ENVTextureLoader implements IInternalTextureLoader {
  61840. /**
  61841. * Defines wether the loader supports cascade loading the different faces.
  61842. */
  61843. readonly supportCascades: boolean;
  61844. /**
  61845. * This returns if the loader support the current file information.
  61846. * @param extension defines the file extension of the file being loaded
  61847. * @returns true if the loader can load the specified file
  61848. */
  61849. canLoad(extension: string): boolean;
  61850. /**
  61851. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61852. * @param data contains the texture data
  61853. * @param texture defines the BabylonJS internal texture
  61854. * @param createPolynomials will be true if polynomials have been requested
  61855. * @param onLoad defines the callback to trigger once the texture is ready
  61856. * @param onError defines the callback to trigger in case of error
  61857. */
  61858. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61859. /**
  61860. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61861. * @param data contains the texture data
  61862. * @param texture defines the BabylonJS internal texture
  61863. * @param callback defines the method to call once ready to upload
  61864. */
  61865. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61866. }
  61867. }
  61868. declare module "babylonjs/Misc/khronosTextureContainer" {
  61869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61870. /**
  61871. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61872. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61873. */
  61874. export class KhronosTextureContainer {
  61875. /** contents of the KTX container file */
  61876. data: ArrayBufferView;
  61877. private static HEADER_LEN;
  61878. private static COMPRESSED_2D;
  61879. private static COMPRESSED_3D;
  61880. private static TEX_2D;
  61881. private static TEX_3D;
  61882. /**
  61883. * Gets the openGL type
  61884. */
  61885. glType: number;
  61886. /**
  61887. * Gets the openGL type size
  61888. */
  61889. glTypeSize: number;
  61890. /**
  61891. * Gets the openGL format
  61892. */
  61893. glFormat: number;
  61894. /**
  61895. * Gets the openGL internal format
  61896. */
  61897. glInternalFormat: number;
  61898. /**
  61899. * Gets the base internal format
  61900. */
  61901. glBaseInternalFormat: number;
  61902. /**
  61903. * Gets image width in pixel
  61904. */
  61905. pixelWidth: number;
  61906. /**
  61907. * Gets image height in pixel
  61908. */
  61909. pixelHeight: number;
  61910. /**
  61911. * Gets image depth in pixels
  61912. */
  61913. pixelDepth: number;
  61914. /**
  61915. * Gets the number of array elements
  61916. */
  61917. numberOfArrayElements: number;
  61918. /**
  61919. * Gets the number of faces
  61920. */
  61921. numberOfFaces: number;
  61922. /**
  61923. * Gets the number of mipmap levels
  61924. */
  61925. numberOfMipmapLevels: number;
  61926. /**
  61927. * Gets the bytes of key value data
  61928. */
  61929. bytesOfKeyValueData: number;
  61930. /**
  61931. * Gets the load type
  61932. */
  61933. loadType: number;
  61934. /**
  61935. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61936. */
  61937. isInvalid: boolean;
  61938. /**
  61939. * Creates a new KhronosTextureContainer
  61940. * @param data contents of the KTX container file
  61941. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61942. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61943. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61944. */
  61945. constructor(
  61946. /** contents of the KTX container file */
  61947. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61948. /**
  61949. * Uploads KTX content to a Babylon Texture.
  61950. * It is assumed that the texture has already been created & is currently bound
  61951. * @hidden
  61952. */
  61953. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61954. private _upload2DCompressedLevels;
  61955. /**
  61956. * Checks if the given data starts with a KTX file identifier.
  61957. * @param data the data to check
  61958. * @returns true if the data is a KTX file or false otherwise
  61959. */
  61960. static IsValid(data: ArrayBufferView): boolean;
  61961. }
  61962. }
  61963. declare module "babylonjs/Misc/workerPool" {
  61964. import { IDisposable } from "babylonjs/scene";
  61965. /**
  61966. * Helper class to push actions to a pool of workers.
  61967. */
  61968. export class WorkerPool implements IDisposable {
  61969. private _workerInfos;
  61970. private _pendingActions;
  61971. /**
  61972. * Constructor
  61973. * @param workers Array of workers to use for actions
  61974. */
  61975. constructor(workers: Array<Worker>);
  61976. /**
  61977. * Terminates all workers and clears any pending actions.
  61978. */
  61979. dispose(): void;
  61980. /**
  61981. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61982. * pended until a worker has completed its action.
  61983. * @param action The action to perform. Call onComplete when the action is complete.
  61984. */
  61985. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61986. private _execute;
  61987. }
  61988. }
  61989. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61991. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61992. /**
  61993. * Class for loading KTX2 files
  61994. */
  61995. export class KhronosTextureContainer2 {
  61996. private static _WorkerPoolPromise?;
  61997. private static _Initialized;
  61998. private static _Ktx2Decoder;
  61999. /**
  62000. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62001. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62002. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62003. * Urls you can change:
  62004. * URLConfig.jsDecoderModule
  62005. * URLConfig.wasmUASTCToASTC
  62006. * URLConfig.wasmUASTCToBC7
  62007. * URLConfig.wasmUASTCToRGBA_UNORM
  62008. * URLConfig.wasmUASTCToRGBA_SRGB
  62009. * URLConfig.jsMSCTranscoder
  62010. * URLConfig.wasmMSCTranscoder
  62011. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  62012. */
  62013. static URLConfig: {
  62014. jsDecoderModule: string;
  62015. wasmUASTCToASTC: null;
  62016. wasmUASTCToBC7: null;
  62017. wasmUASTCToRGBA_UNORM: null;
  62018. wasmUASTCToRGBA_SRGB: null;
  62019. jsMSCTranscoder: null;
  62020. wasmMSCTranscoder: null;
  62021. };
  62022. /**
  62023. * Default number of workers used to handle data decoding
  62024. */
  62025. static DefaultNumWorkers: number;
  62026. private static GetDefaultNumWorkers;
  62027. private _engine;
  62028. private static _CreateWorkerPool;
  62029. /**
  62030. * Constructor
  62031. * @param engine The engine to use
  62032. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62033. */
  62034. constructor(engine: ThinEngine, numWorkers?: number);
  62035. /** @hidden */
  62036. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62037. /**
  62038. * Stop all async operations and release resources.
  62039. */
  62040. dispose(): void;
  62041. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62042. /**
  62043. * Checks if the given data starts with a KTX2 file identifier.
  62044. * @param data the data to check
  62045. * @returns true if the data is a KTX2 file or false otherwise
  62046. */
  62047. static IsValid(data: ArrayBufferView): boolean;
  62048. }
  62049. }
  62050. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  62051. import { Nullable } from "babylonjs/types";
  62052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62053. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62054. /**
  62055. * Implementation of the KTX Texture Loader.
  62056. * @hidden
  62057. */
  62058. export class _KTXTextureLoader implements IInternalTextureLoader {
  62059. /**
  62060. * Defines wether the loader supports cascade loading the different faces.
  62061. */
  62062. readonly supportCascades: boolean;
  62063. /**
  62064. * This returns if the loader support the current file information.
  62065. * @param extension defines the file extension of the file being loaded
  62066. * @param mimeType defines the optional mime type of the file being loaded
  62067. * @returns true if the loader can load the specified file
  62068. */
  62069. canLoad(extension: string, mimeType?: string): boolean;
  62070. /**
  62071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62072. * @param data contains the texture data
  62073. * @param texture defines the BabylonJS internal texture
  62074. * @param createPolynomials will be true if polynomials have been requested
  62075. * @param onLoad defines the callback to trigger once the texture is ready
  62076. * @param onError defines the callback to trigger in case of error
  62077. */
  62078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62079. /**
  62080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62081. * @param data contains the texture data
  62082. * @param texture defines the BabylonJS internal texture
  62083. * @param callback defines the method to call once ready to upload
  62084. */
  62085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62086. }
  62087. }
  62088. declare module "babylonjs/Helpers/sceneHelpers" {
  62089. import { Nullable } from "babylonjs/types";
  62090. import { Mesh } from "babylonjs/Meshes/mesh";
  62091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62092. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  62093. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  62094. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62095. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62096. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62097. import "babylonjs/Meshes/Builders/boxBuilder";
  62098. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  62099. /** @hidden */
  62100. export var _forceSceneHelpersToBundle: boolean;
  62101. module "babylonjs/scene" {
  62102. interface Scene {
  62103. /**
  62104. * Creates a default light for the scene.
  62105. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62106. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62107. */
  62108. createDefaultLight(replace?: boolean): void;
  62109. /**
  62110. * Creates a default camera for the scene.
  62111. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62112. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62113. * @param replace has default false, when true replaces the active camera in the scene
  62114. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62115. */
  62116. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62117. /**
  62118. * Creates a default camera and a default light.
  62119. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62120. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62121. * @param replace has the default false, when true replaces the active camera/light in the scene
  62122. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62123. */
  62124. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62125. /**
  62126. * Creates a new sky box
  62127. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62128. * @param environmentTexture defines the texture to use as environment texture
  62129. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62130. * @param scale defines the overall scale of the skybox
  62131. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62132. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62133. * @returns a new mesh holding the sky box
  62134. */
  62135. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62136. /**
  62137. * Creates a new environment
  62138. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62139. * @param options defines the options you can use to configure the environment
  62140. * @returns the new EnvironmentHelper
  62141. */
  62142. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62143. /**
  62144. * Creates a new VREXperienceHelper
  62145. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62146. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62147. * @returns a new VREXperienceHelper
  62148. */
  62149. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62150. /**
  62151. * Creates a new WebXRDefaultExperience
  62152. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62153. * @param options experience options
  62154. * @returns a promise for a new WebXRDefaultExperience
  62155. */
  62156. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62157. }
  62158. }
  62159. }
  62160. declare module "babylonjs/Helpers/videoDome" {
  62161. import { Scene } from "babylonjs/scene";
  62162. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62163. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62164. /**
  62165. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62166. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62167. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62168. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62169. */
  62170. export class VideoDome extends TextureDome<VideoTexture> {
  62171. /**
  62172. * Define the video source as a Monoscopic panoramic 360 video.
  62173. */
  62174. static readonly MODE_MONOSCOPIC: number;
  62175. /**
  62176. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62177. */
  62178. static readonly MODE_TOPBOTTOM: number;
  62179. /**
  62180. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62181. */
  62182. static readonly MODE_SIDEBYSIDE: number;
  62183. /**
  62184. * Get the video texture associated with this video dome
  62185. */
  62186. get videoTexture(): VideoTexture;
  62187. /**
  62188. * Get the video mode of this dome
  62189. */
  62190. get videoMode(): number;
  62191. /**
  62192. * Set the video mode of this dome.
  62193. * @see textureMode
  62194. */
  62195. set videoMode(value: number);
  62196. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62197. }
  62198. }
  62199. declare module "babylonjs/Helpers/index" {
  62200. export * from "babylonjs/Helpers/environmentHelper";
  62201. export * from "babylonjs/Helpers/photoDome";
  62202. export * from "babylonjs/Helpers/sceneHelpers";
  62203. export * from "babylonjs/Helpers/videoDome";
  62204. }
  62205. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62206. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62207. import { IDisposable } from "babylonjs/scene";
  62208. import { Engine } from "babylonjs/Engines/engine";
  62209. /**
  62210. * This class can be used to get instrumentation data from a Babylon engine
  62211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62212. */
  62213. export class EngineInstrumentation implements IDisposable {
  62214. /**
  62215. * Define the instrumented engine.
  62216. */
  62217. engine: Engine;
  62218. private _captureGPUFrameTime;
  62219. private _gpuFrameTimeToken;
  62220. private _gpuFrameTime;
  62221. private _captureShaderCompilationTime;
  62222. private _shaderCompilationTime;
  62223. private _onBeginFrameObserver;
  62224. private _onEndFrameObserver;
  62225. private _onBeforeShaderCompilationObserver;
  62226. private _onAfterShaderCompilationObserver;
  62227. /**
  62228. * Gets the perf counter used for GPU frame time
  62229. */
  62230. get gpuFrameTimeCounter(): PerfCounter;
  62231. /**
  62232. * Gets the GPU frame time capture status
  62233. */
  62234. get captureGPUFrameTime(): boolean;
  62235. /**
  62236. * Enable or disable the GPU frame time capture
  62237. */
  62238. set captureGPUFrameTime(value: boolean);
  62239. /**
  62240. * Gets the perf counter used for shader compilation time
  62241. */
  62242. get shaderCompilationTimeCounter(): PerfCounter;
  62243. /**
  62244. * Gets the shader compilation time capture status
  62245. */
  62246. get captureShaderCompilationTime(): boolean;
  62247. /**
  62248. * Enable or disable the shader compilation time capture
  62249. */
  62250. set captureShaderCompilationTime(value: boolean);
  62251. /**
  62252. * Instantiates a new engine instrumentation.
  62253. * This class can be used to get instrumentation data from a Babylon engine
  62254. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62255. * @param engine Defines the engine to instrument
  62256. */
  62257. constructor(
  62258. /**
  62259. * Define the instrumented engine.
  62260. */
  62261. engine: Engine);
  62262. /**
  62263. * Dispose and release associated resources.
  62264. */
  62265. dispose(): void;
  62266. }
  62267. }
  62268. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62269. import { Scene, IDisposable } from "babylonjs/scene";
  62270. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62271. /**
  62272. * This class can be used to get instrumentation data from a Babylon engine
  62273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62274. */
  62275. export class SceneInstrumentation implements IDisposable {
  62276. /**
  62277. * Defines the scene to instrument
  62278. */
  62279. scene: Scene;
  62280. private _captureActiveMeshesEvaluationTime;
  62281. private _activeMeshesEvaluationTime;
  62282. private _captureRenderTargetsRenderTime;
  62283. private _renderTargetsRenderTime;
  62284. private _captureFrameTime;
  62285. private _frameTime;
  62286. private _captureRenderTime;
  62287. private _renderTime;
  62288. private _captureInterFrameTime;
  62289. private _interFrameTime;
  62290. private _captureParticlesRenderTime;
  62291. private _particlesRenderTime;
  62292. private _captureSpritesRenderTime;
  62293. private _spritesRenderTime;
  62294. private _capturePhysicsTime;
  62295. private _physicsTime;
  62296. private _captureAnimationsTime;
  62297. private _animationsTime;
  62298. private _captureCameraRenderTime;
  62299. private _cameraRenderTime;
  62300. private _onBeforeActiveMeshesEvaluationObserver;
  62301. private _onAfterActiveMeshesEvaluationObserver;
  62302. private _onBeforeRenderTargetsRenderObserver;
  62303. private _onAfterRenderTargetsRenderObserver;
  62304. private _onAfterRenderObserver;
  62305. private _onBeforeDrawPhaseObserver;
  62306. private _onAfterDrawPhaseObserver;
  62307. private _onBeforeAnimationsObserver;
  62308. private _onBeforeParticlesRenderingObserver;
  62309. private _onAfterParticlesRenderingObserver;
  62310. private _onBeforeSpritesRenderingObserver;
  62311. private _onAfterSpritesRenderingObserver;
  62312. private _onBeforePhysicsObserver;
  62313. private _onAfterPhysicsObserver;
  62314. private _onAfterAnimationsObserver;
  62315. private _onBeforeCameraRenderObserver;
  62316. private _onAfterCameraRenderObserver;
  62317. /**
  62318. * Gets the perf counter used for active meshes evaluation time
  62319. */
  62320. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62321. /**
  62322. * Gets the active meshes evaluation time capture status
  62323. */
  62324. get captureActiveMeshesEvaluationTime(): boolean;
  62325. /**
  62326. * Enable or disable the active meshes evaluation time capture
  62327. */
  62328. set captureActiveMeshesEvaluationTime(value: boolean);
  62329. /**
  62330. * Gets the perf counter used for render targets render time
  62331. */
  62332. get renderTargetsRenderTimeCounter(): PerfCounter;
  62333. /**
  62334. * Gets the render targets render time capture status
  62335. */
  62336. get captureRenderTargetsRenderTime(): boolean;
  62337. /**
  62338. * Enable or disable the render targets render time capture
  62339. */
  62340. set captureRenderTargetsRenderTime(value: boolean);
  62341. /**
  62342. * Gets the perf counter used for particles render time
  62343. */
  62344. get particlesRenderTimeCounter(): PerfCounter;
  62345. /**
  62346. * Gets the particles render time capture status
  62347. */
  62348. get captureParticlesRenderTime(): boolean;
  62349. /**
  62350. * Enable or disable the particles render time capture
  62351. */
  62352. set captureParticlesRenderTime(value: boolean);
  62353. /**
  62354. * Gets the perf counter used for sprites render time
  62355. */
  62356. get spritesRenderTimeCounter(): PerfCounter;
  62357. /**
  62358. * Gets the sprites render time capture status
  62359. */
  62360. get captureSpritesRenderTime(): boolean;
  62361. /**
  62362. * Enable or disable the sprites render time capture
  62363. */
  62364. set captureSpritesRenderTime(value: boolean);
  62365. /**
  62366. * Gets the perf counter used for physics time
  62367. */
  62368. get physicsTimeCounter(): PerfCounter;
  62369. /**
  62370. * Gets the physics time capture status
  62371. */
  62372. get capturePhysicsTime(): boolean;
  62373. /**
  62374. * Enable or disable the physics time capture
  62375. */
  62376. set capturePhysicsTime(value: boolean);
  62377. /**
  62378. * Gets the perf counter used for animations time
  62379. */
  62380. get animationsTimeCounter(): PerfCounter;
  62381. /**
  62382. * Gets the animations time capture status
  62383. */
  62384. get captureAnimationsTime(): boolean;
  62385. /**
  62386. * Enable or disable the animations time capture
  62387. */
  62388. set captureAnimationsTime(value: boolean);
  62389. /**
  62390. * Gets the perf counter used for frame time capture
  62391. */
  62392. get frameTimeCounter(): PerfCounter;
  62393. /**
  62394. * Gets the frame time capture status
  62395. */
  62396. get captureFrameTime(): boolean;
  62397. /**
  62398. * Enable or disable the frame time capture
  62399. */
  62400. set captureFrameTime(value: boolean);
  62401. /**
  62402. * Gets the perf counter used for inter-frames time capture
  62403. */
  62404. get interFrameTimeCounter(): PerfCounter;
  62405. /**
  62406. * Gets the inter-frames time capture status
  62407. */
  62408. get captureInterFrameTime(): boolean;
  62409. /**
  62410. * Enable or disable the inter-frames time capture
  62411. */
  62412. set captureInterFrameTime(value: boolean);
  62413. /**
  62414. * Gets the perf counter used for render time capture
  62415. */
  62416. get renderTimeCounter(): PerfCounter;
  62417. /**
  62418. * Gets the render time capture status
  62419. */
  62420. get captureRenderTime(): boolean;
  62421. /**
  62422. * Enable or disable the render time capture
  62423. */
  62424. set captureRenderTime(value: boolean);
  62425. /**
  62426. * Gets the perf counter used for camera render time capture
  62427. */
  62428. get cameraRenderTimeCounter(): PerfCounter;
  62429. /**
  62430. * Gets the camera render time capture status
  62431. */
  62432. get captureCameraRenderTime(): boolean;
  62433. /**
  62434. * Enable or disable the camera render time capture
  62435. */
  62436. set captureCameraRenderTime(value: boolean);
  62437. /**
  62438. * Gets the perf counter used for draw calls
  62439. */
  62440. get drawCallsCounter(): PerfCounter;
  62441. /**
  62442. * Instantiates a new scene instrumentation.
  62443. * This class can be used to get instrumentation data from a Babylon engine
  62444. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62445. * @param scene Defines the scene to instrument
  62446. */
  62447. constructor(
  62448. /**
  62449. * Defines the scene to instrument
  62450. */
  62451. scene: Scene);
  62452. /**
  62453. * Dispose and release associated resources.
  62454. */
  62455. dispose(): void;
  62456. }
  62457. }
  62458. declare module "babylonjs/Instrumentation/index" {
  62459. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62460. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62461. export * from "babylonjs/Instrumentation/timeToken";
  62462. }
  62463. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62464. /** @hidden */
  62465. export var glowMapGenerationPixelShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62471. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62472. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62473. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62474. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62475. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62476. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62477. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62478. /** @hidden */
  62479. export var glowMapGenerationVertexShader: {
  62480. name: string;
  62481. shader: string;
  62482. };
  62483. }
  62484. declare module "babylonjs/Layers/effectLayer" {
  62485. import { Observable } from "babylonjs/Misc/observable";
  62486. import { Nullable } from "babylonjs/types";
  62487. import { Camera } from "babylonjs/Cameras/camera";
  62488. import { Scene } from "babylonjs/scene";
  62489. import { ISize } from "babylonjs/Maths/math.size";
  62490. import { Color4 } from "babylonjs/Maths/math.color";
  62491. import { Engine } from "babylonjs/Engines/engine";
  62492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62494. import { Mesh } from "babylonjs/Meshes/mesh";
  62495. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62498. import { Effect } from "babylonjs/Materials/effect";
  62499. import { Material } from "babylonjs/Materials/material";
  62500. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62501. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62502. /**
  62503. * Effect layer options. This helps customizing the behaviour
  62504. * of the effect layer.
  62505. */
  62506. export interface IEffectLayerOptions {
  62507. /**
  62508. * Multiplication factor apply to the canvas size to compute the render target size
  62509. * used to generated the objects (the smaller the faster).
  62510. */
  62511. mainTextureRatio: number;
  62512. /**
  62513. * Enforces a fixed size texture to ensure effect stability across devices.
  62514. */
  62515. mainTextureFixedSize?: number;
  62516. /**
  62517. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62518. */
  62519. alphaBlendingMode: number;
  62520. /**
  62521. * The camera attached to the layer.
  62522. */
  62523. camera: Nullable<Camera>;
  62524. /**
  62525. * The rendering group to draw the layer in.
  62526. */
  62527. renderingGroupId: number;
  62528. }
  62529. /**
  62530. * The effect layer Helps adding post process effect blended with the main pass.
  62531. *
  62532. * This can be for instance use to generate glow or higlight effects on the scene.
  62533. *
  62534. * The effect layer class can not be used directly and is intented to inherited from to be
  62535. * customized per effects.
  62536. */
  62537. export abstract class EffectLayer {
  62538. private _vertexBuffers;
  62539. private _indexBuffer;
  62540. private _cachedDefines;
  62541. private _effectLayerMapGenerationEffect;
  62542. private _effectLayerOptions;
  62543. private _mergeEffect;
  62544. protected _scene: Scene;
  62545. protected _engine: Engine;
  62546. protected _maxSize: number;
  62547. protected _mainTextureDesiredSize: ISize;
  62548. protected _mainTexture: RenderTargetTexture;
  62549. protected _shouldRender: boolean;
  62550. protected _postProcesses: PostProcess[];
  62551. protected _textures: BaseTexture[];
  62552. protected _emissiveTextureAndColor: {
  62553. texture: Nullable<BaseTexture>;
  62554. color: Color4;
  62555. };
  62556. /**
  62557. * The name of the layer
  62558. */
  62559. name: string;
  62560. /**
  62561. * The clear color of the texture used to generate the glow map.
  62562. */
  62563. neutralColor: Color4;
  62564. /**
  62565. * Specifies whether the highlight layer is enabled or not.
  62566. */
  62567. isEnabled: boolean;
  62568. /**
  62569. * Gets the camera attached to the layer.
  62570. */
  62571. get camera(): Nullable<Camera>;
  62572. /**
  62573. * Gets the rendering group id the layer should render in.
  62574. */
  62575. get renderingGroupId(): number;
  62576. set renderingGroupId(renderingGroupId: number);
  62577. /**
  62578. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62579. */
  62580. disableBoundingBoxesFromEffectLayer: boolean;
  62581. /**
  62582. * An event triggered when the effect layer has been disposed.
  62583. */
  62584. onDisposeObservable: Observable<EffectLayer>;
  62585. /**
  62586. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62587. */
  62588. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62589. /**
  62590. * An event triggered when the generated texture is being merged in the scene.
  62591. */
  62592. onBeforeComposeObservable: Observable<EffectLayer>;
  62593. /**
  62594. * An event triggered when the mesh is rendered into the effect render target.
  62595. */
  62596. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62597. /**
  62598. * An event triggered after the mesh has been rendered into the effect render target.
  62599. */
  62600. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62601. /**
  62602. * An event triggered when the generated texture has been merged in the scene.
  62603. */
  62604. onAfterComposeObservable: Observable<EffectLayer>;
  62605. /**
  62606. * An event triggered when the efffect layer changes its size.
  62607. */
  62608. onSizeChangedObservable: Observable<EffectLayer>;
  62609. /** @hidden */
  62610. static _SceneComponentInitialization: (scene: Scene) => void;
  62611. /**
  62612. * Instantiates a new effect Layer and references it in the scene.
  62613. * @param name The name of the layer
  62614. * @param scene The scene to use the layer in
  62615. */
  62616. constructor(
  62617. /** The Friendly of the effect in the scene */
  62618. name: string, scene: Scene);
  62619. /**
  62620. * Get the effect name of the layer.
  62621. * @return The effect name
  62622. */
  62623. abstract getEffectName(): string;
  62624. /**
  62625. * Checks for the readiness of the element composing the layer.
  62626. * @param subMesh the mesh to check for
  62627. * @param useInstances specify whether or not to use instances to render the mesh
  62628. * @return true if ready otherwise, false
  62629. */
  62630. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62631. /**
  62632. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62633. * @returns true if the effect requires stencil during the main canvas render pass.
  62634. */
  62635. abstract needStencil(): boolean;
  62636. /**
  62637. * Create the merge effect. This is the shader use to blit the information back
  62638. * to the main canvas at the end of the scene rendering.
  62639. * @returns The effect containing the shader used to merge the effect on the main canvas
  62640. */
  62641. protected abstract _createMergeEffect(): Effect;
  62642. /**
  62643. * Creates the render target textures and post processes used in the effect layer.
  62644. */
  62645. protected abstract _createTextureAndPostProcesses(): void;
  62646. /**
  62647. * Implementation specific of rendering the generating effect on the main canvas.
  62648. * @param effect The effect used to render through
  62649. */
  62650. protected abstract _internalRender(effect: Effect): void;
  62651. /**
  62652. * Sets the required values for both the emissive texture and and the main color.
  62653. */
  62654. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62655. /**
  62656. * Free any resources and references associated to a mesh.
  62657. * Internal use
  62658. * @param mesh The mesh to free.
  62659. */
  62660. abstract _disposeMesh(mesh: Mesh): void;
  62661. /**
  62662. * Serializes this layer (Glow or Highlight for example)
  62663. * @returns a serialized layer object
  62664. */
  62665. abstract serialize?(): any;
  62666. /**
  62667. * Initializes the effect layer with the required options.
  62668. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62669. */
  62670. protected _init(options: Partial<IEffectLayerOptions>): void;
  62671. /**
  62672. * Generates the index buffer of the full screen quad blending to the main canvas.
  62673. */
  62674. private _generateIndexBuffer;
  62675. /**
  62676. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62677. */
  62678. private _generateVertexBuffer;
  62679. /**
  62680. * Sets the main texture desired size which is the closest power of two
  62681. * of the engine canvas size.
  62682. */
  62683. private _setMainTextureSize;
  62684. /**
  62685. * Creates the main texture for the effect layer.
  62686. */
  62687. protected _createMainTexture(): void;
  62688. /**
  62689. * Adds specific effects defines.
  62690. * @param defines The defines to add specifics to.
  62691. */
  62692. protected _addCustomEffectDefines(defines: string[]): void;
  62693. /**
  62694. * Checks for the readiness of the element composing the layer.
  62695. * @param subMesh the mesh to check for
  62696. * @param useInstances specify whether or not to use instances to render the mesh
  62697. * @param emissiveTexture the associated emissive texture used to generate the glow
  62698. * @return true if ready otherwise, false
  62699. */
  62700. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62701. /**
  62702. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62703. */
  62704. render(): void;
  62705. /**
  62706. * Determine if a given mesh will be used in the current effect.
  62707. * @param mesh mesh to test
  62708. * @returns true if the mesh will be used
  62709. */
  62710. hasMesh(mesh: AbstractMesh): boolean;
  62711. /**
  62712. * Returns true if the layer contains information to display, otherwise false.
  62713. * @returns true if the glow layer should be rendered
  62714. */
  62715. shouldRender(): boolean;
  62716. /**
  62717. * Returns true if the mesh should render, otherwise false.
  62718. * @param mesh The mesh to render
  62719. * @returns true if it should render otherwise false
  62720. */
  62721. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62722. /**
  62723. * Returns true if the mesh can be rendered, otherwise false.
  62724. * @param mesh The mesh to render
  62725. * @param material The material used on the mesh
  62726. * @returns true if it can be rendered otherwise false
  62727. */
  62728. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62729. /**
  62730. * Returns true if the mesh should render, otherwise false.
  62731. * @param mesh The mesh to render
  62732. * @returns true if it should render otherwise false
  62733. */
  62734. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62735. /**
  62736. * Renders the submesh passed in parameter to the generation map.
  62737. */
  62738. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62739. /**
  62740. * Defines whether the current material of the mesh should be use to render the effect.
  62741. * @param mesh defines the current mesh to render
  62742. */
  62743. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62744. /**
  62745. * Rebuild the required buffers.
  62746. * @hidden Internal use only.
  62747. */
  62748. _rebuild(): void;
  62749. /**
  62750. * Dispose only the render target textures and post process.
  62751. */
  62752. private _disposeTextureAndPostProcesses;
  62753. /**
  62754. * Dispose the highlight layer and free resources.
  62755. */
  62756. dispose(): void;
  62757. /**
  62758. * Gets the class name of the effect layer
  62759. * @returns the string with the class name of the effect layer
  62760. */
  62761. getClassName(): string;
  62762. /**
  62763. * Creates an effect layer from parsed effect layer data
  62764. * @param parsedEffectLayer defines effect layer data
  62765. * @param scene defines the current scene
  62766. * @param rootUrl defines the root URL containing the effect layer information
  62767. * @returns a parsed effect Layer
  62768. */
  62769. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62770. }
  62771. }
  62772. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62773. import { Scene } from "babylonjs/scene";
  62774. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62775. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62776. import { AbstractScene } from "babylonjs/abstractScene";
  62777. module "babylonjs/abstractScene" {
  62778. interface AbstractScene {
  62779. /**
  62780. * The list of effect layers (highlights/glow) added to the scene
  62781. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62782. * @see https://doc.babylonjs.com/how_to/glow_layer
  62783. */
  62784. effectLayers: Array<EffectLayer>;
  62785. /**
  62786. * Removes the given effect layer from this scene.
  62787. * @param toRemove defines the effect layer to remove
  62788. * @returns the index of the removed effect layer
  62789. */
  62790. removeEffectLayer(toRemove: EffectLayer): number;
  62791. /**
  62792. * Adds the given effect layer to this scene
  62793. * @param newEffectLayer defines the effect layer to add
  62794. */
  62795. addEffectLayer(newEffectLayer: EffectLayer): void;
  62796. }
  62797. }
  62798. /**
  62799. * Defines the layer scene component responsible to manage any effect layers
  62800. * in a given scene.
  62801. */
  62802. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62803. /**
  62804. * The component name helpfull to identify the component in the list of scene components.
  62805. */
  62806. readonly name: string;
  62807. /**
  62808. * The scene the component belongs to.
  62809. */
  62810. scene: Scene;
  62811. private _engine;
  62812. private _renderEffects;
  62813. private _needStencil;
  62814. private _previousStencilState;
  62815. /**
  62816. * Creates a new instance of the component for the given scene
  62817. * @param scene Defines the scene to register the component in
  62818. */
  62819. constructor(scene: Scene);
  62820. /**
  62821. * Registers the component in a given scene
  62822. */
  62823. register(): void;
  62824. /**
  62825. * Rebuilds the elements related to this component in case of
  62826. * context lost for instance.
  62827. */
  62828. rebuild(): void;
  62829. /**
  62830. * Serializes the component data to the specified json object
  62831. * @param serializationObject The object to serialize to
  62832. */
  62833. serialize(serializationObject: any): void;
  62834. /**
  62835. * Adds all the elements from the container to the scene
  62836. * @param container the container holding the elements
  62837. */
  62838. addFromContainer(container: AbstractScene): void;
  62839. /**
  62840. * Removes all the elements in the container from the scene
  62841. * @param container contains the elements to remove
  62842. * @param dispose if the removed element should be disposed (default: false)
  62843. */
  62844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62845. /**
  62846. * Disposes the component and the associated ressources.
  62847. */
  62848. dispose(): void;
  62849. private _isReadyForMesh;
  62850. private _renderMainTexture;
  62851. private _setStencil;
  62852. private _setStencilBack;
  62853. private _draw;
  62854. private _drawCamera;
  62855. private _drawRenderingGroup;
  62856. }
  62857. }
  62858. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62859. /** @hidden */
  62860. export var glowMapMergePixelShader: {
  62861. name: string;
  62862. shader: string;
  62863. };
  62864. }
  62865. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62866. /** @hidden */
  62867. export var glowMapMergeVertexShader: {
  62868. name: string;
  62869. shader: string;
  62870. };
  62871. }
  62872. declare module "babylonjs/Layers/glowLayer" {
  62873. import { Nullable } from "babylonjs/types";
  62874. import { Camera } from "babylonjs/Cameras/camera";
  62875. import { Scene } from "babylonjs/scene";
  62876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62878. import { Mesh } from "babylonjs/Meshes/mesh";
  62879. import { Texture } from "babylonjs/Materials/Textures/texture";
  62880. import { Effect } from "babylonjs/Materials/effect";
  62881. import { Material } from "babylonjs/Materials/material";
  62882. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62883. import { Color4 } from "babylonjs/Maths/math.color";
  62884. import "babylonjs/Shaders/glowMapMerge.fragment";
  62885. import "babylonjs/Shaders/glowMapMerge.vertex";
  62886. import "babylonjs/Layers/effectLayerSceneComponent";
  62887. module "babylonjs/abstractScene" {
  62888. interface AbstractScene {
  62889. /**
  62890. * Return a the first highlight layer of the scene with a given name.
  62891. * @param name The name of the highlight layer to look for.
  62892. * @return The highlight layer if found otherwise null.
  62893. */
  62894. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62895. }
  62896. }
  62897. /**
  62898. * Glow layer options. This helps customizing the behaviour
  62899. * of the glow layer.
  62900. */
  62901. export interface IGlowLayerOptions {
  62902. /**
  62903. * Multiplication factor apply to the canvas size to compute the render target size
  62904. * used to generated the glowing objects (the smaller the faster).
  62905. */
  62906. mainTextureRatio: number;
  62907. /**
  62908. * Enforces a fixed size texture to ensure resize independant blur.
  62909. */
  62910. mainTextureFixedSize?: number;
  62911. /**
  62912. * How big is the kernel of the blur texture.
  62913. */
  62914. blurKernelSize: number;
  62915. /**
  62916. * The camera attached to the layer.
  62917. */
  62918. camera: Nullable<Camera>;
  62919. /**
  62920. * Enable MSAA by chosing the number of samples.
  62921. */
  62922. mainTextureSamples?: number;
  62923. /**
  62924. * The rendering group to draw the layer in.
  62925. */
  62926. renderingGroupId: number;
  62927. }
  62928. /**
  62929. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62930. *
  62931. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62932. *
  62933. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62934. */
  62935. export class GlowLayer extends EffectLayer {
  62936. /**
  62937. * Effect Name of the layer.
  62938. */
  62939. static readonly EffectName: string;
  62940. /**
  62941. * The default blur kernel size used for the glow.
  62942. */
  62943. static DefaultBlurKernelSize: number;
  62944. /**
  62945. * The default texture size ratio used for the glow.
  62946. */
  62947. static DefaultTextureRatio: number;
  62948. /**
  62949. * Sets the kernel size of the blur.
  62950. */
  62951. set blurKernelSize(value: number);
  62952. /**
  62953. * Gets the kernel size of the blur.
  62954. */
  62955. get blurKernelSize(): number;
  62956. /**
  62957. * Sets the glow intensity.
  62958. */
  62959. set intensity(value: number);
  62960. /**
  62961. * Gets the glow intensity.
  62962. */
  62963. get intensity(): number;
  62964. private _options;
  62965. private _intensity;
  62966. private _horizontalBlurPostprocess1;
  62967. private _verticalBlurPostprocess1;
  62968. private _horizontalBlurPostprocess2;
  62969. private _verticalBlurPostprocess2;
  62970. private _blurTexture1;
  62971. private _blurTexture2;
  62972. private _postProcesses1;
  62973. private _postProcesses2;
  62974. private _includedOnlyMeshes;
  62975. private _excludedMeshes;
  62976. private _meshesUsingTheirOwnMaterials;
  62977. /**
  62978. * Callback used to let the user override the color selection on a per mesh basis
  62979. */
  62980. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62981. /**
  62982. * Callback used to let the user override the texture selection on a per mesh basis
  62983. */
  62984. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62985. /**
  62986. * Instantiates a new glow Layer and references it to the scene.
  62987. * @param name The name of the layer
  62988. * @param scene The scene to use the layer in
  62989. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62990. */
  62991. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62992. /**
  62993. * Get the effect name of the layer.
  62994. * @return The effect name
  62995. */
  62996. getEffectName(): string;
  62997. /**
  62998. * Create the merge effect. This is the shader use to blit the information back
  62999. * to the main canvas at the end of the scene rendering.
  63000. */
  63001. protected _createMergeEffect(): Effect;
  63002. /**
  63003. * Creates the render target textures and post processes used in the glow layer.
  63004. */
  63005. protected _createTextureAndPostProcesses(): void;
  63006. /**
  63007. * Checks for the readiness of the element composing the layer.
  63008. * @param subMesh the mesh to check for
  63009. * @param useInstances specify wether or not to use instances to render the mesh
  63010. * @param emissiveTexture the associated emissive texture used to generate the glow
  63011. * @return true if ready otherwise, false
  63012. */
  63013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63014. /**
  63015. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63016. */
  63017. needStencil(): boolean;
  63018. /**
  63019. * Returns true if the mesh can be rendered, otherwise false.
  63020. * @param mesh The mesh to render
  63021. * @param material The material used on the mesh
  63022. * @returns true if it can be rendered otherwise false
  63023. */
  63024. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63025. /**
  63026. * Implementation specific of rendering the generating effect on the main canvas.
  63027. * @param effect The effect used to render through
  63028. */
  63029. protected _internalRender(effect: Effect): void;
  63030. /**
  63031. * Sets the required values for both the emissive texture and and the main color.
  63032. */
  63033. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63034. /**
  63035. * Returns true if the mesh should render, otherwise false.
  63036. * @param mesh The mesh to render
  63037. * @returns true if it should render otherwise false
  63038. */
  63039. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63040. /**
  63041. * Adds specific effects defines.
  63042. * @param defines The defines to add specifics to.
  63043. */
  63044. protected _addCustomEffectDefines(defines: string[]): void;
  63045. /**
  63046. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63047. * @param mesh The mesh to exclude from the glow layer
  63048. */
  63049. addExcludedMesh(mesh: Mesh): void;
  63050. /**
  63051. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63052. * @param mesh The mesh to remove
  63053. */
  63054. removeExcludedMesh(mesh: Mesh): void;
  63055. /**
  63056. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63057. * @param mesh The mesh to include in the glow layer
  63058. */
  63059. addIncludedOnlyMesh(mesh: Mesh): void;
  63060. /**
  63061. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63062. * @param mesh The mesh to remove
  63063. */
  63064. removeIncludedOnlyMesh(mesh: Mesh): void;
  63065. /**
  63066. * Determine if a given mesh will be used in the glow layer
  63067. * @param mesh The mesh to test
  63068. * @returns true if the mesh will be highlighted by the current glow layer
  63069. */
  63070. hasMesh(mesh: AbstractMesh): boolean;
  63071. /**
  63072. * Defines whether the current material of the mesh should be use to render the effect.
  63073. * @param mesh defines the current mesh to render
  63074. */
  63075. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63076. /**
  63077. * Add a mesh to be rendered through its own material and not with emissive only.
  63078. * @param mesh The mesh for which we need to use its material
  63079. */
  63080. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63081. /**
  63082. * Remove a mesh from being rendered through its own material and not with emissive only.
  63083. * @param mesh The mesh for which we need to not use its material
  63084. */
  63085. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63086. /**
  63087. * Free any resources and references associated to a mesh.
  63088. * Internal use
  63089. * @param mesh The mesh to free.
  63090. * @hidden
  63091. */
  63092. _disposeMesh(mesh: Mesh): void;
  63093. /**
  63094. * Gets the class name of the effect layer
  63095. * @returns the string with the class name of the effect layer
  63096. */
  63097. getClassName(): string;
  63098. /**
  63099. * Serializes this glow layer
  63100. * @returns a serialized glow layer object
  63101. */
  63102. serialize(): any;
  63103. /**
  63104. * Creates a Glow Layer from parsed glow layer data
  63105. * @param parsedGlowLayer defines glow layer data
  63106. * @param scene defines the current scene
  63107. * @param rootUrl defines the root URL containing the glow layer information
  63108. * @returns a parsed Glow Layer
  63109. */
  63110. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63111. }
  63112. }
  63113. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  63114. /** @hidden */
  63115. export var glowBlurPostProcessPixelShader: {
  63116. name: string;
  63117. shader: string;
  63118. };
  63119. }
  63120. declare module "babylonjs/Layers/highlightLayer" {
  63121. import { Observable } from "babylonjs/Misc/observable";
  63122. import { Nullable } from "babylonjs/types";
  63123. import { Camera } from "babylonjs/Cameras/camera";
  63124. import { Scene } from "babylonjs/scene";
  63125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63127. import { Mesh } from "babylonjs/Meshes/mesh";
  63128. import { Effect } from "babylonjs/Materials/effect";
  63129. import { Material } from "babylonjs/Materials/material";
  63130. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63131. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63132. import "babylonjs/Shaders/glowMapMerge.fragment";
  63133. import "babylonjs/Shaders/glowMapMerge.vertex";
  63134. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63135. module "babylonjs/abstractScene" {
  63136. interface AbstractScene {
  63137. /**
  63138. * Return a the first highlight layer of the scene with a given name.
  63139. * @param name The name of the highlight layer to look for.
  63140. * @return The highlight layer if found otherwise null.
  63141. */
  63142. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63143. }
  63144. }
  63145. /**
  63146. * Highlight layer options. This helps customizing the behaviour
  63147. * of the highlight layer.
  63148. */
  63149. export interface IHighlightLayerOptions {
  63150. /**
  63151. * Multiplication factor apply to the canvas size to compute the render target size
  63152. * used to generated the glowing objects (the smaller the faster).
  63153. */
  63154. mainTextureRatio: number;
  63155. /**
  63156. * Enforces a fixed size texture to ensure resize independant blur.
  63157. */
  63158. mainTextureFixedSize?: number;
  63159. /**
  63160. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63161. * of the picture to blur (the smaller the faster).
  63162. */
  63163. blurTextureSizeRatio: number;
  63164. /**
  63165. * How big in texel of the blur texture is the vertical blur.
  63166. */
  63167. blurVerticalSize: number;
  63168. /**
  63169. * How big in texel of the blur texture is the horizontal blur.
  63170. */
  63171. blurHorizontalSize: number;
  63172. /**
  63173. * Alpha blending mode used to apply the blur. Default is combine.
  63174. */
  63175. alphaBlendingMode: number;
  63176. /**
  63177. * The camera attached to the layer.
  63178. */
  63179. camera: Nullable<Camera>;
  63180. /**
  63181. * Should we display highlight as a solid stroke?
  63182. */
  63183. isStroke?: boolean;
  63184. /**
  63185. * The rendering group to draw the layer in.
  63186. */
  63187. renderingGroupId: number;
  63188. }
  63189. /**
  63190. * The highlight layer Helps adding a glow effect around a mesh.
  63191. *
  63192. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63193. * glowy meshes to your scene.
  63194. *
  63195. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63196. */
  63197. export class HighlightLayer extends EffectLayer {
  63198. name: string;
  63199. /**
  63200. * Effect Name of the highlight layer.
  63201. */
  63202. static readonly EffectName: string;
  63203. /**
  63204. * The neutral color used during the preparation of the glow effect.
  63205. * This is black by default as the blend operation is a blend operation.
  63206. */
  63207. static NeutralColor: Color4;
  63208. /**
  63209. * Stencil value used for glowing meshes.
  63210. */
  63211. static GlowingMeshStencilReference: number;
  63212. /**
  63213. * Stencil value used for the other meshes in the scene.
  63214. */
  63215. static NormalMeshStencilReference: number;
  63216. /**
  63217. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63218. */
  63219. innerGlow: boolean;
  63220. /**
  63221. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63222. */
  63223. outerGlow: boolean;
  63224. /**
  63225. * Specifies the horizontal size of the blur.
  63226. */
  63227. set blurHorizontalSize(value: number);
  63228. /**
  63229. * Specifies the vertical size of the blur.
  63230. */
  63231. set blurVerticalSize(value: number);
  63232. /**
  63233. * Gets the horizontal size of the blur.
  63234. */
  63235. get blurHorizontalSize(): number;
  63236. /**
  63237. * Gets the vertical size of the blur.
  63238. */
  63239. get blurVerticalSize(): number;
  63240. /**
  63241. * An event triggered when the highlight layer is being blurred.
  63242. */
  63243. onBeforeBlurObservable: Observable<HighlightLayer>;
  63244. /**
  63245. * An event triggered when the highlight layer has been blurred.
  63246. */
  63247. onAfterBlurObservable: Observable<HighlightLayer>;
  63248. private _instanceGlowingMeshStencilReference;
  63249. private _options;
  63250. private _downSamplePostprocess;
  63251. private _horizontalBlurPostprocess;
  63252. private _verticalBlurPostprocess;
  63253. private _blurTexture;
  63254. private _meshes;
  63255. private _excludedMeshes;
  63256. /**
  63257. * Instantiates a new highlight Layer and references it to the scene..
  63258. * @param name The name of the layer
  63259. * @param scene The scene to use the layer in
  63260. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63261. */
  63262. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63263. /**
  63264. * Get the effect name of the layer.
  63265. * @return The effect name
  63266. */
  63267. getEffectName(): string;
  63268. /**
  63269. * Create the merge effect. This is the shader use to blit the information back
  63270. * to the main canvas at the end of the scene rendering.
  63271. */
  63272. protected _createMergeEffect(): Effect;
  63273. /**
  63274. * Creates the render target textures and post processes used in the highlight layer.
  63275. */
  63276. protected _createTextureAndPostProcesses(): void;
  63277. /**
  63278. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63279. */
  63280. needStencil(): boolean;
  63281. /**
  63282. * Checks for the readiness of the element composing the layer.
  63283. * @param subMesh the mesh to check for
  63284. * @param useInstances specify wether or not to use instances to render the mesh
  63285. * @param emissiveTexture the associated emissive texture used to generate the glow
  63286. * @return true if ready otherwise, false
  63287. */
  63288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63289. /**
  63290. * Implementation specific of rendering the generating effect on the main canvas.
  63291. * @param effect The effect used to render through
  63292. */
  63293. protected _internalRender(effect: Effect): void;
  63294. /**
  63295. * Returns true if the layer contains information to display, otherwise false.
  63296. */
  63297. shouldRender(): boolean;
  63298. /**
  63299. * Returns true if the mesh should render, otherwise false.
  63300. * @param mesh The mesh to render
  63301. * @returns true if it should render otherwise false
  63302. */
  63303. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63304. /**
  63305. * Returns true if the mesh can be rendered, otherwise false.
  63306. * @param mesh The mesh to render
  63307. * @param material The material used on the mesh
  63308. * @returns true if it can be rendered otherwise false
  63309. */
  63310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63311. /**
  63312. * Adds specific effects defines.
  63313. * @param defines The defines to add specifics to.
  63314. */
  63315. protected _addCustomEffectDefines(defines: string[]): void;
  63316. /**
  63317. * Sets the required values for both the emissive texture and and the main color.
  63318. */
  63319. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63320. /**
  63321. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63322. * @param mesh The mesh to exclude from the highlight layer
  63323. */
  63324. addExcludedMesh(mesh: Mesh): void;
  63325. /**
  63326. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63327. * @param mesh The mesh to highlight
  63328. */
  63329. removeExcludedMesh(mesh: Mesh): void;
  63330. /**
  63331. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63332. * @param mesh mesh to test
  63333. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63334. */
  63335. hasMesh(mesh: AbstractMesh): boolean;
  63336. /**
  63337. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63338. * @param mesh The mesh to highlight
  63339. * @param color The color of the highlight
  63340. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63341. */
  63342. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63343. /**
  63344. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63345. * @param mesh The mesh to highlight
  63346. */
  63347. removeMesh(mesh: Mesh): void;
  63348. /**
  63349. * Remove all the meshes currently referenced in the highlight layer
  63350. */
  63351. removeAllMeshes(): void;
  63352. /**
  63353. * Force the stencil to the normal expected value for none glowing parts
  63354. */
  63355. private _defaultStencilReference;
  63356. /**
  63357. * Free any resources and references associated to a mesh.
  63358. * Internal use
  63359. * @param mesh The mesh to free.
  63360. * @hidden
  63361. */
  63362. _disposeMesh(mesh: Mesh): void;
  63363. /**
  63364. * Dispose the highlight layer and free resources.
  63365. */
  63366. dispose(): void;
  63367. /**
  63368. * Gets the class name of the effect layer
  63369. * @returns the string with the class name of the effect layer
  63370. */
  63371. getClassName(): string;
  63372. /**
  63373. * Serializes this Highlight layer
  63374. * @returns a serialized Highlight layer object
  63375. */
  63376. serialize(): any;
  63377. /**
  63378. * Creates a Highlight layer from parsed Highlight layer data
  63379. * @param parsedHightlightLayer defines the Highlight layer data
  63380. * @param scene defines the current scene
  63381. * @param rootUrl defines the root URL containing the Highlight layer information
  63382. * @returns a parsed Highlight layer
  63383. */
  63384. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63385. }
  63386. }
  63387. declare module "babylonjs/Layers/layerSceneComponent" {
  63388. import { Scene } from "babylonjs/scene";
  63389. import { ISceneComponent } from "babylonjs/sceneComponent";
  63390. import { Layer } from "babylonjs/Layers/layer";
  63391. import { AbstractScene } from "babylonjs/abstractScene";
  63392. module "babylonjs/abstractScene" {
  63393. interface AbstractScene {
  63394. /**
  63395. * The list of layers (background and foreground) of the scene
  63396. */
  63397. layers: Array<Layer>;
  63398. }
  63399. }
  63400. /**
  63401. * Defines the layer scene component responsible to manage any layers
  63402. * in a given scene.
  63403. */
  63404. export class LayerSceneComponent implements ISceneComponent {
  63405. /**
  63406. * The component name helpfull to identify the component in the list of scene components.
  63407. */
  63408. readonly name: string;
  63409. /**
  63410. * The scene the component belongs to.
  63411. */
  63412. scene: Scene;
  63413. private _engine;
  63414. /**
  63415. * Creates a new instance of the component for the given scene
  63416. * @param scene Defines the scene to register the component in
  63417. */
  63418. constructor(scene: Scene);
  63419. /**
  63420. * Registers the component in a given scene
  63421. */
  63422. register(): void;
  63423. /**
  63424. * Rebuilds the elements related to this component in case of
  63425. * context lost for instance.
  63426. */
  63427. rebuild(): void;
  63428. /**
  63429. * Disposes the component and the associated ressources.
  63430. */
  63431. dispose(): void;
  63432. private _draw;
  63433. private _drawCameraPredicate;
  63434. private _drawCameraBackground;
  63435. private _drawCameraForeground;
  63436. private _drawRenderTargetPredicate;
  63437. private _drawRenderTargetBackground;
  63438. private _drawRenderTargetForeground;
  63439. /**
  63440. * Adds all the elements from the container to the scene
  63441. * @param container the container holding the elements
  63442. */
  63443. addFromContainer(container: AbstractScene): void;
  63444. /**
  63445. * Removes all the elements in the container from the scene
  63446. * @param container contains the elements to remove
  63447. * @param dispose if the removed element should be disposed (default: false)
  63448. */
  63449. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63450. }
  63451. }
  63452. declare module "babylonjs/Shaders/layer.fragment" {
  63453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63454. /** @hidden */
  63455. export var layerPixelShader: {
  63456. name: string;
  63457. shader: string;
  63458. };
  63459. }
  63460. declare module "babylonjs/Shaders/layer.vertex" {
  63461. /** @hidden */
  63462. export var layerVertexShader: {
  63463. name: string;
  63464. shader: string;
  63465. };
  63466. }
  63467. declare module "babylonjs/Layers/layer" {
  63468. import { Observable } from "babylonjs/Misc/observable";
  63469. import { Nullable } from "babylonjs/types";
  63470. import { Scene } from "babylonjs/scene";
  63471. import { Vector2 } from "babylonjs/Maths/math.vector";
  63472. import { Color4 } from "babylonjs/Maths/math.color";
  63473. import { Texture } from "babylonjs/Materials/Textures/texture";
  63474. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63475. import "babylonjs/Shaders/layer.fragment";
  63476. import "babylonjs/Shaders/layer.vertex";
  63477. /**
  63478. * This represents a full screen 2d layer.
  63479. * This can be useful to display a picture in the background of your scene for instance.
  63480. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63481. */
  63482. export class Layer {
  63483. /**
  63484. * Define the name of the layer.
  63485. */
  63486. name: string;
  63487. /**
  63488. * Define the texture the layer should display.
  63489. */
  63490. texture: Nullable<Texture>;
  63491. /**
  63492. * Is the layer in background or foreground.
  63493. */
  63494. isBackground: boolean;
  63495. /**
  63496. * Define the color of the layer (instead of texture).
  63497. */
  63498. color: Color4;
  63499. /**
  63500. * Define the scale of the layer in order to zoom in out of the texture.
  63501. */
  63502. scale: Vector2;
  63503. /**
  63504. * Define an offset for the layer in order to shift the texture.
  63505. */
  63506. offset: Vector2;
  63507. /**
  63508. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63509. */
  63510. alphaBlendingMode: number;
  63511. /**
  63512. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63513. * Alpha test will not mix with the background color in case of transparency.
  63514. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63515. */
  63516. alphaTest: boolean;
  63517. /**
  63518. * Define a mask to restrict the layer to only some of the scene cameras.
  63519. */
  63520. layerMask: number;
  63521. /**
  63522. * Define the list of render target the layer is visible into.
  63523. */
  63524. renderTargetTextures: RenderTargetTexture[];
  63525. /**
  63526. * Define if the layer is only used in renderTarget or if it also
  63527. * renders in the main frame buffer of the canvas.
  63528. */
  63529. renderOnlyInRenderTargetTextures: boolean;
  63530. private _scene;
  63531. private _vertexBuffers;
  63532. private _indexBuffer;
  63533. private _effect;
  63534. private _previousDefines;
  63535. /**
  63536. * An event triggered when the layer is disposed.
  63537. */
  63538. onDisposeObservable: Observable<Layer>;
  63539. private _onDisposeObserver;
  63540. /**
  63541. * Back compatibility with callback before the onDisposeObservable existed.
  63542. * The set callback will be triggered when the layer has been disposed.
  63543. */
  63544. set onDispose(callback: () => void);
  63545. /**
  63546. * An event triggered before rendering the scene
  63547. */
  63548. onBeforeRenderObservable: Observable<Layer>;
  63549. private _onBeforeRenderObserver;
  63550. /**
  63551. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63552. * The set callback will be triggered just before rendering the layer.
  63553. */
  63554. set onBeforeRender(callback: () => void);
  63555. /**
  63556. * An event triggered after rendering the scene
  63557. */
  63558. onAfterRenderObservable: Observable<Layer>;
  63559. private _onAfterRenderObserver;
  63560. /**
  63561. * Back compatibility with callback before the onAfterRenderObservable existed.
  63562. * The set callback will be triggered just after rendering the layer.
  63563. */
  63564. set onAfterRender(callback: () => void);
  63565. /**
  63566. * Instantiates a new layer.
  63567. * This represents a full screen 2d layer.
  63568. * This can be useful to display a picture in the background of your scene for instance.
  63569. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63570. * @param name Define the name of the layer in the scene
  63571. * @param imgUrl Define the url of the texture to display in the layer
  63572. * @param scene Define the scene the layer belongs to
  63573. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63574. * @param color Defines a color for the layer
  63575. */
  63576. constructor(
  63577. /**
  63578. * Define the name of the layer.
  63579. */
  63580. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63581. private _createIndexBuffer;
  63582. /** @hidden */
  63583. _rebuild(): void;
  63584. /**
  63585. * Renders the layer in the scene.
  63586. */
  63587. render(): void;
  63588. /**
  63589. * Disposes and releases the associated ressources.
  63590. */
  63591. dispose(): void;
  63592. }
  63593. }
  63594. declare module "babylonjs/Layers/index" {
  63595. export * from "babylonjs/Layers/effectLayer";
  63596. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63597. export * from "babylonjs/Layers/glowLayer";
  63598. export * from "babylonjs/Layers/highlightLayer";
  63599. export * from "babylonjs/Layers/layer";
  63600. export * from "babylonjs/Layers/layerSceneComponent";
  63601. }
  63602. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63603. /** @hidden */
  63604. export var lensFlarePixelShader: {
  63605. name: string;
  63606. shader: string;
  63607. };
  63608. }
  63609. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63610. /** @hidden */
  63611. export var lensFlareVertexShader: {
  63612. name: string;
  63613. shader: string;
  63614. };
  63615. }
  63616. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63617. import { Scene } from "babylonjs/scene";
  63618. import { Vector3 } from "babylonjs/Maths/math.vector";
  63619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63620. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63621. import "babylonjs/Shaders/lensFlare.fragment";
  63622. import "babylonjs/Shaders/lensFlare.vertex";
  63623. import { Viewport } from "babylonjs/Maths/math.viewport";
  63624. /**
  63625. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63626. * It is usually composed of several `lensFlare`.
  63627. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63628. */
  63629. export class LensFlareSystem {
  63630. /**
  63631. * Define the name of the lens flare system
  63632. */
  63633. name: string;
  63634. /**
  63635. * List of lens flares used in this system.
  63636. */
  63637. lensFlares: LensFlare[];
  63638. /**
  63639. * Define a limit from the border the lens flare can be visible.
  63640. */
  63641. borderLimit: number;
  63642. /**
  63643. * Define a viewport border we do not want to see the lens flare in.
  63644. */
  63645. viewportBorder: number;
  63646. /**
  63647. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63648. */
  63649. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63650. /**
  63651. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63652. */
  63653. layerMask: number;
  63654. /**
  63655. * Define the id of the lens flare system in the scene.
  63656. * (equal to name by default)
  63657. */
  63658. id: string;
  63659. private _scene;
  63660. private _emitter;
  63661. private _vertexBuffers;
  63662. private _indexBuffer;
  63663. private _effect;
  63664. private _positionX;
  63665. private _positionY;
  63666. private _isEnabled;
  63667. /** @hidden */
  63668. static _SceneComponentInitialization: (scene: Scene) => void;
  63669. /**
  63670. * Instantiates a lens flare system.
  63671. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63672. * It is usually composed of several `lensFlare`.
  63673. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63674. * @param name Define the name of the lens flare system in the scene
  63675. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63676. * @param scene Define the scene the lens flare system belongs to
  63677. */
  63678. constructor(
  63679. /**
  63680. * Define the name of the lens flare system
  63681. */
  63682. name: string, emitter: any, scene: Scene);
  63683. /**
  63684. * Define if the lens flare system is enabled.
  63685. */
  63686. get isEnabled(): boolean;
  63687. set isEnabled(value: boolean);
  63688. /**
  63689. * Get the scene the effects belongs to.
  63690. * @returns the scene holding the lens flare system
  63691. */
  63692. getScene(): Scene;
  63693. /**
  63694. * Get the emitter of the lens flare system.
  63695. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63696. * @returns the emitter of the lens flare system
  63697. */
  63698. getEmitter(): any;
  63699. /**
  63700. * Set the emitter of the lens flare system.
  63701. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63702. * @param newEmitter Define the new emitter of the system
  63703. */
  63704. setEmitter(newEmitter: any): void;
  63705. /**
  63706. * Get the lens flare system emitter position.
  63707. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63708. * @returns the position
  63709. */
  63710. getEmitterPosition(): Vector3;
  63711. /**
  63712. * @hidden
  63713. */
  63714. computeEffectivePosition(globalViewport: Viewport): boolean;
  63715. /** @hidden */
  63716. _isVisible(): boolean;
  63717. /**
  63718. * @hidden
  63719. */
  63720. render(): boolean;
  63721. /**
  63722. * Dispose and release the lens flare with its associated resources.
  63723. */
  63724. dispose(): void;
  63725. /**
  63726. * Parse a lens flare system from a JSON repressentation
  63727. * @param parsedLensFlareSystem Define the JSON to parse
  63728. * @param scene Define the scene the parsed system should be instantiated in
  63729. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63730. * @returns the parsed system
  63731. */
  63732. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63733. /**
  63734. * Serialize the current Lens Flare System into a JSON representation.
  63735. * @returns the serialized JSON
  63736. */
  63737. serialize(): any;
  63738. }
  63739. }
  63740. declare module "babylonjs/LensFlares/lensFlare" {
  63741. import { Nullable } from "babylonjs/types";
  63742. import { Color3 } from "babylonjs/Maths/math.color";
  63743. import { Texture } from "babylonjs/Materials/Textures/texture";
  63744. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63745. /**
  63746. * This represents one of the lens effect in a `lensFlareSystem`.
  63747. * It controls one of the indiviual texture used in the effect.
  63748. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63749. */
  63750. export class LensFlare {
  63751. /**
  63752. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63753. */
  63754. size: number;
  63755. /**
  63756. * 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.
  63757. */
  63758. position: number;
  63759. /**
  63760. * Define the lens color.
  63761. */
  63762. color: Color3;
  63763. /**
  63764. * Define the lens texture.
  63765. */
  63766. texture: Nullable<Texture>;
  63767. /**
  63768. * Define the alpha mode to render this particular lens.
  63769. */
  63770. alphaMode: number;
  63771. private _system;
  63772. /**
  63773. * Creates a new Lens Flare.
  63774. * This represents one of the lens effect in a `lensFlareSystem`.
  63775. * It controls one of the indiviual texture used in the effect.
  63776. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63777. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63778. * @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.
  63779. * @param color Define the lens color
  63780. * @param imgUrl Define the lens texture url
  63781. * @param system Define the `lensFlareSystem` this flare is part of
  63782. * @returns The newly created Lens Flare
  63783. */
  63784. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63785. /**
  63786. * Instantiates a new Lens Flare.
  63787. * This represents one of the lens effect in a `lensFlareSystem`.
  63788. * It controls one of the indiviual texture used in the effect.
  63789. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63790. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63791. * @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.
  63792. * @param color Define the lens color
  63793. * @param imgUrl Define the lens texture url
  63794. * @param system Define the `lensFlareSystem` this flare is part of
  63795. */
  63796. constructor(
  63797. /**
  63798. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63799. */
  63800. size: number,
  63801. /**
  63802. * 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. */
  63804. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63805. /**
  63806. * Dispose and release the lens flare with its associated resources.
  63807. */
  63808. dispose(): void;
  63809. }
  63810. }
  63811. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63812. import { Nullable } from "babylonjs/types";
  63813. import { Scene } from "babylonjs/scene";
  63814. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63815. import { AbstractScene } from "babylonjs/abstractScene";
  63816. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63817. module "babylonjs/abstractScene" {
  63818. interface AbstractScene {
  63819. /**
  63820. * The list of lens flare system added to the scene
  63821. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63822. */
  63823. lensFlareSystems: Array<LensFlareSystem>;
  63824. /**
  63825. * Removes the given lens flare system from this scene.
  63826. * @param toRemove The lens flare system to remove
  63827. * @returns The index of the removed lens flare system
  63828. */
  63829. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63830. /**
  63831. * Adds the given lens flare system to this scene
  63832. * @param newLensFlareSystem The lens flare system to add
  63833. */
  63834. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63835. /**
  63836. * Gets a lens flare system using its name
  63837. * @param name defines the name to look for
  63838. * @returns the lens flare system or null if not found
  63839. */
  63840. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63841. /**
  63842. * Gets a lens flare system using its id
  63843. * @param id defines the id to look for
  63844. * @returns the lens flare system or null if not found
  63845. */
  63846. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63847. }
  63848. }
  63849. /**
  63850. * Defines the lens flare scene component responsible to manage any lens flares
  63851. * in a given scene.
  63852. */
  63853. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63854. /**
  63855. * The component name helpfull to identify the component in the list of scene components.
  63856. */
  63857. readonly name: string;
  63858. /**
  63859. * The scene the component belongs to.
  63860. */
  63861. scene: Scene;
  63862. /**
  63863. * Creates a new instance of the component for the given scene
  63864. * @param scene Defines the scene to register the component in
  63865. */
  63866. constructor(scene: Scene);
  63867. /**
  63868. * Registers the component in a given scene
  63869. */
  63870. register(): void;
  63871. /**
  63872. * Rebuilds the elements related to this component in case of
  63873. * context lost for instance.
  63874. */
  63875. rebuild(): void;
  63876. /**
  63877. * Adds all the elements from the container to the scene
  63878. * @param container the container holding the elements
  63879. */
  63880. addFromContainer(container: AbstractScene): void;
  63881. /**
  63882. * Removes all the elements in the container from the scene
  63883. * @param container contains the elements to remove
  63884. * @param dispose if the removed element should be disposed (default: false)
  63885. */
  63886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63887. /**
  63888. * Serializes the component data to the specified json object
  63889. * @param serializationObject The object to serialize to
  63890. */
  63891. serialize(serializationObject: any): void;
  63892. /**
  63893. * Disposes the component and the associated ressources.
  63894. */
  63895. dispose(): void;
  63896. private _draw;
  63897. }
  63898. }
  63899. declare module "babylonjs/LensFlares/index" {
  63900. export * from "babylonjs/LensFlares/lensFlare";
  63901. export * from "babylonjs/LensFlares/lensFlareSystem";
  63902. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63903. }
  63904. declare module "babylonjs/Shaders/depth.fragment" {
  63905. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63906. /** @hidden */
  63907. export var depthPixelShader: {
  63908. name: string;
  63909. shader: string;
  63910. };
  63911. }
  63912. declare module "babylonjs/Shaders/depth.vertex" {
  63913. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63918. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63919. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63920. /** @hidden */
  63921. export var depthVertexShader: {
  63922. name: string;
  63923. shader: string;
  63924. };
  63925. }
  63926. declare module "babylonjs/Rendering/depthRenderer" {
  63927. import { Nullable } from "babylonjs/types";
  63928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63929. import { Scene } from "babylonjs/scene";
  63930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63931. import { Camera } from "babylonjs/Cameras/camera";
  63932. import "babylonjs/Shaders/depth.fragment";
  63933. import "babylonjs/Shaders/depth.vertex";
  63934. /**
  63935. * This represents a depth renderer in Babylon.
  63936. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63937. */
  63938. export class DepthRenderer {
  63939. private _scene;
  63940. private _depthMap;
  63941. private _effect;
  63942. private readonly _storeNonLinearDepth;
  63943. private readonly _clearColor;
  63944. /** Get if the depth renderer is using packed depth or not */
  63945. readonly isPacked: boolean;
  63946. private _cachedDefines;
  63947. private _camera;
  63948. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63949. enabled: boolean;
  63950. /**
  63951. * Specifiess that the depth renderer will only be used within
  63952. * the camera it is created for.
  63953. * This can help forcing its rendering during the camera processing.
  63954. */
  63955. useOnlyInActiveCamera: boolean;
  63956. /** @hidden */
  63957. static _SceneComponentInitialization: (scene: Scene) => void;
  63958. /**
  63959. * Instantiates a depth renderer
  63960. * @param scene The scene the renderer belongs to
  63961. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63962. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63963. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63964. */
  63965. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63966. /**
  63967. * Creates the depth rendering effect and checks if the effect is ready.
  63968. * @param subMesh The submesh to be used to render the depth map of
  63969. * @param useInstances If multiple world instances should be used
  63970. * @returns if the depth renderer is ready to render the depth map
  63971. */
  63972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63973. /**
  63974. * Gets the texture which the depth map will be written to.
  63975. * @returns The depth map texture
  63976. */
  63977. getDepthMap(): RenderTargetTexture;
  63978. /**
  63979. * Disposes of the depth renderer.
  63980. */
  63981. dispose(): void;
  63982. }
  63983. }
  63984. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63985. /** @hidden */
  63986. export var minmaxReduxPixelShader: {
  63987. name: string;
  63988. shader: string;
  63989. };
  63990. }
  63991. declare module "babylonjs/Misc/minMaxReducer" {
  63992. import { Nullable } from "babylonjs/types";
  63993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63994. import { Camera } from "babylonjs/Cameras/camera";
  63995. import { Observer } from "babylonjs/Misc/observable";
  63996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63997. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63998. import { Observable } from "babylonjs/Misc/observable";
  63999. import "babylonjs/Shaders/minmaxRedux.fragment";
  64000. /**
  64001. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64002. * and maximum values from all values of the texture.
  64003. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64004. * The source values are read from the red channel of the texture.
  64005. */
  64006. export class MinMaxReducer {
  64007. /**
  64008. * Observable triggered when the computation has been performed
  64009. */
  64010. onAfterReductionPerformed: Observable<{
  64011. min: number;
  64012. max: number;
  64013. }>;
  64014. protected _camera: Camera;
  64015. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64016. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64017. protected _postProcessManager: PostProcessManager;
  64018. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64019. protected _forceFullscreenViewport: boolean;
  64020. /**
  64021. * Creates a min/max reducer
  64022. * @param camera The camera to use for the post processes
  64023. */
  64024. constructor(camera: Camera);
  64025. /**
  64026. * Gets the texture used to read the values from.
  64027. */
  64028. get sourceTexture(): Nullable<RenderTargetTexture>;
  64029. /**
  64030. * Sets the source texture to read the values from.
  64031. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64032. * because in such textures '1' value must not be taken into account to compute the maximum
  64033. * as this value is used to clear the texture.
  64034. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64035. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64036. * @param depthRedux Indicates if the texture is a depth texture or not
  64037. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64038. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64039. */
  64040. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64041. /**
  64042. * Defines the refresh rate of the computation.
  64043. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64044. */
  64045. get refreshRate(): number;
  64046. set refreshRate(value: number);
  64047. protected _activated: boolean;
  64048. /**
  64049. * Gets the activation status of the reducer
  64050. */
  64051. get activated(): boolean;
  64052. /**
  64053. * Activates the reduction computation.
  64054. * When activated, the observers registered in onAfterReductionPerformed are
  64055. * called after the compuation is performed
  64056. */
  64057. activate(): void;
  64058. /**
  64059. * Deactivates the reduction computation.
  64060. */
  64061. deactivate(): void;
  64062. /**
  64063. * Disposes the min/max reducer
  64064. * @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.
  64065. */
  64066. dispose(disposeAll?: boolean): void;
  64067. }
  64068. }
  64069. declare module "babylonjs/Misc/depthReducer" {
  64070. import { Nullable } from "babylonjs/types";
  64071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64072. import { Camera } from "babylonjs/Cameras/camera";
  64073. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64074. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  64075. /**
  64076. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64077. */
  64078. export class DepthReducer extends MinMaxReducer {
  64079. private _depthRenderer;
  64080. private _depthRendererId;
  64081. /**
  64082. * Gets the depth renderer used for the computation.
  64083. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64084. */
  64085. get depthRenderer(): Nullable<DepthRenderer>;
  64086. /**
  64087. * Creates a depth reducer
  64088. * @param camera The camera used to render the depth texture
  64089. */
  64090. constructor(camera: Camera);
  64091. /**
  64092. * Sets the depth renderer to use to generate the depth map
  64093. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64094. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64095. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64096. */
  64097. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64098. /** @hidden */
  64099. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64100. /**
  64101. * Activates the reduction computation.
  64102. * When activated, the observers registered in onAfterReductionPerformed are
  64103. * called after the compuation is performed
  64104. */
  64105. activate(): void;
  64106. /**
  64107. * Deactivates the reduction computation.
  64108. */
  64109. deactivate(): void;
  64110. /**
  64111. * Disposes the depth reducer
  64112. * @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.
  64113. */
  64114. dispose(disposeAll?: boolean): void;
  64115. }
  64116. }
  64117. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64118. import { Nullable } from "babylonjs/types";
  64119. import { Scene } from "babylonjs/scene";
  64120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64123. import { Effect } from "babylonjs/Materials/effect";
  64124. import "babylonjs/Shaders/shadowMap.fragment";
  64125. import "babylonjs/Shaders/shadowMap.vertex";
  64126. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64127. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64128. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64129. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64130. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64131. /**
  64132. * A CSM implementation allowing casting shadows on large scenes.
  64133. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64134. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64135. */
  64136. export class CascadedShadowGenerator extends ShadowGenerator {
  64137. private static readonly frustumCornersNDCSpace;
  64138. /**
  64139. * Name of the CSM class
  64140. */
  64141. static CLASSNAME: string;
  64142. /**
  64143. * Defines the default number of cascades used by the CSM.
  64144. */
  64145. static readonly DEFAULT_CASCADES_COUNT: number;
  64146. /**
  64147. * Defines the minimum number of cascades used by the CSM.
  64148. */
  64149. static readonly MIN_CASCADES_COUNT: number;
  64150. /**
  64151. * Defines the maximum number of cascades used by the CSM.
  64152. */
  64153. static readonly MAX_CASCADES_COUNT: number;
  64154. protected _validateFilter(filter: number): number;
  64155. /**
  64156. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64157. */
  64158. penumbraDarkness: number;
  64159. private _numCascades;
  64160. /**
  64161. * Gets or set the number of cascades used by the CSM.
  64162. */
  64163. get numCascades(): number;
  64164. set numCascades(value: number);
  64165. /**
  64166. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64167. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64168. */
  64169. stabilizeCascades: boolean;
  64170. private _freezeShadowCastersBoundingInfo;
  64171. private _freezeShadowCastersBoundingInfoObservable;
  64172. /**
  64173. * Enables or disables the shadow casters bounding info computation.
  64174. * If your shadow casters don't move, you can disable this feature.
  64175. * If it is enabled, the bounding box computation is done every frame.
  64176. */
  64177. get freezeShadowCastersBoundingInfo(): boolean;
  64178. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64179. private _scbiMin;
  64180. private _scbiMax;
  64181. protected _computeShadowCastersBoundingInfo(): void;
  64182. protected _shadowCastersBoundingInfo: BoundingInfo;
  64183. /**
  64184. * Gets or sets the shadow casters bounding info.
  64185. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64186. * so that the system won't overwrite the bounds you provide
  64187. */
  64188. get shadowCastersBoundingInfo(): BoundingInfo;
  64189. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64190. protected _breaksAreDirty: boolean;
  64191. protected _minDistance: number;
  64192. protected _maxDistance: number;
  64193. /**
  64194. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64195. *
  64196. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64197. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64198. * @param min minimal distance for the breaks (default to 0.)
  64199. * @param max maximal distance for the breaks (default to 1.)
  64200. */
  64201. setMinMaxDistance(min: number, max: number): void;
  64202. /** Gets the minimal distance used in the cascade break computation */
  64203. get minDistance(): number;
  64204. /** Gets the maximal distance used in the cascade break computation */
  64205. get maxDistance(): number;
  64206. /**
  64207. * Gets the class name of that object
  64208. * @returns "CascadedShadowGenerator"
  64209. */
  64210. getClassName(): string;
  64211. private _cascadeMinExtents;
  64212. private _cascadeMaxExtents;
  64213. /**
  64214. * Gets a cascade minimum extents
  64215. * @param cascadeIndex index of the cascade
  64216. * @returns the minimum cascade extents
  64217. */
  64218. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64219. /**
  64220. * Gets a cascade maximum extents
  64221. * @param cascadeIndex index of the cascade
  64222. * @returns the maximum cascade extents
  64223. */
  64224. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64225. private _cascades;
  64226. private _currentLayer;
  64227. private _viewSpaceFrustumsZ;
  64228. private _viewMatrices;
  64229. private _projectionMatrices;
  64230. private _transformMatrices;
  64231. private _transformMatricesAsArray;
  64232. private _frustumLengths;
  64233. private _lightSizeUVCorrection;
  64234. private _depthCorrection;
  64235. private _frustumCornersWorldSpace;
  64236. private _frustumCenter;
  64237. private _shadowCameraPos;
  64238. private _shadowMaxZ;
  64239. /**
  64240. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64241. * It defaults to camera.maxZ
  64242. */
  64243. get shadowMaxZ(): number;
  64244. /**
  64245. * Sets the shadow max z distance.
  64246. */
  64247. set shadowMaxZ(value: number);
  64248. protected _debug: boolean;
  64249. /**
  64250. * Gets or sets the debug flag.
  64251. * When enabled, the cascades are materialized by different colors on the screen.
  64252. */
  64253. get debug(): boolean;
  64254. set debug(dbg: boolean);
  64255. private _depthClamp;
  64256. /**
  64257. * Gets or sets the depth clamping value.
  64258. *
  64259. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64260. * to account for the shadow casters far away.
  64261. *
  64262. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64263. */
  64264. get depthClamp(): boolean;
  64265. set depthClamp(value: boolean);
  64266. private _cascadeBlendPercentage;
  64267. /**
  64268. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64269. * It defaults to 0.1 (10% blending).
  64270. */
  64271. get cascadeBlendPercentage(): number;
  64272. set cascadeBlendPercentage(value: number);
  64273. private _lambda;
  64274. /**
  64275. * Gets or set the lambda parameter.
  64276. * This parameter is used to split the camera frustum and create the cascades.
  64277. * 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.
  64278. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64279. */
  64280. get lambda(): number;
  64281. set lambda(value: number);
  64282. /**
  64283. * Gets the view matrix corresponding to a given cascade
  64284. * @param cascadeNum cascade to retrieve the view matrix from
  64285. * @returns the cascade view matrix
  64286. */
  64287. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64288. /**
  64289. * Gets the projection matrix corresponding to a given cascade
  64290. * @param cascadeNum cascade to retrieve the projection matrix from
  64291. * @returns the cascade projection matrix
  64292. */
  64293. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64294. /**
  64295. * Gets the transformation matrix corresponding to a given cascade
  64296. * @param cascadeNum cascade to retrieve the transformation matrix from
  64297. * @returns the cascade transformation matrix
  64298. */
  64299. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64300. private _depthRenderer;
  64301. /**
  64302. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64303. *
  64304. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64305. *
  64306. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64307. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64308. * @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
  64309. */
  64310. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64311. private _depthReducer;
  64312. private _autoCalcDepthBounds;
  64313. /**
  64314. * Gets or sets the autoCalcDepthBounds property.
  64315. *
  64316. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64317. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64318. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64319. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64320. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64321. */
  64322. get autoCalcDepthBounds(): boolean;
  64323. set autoCalcDepthBounds(value: boolean);
  64324. /**
  64325. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64326. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64327. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64328. * for setting the refresh rate on the renderer yourself!
  64329. */
  64330. get autoCalcDepthBoundsRefreshRate(): number;
  64331. set autoCalcDepthBoundsRefreshRate(value: number);
  64332. /**
  64333. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64334. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64335. * you change the camera near/far planes!
  64336. */
  64337. splitFrustum(): void;
  64338. private _splitFrustum;
  64339. private _computeMatrices;
  64340. private _computeFrustumInWorldSpace;
  64341. private _computeCascadeFrustum;
  64342. /**
  64343. * Support test.
  64344. */
  64345. static get IsSupported(): boolean;
  64346. /** @hidden */
  64347. static _SceneComponentInitialization: (scene: Scene) => void;
  64348. /**
  64349. * Creates a Cascaded Shadow Generator object.
  64350. * A ShadowGenerator is the required tool to use the shadows.
  64351. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64352. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64353. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64354. * @param light The directional light object generating the shadows.
  64355. * @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.
  64356. */
  64357. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64358. protected _initializeGenerator(): void;
  64359. protected _createTargetRenderTexture(): void;
  64360. protected _initializeShadowMap(): void;
  64361. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64362. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64363. /**
  64364. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64365. * @param defines Defines of the material we want to update
  64366. * @param lightIndex Index of the light in the enabled light list of the material
  64367. */
  64368. prepareDefines(defines: any, lightIndex: number): void;
  64369. /**
  64370. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64371. * defined in the generator but impacting the effect).
  64372. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64373. * @param effect The effect we are binfing the information for
  64374. */
  64375. bindShadowLight(lightIndex: string, effect: Effect): void;
  64376. /**
  64377. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64378. * (eq to view projection * shadow projection matrices)
  64379. * @returns The transform matrix used to create the shadow map
  64380. */
  64381. getTransformMatrix(): Matrix;
  64382. /**
  64383. * Disposes the ShadowGenerator.
  64384. * Returns nothing.
  64385. */
  64386. dispose(): void;
  64387. /**
  64388. * Serializes the shadow generator setup to a json object.
  64389. * @returns The serialized JSON object
  64390. */
  64391. serialize(): any;
  64392. /**
  64393. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64394. * @param parsedShadowGenerator The JSON object to parse
  64395. * @param scene The scene to create the shadow map for
  64396. * @returns The parsed shadow generator
  64397. */
  64398. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64399. }
  64400. }
  64401. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64402. import { Scene } from "babylonjs/scene";
  64403. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64404. import { AbstractScene } from "babylonjs/abstractScene";
  64405. /**
  64406. * Defines the shadow generator component responsible to manage any shadow generators
  64407. * in a given scene.
  64408. */
  64409. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64410. /**
  64411. * The component name helpfull to identify the component in the list of scene components.
  64412. */
  64413. readonly name: string;
  64414. /**
  64415. * The scene the component belongs to.
  64416. */
  64417. scene: Scene;
  64418. /**
  64419. * Creates a new instance of the component for the given scene
  64420. * @param scene Defines the scene to register the component in
  64421. */
  64422. constructor(scene: Scene);
  64423. /**
  64424. * Registers the component in a given scene
  64425. */
  64426. register(): void;
  64427. /**
  64428. * Rebuilds the elements related to this component in case of
  64429. * context lost for instance.
  64430. */
  64431. rebuild(): void;
  64432. /**
  64433. * Serializes the component data to the specified json object
  64434. * @param serializationObject The object to serialize to
  64435. */
  64436. serialize(serializationObject: any): void;
  64437. /**
  64438. * Adds all the elements from the container to the scene
  64439. * @param container the container holding the elements
  64440. */
  64441. addFromContainer(container: AbstractScene): void;
  64442. /**
  64443. * Removes all the elements in the container from the scene
  64444. * @param container contains the elements to remove
  64445. * @param dispose if the removed element should be disposed (default: false)
  64446. */
  64447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64448. /**
  64449. * Rebuilds the elements related to this component in case of
  64450. * context lost for instance.
  64451. */
  64452. dispose(): void;
  64453. private _gatherRenderTargets;
  64454. }
  64455. }
  64456. declare module "babylonjs/Lights/Shadows/index" {
  64457. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64458. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64459. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64460. }
  64461. declare module "babylonjs/Lights/pointLight" {
  64462. import { Scene } from "babylonjs/scene";
  64463. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64465. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64466. import { Effect } from "babylonjs/Materials/effect";
  64467. /**
  64468. * A point light is a light defined by an unique point in world space.
  64469. * The light is emitted in every direction from this point.
  64470. * A good example of a point light is a standard light bulb.
  64471. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64472. */
  64473. export class PointLight extends ShadowLight {
  64474. private _shadowAngle;
  64475. /**
  64476. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64477. * This specifies what angle the shadow will use to be created.
  64478. *
  64479. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64480. */
  64481. get shadowAngle(): number;
  64482. /**
  64483. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64484. * This specifies what angle the shadow will use to be created.
  64485. *
  64486. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64487. */
  64488. set shadowAngle(value: number);
  64489. /**
  64490. * Gets the direction if it has been set.
  64491. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64492. */
  64493. get direction(): Vector3;
  64494. /**
  64495. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64496. */
  64497. set direction(value: Vector3);
  64498. /**
  64499. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64500. * A PointLight emits the light in every direction.
  64501. * It can cast shadows.
  64502. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64503. * ```javascript
  64504. * var pointLight = new PointLight("pl", camera.position, scene);
  64505. * ```
  64506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64507. * @param name The light friendly name
  64508. * @param position The position of the point light in the scene
  64509. * @param scene The scene the lights belongs to
  64510. */
  64511. constructor(name: string, position: Vector3, scene: Scene);
  64512. /**
  64513. * Returns the string "PointLight"
  64514. * @returns the class name
  64515. */
  64516. getClassName(): string;
  64517. /**
  64518. * Returns the integer 0.
  64519. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64520. */
  64521. getTypeID(): number;
  64522. /**
  64523. * Specifies wether or not the shadowmap should be a cube texture.
  64524. * @returns true if the shadowmap needs to be a cube texture.
  64525. */
  64526. needCube(): boolean;
  64527. /**
  64528. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64529. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64530. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64531. */
  64532. getShadowDirection(faceIndex?: number): Vector3;
  64533. /**
  64534. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64535. * - fov = PI / 2
  64536. * - aspect ratio : 1.0
  64537. * - z-near and far equal to the active camera minZ and maxZ.
  64538. * Returns the PointLight.
  64539. */
  64540. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64541. protected _buildUniformLayout(): void;
  64542. /**
  64543. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64544. * @param effect The effect to update
  64545. * @param lightIndex The index of the light in the effect to update
  64546. * @returns The point light
  64547. */
  64548. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64549. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64550. /**
  64551. * Prepares the list of defines specific to the light type.
  64552. * @param defines the list of defines
  64553. * @param lightIndex defines the index of the light for the effect
  64554. */
  64555. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64556. }
  64557. }
  64558. declare module "babylonjs/Lights/index" {
  64559. export * from "babylonjs/Lights/light";
  64560. export * from "babylonjs/Lights/shadowLight";
  64561. export * from "babylonjs/Lights/Shadows/index";
  64562. export * from "babylonjs/Lights/directionalLight";
  64563. export * from "babylonjs/Lights/hemisphericLight";
  64564. export * from "babylonjs/Lights/pointLight";
  64565. export * from "babylonjs/Lights/spotLight";
  64566. }
  64567. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64568. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64569. /**
  64570. * Header information of HDR texture files.
  64571. */
  64572. export interface HDRInfo {
  64573. /**
  64574. * The height of the texture in pixels.
  64575. */
  64576. height: number;
  64577. /**
  64578. * The width of the texture in pixels.
  64579. */
  64580. width: number;
  64581. /**
  64582. * The index of the beginning of the data in the binary file.
  64583. */
  64584. dataPosition: number;
  64585. }
  64586. /**
  64587. * This groups tools to convert HDR texture to native colors array.
  64588. */
  64589. export class HDRTools {
  64590. private static Ldexp;
  64591. private static Rgbe2float;
  64592. private static readStringLine;
  64593. /**
  64594. * Reads header information from an RGBE texture stored in a native array.
  64595. * More information on this format are available here:
  64596. * https://en.wikipedia.org/wiki/RGBE_image_format
  64597. *
  64598. * @param uint8array The binary file stored in native array.
  64599. * @return The header information.
  64600. */
  64601. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64602. /**
  64603. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64604. * This RGBE texture needs to store the information as a panorama.
  64605. *
  64606. * More information on this format are available here:
  64607. * https://en.wikipedia.org/wiki/RGBE_image_format
  64608. *
  64609. * @param buffer The binary file stored in an array buffer.
  64610. * @param size The expected size of the extracted cubemap.
  64611. * @return The Cube Map information.
  64612. */
  64613. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64614. /**
  64615. * Returns the pixels data extracted from an RGBE texture.
  64616. * This pixels will be stored left to right up to down in the R G B order in one array.
  64617. *
  64618. * More information on this format are available here:
  64619. * https://en.wikipedia.org/wiki/RGBE_image_format
  64620. *
  64621. * @param uint8array The binary file stored in an array buffer.
  64622. * @param hdrInfo The header information of the file.
  64623. * @return The pixels data in RGB right to left up to down order.
  64624. */
  64625. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64626. private static RGBE_ReadPixels_RLE;
  64627. private static RGBE_ReadPixels_NOT_RLE;
  64628. }
  64629. }
  64630. declare module "babylonjs/Materials/effectRenderer" {
  64631. import { Nullable } from "babylonjs/types";
  64632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64634. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64635. import { Viewport } from "babylonjs/Maths/math.viewport";
  64636. import { Observable } from "babylonjs/Misc/observable";
  64637. import { Effect } from "babylonjs/Materials/effect";
  64638. import "babylonjs/Shaders/postprocess.vertex";
  64639. /**
  64640. * Effect Render Options
  64641. */
  64642. export interface IEffectRendererOptions {
  64643. /**
  64644. * Defines the vertices positions.
  64645. */
  64646. positions?: number[];
  64647. /**
  64648. * Defines the indices.
  64649. */
  64650. indices?: number[];
  64651. }
  64652. /**
  64653. * Helper class to render one or more effects.
  64654. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64655. */
  64656. export class EffectRenderer {
  64657. private engine;
  64658. private static _DefaultOptions;
  64659. private _vertexBuffers;
  64660. private _indexBuffer;
  64661. private _fullscreenViewport;
  64662. /**
  64663. * Creates an effect renderer
  64664. * @param engine the engine to use for rendering
  64665. * @param options defines the options of the effect renderer
  64666. */
  64667. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64668. /**
  64669. * Sets the current viewport in normalized coordinates 0-1
  64670. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64671. */
  64672. setViewport(viewport?: Viewport): void;
  64673. /**
  64674. * Binds the embedded attributes buffer to the effect.
  64675. * @param effect Defines the effect to bind the attributes for
  64676. */
  64677. bindBuffers(effect: Effect): void;
  64678. /**
  64679. * Sets the current effect wrapper to use during draw.
  64680. * The effect needs to be ready before calling this api.
  64681. * This also sets the default full screen position attribute.
  64682. * @param effectWrapper Defines the effect to draw with
  64683. */
  64684. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64685. /**
  64686. * Restores engine states
  64687. */
  64688. restoreStates(): void;
  64689. /**
  64690. * Draws a full screen quad.
  64691. */
  64692. draw(): void;
  64693. private isRenderTargetTexture;
  64694. /**
  64695. * renders one or more effects to a specified texture
  64696. * @param effectWrapper the effect to renderer
  64697. * @param outputTexture texture to draw to, if null it will render to the screen.
  64698. */
  64699. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64700. /**
  64701. * Disposes of the effect renderer
  64702. */
  64703. dispose(): void;
  64704. }
  64705. /**
  64706. * Options to create an EffectWrapper
  64707. */
  64708. interface EffectWrapperCreationOptions {
  64709. /**
  64710. * Engine to use to create the effect
  64711. */
  64712. engine: ThinEngine;
  64713. /**
  64714. * Fragment shader for the effect
  64715. */
  64716. fragmentShader: string;
  64717. /**
  64718. * Use the shader store instead of direct source code
  64719. */
  64720. useShaderStore?: boolean;
  64721. /**
  64722. * Vertex shader for the effect
  64723. */
  64724. vertexShader?: string;
  64725. /**
  64726. * Attributes to use in the shader
  64727. */
  64728. attributeNames?: Array<string>;
  64729. /**
  64730. * Uniforms to use in the shader
  64731. */
  64732. uniformNames?: Array<string>;
  64733. /**
  64734. * Texture sampler names to use in the shader
  64735. */
  64736. samplerNames?: Array<string>;
  64737. /**
  64738. * Defines to use in the shader
  64739. */
  64740. defines?: Array<string>;
  64741. /**
  64742. * Callback when effect is compiled
  64743. */
  64744. onCompiled?: Nullable<(effect: Effect) => void>;
  64745. /**
  64746. * The friendly name of the effect displayed in Spector.
  64747. */
  64748. name?: string;
  64749. }
  64750. /**
  64751. * Wraps an effect to be used for rendering
  64752. */
  64753. export class EffectWrapper {
  64754. /**
  64755. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64756. */
  64757. onApplyObservable: Observable<{}>;
  64758. /**
  64759. * The underlying effect
  64760. */
  64761. effect: Effect;
  64762. /**
  64763. * Creates an effect to be renderer
  64764. * @param creationOptions options to create the effect
  64765. */
  64766. constructor(creationOptions: EffectWrapperCreationOptions);
  64767. /**
  64768. * Disposes of the effect wrapper
  64769. */
  64770. dispose(): void;
  64771. }
  64772. }
  64773. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64774. /** @hidden */
  64775. export var hdrFilteringVertexShader: {
  64776. name: string;
  64777. shader: string;
  64778. };
  64779. }
  64780. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64781. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64782. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64783. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64784. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64785. /** @hidden */
  64786. export var hdrFilteringPixelShader: {
  64787. name: string;
  64788. shader: string;
  64789. };
  64790. }
  64791. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64793. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64794. import { Nullable } from "babylonjs/types";
  64795. import "babylonjs/Shaders/hdrFiltering.vertex";
  64796. import "babylonjs/Shaders/hdrFiltering.fragment";
  64797. /**
  64798. * Options for texture filtering
  64799. */
  64800. interface IHDRFilteringOptions {
  64801. /**
  64802. * Scales pixel intensity for the input HDR map.
  64803. */
  64804. hdrScale?: number;
  64805. /**
  64806. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64807. */
  64808. quality?: number;
  64809. }
  64810. /**
  64811. * Filters HDR maps to get correct renderings of PBR reflections
  64812. */
  64813. export class HDRFiltering {
  64814. private _engine;
  64815. private _effectRenderer;
  64816. private _effectWrapper;
  64817. private _lodGenerationOffset;
  64818. private _lodGenerationScale;
  64819. /**
  64820. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64821. * you care about baking speed.
  64822. */
  64823. quality: number;
  64824. /**
  64825. * Scales pixel intensity for the input HDR map.
  64826. */
  64827. hdrScale: number;
  64828. /**
  64829. * Instantiates HDR filter for reflection maps
  64830. *
  64831. * @param engine Thin engine
  64832. * @param options Options
  64833. */
  64834. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64835. private _createRenderTarget;
  64836. private _prefilterInternal;
  64837. private _createEffect;
  64838. /**
  64839. * Get a value indicating if the filter is ready to be used
  64840. * @param texture Texture to filter
  64841. * @returns true if the filter is ready
  64842. */
  64843. isReady(texture: BaseTexture): boolean;
  64844. /**
  64845. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64846. * Prefiltering will be invoked at the end of next rendering pass.
  64847. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64848. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64849. * @param texture Texture to filter
  64850. * @param onFinished Callback when filtering is done
  64851. * @return Promise called when prefiltering is done
  64852. */
  64853. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64854. }
  64855. }
  64856. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64857. import { Nullable } from "babylonjs/types";
  64858. import { Scene } from "babylonjs/scene";
  64859. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64861. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64862. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64863. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64864. /**
  64865. * This represents a texture coming from an HDR input.
  64866. *
  64867. * The only supported format is currently panorama picture stored in RGBE format.
  64868. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64869. */
  64870. export class HDRCubeTexture extends BaseTexture {
  64871. private static _facesMapping;
  64872. private _generateHarmonics;
  64873. private _noMipmap;
  64874. private _prefilterOnLoad;
  64875. private _textureMatrix;
  64876. private _size;
  64877. private _onLoad;
  64878. private _onError;
  64879. /**
  64880. * The texture URL.
  64881. */
  64882. url: string;
  64883. protected _isBlocking: boolean;
  64884. /**
  64885. * Sets wether or not the texture is blocking during loading.
  64886. */
  64887. set isBlocking(value: boolean);
  64888. /**
  64889. * Gets wether or not the texture is blocking during loading.
  64890. */
  64891. get isBlocking(): boolean;
  64892. protected _rotationY: number;
  64893. /**
  64894. * Sets texture matrix rotation angle around Y axis in radians.
  64895. */
  64896. set rotationY(value: number);
  64897. /**
  64898. * Gets texture matrix rotation angle around Y axis radians.
  64899. */
  64900. get rotationY(): number;
  64901. /**
  64902. * Gets or sets the center of the bounding box associated with the cube texture
  64903. * It must define where the camera used to render the texture was set
  64904. */
  64905. boundingBoxPosition: Vector3;
  64906. private _boundingBoxSize;
  64907. /**
  64908. * Gets or sets the size of the bounding box associated with the cube texture
  64909. * When defined, the cubemap will switch to local mode
  64910. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64911. * @example https://www.babylonjs-playground.com/#RNASML
  64912. */
  64913. set boundingBoxSize(value: Vector3);
  64914. get boundingBoxSize(): Vector3;
  64915. /**
  64916. * Instantiates an HDRTexture from the following parameters.
  64917. *
  64918. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64919. * @param sceneOrEngine The scene or engine the texture will be used in
  64920. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64921. * @param noMipmap Forces to not generate the mipmap if true
  64922. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64923. * @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)
  64924. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64925. */
  64926. 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>);
  64927. /**
  64928. * Get the current class name of the texture useful for serialization or dynamic coding.
  64929. * @returns "HDRCubeTexture"
  64930. */
  64931. getClassName(): string;
  64932. /**
  64933. * Occurs when the file is raw .hdr file.
  64934. */
  64935. private loadTexture;
  64936. clone(): HDRCubeTexture;
  64937. delayLoad(): void;
  64938. /**
  64939. * Get the texture reflection matrix used to rotate/transform the reflection.
  64940. * @returns the reflection matrix
  64941. */
  64942. getReflectionTextureMatrix(): Matrix;
  64943. /**
  64944. * Set the texture reflection matrix used to rotate/transform the reflection.
  64945. * @param value Define the reflection matrix to set
  64946. */
  64947. setReflectionTextureMatrix(value: Matrix): void;
  64948. /**
  64949. * Parses a JSON representation of an HDR Texture in order to create the texture
  64950. * @param parsedTexture Define the JSON representation
  64951. * @param scene Define the scene the texture should be created in
  64952. * @param rootUrl Define the root url in case we need to load relative dependencies
  64953. * @returns the newly created texture after parsing
  64954. */
  64955. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64956. serialize(): any;
  64957. }
  64958. }
  64959. declare module "babylonjs/Physics/physicsEngine" {
  64960. import { Nullable } from "babylonjs/types";
  64961. import { Vector3 } from "babylonjs/Maths/math.vector";
  64962. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64963. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64964. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64965. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64966. /**
  64967. * Class used to control physics engine
  64968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64969. */
  64970. export class PhysicsEngine implements IPhysicsEngine {
  64971. private _physicsPlugin;
  64972. /**
  64973. * Global value used to control the smallest number supported by the simulation
  64974. */
  64975. static Epsilon: number;
  64976. private _impostors;
  64977. private _joints;
  64978. private _subTimeStep;
  64979. /**
  64980. * Gets the gravity vector used by the simulation
  64981. */
  64982. gravity: Vector3;
  64983. /**
  64984. * Factory used to create the default physics plugin.
  64985. * @returns The default physics plugin
  64986. */
  64987. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64988. /**
  64989. * Creates a new Physics Engine
  64990. * @param gravity defines the gravity vector used by the simulation
  64991. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64992. */
  64993. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64994. /**
  64995. * Sets the gravity vector used by the simulation
  64996. * @param gravity defines the gravity vector to use
  64997. */
  64998. setGravity(gravity: Vector3): void;
  64999. /**
  65000. * Set the time step of the physics engine.
  65001. * Default is 1/60.
  65002. * To slow it down, enter 1/600 for example.
  65003. * To speed it up, 1/30
  65004. * @param newTimeStep defines the new timestep to apply to this world.
  65005. */
  65006. setTimeStep(newTimeStep?: number): void;
  65007. /**
  65008. * Get the time step of the physics engine.
  65009. * @returns the current time step
  65010. */
  65011. getTimeStep(): number;
  65012. /**
  65013. * Set the sub time step of the physics engine.
  65014. * Default is 0 meaning there is no sub steps
  65015. * To increase physics resolution precision, set a small value (like 1 ms)
  65016. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65017. */
  65018. setSubTimeStep(subTimeStep?: number): void;
  65019. /**
  65020. * Get the sub time step of the physics engine.
  65021. * @returns the current sub time step
  65022. */
  65023. getSubTimeStep(): number;
  65024. /**
  65025. * Release all resources
  65026. */
  65027. dispose(): void;
  65028. /**
  65029. * Gets the name of the current physics plugin
  65030. * @returns the name of the plugin
  65031. */
  65032. getPhysicsPluginName(): string;
  65033. /**
  65034. * Adding a new impostor for the impostor tracking.
  65035. * This will be done by the impostor itself.
  65036. * @param impostor the impostor to add
  65037. */
  65038. addImpostor(impostor: PhysicsImpostor): void;
  65039. /**
  65040. * Remove an impostor from the engine.
  65041. * This impostor and its mesh will not longer be updated by the physics engine.
  65042. * @param impostor the impostor to remove
  65043. */
  65044. removeImpostor(impostor: PhysicsImpostor): void;
  65045. /**
  65046. * Add a joint to the physics engine
  65047. * @param mainImpostor defines the main impostor to which the joint is added.
  65048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65049. * @param joint defines the joint that will connect both impostors.
  65050. */
  65051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65052. /**
  65053. * Removes a joint from the simulation
  65054. * @param mainImpostor defines the impostor used with the joint
  65055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65056. * @param joint defines the joint to remove
  65057. */
  65058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65059. /**
  65060. * Called by the scene. No need to call it.
  65061. * @param delta defines the timespam between frames
  65062. */
  65063. _step(delta: number): void;
  65064. /**
  65065. * Gets the current plugin used to run the simulation
  65066. * @returns current plugin
  65067. */
  65068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65069. /**
  65070. * Gets the list of physic impostors
  65071. * @returns an array of PhysicsImpostor
  65072. */
  65073. getImpostors(): Array<PhysicsImpostor>;
  65074. /**
  65075. * Gets the impostor for a physics enabled object
  65076. * @param object defines the object impersonated by the impostor
  65077. * @returns the PhysicsImpostor or null if not found
  65078. */
  65079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65080. /**
  65081. * Gets the impostor for a physics body object
  65082. * @param body defines physics body used by the impostor
  65083. * @returns the PhysicsImpostor or null if not found
  65084. */
  65085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65086. /**
  65087. * Does a raycast in the physics world
  65088. * @param from when should the ray start?
  65089. * @param to when should the ray end?
  65090. * @returns PhysicsRaycastResult
  65091. */
  65092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65093. }
  65094. }
  65095. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  65096. import { Nullable } from "babylonjs/types";
  65097. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65099. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65101. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65102. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65103. /** @hidden */
  65104. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65105. private _useDeltaForWorldStep;
  65106. world: any;
  65107. name: string;
  65108. private _physicsMaterials;
  65109. private _fixedTimeStep;
  65110. private _cannonRaycastResult;
  65111. private _raycastResult;
  65112. private _physicsBodysToRemoveAfterStep;
  65113. private _firstFrame;
  65114. BJSCANNON: any;
  65115. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65116. setGravity(gravity: Vector3): void;
  65117. setTimeStep(timeStep: number): void;
  65118. getTimeStep(): number;
  65119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65120. private _removeMarkedPhysicsBodiesFromWorld;
  65121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65122. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65124. private _processChildMeshes;
  65125. removePhysicsBody(impostor: PhysicsImpostor): void;
  65126. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65127. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65128. private _addMaterial;
  65129. private _checkWithEpsilon;
  65130. private _createShape;
  65131. private _createHeightmap;
  65132. private _minus90X;
  65133. private _plus90X;
  65134. private _tmpPosition;
  65135. private _tmpDeltaPosition;
  65136. private _tmpUnityRotation;
  65137. private _updatePhysicsBodyTransformation;
  65138. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65139. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65140. isSupported(): boolean;
  65141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65146. getBodyMass(impostor: PhysicsImpostor): number;
  65147. getBodyFriction(impostor: PhysicsImpostor): number;
  65148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65149. getBodyRestitution(impostor: PhysicsImpostor): number;
  65150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65151. sleepBody(impostor: PhysicsImpostor): void;
  65152. wakeUpBody(impostor: PhysicsImpostor): void;
  65153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65154. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65157. getRadius(impostor: PhysicsImpostor): number;
  65158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65159. dispose(): void;
  65160. private _extendNamespace;
  65161. /**
  65162. * Does a raycast in the physics world
  65163. * @param from when should the ray start?
  65164. * @param to when should the ray end?
  65165. * @returns PhysicsRaycastResult
  65166. */
  65167. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65168. }
  65169. }
  65170. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65171. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65172. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65173. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65175. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65176. import { Nullable } from "babylonjs/types";
  65177. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65178. /** @hidden */
  65179. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65180. private _useDeltaForWorldStep;
  65181. world: any;
  65182. name: string;
  65183. BJSOIMO: any;
  65184. private _raycastResult;
  65185. private _fixedTimeStep;
  65186. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65187. setGravity(gravity: Vector3): void;
  65188. setTimeStep(timeStep: number): void;
  65189. getTimeStep(): number;
  65190. private _tmpImpostorsArray;
  65191. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65192. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65193. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65194. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65195. private _tmpPositionVector;
  65196. removePhysicsBody(impostor: PhysicsImpostor): void;
  65197. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65198. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65199. isSupported(): boolean;
  65200. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65201. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65202. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65203. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65204. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65205. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65206. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65207. getBodyMass(impostor: PhysicsImpostor): number;
  65208. getBodyFriction(impostor: PhysicsImpostor): number;
  65209. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65210. getBodyRestitution(impostor: PhysicsImpostor): number;
  65211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65212. sleepBody(impostor: PhysicsImpostor): void;
  65213. wakeUpBody(impostor: PhysicsImpostor): void;
  65214. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65215. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65216. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65217. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65218. getRadius(impostor: PhysicsImpostor): number;
  65219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65220. dispose(): void;
  65221. /**
  65222. * Does a raycast in the physics world
  65223. * @param from when should the ray start?
  65224. * @param to when should the ray end?
  65225. * @returns PhysicsRaycastResult
  65226. */
  65227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65228. }
  65229. }
  65230. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65231. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65232. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65233. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65234. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65235. import { Nullable } from "babylonjs/types";
  65236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65237. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65238. /**
  65239. * AmmoJS Physics plugin
  65240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65241. * @see https://github.com/kripken/ammo.js/
  65242. */
  65243. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65244. private _useDeltaForWorldStep;
  65245. /**
  65246. * Reference to the Ammo library
  65247. */
  65248. bjsAMMO: any;
  65249. /**
  65250. * Created ammoJS world which physics bodies are added to
  65251. */
  65252. world: any;
  65253. /**
  65254. * Name of the plugin
  65255. */
  65256. name: string;
  65257. private _timeStep;
  65258. private _fixedTimeStep;
  65259. private _maxSteps;
  65260. private _tmpQuaternion;
  65261. private _tmpAmmoTransform;
  65262. private _tmpAmmoQuaternion;
  65263. private _tmpAmmoConcreteContactResultCallback;
  65264. private _collisionConfiguration;
  65265. private _dispatcher;
  65266. private _overlappingPairCache;
  65267. private _solver;
  65268. private _softBodySolver;
  65269. private _tmpAmmoVectorA;
  65270. private _tmpAmmoVectorB;
  65271. private _tmpAmmoVectorC;
  65272. private _tmpAmmoVectorD;
  65273. private _tmpContactCallbackResult;
  65274. private _tmpAmmoVectorRCA;
  65275. private _tmpAmmoVectorRCB;
  65276. private _raycastResult;
  65277. private _tmpContactPoint;
  65278. private static readonly DISABLE_COLLISION_FLAG;
  65279. private static readonly KINEMATIC_FLAG;
  65280. private static readonly DISABLE_DEACTIVATION_FLAG;
  65281. /**
  65282. * Initializes the ammoJS plugin
  65283. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65284. * @param ammoInjection can be used to inject your own ammo reference
  65285. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65286. */
  65287. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65288. /**
  65289. * Sets the gravity of the physics world (m/(s^2))
  65290. * @param gravity Gravity to set
  65291. */
  65292. setGravity(gravity: Vector3): void;
  65293. /**
  65294. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65295. * @param timeStep timestep to use in seconds
  65296. */
  65297. setTimeStep(timeStep: number): void;
  65298. /**
  65299. * 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)
  65300. * @param fixedTimeStep fixedTimeStep to use in seconds
  65301. */
  65302. setFixedTimeStep(fixedTimeStep: number): void;
  65303. /**
  65304. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65305. * @param maxSteps the maximum number of steps by the physics engine per frame
  65306. */
  65307. setMaxSteps(maxSteps: number): void;
  65308. /**
  65309. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65310. * @returns the current timestep in seconds
  65311. */
  65312. getTimeStep(): number;
  65313. /**
  65314. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65315. */
  65316. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65317. private _isImpostorInContact;
  65318. private _isImpostorPairInContact;
  65319. private _stepSimulation;
  65320. /**
  65321. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65322. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65323. * After the step the babylon meshes are set to the position of the physics imposters
  65324. * @param delta amount of time to step forward
  65325. * @param impostors array of imposters to update before/after the step
  65326. */
  65327. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65328. /**
  65329. * Update babylon mesh to match physics world object
  65330. * @param impostor imposter to match
  65331. */
  65332. private _afterSoftStep;
  65333. /**
  65334. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65335. * @param impostor imposter to match
  65336. */
  65337. private _ropeStep;
  65338. /**
  65339. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65340. * @param impostor imposter to match
  65341. */
  65342. private _softbodyOrClothStep;
  65343. private _tmpMatrix;
  65344. /**
  65345. * Applies an impulse on the imposter
  65346. * @param impostor imposter to apply impulse to
  65347. * @param force amount of force to be applied to the imposter
  65348. * @param contactPoint the location to apply the impulse on the imposter
  65349. */
  65350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65351. /**
  65352. * Applies a force on the imposter
  65353. * @param impostor imposter to apply force
  65354. * @param force amount of force to be applied to the imposter
  65355. * @param contactPoint the location to apply the force on the imposter
  65356. */
  65357. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65358. /**
  65359. * Creates a physics body using the plugin
  65360. * @param impostor the imposter to create the physics body on
  65361. */
  65362. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65363. /**
  65364. * Removes the physics body from the imposter and disposes of the body's memory
  65365. * @param impostor imposter to remove the physics body from
  65366. */
  65367. removePhysicsBody(impostor: PhysicsImpostor): void;
  65368. /**
  65369. * Generates a joint
  65370. * @param impostorJoint the imposter joint to create the joint with
  65371. */
  65372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65373. /**
  65374. * Removes a joint
  65375. * @param impostorJoint the imposter joint to remove the joint from
  65376. */
  65377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65378. private _addMeshVerts;
  65379. /**
  65380. * Initialise the soft body vertices to match its object's (mesh) vertices
  65381. * Softbody vertices (nodes) are in world space and to match this
  65382. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65383. * @param impostor to create the softbody for
  65384. */
  65385. private _softVertexData;
  65386. /**
  65387. * Create an impostor's soft body
  65388. * @param impostor to create the softbody for
  65389. */
  65390. private _createSoftbody;
  65391. /**
  65392. * Create cloth for an impostor
  65393. * @param impostor to create the softbody for
  65394. */
  65395. private _createCloth;
  65396. /**
  65397. * Create rope for an impostor
  65398. * @param impostor to create the softbody for
  65399. */
  65400. private _createRope;
  65401. /**
  65402. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65403. * @param impostor to create the custom physics shape for
  65404. */
  65405. private _createCustom;
  65406. private _addHullVerts;
  65407. private _createShape;
  65408. /**
  65409. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65410. * @param impostor imposter containing the physics body and babylon object
  65411. */
  65412. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65413. /**
  65414. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65415. * @param impostor imposter containing the physics body and babylon object
  65416. * @param newPosition new position
  65417. * @param newRotation new rotation
  65418. */
  65419. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65420. /**
  65421. * If this plugin is supported
  65422. * @returns true if its supported
  65423. */
  65424. isSupported(): boolean;
  65425. /**
  65426. * Sets the linear velocity of the physics body
  65427. * @param impostor imposter to set the velocity on
  65428. * @param velocity velocity to set
  65429. */
  65430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65431. /**
  65432. * Sets the angular velocity of the physics body
  65433. * @param impostor imposter to set the velocity on
  65434. * @param velocity velocity to set
  65435. */
  65436. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65437. /**
  65438. * gets the linear velocity
  65439. * @param impostor imposter to get linear velocity from
  65440. * @returns linear velocity
  65441. */
  65442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65443. /**
  65444. * gets the angular velocity
  65445. * @param impostor imposter to get angular velocity from
  65446. * @returns angular velocity
  65447. */
  65448. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65449. /**
  65450. * Sets the mass of physics body
  65451. * @param impostor imposter to set the mass on
  65452. * @param mass mass to set
  65453. */
  65454. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65455. /**
  65456. * Gets the mass of the physics body
  65457. * @param impostor imposter to get the mass from
  65458. * @returns mass
  65459. */
  65460. getBodyMass(impostor: PhysicsImpostor): number;
  65461. /**
  65462. * Gets friction of the impostor
  65463. * @param impostor impostor to get friction from
  65464. * @returns friction value
  65465. */
  65466. getBodyFriction(impostor: PhysicsImpostor): number;
  65467. /**
  65468. * Sets friction of the impostor
  65469. * @param impostor impostor to set friction on
  65470. * @param friction friction value
  65471. */
  65472. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65473. /**
  65474. * Gets restitution of the impostor
  65475. * @param impostor impostor to get restitution from
  65476. * @returns restitution value
  65477. */
  65478. getBodyRestitution(impostor: PhysicsImpostor): number;
  65479. /**
  65480. * Sets resitution of the impostor
  65481. * @param impostor impostor to set resitution on
  65482. * @param restitution resitution value
  65483. */
  65484. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65485. /**
  65486. * Gets pressure inside the impostor
  65487. * @param impostor impostor to get pressure from
  65488. * @returns pressure value
  65489. */
  65490. getBodyPressure(impostor: PhysicsImpostor): number;
  65491. /**
  65492. * Sets pressure inside a soft body impostor
  65493. * Cloth and rope must remain 0 pressure
  65494. * @param impostor impostor to set pressure on
  65495. * @param pressure pressure value
  65496. */
  65497. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65498. /**
  65499. * Gets stiffness of the impostor
  65500. * @param impostor impostor to get stiffness from
  65501. * @returns pressure value
  65502. */
  65503. getBodyStiffness(impostor: PhysicsImpostor): number;
  65504. /**
  65505. * Sets stiffness of the impostor
  65506. * @param impostor impostor to set stiffness on
  65507. * @param stiffness stiffness value from 0 to 1
  65508. */
  65509. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65510. /**
  65511. * Gets velocityIterations of the impostor
  65512. * @param impostor impostor to get velocity iterations from
  65513. * @returns velocityIterations value
  65514. */
  65515. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65516. /**
  65517. * Sets velocityIterations of the impostor
  65518. * @param impostor impostor to set velocity iterations on
  65519. * @param velocityIterations velocityIterations value
  65520. */
  65521. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65522. /**
  65523. * Gets positionIterations of the impostor
  65524. * @param impostor impostor to get position iterations from
  65525. * @returns positionIterations value
  65526. */
  65527. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65528. /**
  65529. * Sets positionIterations of the impostor
  65530. * @param impostor impostor to set position on
  65531. * @param positionIterations positionIterations value
  65532. */
  65533. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65534. /**
  65535. * Append an anchor to a cloth object
  65536. * @param impostor is the cloth impostor to add anchor to
  65537. * @param otherImpostor is the rigid impostor to anchor to
  65538. * @param width ratio across width from 0 to 1
  65539. * @param height ratio up height from 0 to 1
  65540. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65541. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65542. */
  65543. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65544. /**
  65545. * Append an hook to a rope object
  65546. * @param impostor is the rope impostor to add hook to
  65547. * @param otherImpostor is the rigid impostor to hook to
  65548. * @param length ratio along the rope from 0 to 1
  65549. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65550. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65551. */
  65552. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65553. /**
  65554. * Sleeps the physics body and stops it from being active
  65555. * @param impostor impostor to sleep
  65556. */
  65557. sleepBody(impostor: PhysicsImpostor): void;
  65558. /**
  65559. * Activates the physics body
  65560. * @param impostor impostor to activate
  65561. */
  65562. wakeUpBody(impostor: PhysicsImpostor): void;
  65563. /**
  65564. * Updates the distance parameters of the joint
  65565. * @param joint joint to update
  65566. * @param maxDistance maximum distance of the joint
  65567. * @param minDistance minimum distance of the joint
  65568. */
  65569. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65570. /**
  65571. * Sets a motor on the joint
  65572. * @param joint joint to set motor on
  65573. * @param speed speed of the motor
  65574. * @param maxForce maximum force of the motor
  65575. * @param motorIndex index of the motor
  65576. */
  65577. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65578. /**
  65579. * Sets the motors limit
  65580. * @param joint joint to set limit on
  65581. * @param upperLimit upper limit
  65582. * @param lowerLimit lower limit
  65583. */
  65584. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65585. /**
  65586. * Syncs the position and rotation of a mesh with the impostor
  65587. * @param mesh mesh to sync
  65588. * @param impostor impostor to update the mesh with
  65589. */
  65590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65591. /**
  65592. * Gets the radius of the impostor
  65593. * @param impostor impostor to get radius from
  65594. * @returns the radius
  65595. */
  65596. getRadius(impostor: PhysicsImpostor): number;
  65597. /**
  65598. * Gets the box size of the impostor
  65599. * @param impostor impostor to get box size from
  65600. * @param result the resulting box size
  65601. */
  65602. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65603. /**
  65604. * Disposes of the impostor
  65605. */
  65606. dispose(): void;
  65607. /**
  65608. * Does a raycast in the physics world
  65609. * @param from when should the ray start?
  65610. * @param to when should the ray end?
  65611. * @returns PhysicsRaycastResult
  65612. */
  65613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65614. }
  65615. }
  65616. declare module "babylonjs/Probes/reflectionProbe" {
  65617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65618. import { Vector3 } from "babylonjs/Maths/math.vector";
  65619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65620. import { Nullable } from "babylonjs/types";
  65621. import { Scene } from "babylonjs/scene";
  65622. module "babylonjs/abstractScene" {
  65623. interface AbstractScene {
  65624. /**
  65625. * The list of reflection probes added to the scene
  65626. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65627. */
  65628. reflectionProbes: Array<ReflectionProbe>;
  65629. /**
  65630. * Removes the given reflection probe from this scene.
  65631. * @param toRemove The reflection probe to remove
  65632. * @returns The index of the removed reflection probe
  65633. */
  65634. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65635. /**
  65636. * Adds the given reflection probe to this scene.
  65637. * @param newReflectionProbe The reflection probe to add
  65638. */
  65639. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65640. }
  65641. }
  65642. /**
  65643. * Class used to generate realtime reflection / refraction cube textures
  65644. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65645. */
  65646. export class ReflectionProbe {
  65647. /** defines the name of the probe */
  65648. name: string;
  65649. private _scene;
  65650. private _renderTargetTexture;
  65651. private _projectionMatrix;
  65652. private _viewMatrix;
  65653. private _target;
  65654. private _add;
  65655. private _attachedMesh;
  65656. private _invertYAxis;
  65657. /** Gets or sets probe position (center of the cube map) */
  65658. position: Vector3;
  65659. /**
  65660. * Creates a new reflection probe
  65661. * @param name defines the name of the probe
  65662. * @param size defines the texture resolution (for each face)
  65663. * @param scene defines the hosting scene
  65664. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65665. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65666. */
  65667. constructor(
  65668. /** defines the name of the probe */
  65669. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65670. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65671. get samples(): number;
  65672. set samples(value: number);
  65673. /** Gets or sets the refresh rate to use (on every frame by default) */
  65674. get refreshRate(): number;
  65675. set refreshRate(value: number);
  65676. /**
  65677. * Gets the hosting scene
  65678. * @returns a Scene
  65679. */
  65680. getScene(): Scene;
  65681. /** Gets the internal CubeTexture used to render to */
  65682. get cubeTexture(): RenderTargetTexture;
  65683. /** Gets the list of meshes to render */
  65684. get renderList(): Nullable<AbstractMesh[]>;
  65685. /**
  65686. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65687. * @param mesh defines the mesh to attach to
  65688. */
  65689. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65690. /**
  65691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65692. * @param renderingGroupId The rendering group id corresponding to its index
  65693. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65694. */
  65695. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65696. /**
  65697. * Clean all associated resources
  65698. */
  65699. dispose(): void;
  65700. /**
  65701. * Converts the reflection probe information to a readable string for debug purpose.
  65702. * @param fullDetails Supports for multiple levels of logging within scene loading
  65703. * @returns the human readable reflection probe info
  65704. */
  65705. toString(fullDetails?: boolean): string;
  65706. /**
  65707. * Get the class name of the relfection probe.
  65708. * @returns "ReflectionProbe"
  65709. */
  65710. getClassName(): string;
  65711. /**
  65712. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65713. * @returns The JSON representation of the texture
  65714. */
  65715. serialize(): any;
  65716. /**
  65717. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65718. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65719. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65720. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65721. * @returns The parsed reflection probe if successful
  65722. */
  65723. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65724. }
  65725. }
  65726. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65727. /** @hidden */
  65728. export var _BabylonLoaderRegistered: boolean;
  65729. /**
  65730. * Helps setting up some configuration for the babylon file loader.
  65731. */
  65732. export class BabylonFileLoaderConfiguration {
  65733. /**
  65734. * The loader does not allow injecting custom physix engine into the plugins.
  65735. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65736. * So you could set this variable to your engine import to make it work.
  65737. */
  65738. static LoaderInjectedPhysicsEngine: any;
  65739. }
  65740. }
  65741. declare module "babylonjs/Loading/Plugins/index" {
  65742. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65743. }
  65744. declare module "babylonjs/Loading/index" {
  65745. export * from "babylonjs/Loading/loadingScreen";
  65746. export * from "babylonjs/Loading/Plugins/index";
  65747. export * from "babylonjs/Loading/sceneLoader";
  65748. export * from "babylonjs/Loading/sceneLoaderFlags";
  65749. }
  65750. declare module "babylonjs/Materials/Background/index" {
  65751. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65752. }
  65753. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65754. import { Scene } from "babylonjs/scene";
  65755. import { Color3 } from "babylonjs/Maths/math.color";
  65756. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65758. /**
  65759. * The Physically based simple base material of BJS.
  65760. *
  65761. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65762. * It is used as the base class for both the specGloss and metalRough conventions.
  65763. */
  65764. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65765. /**
  65766. * Number of Simultaneous lights allowed on the material.
  65767. */
  65768. maxSimultaneousLights: number;
  65769. /**
  65770. * If sets to true, disables all the lights affecting the material.
  65771. */
  65772. disableLighting: boolean;
  65773. /**
  65774. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65775. */
  65776. environmentTexture: BaseTexture;
  65777. /**
  65778. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65779. */
  65780. invertNormalMapX: boolean;
  65781. /**
  65782. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65783. */
  65784. invertNormalMapY: boolean;
  65785. /**
  65786. * Normal map used in the model.
  65787. */
  65788. normalTexture: BaseTexture;
  65789. /**
  65790. * Emissivie color used to self-illuminate the model.
  65791. */
  65792. emissiveColor: Color3;
  65793. /**
  65794. * Emissivie texture used to self-illuminate the model.
  65795. */
  65796. emissiveTexture: BaseTexture;
  65797. /**
  65798. * Occlusion Channel Strenght.
  65799. */
  65800. occlusionStrength: number;
  65801. /**
  65802. * Occlusion Texture of the material (adding extra occlusion effects).
  65803. */
  65804. occlusionTexture: BaseTexture;
  65805. /**
  65806. * Defines the alpha limits in alpha test mode.
  65807. */
  65808. alphaCutOff: number;
  65809. /**
  65810. * Gets the current double sided mode.
  65811. */
  65812. get doubleSided(): boolean;
  65813. /**
  65814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65815. */
  65816. set doubleSided(value: boolean);
  65817. /**
  65818. * Stores the pre-calculated light information of a mesh in a texture.
  65819. */
  65820. lightmapTexture: BaseTexture;
  65821. /**
  65822. * If true, the light map contains occlusion information instead of lighting info.
  65823. */
  65824. useLightmapAsShadowmap: boolean;
  65825. /**
  65826. * Instantiates a new PBRMaterial instance.
  65827. *
  65828. * @param name The material name
  65829. * @param scene The scene the material will be use in.
  65830. */
  65831. constructor(name: string, scene: Scene);
  65832. getClassName(): string;
  65833. }
  65834. }
  65835. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65836. import { Scene } from "babylonjs/scene";
  65837. import { Color3 } from "babylonjs/Maths/math.color";
  65838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65839. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65840. /**
  65841. * The PBR material of BJS following the metal roughness convention.
  65842. *
  65843. * This fits to the PBR convention in the GLTF definition:
  65844. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65845. */
  65846. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65847. /**
  65848. * The base color has two different interpretations depending on the value of metalness.
  65849. * When the material is a metal, the base color is the specific measured reflectance value
  65850. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65851. * of the material.
  65852. */
  65853. baseColor: Color3;
  65854. /**
  65855. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65856. * well as opacity information in the alpha channel.
  65857. */
  65858. baseTexture: BaseTexture;
  65859. /**
  65860. * Specifies the metallic scalar value of the material.
  65861. * Can also be used to scale the metalness values of the metallic texture.
  65862. */
  65863. metallic: number;
  65864. /**
  65865. * Specifies the roughness scalar value of the material.
  65866. * Can also be used to scale the roughness values of the metallic texture.
  65867. */
  65868. roughness: number;
  65869. /**
  65870. * Texture containing both the metallic value in the B channel and the
  65871. * roughness value in the G channel to keep better precision.
  65872. */
  65873. metallicRoughnessTexture: BaseTexture;
  65874. /**
  65875. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65876. *
  65877. * @param name The material name
  65878. * @param scene The scene the material will be use in.
  65879. */
  65880. constructor(name: string, scene: Scene);
  65881. /**
  65882. * Return the currrent class name of the material.
  65883. */
  65884. getClassName(): string;
  65885. /**
  65886. * Makes a duplicate of the current material.
  65887. * @param name - name to use for the new material.
  65888. */
  65889. clone(name: string): PBRMetallicRoughnessMaterial;
  65890. /**
  65891. * Serialize the material to a parsable JSON object.
  65892. */
  65893. serialize(): any;
  65894. /**
  65895. * Parses a JSON object correponding to the serialize function.
  65896. */
  65897. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65898. }
  65899. }
  65900. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65901. import { Scene } from "babylonjs/scene";
  65902. import { Color3 } from "babylonjs/Maths/math.color";
  65903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65904. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65905. /**
  65906. * The PBR material of BJS following the specular glossiness convention.
  65907. *
  65908. * This fits to the PBR convention in the GLTF definition:
  65909. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65910. */
  65911. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65912. /**
  65913. * Specifies the diffuse color of the material.
  65914. */
  65915. diffuseColor: Color3;
  65916. /**
  65917. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65918. * channel.
  65919. */
  65920. diffuseTexture: BaseTexture;
  65921. /**
  65922. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65923. */
  65924. specularColor: Color3;
  65925. /**
  65926. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65927. */
  65928. glossiness: number;
  65929. /**
  65930. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65931. */
  65932. specularGlossinessTexture: BaseTexture;
  65933. /**
  65934. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65935. *
  65936. * @param name The material name
  65937. * @param scene The scene the material will be use in.
  65938. */
  65939. constructor(name: string, scene: Scene);
  65940. /**
  65941. * Return the currrent class name of the material.
  65942. */
  65943. getClassName(): string;
  65944. /**
  65945. * Makes a duplicate of the current material.
  65946. * @param name - name to use for the new material.
  65947. */
  65948. clone(name: string): PBRSpecularGlossinessMaterial;
  65949. /**
  65950. * Serialize the material to a parsable JSON object.
  65951. */
  65952. serialize(): any;
  65953. /**
  65954. * Parses a JSON object correponding to the serialize function.
  65955. */
  65956. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65957. }
  65958. }
  65959. declare module "babylonjs/Materials/PBR/index" {
  65960. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65961. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65962. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65963. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65964. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65965. }
  65966. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65967. import { Nullable } from "babylonjs/types";
  65968. import { Scene } from "babylonjs/scene";
  65969. import { Matrix } from "babylonjs/Maths/math.vector";
  65970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65971. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65972. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65973. /**
  65974. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65975. * It can help converting any input color in a desired output one. This can then be used to create effects
  65976. * from sepia, black and white to sixties or futuristic rendering...
  65977. *
  65978. * The only supported format is currently 3dl.
  65979. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65980. */
  65981. export class ColorGradingTexture extends BaseTexture {
  65982. /**
  65983. * The texture URL.
  65984. */
  65985. url: string;
  65986. /**
  65987. * Empty line regex stored for GC.
  65988. */
  65989. private static _noneEmptyLineRegex;
  65990. private _textureMatrix;
  65991. private _onLoad;
  65992. /**
  65993. * Instantiates a ColorGradingTexture from the following parameters.
  65994. *
  65995. * @param url The location of the color gradind data (currently only supporting 3dl)
  65996. * @param sceneOrEngine The scene or engine the texture will be used in
  65997. * @param onLoad defines a callback triggered when the texture has been loaded
  65998. */
  65999. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66000. /**
  66001. * Fires the onload event from the constructor if requested.
  66002. */
  66003. private _triggerOnLoad;
  66004. /**
  66005. * Returns the texture matrix used in most of the material.
  66006. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66007. */
  66008. getTextureMatrix(): Matrix;
  66009. /**
  66010. * Occurs when the file being loaded is a .3dl LUT file.
  66011. */
  66012. private load3dlTexture;
  66013. /**
  66014. * Starts the loading process of the texture.
  66015. */
  66016. private loadTexture;
  66017. /**
  66018. * Clones the color gradind texture.
  66019. */
  66020. clone(): ColorGradingTexture;
  66021. /**
  66022. * Called during delayed load for textures.
  66023. */
  66024. delayLoad(): void;
  66025. /**
  66026. * Parses a color grading texture serialized by Babylon.
  66027. * @param parsedTexture The texture information being parsedTexture
  66028. * @param scene The scene to load the texture in
  66029. * @param rootUrl The root url of the data assets to load
  66030. * @return A color gradind texture
  66031. */
  66032. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66033. /**
  66034. * Serializes the LUT texture to json format.
  66035. */
  66036. serialize(): any;
  66037. }
  66038. }
  66039. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  66040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66041. import { Scene } from "babylonjs/scene";
  66042. import { Nullable } from "babylonjs/types";
  66043. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66044. /**
  66045. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66046. */
  66047. export class EquiRectangularCubeTexture extends BaseTexture {
  66048. /** The six faces of the cube. */
  66049. private static _FacesMapping;
  66050. private _noMipmap;
  66051. private _onLoad;
  66052. private _onError;
  66053. /** The size of the cubemap. */
  66054. private _size;
  66055. /** The buffer of the image. */
  66056. private _buffer;
  66057. /** The width of the input image. */
  66058. private _width;
  66059. /** The height of the input image. */
  66060. private _height;
  66061. /** The URL to the image. */
  66062. url: string;
  66063. /**
  66064. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66065. * @param url The location of the image
  66066. * @param scene The scene the texture will be used in
  66067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66068. * @param noMipmap Forces to not generate the mipmap if true
  66069. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66070. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66071. * @param onLoad — defines a callback called when texture is loaded
  66072. * @param onError — defines a callback called if there is an error
  66073. */
  66074. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66075. /**
  66076. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66077. */
  66078. private loadImage;
  66079. /**
  66080. * Convert the image buffer into a cubemap and create a CubeTexture.
  66081. */
  66082. private loadTexture;
  66083. /**
  66084. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66085. * @param buffer The ArrayBuffer that should be converted.
  66086. * @returns The buffer as Float32Array.
  66087. */
  66088. private getFloat32ArrayFromArrayBuffer;
  66089. /**
  66090. * Get the current class name of the texture useful for serialization or dynamic coding.
  66091. * @returns "EquiRectangularCubeTexture"
  66092. */
  66093. getClassName(): string;
  66094. /**
  66095. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66096. * @returns A clone of the current EquiRectangularCubeTexture.
  66097. */
  66098. clone(): EquiRectangularCubeTexture;
  66099. }
  66100. }
  66101. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  66102. import { Nullable } from "babylonjs/types";
  66103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66104. import { Matrix } from "babylonjs/Maths/math.vector";
  66105. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  66106. import "babylonjs/Engines/Extensions/engine.videoTexture";
  66107. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66108. import { Scene } from "babylonjs/scene";
  66109. /**
  66110. * Defines the options related to the creation of an HtmlElementTexture
  66111. */
  66112. export interface IHtmlElementTextureOptions {
  66113. /**
  66114. * Defines wether mip maps should be created or not.
  66115. */
  66116. generateMipMaps?: boolean;
  66117. /**
  66118. * Defines the sampling mode of the texture.
  66119. */
  66120. samplingMode?: number;
  66121. /**
  66122. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66123. */
  66124. engine: Nullable<ThinEngine>;
  66125. /**
  66126. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66127. */
  66128. scene: Nullable<Scene>;
  66129. }
  66130. /**
  66131. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66132. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66133. * is automatically managed.
  66134. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66135. * in your application.
  66136. *
  66137. * As the update is not automatic, you need to call them manually.
  66138. */
  66139. export class HtmlElementTexture extends BaseTexture {
  66140. /**
  66141. * The texture URL.
  66142. */
  66143. element: HTMLVideoElement | HTMLCanvasElement;
  66144. private static readonly DefaultOptions;
  66145. private _textureMatrix;
  66146. private _isVideo;
  66147. private _generateMipMaps;
  66148. private _samplingMode;
  66149. /**
  66150. * Instantiates a HtmlElementTexture from the following parameters.
  66151. *
  66152. * @param name Defines the name of the texture
  66153. * @param element Defines the video or canvas the texture is filled with
  66154. * @param options Defines the other none mandatory texture creation options
  66155. */
  66156. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66157. private _createInternalTexture;
  66158. /**
  66159. * Returns the texture matrix used in most of the material.
  66160. */
  66161. getTextureMatrix(): Matrix;
  66162. /**
  66163. * Updates the content of the texture.
  66164. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66165. */
  66166. update(invertY?: Nullable<boolean>): void;
  66167. }
  66168. }
  66169. declare module "babylonjs/Misc/tga" {
  66170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66171. /**
  66172. * Based on jsTGALoader - Javascript loader for TGA file
  66173. * By Vincent Thibault
  66174. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66175. */
  66176. export class TGATools {
  66177. private static _TYPE_INDEXED;
  66178. private static _TYPE_RGB;
  66179. private static _TYPE_GREY;
  66180. private static _TYPE_RLE_INDEXED;
  66181. private static _TYPE_RLE_RGB;
  66182. private static _TYPE_RLE_GREY;
  66183. private static _ORIGIN_MASK;
  66184. private static _ORIGIN_SHIFT;
  66185. private static _ORIGIN_BL;
  66186. private static _ORIGIN_BR;
  66187. private static _ORIGIN_UL;
  66188. private static _ORIGIN_UR;
  66189. /**
  66190. * Gets the header of a TGA file
  66191. * @param data defines the TGA data
  66192. * @returns the header
  66193. */
  66194. static GetTGAHeader(data: Uint8Array): any;
  66195. /**
  66196. * Uploads TGA content to a Babylon Texture
  66197. * @hidden
  66198. */
  66199. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66200. /** @hidden */
  66201. 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;
  66202. /** @hidden */
  66203. 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;
  66204. /** @hidden */
  66205. 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;
  66206. /** @hidden */
  66207. 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;
  66208. /** @hidden */
  66209. 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;
  66210. /** @hidden */
  66211. 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;
  66212. }
  66213. }
  66214. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66215. import { Nullable } from "babylonjs/types";
  66216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66218. /**
  66219. * Implementation of the TGA Texture Loader.
  66220. * @hidden
  66221. */
  66222. export class _TGATextureLoader implements IInternalTextureLoader {
  66223. /**
  66224. * Defines wether the loader supports cascade loading the different faces.
  66225. */
  66226. readonly supportCascades: boolean;
  66227. /**
  66228. * This returns if the loader support the current file information.
  66229. * @param extension defines the file extension of the file being loaded
  66230. * @returns true if the loader can load the specified file
  66231. */
  66232. canLoad(extension: string): boolean;
  66233. /**
  66234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66235. * @param data contains the texture data
  66236. * @param texture defines the BabylonJS internal texture
  66237. * @param createPolynomials will be true if polynomials have been requested
  66238. * @param onLoad defines the callback to trigger once the texture is ready
  66239. * @param onError defines the callback to trigger in case of error
  66240. */
  66241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66242. /**
  66243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66244. * @param data contains the texture data
  66245. * @param texture defines the BabylonJS internal texture
  66246. * @param callback defines the method to call once ready to upload
  66247. */
  66248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66249. }
  66250. }
  66251. declare module "babylonjs/Misc/basis" {
  66252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66253. /**
  66254. * Info about the .basis files
  66255. */
  66256. class BasisFileInfo {
  66257. /**
  66258. * If the file has alpha
  66259. */
  66260. hasAlpha: boolean;
  66261. /**
  66262. * Info about each image of the basis file
  66263. */
  66264. images: Array<{
  66265. levels: Array<{
  66266. width: number;
  66267. height: number;
  66268. transcodedPixels: ArrayBufferView;
  66269. }>;
  66270. }>;
  66271. }
  66272. /**
  66273. * Result of transcoding a basis file
  66274. */
  66275. class TranscodeResult {
  66276. /**
  66277. * Info about the .basis file
  66278. */
  66279. fileInfo: BasisFileInfo;
  66280. /**
  66281. * Format to use when loading the file
  66282. */
  66283. format: number;
  66284. }
  66285. /**
  66286. * Configuration options for the Basis transcoder
  66287. */
  66288. export class BasisTranscodeConfiguration {
  66289. /**
  66290. * Supported compression formats used to determine the supported output format of the transcoder
  66291. */
  66292. supportedCompressionFormats?: {
  66293. /**
  66294. * etc1 compression format
  66295. */
  66296. etc1?: boolean;
  66297. /**
  66298. * s3tc compression format
  66299. */
  66300. s3tc?: boolean;
  66301. /**
  66302. * pvrtc compression format
  66303. */
  66304. pvrtc?: boolean;
  66305. /**
  66306. * etc2 compression format
  66307. */
  66308. etc2?: boolean;
  66309. };
  66310. /**
  66311. * If mipmap levels should be loaded for transcoded images (Default: true)
  66312. */
  66313. loadMipmapLevels?: boolean;
  66314. /**
  66315. * Index of a single image to load (Default: all images)
  66316. */
  66317. loadSingleImage?: number;
  66318. }
  66319. /**
  66320. * Used to load .Basis files
  66321. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66322. */
  66323. export class BasisTools {
  66324. private static _IgnoreSupportedFormats;
  66325. /**
  66326. * URL to use when loading the basis transcoder
  66327. */
  66328. static JSModuleURL: string;
  66329. /**
  66330. * URL to use when loading the wasm module for the transcoder
  66331. */
  66332. static WasmModuleURL: string;
  66333. /**
  66334. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66335. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66336. * @returns internal format corresponding to the Basis format
  66337. */
  66338. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66339. private static _WorkerPromise;
  66340. private static _Worker;
  66341. private static _actionId;
  66342. private static _CreateWorkerAsync;
  66343. /**
  66344. * Transcodes a loaded image file to compressed pixel data
  66345. * @param data image data to transcode
  66346. * @param config configuration options for the transcoding
  66347. * @returns a promise resulting in the transcoded image
  66348. */
  66349. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66350. /**
  66351. * Loads a texture from the transcode result
  66352. * @param texture texture load to
  66353. * @param transcodeResult the result of transcoding the basis file to load from
  66354. */
  66355. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66356. }
  66357. }
  66358. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66359. import { Nullable } from "babylonjs/types";
  66360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66362. /**
  66363. * Loader for .basis file format
  66364. */
  66365. export class _BasisTextureLoader implements IInternalTextureLoader {
  66366. /**
  66367. * Defines whether the loader supports cascade loading the different faces.
  66368. */
  66369. readonly supportCascades: boolean;
  66370. /**
  66371. * This returns if the loader support the current file information.
  66372. * @param extension defines the file extension of the file being loaded
  66373. * @returns true if the loader can load the specified file
  66374. */
  66375. canLoad(extension: string): boolean;
  66376. /**
  66377. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66378. * @param data contains the texture data
  66379. * @param texture defines the BabylonJS internal texture
  66380. * @param createPolynomials will be true if polynomials have been requested
  66381. * @param onLoad defines the callback to trigger once the texture is ready
  66382. * @param onError defines the callback to trigger in case of error
  66383. */
  66384. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66385. /**
  66386. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66387. * @param data contains the texture data
  66388. * @param texture defines the BabylonJS internal texture
  66389. * @param callback defines the method to call once ready to upload
  66390. */
  66391. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66392. }
  66393. }
  66394. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66395. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66396. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66397. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66398. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66399. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66400. }
  66401. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66402. import { Vector2 } from "babylonjs/Maths/math.vector";
  66403. /**
  66404. * Defines the basic options interface of a TexturePacker Frame
  66405. */
  66406. export interface ITexturePackerFrame {
  66407. /**
  66408. * The frame ID
  66409. */
  66410. id: number;
  66411. /**
  66412. * The frames Scale
  66413. */
  66414. scale: Vector2;
  66415. /**
  66416. * The Frames offset
  66417. */
  66418. offset: Vector2;
  66419. }
  66420. /**
  66421. * This is a support class for frame Data on texture packer sets.
  66422. */
  66423. export class TexturePackerFrame implements ITexturePackerFrame {
  66424. /**
  66425. * The frame ID
  66426. */
  66427. id: number;
  66428. /**
  66429. * The frames Scale
  66430. */
  66431. scale: Vector2;
  66432. /**
  66433. * The Frames offset
  66434. */
  66435. offset: Vector2;
  66436. /**
  66437. * Initializes a texture package frame.
  66438. * @param id The numerical frame identifier
  66439. * @param scale Scalar Vector2 for UV frame
  66440. * @param offset Vector2 for the frame position in UV units.
  66441. * @returns TexturePackerFrame
  66442. */
  66443. constructor(id: number, scale: Vector2, offset: Vector2);
  66444. }
  66445. }
  66446. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66448. import { Scene } from "babylonjs/scene";
  66449. import { Nullable } from "babylonjs/types";
  66450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66451. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66452. /**
  66453. * Defines the basic options interface of a TexturePacker
  66454. */
  66455. export interface ITexturePackerOptions {
  66456. /**
  66457. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66458. */
  66459. map?: string[];
  66460. /**
  66461. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66462. */
  66463. uvsIn?: string;
  66464. /**
  66465. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66466. */
  66467. uvsOut?: string;
  66468. /**
  66469. * number representing the layout style. Defaults to LAYOUT_STRIP
  66470. */
  66471. layout?: number;
  66472. /**
  66473. * number of columns if using custom column count layout(2). This defaults to 4.
  66474. */
  66475. colnum?: number;
  66476. /**
  66477. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66478. */
  66479. updateInputMeshes?: boolean;
  66480. /**
  66481. * boolean flag to dispose all the source textures. Defaults to true.
  66482. */
  66483. disposeSources?: boolean;
  66484. /**
  66485. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66486. */
  66487. fillBlanks?: boolean;
  66488. /**
  66489. * string value representing the context fill style color. Defaults to 'black'.
  66490. */
  66491. customFillColor?: string;
  66492. /**
  66493. * Width and Height Value of each Frame in the TexturePacker Sets
  66494. */
  66495. frameSize?: number;
  66496. /**
  66497. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66498. */
  66499. paddingRatio?: number;
  66500. /**
  66501. * Number that declares the fill method for the padding gutter.
  66502. */
  66503. paddingMode?: number;
  66504. /**
  66505. * If in SUBUV_COLOR padding mode what color to use.
  66506. */
  66507. paddingColor?: Color3 | Color4;
  66508. }
  66509. /**
  66510. * Defines the basic interface of a TexturePacker JSON File
  66511. */
  66512. export interface ITexturePackerJSON {
  66513. /**
  66514. * The frame ID
  66515. */
  66516. name: string;
  66517. /**
  66518. * The base64 channel data
  66519. */
  66520. sets: any;
  66521. /**
  66522. * The options of the Packer
  66523. */
  66524. options: ITexturePackerOptions;
  66525. /**
  66526. * The frame data of the Packer
  66527. */
  66528. frames: Array<number>;
  66529. }
  66530. /**
  66531. * This is a support class that generates a series of packed texture sets.
  66532. * @see https://doc.babylonjs.com/babylon101/materials
  66533. */
  66534. export class TexturePacker {
  66535. /** Packer Layout Constant 0 */
  66536. static readonly LAYOUT_STRIP: number;
  66537. /** Packer Layout Constant 1 */
  66538. static readonly LAYOUT_POWER2: number;
  66539. /** Packer Layout Constant 2 */
  66540. static readonly LAYOUT_COLNUM: number;
  66541. /** Packer Layout Constant 0 */
  66542. static readonly SUBUV_WRAP: number;
  66543. /** Packer Layout Constant 1 */
  66544. static readonly SUBUV_EXTEND: number;
  66545. /** Packer Layout Constant 2 */
  66546. static readonly SUBUV_COLOR: number;
  66547. /** The Name of the Texture Package */
  66548. name: string;
  66549. /** The scene scope of the TexturePacker */
  66550. scene: Scene;
  66551. /** The Meshes to target */
  66552. meshes: AbstractMesh[];
  66553. /** Arguments passed with the Constructor */
  66554. options: ITexturePackerOptions;
  66555. /** The promise that is started upon initialization */
  66556. promise: Nullable<Promise<TexturePacker | string>>;
  66557. /** The Container object for the channel sets that are generated */
  66558. sets: object;
  66559. /** The Container array for the frames that are generated */
  66560. frames: TexturePackerFrame[];
  66561. /** The expected number of textures the system is parsing. */
  66562. private _expecting;
  66563. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66564. private _paddingValue;
  66565. /**
  66566. * Initializes a texture package series from an array of meshes or a single mesh.
  66567. * @param name The name of the package
  66568. * @param meshes The target meshes to compose the package from
  66569. * @param options The arguments that texture packer should follow while building.
  66570. * @param scene The scene which the textures are scoped to.
  66571. * @returns TexturePacker
  66572. */
  66573. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66574. /**
  66575. * Starts the package process
  66576. * @param resolve The promises resolution function
  66577. * @returns TexturePacker
  66578. */
  66579. private _createFrames;
  66580. /**
  66581. * Calculates the Size of the Channel Sets
  66582. * @returns Vector2
  66583. */
  66584. private _calculateSize;
  66585. /**
  66586. * Calculates the UV data for the frames.
  66587. * @param baseSize the base frameSize
  66588. * @param padding the base frame padding
  66589. * @param dtSize size of the Dynamic Texture for that channel
  66590. * @param dtUnits is 1/dtSize
  66591. * @param update flag to update the input meshes
  66592. */
  66593. private _calculateMeshUVFrames;
  66594. /**
  66595. * Calculates the frames Offset.
  66596. * @param index of the frame
  66597. * @returns Vector2
  66598. */
  66599. private _getFrameOffset;
  66600. /**
  66601. * Updates a Mesh to the frame data
  66602. * @param mesh that is the target
  66603. * @param frameID or the frame index
  66604. */
  66605. private _updateMeshUV;
  66606. /**
  66607. * Updates a Meshes materials to use the texture packer channels
  66608. * @param m is the mesh to target
  66609. * @param force all channels on the packer to be set.
  66610. */
  66611. private _updateTextureReferences;
  66612. /**
  66613. * Public method to set a Mesh to a frame
  66614. * @param m that is the target
  66615. * @param frameID or the frame index
  66616. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66617. */
  66618. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66619. /**
  66620. * Starts the async promise to compile the texture packer.
  66621. * @returns Promise<void>
  66622. */
  66623. processAsync(): Promise<void>;
  66624. /**
  66625. * Disposes all textures associated with this packer
  66626. */
  66627. dispose(): void;
  66628. /**
  66629. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66630. * @param imageType is the image type to use.
  66631. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66632. */
  66633. download(imageType?: string, quality?: number): void;
  66634. /**
  66635. * Public method to load a texturePacker JSON file.
  66636. * @param data of the JSON file in string format.
  66637. */
  66638. updateFromJSON(data: string): void;
  66639. }
  66640. }
  66641. declare module "babylonjs/Materials/Textures/Packer/index" {
  66642. export * from "babylonjs/Materials/Textures/Packer/packer";
  66643. export * from "babylonjs/Materials/Textures/Packer/frame";
  66644. }
  66645. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66646. import { Scene } from "babylonjs/scene";
  66647. import { Texture } from "babylonjs/Materials/Textures/texture";
  66648. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66649. /**
  66650. * 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.
  66651. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66652. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66653. */
  66654. export class CustomProceduralTexture extends ProceduralTexture {
  66655. private _animate;
  66656. private _time;
  66657. private _config;
  66658. private _texturePath;
  66659. /**
  66660. * Instantiates a new Custom Procedural Texture.
  66661. * 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.
  66662. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66664. * @param name Define the name of the texture
  66665. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66666. * @param size Define the size of the texture to create
  66667. * @param scene Define the scene the texture belongs to
  66668. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66669. * @param generateMipMaps Define if the texture should creates mip maps or not
  66670. */
  66671. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66672. private _loadJson;
  66673. /**
  66674. * Is the texture ready to be used ? (rendered at least once)
  66675. * @returns true if ready, otherwise, false.
  66676. */
  66677. isReady(): boolean;
  66678. /**
  66679. * Render the texture to its associated render target.
  66680. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66681. */
  66682. render(useCameraPostProcess?: boolean): void;
  66683. /**
  66684. * Update the list of dependant textures samplers in the shader.
  66685. */
  66686. updateTextures(): void;
  66687. /**
  66688. * Update the uniform values of the procedural texture in the shader.
  66689. */
  66690. updateShaderUniforms(): void;
  66691. /**
  66692. * Define if the texture animates or not.
  66693. */
  66694. get animate(): boolean;
  66695. set animate(value: boolean);
  66696. }
  66697. }
  66698. declare module "babylonjs/Shaders/noise.fragment" {
  66699. /** @hidden */
  66700. export var noisePixelShader: {
  66701. name: string;
  66702. shader: string;
  66703. };
  66704. }
  66705. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66706. import { Nullable } from "babylonjs/types";
  66707. import { Scene } from "babylonjs/scene";
  66708. import { Texture } from "babylonjs/Materials/Textures/texture";
  66709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66710. import "babylonjs/Shaders/noise.fragment";
  66711. /**
  66712. * Class used to generate noise procedural textures
  66713. */
  66714. export class NoiseProceduralTexture extends ProceduralTexture {
  66715. /** Gets or sets the start time (default is 0) */
  66716. time: number;
  66717. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66718. brightness: number;
  66719. /** Defines the number of octaves to process */
  66720. octaves: number;
  66721. /** Defines the level of persistence (0.8 by default) */
  66722. persistence: number;
  66723. /** Gets or sets animation speed factor (default is 1) */
  66724. animationSpeedFactor: number;
  66725. /**
  66726. * Creates a new NoiseProceduralTexture
  66727. * @param name defines the name fo the texture
  66728. * @param size defines the size of the texture (default is 256)
  66729. * @param scene defines the hosting scene
  66730. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66731. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66732. */
  66733. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66734. private _updateShaderUniforms;
  66735. protected _getDefines(): string;
  66736. /** Generate the current state of the procedural texture */
  66737. render(useCameraPostProcess?: boolean): void;
  66738. /**
  66739. * Serializes this noise procedural texture
  66740. * @returns a serialized noise procedural texture object
  66741. */
  66742. serialize(): any;
  66743. /**
  66744. * Clone the texture.
  66745. * @returns the cloned texture
  66746. */
  66747. clone(): NoiseProceduralTexture;
  66748. /**
  66749. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66750. * @param parsedTexture defines parsed texture data
  66751. * @param scene defines the current scene
  66752. * @param rootUrl defines the root URL containing noise procedural texture information
  66753. * @returns a parsed NoiseProceduralTexture
  66754. */
  66755. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66756. }
  66757. }
  66758. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66759. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66760. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66761. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66762. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66763. }
  66764. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66765. import { Nullable } from "babylonjs/types";
  66766. import { Scene } from "babylonjs/scene";
  66767. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66769. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66771. /**
  66772. * Raw cube texture where the raw buffers are passed in
  66773. */
  66774. export class RawCubeTexture extends CubeTexture {
  66775. /**
  66776. * Creates a cube texture where the raw buffers are passed in.
  66777. * @param scene defines the scene the texture is attached to
  66778. * @param data defines the array of data to use to create each face
  66779. * @param size defines the size of the textures
  66780. * @param format defines the format of the data
  66781. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66782. * @param generateMipMaps defines if the engine should generate the mip levels
  66783. * @param invertY defines if data must be stored with Y axis inverted
  66784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66785. * @param compression defines the compression used (null by default)
  66786. */
  66787. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66788. /**
  66789. * Updates the raw cube texture.
  66790. * @param data defines the data to store
  66791. * @param format defines the data format
  66792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66793. * @param invertY defines if data must be stored with Y axis inverted
  66794. * @param compression defines the compression used (null by default)
  66795. * @param level defines which level of the texture to update
  66796. */
  66797. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66798. /**
  66799. * Updates a raw cube texture with RGBD encoded data.
  66800. * @param data defines the array of data [mipmap][face] to use to create each face
  66801. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66802. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66803. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66804. * @returns a promsie that resolves when the operation is complete
  66805. */
  66806. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66807. /**
  66808. * Clones the raw cube texture.
  66809. * @return a new cube texture
  66810. */
  66811. clone(): CubeTexture;
  66812. /** @hidden */
  66813. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66814. }
  66815. }
  66816. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66817. import { Scene } from "babylonjs/scene";
  66818. import { Texture } from "babylonjs/Materials/Textures/texture";
  66819. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66820. /**
  66821. * Class used to store 2D array textures containing user data
  66822. */
  66823. export class RawTexture2DArray extends Texture {
  66824. /** Gets or sets the texture format to use */
  66825. format: number;
  66826. /**
  66827. * Create a new RawTexture2DArray
  66828. * @param data defines the data of the texture
  66829. * @param width defines the width of the texture
  66830. * @param height defines the height of the texture
  66831. * @param depth defines the number of layers of the texture
  66832. * @param format defines the texture format to use
  66833. * @param scene defines the hosting scene
  66834. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66835. * @param invertY defines if texture must be stored with Y axis inverted
  66836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66838. */
  66839. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66840. /** Gets or sets the texture format to use */
  66841. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66842. /**
  66843. * Update the texture with new data
  66844. * @param data defines the data to store in the texture
  66845. */
  66846. update(data: ArrayBufferView): void;
  66847. }
  66848. }
  66849. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66850. import { Scene } from "babylonjs/scene";
  66851. import { Texture } from "babylonjs/Materials/Textures/texture";
  66852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66853. /**
  66854. * Class used to store 3D textures containing user data
  66855. */
  66856. export class RawTexture3D extends Texture {
  66857. /** Gets or sets the texture format to use */
  66858. format: number;
  66859. /**
  66860. * Create a new RawTexture3D
  66861. * @param data defines the data of the texture
  66862. * @param width defines the width of the texture
  66863. * @param height defines the height of the texture
  66864. * @param depth defines the depth of the texture
  66865. * @param format defines the texture format to use
  66866. * @param scene defines the hosting scene
  66867. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66868. * @param invertY defines if texture must be stored with Y axis inverted
  66869. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66871. */
  66872. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66873. /** Gets or sets the texture format to use */
  66874. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66875. /**
  66876. * Update the texture with new data
  66877. * @param data defines the data to store in the texture
  66878. */
  66879. update(data: ArrayBufferView): void;
  66880. }
  66881. }
  66882. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66883. import { Scene } from "babylonjs/scene";
  66884. import { Plane } from "babylonjs/Maths/math.plane";
  66885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66886. /**
  66887. * Creates a refraction texture used by refraction channel of the standard material.
  66888. * It is like a mirror but to see through a material.
  66889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66890. */
  66891. export class RefractionTexture extends RenderTargetTexture {
  66892. /**
  66893. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66894. * 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.
  66895. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66896. */
  66897. refractionPlane: Plane;
  66898. /**
  66899. * Define how deep under the surface we should see.
  66900. */
  66901. depth: number;
  66902. /**
  66903. * Creates a refraction texture used by refraction channel of the standard material.
  66904. * It is like a mirror but to see through a material.
  66905. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66906. * @param name Define the texture name
  66907. * @param size Define the size of the underlying texture
  66908. * @param scene Define the scene the refraction belongs to
  66909. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66910. */
  66911. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66912. /**
  66913. * Clone the refraction texture.
  66914. * @returns the cloned texture
  66915. */
  66916. clone(): RefractionTexture;
  66917. /**
  66918. * Serialize the texture to a JSON representation you could use in Parse later on
  66919. * @returns the serialized JSON representation
  66920. */
  66921. serialize(): any;
  66922. }
  66923. }
  66924. declare module "babylonjs/Materials/Textures/index" {
  66925. export * from "babylonjs/Materials/Textures/baseTexture";
  66926. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66927. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66928. export * from "babylonjs/Materials/Textures/cubeTexture";
  66929. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66930. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66931. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66932. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66933. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66934. export * from "babylonjs/Materials/Textures/internalTexture";
  66935. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66936. export * from "babylonjs/Materials/Textures/Loaders/index";
  66937. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66938. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66939. export * from "babylonjs/Materials/Textures/Packer/index";
  66940. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66941. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66942. export * from "babylonjs/Materials/Textures/rawTexture";
  66943. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66944. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66945. export * from "babylonjs/Materials/Textures/refractionTexture";
  66946. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66947. export * from "babylonjs/Materials/Textures/texture";
  66948. export * from "babylonjs/Materials/Textures/videoTexture";
  66949. }
  66950. declare module "babylonjs/Materials/Node/Enums/index" {
  66951. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66952. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66953. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66954. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66955. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66956. }
  66957. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66961. import { Mesh } from "babylonjs/Meshes/mesh";
  66962. import { Effect } from "babylonjs/Materials/effect";
  66963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66964. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66965. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66966. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66967. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66968. /**
  66969. * Block used to add support for vertex skinning (bones)
  66970. */
  66971. export class BonesBlock extends NodeMaterialBlock {
  66972. /**
  66973. * Creates a new BonesBlock
  66974. * @param name defines the block name
  66975. */
  66976. constructor(name: string);
  66977. /**
  66978. * Initialize the block and prepare the context for build
  66979. * @param state defines the state that will be used for the build
  66980. */
  66981. initialize(state: NodeMaterialBuildState): void;
  66982. /**
  66983. * Gets the current class name
  66984. * @returns the class name
  66985. */
  66986. getClassName(): string;
  66987. /**
  66988. * Gets the matrix indices input component
  66989. */
  66990. get matricesIndices(): NodeMaterialConnectionPoint;
  66991. /**
  66992. * Gets the matrix weights input component
  66993. */
  66994. get matricesWeights(): NodeMaterialConnectionPoint;
  66995. /**
  66996. * Gets the extra matrix indices input component
  66997. */
  66998. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the extra matrix weights input component
  67001. */
  67002. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the world input component
  67005. */
  67006. get world(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the output component
  67009. */
  67010. get output(): NodeMaterialConnectionPoint;
  67011. autoConfigure(material: NodeMaterial): void;
  67012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67015. protected _buildBlock(state: NodeMaterialBuildState): this;
  67016. }
  67017. }
  67018. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  67019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67023. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67024. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67025. /**
  67026. * Block used to add support for instances
  67027. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67028. */
  67029. export class InstancesBlock extends NodeMaterialBlock {
  67030. /**
  67031. * Creates a new InstancesBlock
  67032. * @param name defines the block name
  67033. */
  67034. constructor(name: string);
  67035. /**
  67036. * Gets the current class name
  67037. * @returns the class name
  67038. */
  67039. getClassName(): string;
  67040. /**
  67041. * Gets the first world row input component
  67042. */
  67043. get world0(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the second world row input component
  67046. */
  67047. get world1(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the third world row input component
  67050. */
  67051. get world2(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the forth world row input component
  67054. */
  67055. get world3(): NodeMaterialConnectionPoint;
  67056. /**
  67057. * Gets the world input component
  67058. */
  67059. get world(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the output component
  67062. */
  67063. get output(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the isntanceID component
  67066. */
  67067. get instanceID(): NodeMaterialConnectionPoint;
  67068. autoConfigure(material: NodeMaterial): void;
  67069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67070. protected _buildBlock(state: NodeMaterialBuildState): this;
  67071. }
  67072. }
  67073. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  67074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67079. import { Effect } from "babylonjs/Materials/effect";
  67080. import { Mesh } from "babylonjs/Meshes/mesh";
  67081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67083. /**
  67084. * Block used to add morph targets support to vertex shader
  67085. */
  67086. export class MorphTargetsBlock extends NodeMaterialBlock {
  67087. private _repeatableContentAnchor;
  67088. /**
  67089. * Create a new MorphTargetsBlock
  67090. * @param name defines the block name
  67091. */
  67092. constructor(name: string);
  67093. /**
  67094. * Gets the current class name
  67095. * @returns the class name
  67096. */
  67097. getClassName(): string;
  67098. /**
  67099. * Gets the position input component
  67100. */
  67101. get position(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the normal input component
  67104. */
  67105. get normal(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the tangent input component
  67108. */
  67109. get tangent(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the tangent input component
  67112. */
  67113. get uv(): NodeMaterialConnectionPoint;
  67114. /**
  67115. * Gets the position output component
  67116. */
  67117. get positionOutput(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the normal output component
  67120. */
  67121. get normalOutput(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the tangent output component
  67124. */
  67125. get tangentOutput(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the tangent output component
  67128. */
  67129. get uvOutput(): NodeMaterialConnectionPoint;
  67130. initialize(state: NodeMaterialBuildState): void;
  67131. autoConfigure(material: NodeMaterial): void;
  67132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67133. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67134. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67135. protected _buildBlock(state: NodeMaterialBuildState): this;
  67136. }
  67137. }
  67138. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67142. import { Nullable } from "babylonjs/types";
  67143. import { Scene } from "babylonjs/scene";
  67144. import { Effect } from "babylonjs/Materials/effect";
  67145. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67146. import { Mesh } from "babylonjs/Meshes/mesh";
  67147. import { Light } from "babylonjs/Lights/light";
  67148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67149. /**
  67150. * Block used to get data information from a light
  67151. */
  67152. export class LightInformationBlock extends NodeMaterialBlock {
  67153. private _lightDataUniformName;
  67154. private _lightColorUniformName;
  67155. private _lightTypeDefineName;
  67156. /**
  67157. * Gets or sets the light associated with this block
  67158. */
  67159. light: Nullable<Light>;
  67160. /**
  67161. * Creates a new LightInformationBlock
  67162. * @param name defines the block name
  67163. */
  67164. constructor(name: string);
  67165. /**
  67166. * Gets the current class name
  67167. * @returns the class name
  67168. */
  67169. getClassName(): string;
  67170. /**
  67171. * Gets the world position input component
  67172. */
  67173. get worldPosition(): NodeMaterialConnectionPoint;
  67174. /**
  67175. * Gets the direction output component
  67176. */
  67177. get direction(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the direction output component
  67180. */
  67181. get color(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the direction output component
  67184. */
  67185. get intensity(): NodeMaterialConnectionPoint;
  67186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67188. protected _buildBlock(state: NodeMaterialBuildState): this;
  67189. serialize(): any;
  67190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67191. }
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67194. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67199. }
  67200. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67205. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67206. import { Effect } from "babylonjs/Materials/effect";
  67207. import { Mesh } from "babylonjs/Meshes/mesh";
  67208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67209. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67210. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67211. /**
  67212. * Block used to add image processing support to fragment shader
  67213. */
  67214. export class ImageProcessingBlock extends NodeMaterialBlock {
  67215. /**
  67216. * Create a new ImageProcessingBlock
  67217. * @param name defines the block name
  67218. */
  67219. constructor(name: string);
  67220. /**
  67221. * Gets the current class name
  67222. * @returns the class name
  67223. */
  67224. getClassName(): string;
  67225. /**
  67226. * Gets the color input component
  67227. */
  67228. get color(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the output component
  67231. */
  67232. get output(): NodeMaterialConnectionPoint;
  67233. /**
  67234. * Initialize the block and prepare the context for build
  67235. * @param state defines the state that will be used for the build
  67236. */
  67237. initialize(state: NodeMaterialBuildState): void;
  67238. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67241. protected _buildBlock(state: NodeMaterialBuildState): this;
  67242. }
  67243. }
  67244. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67250. import { Effect } from "babylonjs/Materials/effect";
  67251. import { Mesh } from "babylonjs/Meshes/mesh";
  67252. import { Scene } from "babylonjs/scene";
  67253. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67254. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67255. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67256. /**
  67257. * Block used to pertub normals based on a normal map
  67258. */
  67259. export class PerturbNormalBlock extends NodeMaterialBlock {
  67260. private _tangentSpaceParameterName;
  67261. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67262. invertX: boolean;
  67263. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67264. invertY: boolean;
  67265. /**
  67266. * Create a new PerturbNormalBlock
  67267. * @param name defines the block name
  67268. */
  67269. constructor(name: string);
  67270. /**
  67271. * Gets the current class name
  67272. * @returns the class name
  67273. */
  67274. getClassName(): string;
  67275. /**
  67276. * Gets the world position input component
  67277. */
  67278. get worldPosition(): NodeMaterialConnectionPoint;
  67279. /**
  67280. * Gets the world normal input component
  67281. */
  67282. get worldNormal(): NodeMaterialConnectionPoint;
  67283. /**
  67284. * Gets the world tangent input component
  67285. */
  67286. get worldTangent(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the uv input component
  67289. */
  67290. get uv(): NodeMaterialConnectionPoint;
  67291. /**
  67292. * Gets the normal map color input component
  67293. */
  67294. get normalMapColor(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the strength input component
  67297. */
  67298. get strength(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the output component
  67301. */
  67302. get output(): NodeMaterialConnectionPoint;
  67303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67305. autoConfigure(material: NodeMaterial): void;
  67306. protected _buildBlock(state: NodeMaterialBuildState): this;
  67307. protected _dumpPropertiesCode(): string;
  67308. serialize(): any;
  67309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67310. }
  67311. }
  67312. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  67313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67316. /**
  67317. * Block used to discard a pixel if a value is smaller than a cutoff
  67318. */
  67319. export class DiscardBlock extends NodeMaterialBlock {
  67320. /**
  67321. * Create a new DiscardBlock
  67322. * @param name defines the block name
  67323. */
  67324. constructor(name: string);
  67325. /**
  67326. * Gets the current class name
  67327. * @returns the class name
  67328. */
  67329. getClassName(): string;
  67330. /**
  67331. * Gets the color input component
  67332. */
  67333. get value(): NodeMaterialConnectionPoint;
  67334. /**
  67335. * Gets the cutoff input component
  67336. */
  67337. get cutoff(): NodeMaterialConnectionPoint;
  67338. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67339. }
  67340. }
  67341. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67345. /**
  67346. * Block used to test if the fragment shader is front facing
  67347. */
  67348. export class FrontFacingBlock extends NodeMaterialBlock {
  67349. /**
  67350. * Creates a new FrontFacingBlock
  67351. * @param name defines the block name
  67352. */
  67353. constructor(name: string);
  67354. /**
  67355. * Gets the current class name
  67356. * @returns the class name
  67357. */
  67358. getClassName(): string;
  67359. /**
  67360. * Gets the output component
  67361. */
  67362. get output(): NodeMaterialConnectionPoint;
  67363. protected _buildBlock(state: NodeMaterialBuildState): this;
  67364. }
  67365. }
  67366. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67370. /**
  67371. * Block used to get the derivative value on x and y of a given input
  67372. */
  67373. export class DerivativeBlock extends NodeMaterialBlock {
  67374. /**
  67375. * Create a new DerivativeBlock
  67376. * @param name defines the block name
  67377. */
  67378. constructor(name: string);
  67379. /**
  67380. * Gets the current class name
  67381. * @returns the class name
  67382. */
  67383. getClassName(): string;
  67384. /**
  67385. * Gets the input component
  67386. */
  67387. get input(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the derivative output on x
  67390. */
  67391. get dx(): NodeMaterialConnectionPoint;
  67392. /**
  67393. * Gets the derivative output on y
  67394. */
  67395. get dy(): NodeMaterialConnectionPoint;
  67396. protected _buildBlock(state: NodeMaterialBuildState): this;
  67397. }
  67398. }
  67399. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67403. /**
  67404. * Block used to make gl_FragCoord available
  67405. */
  67406. export class FragCoordBlock extends NodeMaterialBlock {
  67407. /**
  67408. * Creates a new FragCoordBlock
  67409. * @param name defines the block name
  67410. */
  67411. constructor(name: string);
  67412. /**
  67413. * Gets the current class name
  67414. * @returns the class name
  67415. */
  67416. getClassName(): string;
  67417. /**
  67418. * Gets the xy component
  67419. */
  67420. get xy(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the xyz component
  67423. */
  67424. get xyz(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the xyzw component
  67427. */
  67428. get xyzw(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the x component
  67431. */
  67432. get x(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the y component
  67435. */
  67436. get y(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the z component
  67439. */
  67440. get z(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the w component
  67443. */
  67444. get output(): NodeMaterialConnectionPoint;
  67445. protected writeOutputs(state: NodeMaterialBuildState): string;
  67446. protected _buildBlock(state: NodeMaterialBuildState): this;
  67447. }
  67448. }
  67449. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67453. import { Effect } from "babylonjs/Materials/effect";
  67454. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67455. import { Mesh } from "babylonjs/Meshes/mesh";
  67456. /**
  67457. * Block used to get the screen sizes
  67458. */
  67459. export class ScreenSizeBlock extends NodeMaterialBlock {
  67460. private _varName;
  67461. private _scene;
  67462. /**
  67463. * Creates a new ScreenSizeBlock
  67464. * @param name defines the block name
  67465. */
  67466. constructor(name: string);
  67467. /**
  67468. * Gets the current class name
  67469. * @returns the class name
  67470. */
  67471. getClassName(): string;
  67472. /**
  67473. * Gets the xy component
  67474. */
  67475. get xy(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the x component
  67478. */
  67479. get x(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the y component
  67482. */
  67483. get y(): NodeMaterialConnectionPoint;
  67484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67485. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67486. protected _buildBlock(state: NodeMaterialBuildState): this;
  67487. }
  67488. }
  67489. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67490. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67491. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67492. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67493. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67494. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67495. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67496. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67497. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67498. }
  67499. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67502. import { Mesh } from "babylonjs/Meshes/mesh";
  67503. import { Effect } from "babylonjs/Materials/effect";
  67504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67506. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67508. /**
  67509. * Block used to add support for scene fog
  67510. */
  67511. export class FogBlock extends NodeMaterialBlock {
  67512. private _fogDistanceName;
  67513. private _fogParameters;
  67514. /**
  67515. * Create a new FogBlock
  67516. * @param name defines the block name
  67517. */
  67518. constructor(name: string);
  67519. /**
  67520. * Gets the current class name
  67521. * @returns the class name
  67522. */
  67523. getClassName(): string;
  67524. /**
  67525. * Gets the world position input component
  67526. */
  67527. get worldPosition(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the view input component
  67530. */
  67531. get view(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the color input component
  67534. */
  67535. get input(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the fog color input component
  67538. */
  67539. get fogColor(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the output component
  67542. */
  67543. get output(): NodeMaterialConnectionPoint;
  67544. autoConfigure(material: NodeMaterial): void;
  67545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67547. protected _buildBlock(state: NodeMaterialBuildState): this;
  67548. }
  67549. }
  67550. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67556. import { Effect } from "babylonjs/Materials/effect";
  67557. import { Mesh } from "babylonjs/Meshes/mesh";
  67558. import { Light } from "babylonjs/Lights/light";
  67559. import { Nullable } from "babylonjs/types";
  67560. import { Scene } from "babylonjs/scene";
  67561. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67562. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67565. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67566. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67567. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67568. /**
  67569. * Block used to add light in the fragment shader
  67570. */
  67571. export class LightBlock extends NodeMaterialBlock {
  67572. private _lightId;
  67573. /**
  67574. * Gets or sets the light associated with this block
  67575. */
  67576. light: Nullable<Light>;
  67577. /**
  67578. * Create a new LightBlock
  67579. * @param name defines the block name
  67580. */
  67581. constructor(name: string);
  67582. /**
  67583. * Gets the current class name
  67584. * @returns the class name
  67585. */
  67586. getClassName(): string;
  67587. /**
  67588. * Gets the world position input component
  67589. */
  67590. get worldPosition(): NodeMaterialConnectionPoint;
  67591. /**
  67592. * Gets the world normal input component
  67593. */
  67594. get worldNormal(): NodeMaterialConnectionPoint;
  67595. /**
  67596. * Gets the camera (or eye) position component
  67597. */
  67598. get cameraPosition(): NodeMaterialConnectionPoint;
  67599. /**
  67600. * Gets the glossiness component
  67601. */
  67602. get glossiness(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the glossinness power component
  67605. */
  67606. get glossPower(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the diffuse color component
  67609. */
  67610. get diffuseColor(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the specular color component
  67613. */
  67614. get specularColor(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the view matrix component
  67617. */
  67618. get view(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the diffuse output component
  67621. */
  67622. get diffuseOutput(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the specular output component
  67625. */
  67626. get specularOutput(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the shadow output component
  67629. */
  67630. get shadow(): NodeMaterialConnectionPoint;
  67631. autoConfigure(material: NodeMaterial): void;
  67632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67633. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67635. private _injectVertexCode;
  67636. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67637. serialize(): any;
  67638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67639. }
  67640. }
  67641. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67644. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67645. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67646. /**
  67647. * Block used to read a reflection texture from a sampler
  67648. */
  67649. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67650. /**
  67651. * Create a new ReflectionTextureBlock
  67652. * @param name defines the block name
  67653. */
  67654. constructor(name: string);
  67655. /**
  67656. * Gets the current class name
  67657. * @returns the class name
  67658. */
  67659. getClassName(): string;
  67660. /**
  67661. * Gets the world position input component
  67662. */
  67663. get position(): NodeMaterialConnectionPoint;
  67664. /**
  67665. * Gets the world position input component
  67666. */
  67667. get worldPosition(): NodeMaterialConnectionPoint;
  67668. /**
  67669. * Gets the world normal input component
  67670. */
  67671. get worldNormal(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the world input component
  67674. */
  67675. get world(): NodeMaterialConnectionPoint;
  67676. /**
  67677. * Gets the camera (or eye) position component
  67678. */
  67679. get cameraPosition(): NodeMaterialConnectionPoint;
  67680. /**
  67681. * Gets the view input component
  67682. */
  67683. get view(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the rgb output component
  67686. */
  67687. get rgb(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the rgba output component
  67690. */
  67691. get rgba(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the r output component
  67694. */
  67695. get r(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the g output component
  67698. */
  67699. get g(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Gets the b output component
  67702. */
  67703. get b(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the a output component
  67706. */
  67707. get a(): NodeMaterialConnectionPoint;
  67708. autoConfigure(material: NodeMaterial): void;
  67709. protected _buildBlock(state: NodeMaterialBuildState): this;
  67710. }
  67711. }
  67712. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67713. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67714. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67715. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67716. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67717. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67718. }
  67719. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67720. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67721. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67722. }
  67723. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67727. /**
  67728. * Block used to add 2 vectors
  67729. */
  67730. export class AddBlock extends NodeMaterialBlock {
  67731. /**
  67732. * Creates a new AddBlock
  67733. * @param name defines the block name
  67734. */
  67735. constructor(name: string);
  67736. /**
  67737. * Gets the current class name
  67738. * @returns the class name
  67739. */
  67740. getClassName(): string;
  67741. /**
  67742. * Gets the left operand input component
  67743. */
  67744. get left(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the right operand input component
  67747. */
  67748. get right(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the output component
  67751. */
  67752. get output(): NodeMaterialConnectionPoint;
  67753. protected _buildBlock(state: NodeMaterialBuildState): this;
  67754. }
  67755. }
  67756. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67760. /**
  67761. * Block used to scale a vector by a float
  67762. */
  67763. export class ScaleBlock extends NodeMaterialBlock {
  67764. /**
  67765. * Creates a new ScaleBlock
  67766. * @param name defines the block name
  67767. */
  67768. constructor(name: string);
  67769. /**
  67770. * Gets the current class name
  67771. * @returns the class name
  67772. */
  67773. getClassName(): string;
  67774. /**
  67775. * Gets the input component
  67776. */
  67777. get input(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the factor input component
  67780. */
  67781. get factor(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the output component
  67784. */
  67785. get output(): NodeMaterialConnectionPoint;
  67786. protected _buildBlock(state: NodeMaterialBuildState): this;
  67787. }
  67788. }
  67789. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67793. import { Scene } from "babylonjs/scene";
  67794. /**
  67795. * Block used to clamp a float
  67796. */
  67797. export class ClampBlock extends NodeMaterialBlock {
  67798. /** Gets or sets the minimum range */
  67799. minimum: number;
  67800. /** Gets or sets the maximum range */
  67801. maximum: number;
  67802. /**
  67803. * Creates a new ClampBlock
  67804. * @param name defines the block name
  67805. */
  67806. constructor(name: string);
  67807. /**
  67808. * Gets the current class name
  67809. * @returns the class name
  67810. */
  67811. getClassName(): string;
  67812. /**
  67813. * Gets the value input component
  67814. */
  67815. get value(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the output component
  67818. */
  67819. get output(): NodeMaterialConnectionPoint;
  67820. protected _buildBlock(state: NodeMaterialBuildState): this;
  67821. protected _dumpPropertiesCode(): string;
  67822. serialize(): any;
  67823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67824. }
  67825. }
  67826. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67830. /**
  67831. * Block used to apply a cross product between 2 vectors
  67832. */
  67833. export class CrossBlock extends NodeMaterialBlock {
  67834. /**
  67835. * Creates a new CrossBlock
  67836. * @param name defines the block name
  67837. */
  67838. constructor(name: string);
  67839. /**
  67840. * Gets the current class name
  67841. * @returns the class name
  67842. */
  67843. getClassName(): string;
  67844. /**
  67845. * Gets the left operand input component
  67846. */
  67847. get left(): NodeMaterialConnectionPoint;
  67848. /**
  67849. * Gets the right operand input component
  67850. */
  67851. get right(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the output component
  67854. */
  67855. get output(): NodeMaterialConnectionPoint;
  67856. protected _buildBlock(state: NodeMaterialBuildState): this;
  67857. }
  67858. }
  67859. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67863. /**
  67864. * Block used to apply a dot product between 2 vectors
  67865. */
  67866. export class DotBlock extends NodeMaterialBlock {
  67867. /**
  67868. * Creates a new DotBlock
  67869. * @param name defines the block name
  67870. */
  67871. constructor(name: string);
  67872. /**
  67873. * Gets the current class name
  67874. * @returns the class name
  67875. */
  67876. getClassName(): string;
  67877. /**
  67878. * Gets the left operand input component
  67879. */
  67880. get left(): NodeMaterialConnectionPoint;
  67881. /**
  67882. * Gets the right operand input component
  67883. */
  67884. get right(): NodeMaterialConnectionPoint;
  67885. /**
  67886. * Gets the output component
  67887. */
  67888. get output(): NodeMaterialConnectionPoint;
  67889. protected _buildBlock(state: NodeMaterialBuildState): this;
  67890. }
  67891. }
  67892. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67896. /**
  67897. * Block used to normalize a vector
  67898. */
  67899. export class NormalizeBlock extends NodeMaterialBlock {
  67900. /**
  67901. * Creates a new NormalizeBlock
  67902. * @param name defines the block name
  67903. */
  67904. constructor(name: string);
  67905. /**
  67906. * Gets the current class name
  67907. * @returns the class name
  67908. */
  67909. getClassName(): string;
  67910. /**
  67911. * Gets the input component
  67912. */
  67913. get input(): NodeMaterialConnectionPoint;
  67914. /**
  67915. * Gets the output component
  67916. */
  67917. get output(): NodeMaterialConnectionPoint;
  67918. protected _buildBlock(state: NodeMaterialBuildState): this;
  67919. }
  67920. }
  67921. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67925. /**
  67926. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67927. */
  67928. export class ColorMergerBlock extends NodeMaterialBlock {
  67929. /**
  67930. * Create a new ColorMergerBlock
  67931. * @param name defines the block name
  67932. */
  67933. constructor(name: string);
  67934. /**
  67935. * Gets the current class name
  67936. * @returns the class name
  67937. */
  67938. getClassName(): string;
  67939. /**
  67940. * Gets the rgb component (input)
  67941. */
  67942. get rgbIn(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the r component (input)
  67945. */
  67946. get r(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the g component (input)
  67949. */
  67950. get g(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the b component (input)
  67953. */
  67954. get b(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the a component (input)
  67957. */
  67958. get a(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the rgba component (output)
  67961. */
  67962. get rgba(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the rgb component (output)
  67965. */
  67966. get rgbOut(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the rgb component (output)
  67969. * @deprecated Please use rgbOut instead.
  67970. */
  67971. get rgb(): NodeMaterialConnectionPoint;
  67972. protected _buildBlock(state: NodeMaterialBuildState): this;
  67973. }
  67974. }
  67975. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67979. /**
  67980. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67981. */
  67982. export class VectorSplitterBlock extends NodeMaterialBlock {
  67983. /**
  67984. * Create a new VectorSplitterBlock
  67985. * @param name defines the block name
  67986. */
  67987. constructor(name: string);
  67988. /**
  67989. * Gets the current class name
  67990. * @returns the class name
  67991. */
  67992. getClassName(): string;
  67993. /**
  67994. * Gets the xyzw component (input)
  67995. */
  67996. get xyzw(): NodeMaterialConnectionPoint;
  67997. /**
  67998. * Gets the xyz component (input)
  67999. */
  68000. get xyzIn(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the xy component (input)
  68003. */
  68004. get xyIn(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the xyz component (output)
  68007. */
  68008. get xyzOut(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the xy component (output)
  68011. */
  68012. get xyOut(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the x component (output)
  68015. */
  68016. get x(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the y component (output)
  68019. */
  68020. get y(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the z component (output)
  68023. */
  68024. get z(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the w component (output)
  68027. */
  68028. get w(): NodeMaterialConnectionPoint;
  68029. protected _inputRename(name: string): string;
  68030. protected _outputRename(name: string): string;
  68031. protected _buildBlock(state: NodeMaterialBuildState): this;
  68032. }
  68033. }
  68034. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  68035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68038. /**
  68039. * Block used to lerp between 2 values
  68040. */
  68041. export class LerpBlock extends NodeMaterialBlock {
  68042. /**
  68043. * Creates a new LerpBlock
  68044. * @param name defines the block name
  68045. */
  68046. constructor(name: string);
  68047. /**
  68048. * Gets the current class name
  68049. * @returns the class name
  68050. */
  68051. getClassName(): string;
  68052. /**
  68053. * Gets the left operand input component
  68054. */
  68055. get left(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the right operand input component
  68058. */
  68059. get right(): NodeMaterialConnectionPoint;
  68060. /**
  68061. * Gets the gradient operand input component
  68062. */
  68063. get gradient(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the output component
  68066. */
  68067. get output(): NodeMaterialConnectionPoint;
  68068. protected _buildBlock(state: NodeMaterialBuildState): this;
  68069. }
  68070. }
  68071. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  68072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68075. /**
  68076. * Block used to divide 2 vectors
  68077. */
  68078. export class DivideBlock extends NodeMaterialBlock {
  68079. /**
  68080. * Creates a new DivideBlock
  68081. * @param name defines the block name
  68082. */
  68083. constructor(name: string);
  68084. /**
  68085. * Gets the current class name
  68086. * @returns the class name
  68087. */
  68088. getClassName(): string;
  68089. /**
  68090. * Gets the left operand input component
  68091. */
  68092. get left(): NodeMaterialConnectionPoint;
  68093. /**
  68094. * Gets the right operand input component
  68095. */
  68096. get right(): NodeMaterialConnectionPoint;
  68097. /**
  68098. * Gets the output component
  68099. */
  68100. get output(): NodeMaterialConnectionPoint;
  68101. protected _buildBlock(state: NodeMaterialBuildState): this;
  68102. }
  68103. }
  68104. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  68105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68108. /**
  68109. * Block used to subtract 2 vectors
  68110. */
  68111. export class SubtractBlock extends NodeMaterialBlock {
  68112. /**
  68113. * Creates a new SubtractBlock
  68114. * @param name defines the block name
  68115. */
  68116. constructor(name: string);
  68117. /**
  68118. * Gets the current class name
  68119. * @returns the class name
  68120. */
  68121. getClassName(): string;
  68122. /**
  68123. * Gets the left operand input component
  68124. */
  68125. get left(): NodeMaterialConnectionPoint;
  68126. /**
  68127. * Gets the right operand input component
  68128. */
  68129. get right(): NodeMaterialConnectionPoint;
  68130. /**
  68131. * Gets the output component
  68132. */
  68133. get output(): NodeMaterialConnectionPoint;
  68134. protected _buildBlock(state: NodeMaterialBuildState): this;
  68135. }
  68136. }
  68137. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68141. /**
  68142. * Block used to step a value
  68143. */
  68144. export class StepBlock extends NodeMaterialBlock {
  68145. /**
  68146. * Creates a new StepBlock
  68147. * @param name defines the block name
  68148. */
  68149. constructor(name: string);
  68150. /**
  68151. * Gets the current class name
  68152. * @returns the class name
  68153. */
  68154. getClassName(): string;
  68155. /**
  68156. * Gets the value operand input component
  68157. */
  68158. get value(): NodeMaterialConnectionPoint;
  68159. /**
  68160. * Gets the edge operand input component
  68161. */
  68162. get edge(): NodeMaterialConnectionPoint;
  68163. /**
  68164. * Gets the output component
  68165. */
  68166. get output(): NodeMaterialConnectionPoint;
  68167. protected _buildBlock(state: NodeMaterialBuildState): this;
  68168. }
  68169. }
  68170. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68174. /**
  68175. * Block used to get the opposite (1 - x) of a value
  68176. */
  68177. export class OneMinusBlock extends NodeMaterialBlock {
  68178. /**
  68179. * Creates a new OneMinusBlock
  68180. * @param name defines the block name
  68181. */
  68182. constructor(name: string);
  68183. /**
  68184. * Gets the current class name
  68185. * @returns the class name
  68186. */
  68187. getClassName(): string;
  68188. /**
  68189. * Gets the input component
  68190. */
  68191. get input(): NodeMaterialConnectionPoint;
  68192. /**
  68193. * Gets the output component
  68194. */
  68195. get output(): NodeMaterialConnectionPoint;
  68196. protected _buildBlock(state: NodeMaterialBuildState): this;
  68197. }
  68198. }
  68199. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68203. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68204. /**
  68205. * Block used to get the view direction
  68206. */
  68207. export class ViewDirectionBlock extends NodeMaterialBlock {
  68208. /**
  68209. * Creates a new ViewDirectionBlock
  68210. * @param name defines the block name
  68211. */
  68212. constructor(name: string);
  68213. /**
  68214. * Gets the current class name
  68215. * @returns the class name
  68216. */
  68217. getClassName(): string;
  68218. /**
  68219. * Gets the world position component
  68220. */
  68221. get worldPosition(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the camera position component
  68224. */
  68225. get cameraPosition(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the output component
  68228. */
  68229. get output(): NodeMaterialConnectionPoint;
  68230. autoConfigure(material: NodeMaterial): void;
  68231. protected _buildBlock(state: NodeMaterialBuildState): this;
  68232. }
  68233. }
  68234. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68238. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68239. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68240. /**
  68241. * Block used to compute fresnel value
  68242. */
  68243. export class FresnelBlock extends NodeMaterialBlock {
  68244. /**
  68245. * Create a new FresnelBlock
  68246. * @param name defines the block name
  68247. */
  68248. constructor(name: string);
  68249. /**
  68250. * Gets the current class name
  68251. * @returns the class name
  68252. */
  68253. getClassName(): string;
  68254. /**
  68255. * Gets the world normal input component
  68256. */
  68257. get worldNormal(): NodeMaterialConnectionPoint;
  68258. /**
  68259. * Gets the view direction input component
  68260. */
  68261. get viewDirection(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the bias input component
  68264. */
  68265. get bias(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the camera (or eye) position component
  68268. */
  68269. get power(): NodeMaterialConnectionPoint;
  68270. /**
  68271. * Gets the fresnel output component
  68272. */
  68273. get fresnel(): NodeMaterialConnectionPoint;
  68274. autoConfigure(material: NodeMaterial): void;
  68275. protected _buildBlock(state: NodeMaterialBuildState): this;
  68276. }
  68277. }
  68278. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68282. /**
  68283. * Block used to get the max of 2 values
  68284. */
  68285. export class MaxBlock extends NodeMaterialBlock {
  68286. /**
  68287. * Creates a new MaxBlock
  68288. * @param name defines the block name
  68289. */
  68290. constructor(name: string);
  68291. /**
  68292. * Gets the current class name
  68293. * @returns the class name
  68294. */
  68295. getClassName(): string;
  68296. /**
  68297. * Gets the left operand input component
  68298. */
  68299. get left(): NodeMaterialConnectionPoint;
  68300. /**
  68301. * Gets the right operand input component
  68302. */
  68303. get right(): NodeMaterialConnectionPoint;
  68304. /**
  68305. * Gets the output component
  68306. */
  68307. get output(): NodeMaterialConnectionPoint;
  68308. protected _buildBlock(state: NodeMaterialBuildState): this;
  68309. }
  68310. }
  68311. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68315. /**
  68316. * Block used to get the min of 2 values
  68317. */
  68318. export class MinBlock extends NodeMaterialBlock {
  68319. /**
  68320. * Creates a new MinBlock
  68321. * @param name defines the block name
  68322. */
  68323. constructor(name: string);
  68324. /**
  68325. * Gets the current class name
  68326. * @returns the class name
  68327. */
  68328. getClassName(): string;
  68329. /**
  68330. * Gets the left operand input component
  68331. */
  68332. get left(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the right operand input component
  68335. */
  68336. get right(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the output component
  68339. */
  68340. get output(): NodeMaterialConnectionPoint;
  68341. protected _buildBlock(state: NodeMaterialBuildState): this;
  68342. }
  68343. }
  68344. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68348. /**
  68349. * Block used to get the distance between 2 values
  68350. */
  68351. export class DistanceBlock extends NodeMaterialBlock {
  68352. /**
  68353. * Creates a new DistanceBlock
  68354. * @param name defines the block name
  68355. */
  68356. constructor(name: string);
  68357. /**
  68358. * Gets the current class name
  68359. * @returns the class name
  68360. */
  68361. getClassName(): string;
  68362. /**
  68363. * Gets the left operand input component
  68364. */
  68365. get left(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the right operand input component
  68368. */
  68369. get right(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the output component
  68372. */
  68373. get output(): NodeMaterialConnectionPoint;
  68374. protected _buildBlock(state: NodeMaterialBuildState): this;
  68375. }
  68376. }
  68377. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68381. /**
  68382. * Block used to get the length of a vector
  68383. */
  68384. export class LengthBlock extends NodeMaterialBlock {
  68385. /**
  68386. * Creates a new LengthBlock
  68387. * @param name defines the block name
  68388. */
  68389. constructor(name: string);
  68390. /**
  68391. * Gets the current class name
  68392. * @returns the class name
  68393. */
  68394. getClassName(): string;
  68395. /**
  68396. * Gets the value input component
  68397. */
  68398. get value(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the output component
  68401. */
  68402. get output(): NodeMaterialConnectionPoint;
  68403. protected _buildBlock(state: NodeMaterialBuildState): this;
  68404. }
  68405. }
  68406. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68410. /**
  68411. * Block used to get negative version of a value (i.e. x * -1)
  68412. */
  68413. export class NegateBlock extends NodeMaterialBlock {
  68414. /**
  68415. * Creates a new NegateBlock
  68416. * @param name defines the block name
  68417. */
  68418. constructor(name: string);
  68419. /**
  68420. * Gets the current class name
  68421. * @returns the class name
  68422. */
  68423. getClassName(): string;
  68424. /**
  68425. * Gets the value input component
  68426. */
  68427. get value(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the output component
  68430. */
  68431. get output(): NodeMaterialConnectionPoint;
  68432. protected _buildBlock(state: NodeMaterialBuildState): this;
  68433. }
  68434. }
  68435. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68439. /**
  68440. * Block used to get the value of the first parameter raised to the power of the second
  68441. */
  68442. export class PowBlock extends NodeMaterialBlock {
  68443. /**
  68444. * Creates a new PowBlock
  68445. * @param name defines the block name
  68446. */
  68447. constructor(name: string);
  68448. /**
  68449. * Gets the current class name
  68450. * @returns the class name
  68451. */
  68452. getClassName(): string;
  68453. /**
  68454. * Gets the value operand input component
  68455. */
  68456. get value(): NodeMaterialConnectionPoint;
  68457. /**
  68458. * Gets the power operand input component
  68459. */
  68460. get power(): NodeMaterialConnectionPoint;
  68461. /**
  68462. * Gets the output component
  68463. */
  68464. get output(): NodeMaterialConnectionPoint;
  68465. protected _buildBlock(state: NodeMaterialBuildState): this;
  68466. }
  68467. }
  68468. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68472. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68473. /**
  68474. * Block used to get a random number
  68475. */
  68476. export class RandomNumberBlock extends NodeMaterialBlock {
  68477. /**
  68478. * Creates a new RandomNumberBlock
  68479. * @param name defines the block name
  68480. */
  68481. constructor(name: string);
  68482. /**
  68483. * Gets the current class name
  68484. * @returns the class name
  68485. */
  68486. getClassName(): string;
  68487. /**
  68488. * Gets the seed input component
  68489. */
  68490. get seed(): NodeMaterialConnectionPoint;
  68491. /**
  68492. * Gets the output component
  68493. */
  68494. get output(): NodeMaterialConnectionPoint;
  68495. protected _buildBlock(state: NodeMaterialBuildState): this;
  68496. }
  68497. }
  68498. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68502. /**
  68503. * Block used to compute arc tangent of 2 values
  68504. */
  68505. export class ArcTan2Block extends NodeMaterialBlock {
  68506. /**
  68507. * Creates a new ArcTan2Block
  68508. * @param name defines the block name
  68509. */
  68510. constructor(name: string);
  68511. /**
  68512. * Gets the current class name
  68513. * @returns the class name
  68514. */
  68515. getClassName(): string;
  68516. /**
  68517. * Gets the x operand input component
  68518. */
  68519. get x(): NodeMaterialConnectionPoint;
  68520. /**
  68521. * Gets the y operand input component
  68522. */
  68523. get y(): NodeMaterialConnectionPoint;
  68524. /**
  68525. * Gets the output component
  68526. */
  68527. get output(): NodeMaterialConnectionPoint;
  68528. protected _buildBlock(state: NodeMaterialBuildState): this;
  68529. }
  68530. }
  68531. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68535. /**
  68536. * Block used to smooth step a value
  68537. */
  68538. export class SmoothStepBlock extends NodeMaterialBlock {
  68539. /**
  68540. * Creates a new SmoothStepBlock
  68541. * @param name defines the block name
  68542. */
  68543. constructor(name: string);
  68544. /**
  68545. * Gets the current class name
  68546. * @returns the class name
  68547. */
  68548. getClassName(): string;
  68549. /**
  68550. * Gets the value operand input component
  68551. */
  68552. get value(): NodeMaterialConnectionPoint;
  68553. /**
  68554. * Gets the first edge operand input component
  68555. */
  68556. get edge0(): NodeMaterialConnectionPoint;
  68557. /**
  68558. * Gets the second edge operand input component
  68559. */
  68560. get edge1(): NodeMaterialConnectionPoint;
  68561. /**
  68562. * Gets the output component
  68563. */
  68564. get output(): NodeMaterialConnectionPoint;
  68565. protected _buildBlock(state: NodeMaterialBuildState): this;
  68566. }
  68567. }
  68568. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68572. /**
  68573. * Block used to get the reciprocal (1 / x) of a value
  68574. */
  68575. export class ReciprocalBlock extends NodeMaterialBlock {
  68576. /**
  68577. * Creates a new ReciprocalBlock
  68578. * @param name defines the block name
  68579. */
  68580. constructor(name: string);
  68581. /**
  68582. * Gets the current class name
  68583. * @returns the class name
  68584. */
  68585. getClassName(): string;
  68586. /**
  68587. * Gets the input component
  68588. */
  68589. get input(): NodeMaterialConnectionPoint;
  68590. /**
  68591. * Gets the output component
  68592. */
  68593. get output(): NodeMaterialConnectionPoint;
  68594. protected _buildBlock(state: NodeMaterialBuildState): this;
  68595. }
  68596. }
  68597. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68601. /**
  68602. * Block used to replace a color by another one
  68603. */
  68604. export class ReplaceColorBlock extends NodeMaterialBlock {
  68605. /**
  68606. * Creates a new ReplaceColorBlock
  68607. * @param name defines the block name
  68608. */
  68609. constructor(name: string);
  68610. /**
  68611. * Gets the current class name
  68612. * @returns the class name
  68613. */
  68614. getClassName(): string;
  68615. /**
  68616. * Gets the value input component
  68617. */
  68618. get value(): NodeMaterialConnectionPoint;
  68619. /**
  68620. * Gets the reference input component
  68621. */
  68622. get reference(): NodeMaterialConnectionPoint;
  68623. /**
  68624. * Gets the distance input component
  68625. */
  68626. get distance(): NodeMaterialConnectionPoint;
  68627. /**
  68628. * Gets the replacement input component
  68629. */
  68630. get replacement(): NodeMaterialConnectionPoint;
  68631. /**
  68632. * Gets the output component
  68633. */
  68634. get output(): NodeMaterialConnectionPoint;
  68635. protected _buildBlock(state: NodeMaterialBuildState): this;
  68636. }
  68637. }
  68638. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68642. /**
  68643. * Block used to posterize a value
  68644. * @see https://en.wikipedia.org/wiki/Posterization
  68645. */
  68646. export class PosterizeBlock extends NodeMaterialBlock {
  68647. /**
  68648. * Creates a new PosterizeBlock
  68649. * @param name defines the block name
  68650. */
  68651. constructor(name: string);
  68652. /**
  68653. * Gets the current class name
  68654. * @returns the class name
  68655. */
  68656. getClassName(): string;
  68657. /**
  68658. * Gets the value input component
  68659. */
  68660. get value(): NodeMaterialConnectionPoint;
  68661. /**
  68662. * Gets the steps input component
  68663. */
  68664. get steps(): NodeMaterialConnectionPoint;
  68665. /**
  68666. * Gets the output component
  68667. */
  68668. get output(): NodeMaterialConnectionPoint;
  68669. protected _buildBlock(state: NodeMaterialBuildState): this;
  68670. }
  68671. }
  68672. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68676. import { Scene } from "babylonjs/scene";
  68677. /**
  68678. * Operations supported by the Wave block
  68679. */
  68680. export enum WaveBlockKind {
  68681. /** SawTooth */
  68682. SawTooth = 0,
  68683. /** Square */
  68684. Square = 1,
  68685. /** Triangle */
  68686. Triangle = 2
  68687. }
  68688. /**
  68689. * Block used to apply wave operation to floats
  68690. */
  68691. export class WaveBlock extends NodeMaterialBlock {
  68692. /**
  68693. * Gets or sets the kibnd of wave to be applied by the block
  68694. */
  68695. kind: WaveBlockKind;
  68696. /**
  68697. * Creates a new WaveBlock
  68698. * @param name defines the block name
  68699. */
  68700. constructor(name: string);
  68701. /**
  68702. * Gets the current class name
  68703. * @returns the class name
  68704. */
  68705. getClassName(): string;
  68706. /**
  68707. * Gets the input component
  68708. */
  68709. get input(): NodeMaterialConnectionPoint;
  68710. /**
  68711. * Gets the output component
  68712. */
  68713. get output(): NodeMaterialConnectionPoint;
  68714. protected _buildBlock(state: NodeMaterialBuildState): this;
  68715. serialize(): any;
  68716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68717. }
  68718. }
  68719. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68723. import { Color3 } from "babylonjs/Maths/math.color";
  68724. import { Scene } from "babylonjs/scene";
  68725. import { Observable } from "babylonjs/Misc/observable";
  68726. /**
  68727. * Class used to store a color step for the GradientBlock
  68728. */
  68729. export class GradientBlockColorStep {
  68730. private _step;
  68731. /**
  68732. * Gets value indicating which step this color is associated with (between 0 and 1)
  68733. */
  68734. get step(): number;
  68735. /**
  68736. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68737. */
  68738. set step(val: number);
  68739. private _color;
  68740. /**
  68741. * Gets the color associated with this step
  68742. */
  68743. get color(): Color3;
  68744. /**
  68745. * Sets the color associated with this step
  68746. */
  68747. set color(val: Color3);
  68748. /**
  68749. * Creates a new GradientBlockColorStep
  68750. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68751. * @param color defines the color associated with this step
  68752. */
  68753. constructor(step: number, color: Color3);
  68754. }
  68755. /**
  68756. * Block used to return a color from a gradient based on an input value between 0 and 1
  68757. */
  68758. export class GradientBlock extends NodeMaterialBlock {
  68759. /**
  68760. * Gets or sets the list of color steps
  68761. */
  68762. colorSteps: GradientBlockColorStep[];
  68763. /** Gets an observable raised when the value is changed */
  68764. onValueChangedObservable: Observable<GradientBlock>;
  68765. /** calls observable when the value is changed*/
  68766. colorStepsUpdated(): void;
  68767. /**
  68768. * Creates a new GradientBlock
  68769. * @param name defines the block name
  68770. */
  68771. constructor(name: string);
  68772. /**
  68773. * Gets the current class name
  68774. * @returns the class name
  68775. */
  68776. getClassName(): string;
  68777. /**
  68778. * Gets the gradient input component
  68779. */
  68780. get gradient(): NodeMaterialConnectionPoint;
  68781. /**
  68782. * Gets the output component
  68783. */
  68784. get output(): NodeMaterialConnectionPoint;
  68785. private _writeColorConstant;
  68786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68787. serialize(): any;
  68788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68789. protected _dumpPropertiesCode(): string;
  68790. }
  68791. }
  68792. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68796. /**
  68797. * Block used to normalize lerp between 2 values
  68798. */
  68799. export class NLerpBlock extends NodeMaterialBlock {
  68800. /**
  68801. * Creates a new NLerpBlock
  68802. * @param name defines the block name
  68803. */
  68804. constructor(name: string);
  68805. /**
  68806. * Gets the current class name
  68807. * @returns the class name
  68808. */
  68809. getClassName(): string;
  68810. /**
  68811. * Gets the left operand input component
  68812. */
  68813. get left(): NodeMaterialConnectionPoint;
  68814. /**
  68815. * Gets the right operand input component
  68816. */
  68817. get right(): NodeMaterialConnectionPoint;
  68818. /**
  68819. * Gets the gradient operand input component
  68820. */
  68821. get gradient(): NodeMaterialConnectionPoint;
  68822. /**
  68823. * Gets the output component
  68824. */
  68825. get output(): NodeMaterialConnectionPoint;
  68826. protected _buildBlock(state: NodeMaterialBuildState): this;
  68827. }
  68828. }
  68829. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68833. import { Scene } from "babylonjs/scene";
  68834. /**
  68835. * block used to Generate a Worley Noise 3D Noise Pattern
  68836. */
  68837. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68838. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68839. manhattanDistance: boolean;
  68840. /**
  68841. * Creates a new WorleyNoise3DBlock
  68842. * @param name defines the block name
  68843. */
  68844. constructor(name: string);
  68845. /**
  68846. * Gets the current class name
  68847. * @returns the class name
  68848. */
  68849. getClassName(): string;
  68850. /**
  68851. * Gets the seed input component
  68852. */
  68853. get seed(): NodeMaterialConnectionPoint;
  68854. /**
  68855. * Gets the jitter input component
  68856. */
  68857. get jitter(): NodeMaterialConnectionPoint;
  68858. /**
  68859. * Gets the output component
  68860. */
  68861. get output(): NodeMaterialConnectionPoint;
  68862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68863. /**
  68864. * Exposes the properties to the UI?
  68865. */
  68866. protected _dumpPropertiesCode(): string;
  68867. /**
  68868. * Exposes the properties to the Seralize?
  68869. */
  68870. serialize(): any;
  68871. /**
  68872. * Exposes the properties to the deseralize?
  68873. */
  68874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68875. }
  68876. }
  68877. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68881. /**
  68882. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68883. */
  68884. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68885. /**
  68886. * Creates a new SimplexPerlin3DBlock
  68887. * @param name defines the block name
  68888. */
  68889. constructor(name: string);
  68890. /**
  68891. * Gets the current class name
  68892. * @returns the class name
  68893. */
  68894. getClassName(): string;
  68895. /**
  68896. * Gets the seed operand input component
  68897. */
  68898. get seed(): NodeMaterialConnectionPoint;
  68899. /**
  68900. * Gets the output component
  68901. */
  68902. get output(): NodeMaterialConnectionPoint;
  68903. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68904. }
  68905. }
  68906. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68910. /**
  68911. * Block used to blend normals
  68912. */
  68913. export class NormalBlendBlock extends NodeMaterialBlock {
  68914. /**
  68915. * Creates a new NormalBlendBlock
  68916. * @param name defines the block name
  68917. */
  68918. constructor(name: string);
  68919. /**
  68920. * Gets the current class name
  68921. * @returns the class name
  68922. */
  68923. getClassName(): string;
  68924. /**
  68925. * Gets the first input component
  68926. */
  68927. get normalMap0(): NodeMaterialConnectionPoint;
  68928. /**
  68929. * Gets the second input component
  68930. */
  68931. get normalMap1(): NodeMaterialConnectionPoint;
  68932. /**
  68933. * Gets the output component
  68934. */
  68935. get output(): NodeMaterialConnectionPoint;
  68936. protected _buildBlock(state: NodeMaterialBuildState): this;
  68937. }
  68938. }
  68939. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68943. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68944. /**
  68945. * Block used to rotate a 2d vector by a given angle
  68946. */
  68947. export class Rotate2dBlock extends NodeMaterialBlock {
  68948. /**
  68949. * Creates a new Rotate2dBlock
  68950. * @param name defines the block name
  68951. */
  68952. constructor(name: string);
  68953. /**
  68954. * Gets the current class name
  68955. * @returns the class name
  68956. */
  68957. getClassName(): string;
  68958. /**
  68959. * Gets the input vector
  68960. */
  68961. get input(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the input angle
  68964. */
  68965. get angle(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the output component
  68968. */
  68969. get output(): NodeMaterialConnectionPoint;
  68970. autoConfigure(material: NodeMaterial): void;
  68971. protected _buildBlock(state: NodeMaterialBuildState): this;
  68972. }
  68973. }
  68974. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68978. /**
  68979. * Block used to get the reflected vector from a direction and a normal
  68980. */
  68981. export class ReflectBlock extends NodeMaterialBlock {
  68982. /**
  68983. * Creates a new ReflectBlock
  68984. * @param name defines the block name
  68985. */
  68986. constructor(name: string);
  68987. /**
  68988. * Gets the current class name
  68989. * @returns the class name
  68990. */
  68991. getClassName(): string;
  68992. /**
  68993. * Gets the incident component
  68994. */
  68995. get incident(): NodeMaterialConnectionPoint;
  68996. /**
  68997. * Gets the normal component
  68998. */
  68999. get normal(): NodeMaterialConnectionPoint;
  69000. /**
  69001. * Gets the output component
  69002. */
  69003. get output(): NodeMaterialConnectionPoint;
  69004. protected _buildBlock(state: NodeMaterialBuildState): this;
  69005. }
  69006. }
  69007. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  69008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69011. /**
  69012. * Block used to get the refracted vector from a direction and a normal
  69013. */
  69014. export class RefractBlock extends NodeMaterialBlock {
  69015. /**
  69016. * Creates a new RefractBlock
  69017. * @param name defines the block name
  69018. */
  69019. constructor(name: string);
  69020. /**
  69021. * Gets the current class name
  69022. * @returns the class name
  69023. */
  69024. getClassName(): string;
  69025. /**
  69026. * Gets the incident component
  69027. */
  69028. get incident(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the normal component
  69031. */
  69032. get normal(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the index of refraction component
  69035. */
  69036. get ior(): NodeMaterialConnectionPoint;
  69037. /**
  69038. * Gets the output component
  69039. */
  69040. get output(): NodeMaterialConnectionPoint;
  69041. protected _buildBlock(state: NodeMaterialBuildState): this;
  69042. }
  69043. }
  69044. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  69045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69048. /**
  69049. * Block used to desaturate a color
  69050. */
  69051. export class DesaturateBlock extends NodeMaterialBlock {
  69052. /**
  69053. * Creates a new DesaturateBlock
  69054. * @param name defines the block name
  69055. */
  69056. constructor(name: string);
  69057. /**
  69058. * Gets the current class name
  69059. * @returns the class name
  69060. */
  69061. getClassName(): string;
  69062. /**
  69063. * Gets the color operand input component
  69064. */
  69065. get color(): NodeMaterialConnectionPoint;
  69066. /**
  69067. * Gets the level operand input component
  69068. */
  69069. get level(): NodeMaterialConnectionPoint;
  69070. /**
  69071. * Gets the output component
  69072. */
  69073. get output(): NodeMaterialConnectionPoint;
  69074. protected _buildBlock(state: NodeMaterialBuildState): this;
  69075. }
  69076. }
  69077. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  69078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69081. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  69082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69083. import { Nullable } from "babylonjs/types";
  69084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69085. import { Mesh } from "babylonjs/Meshes/mesh";
  69086. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69087. import { Effect } from "babylonjs/Materials/effect";
  69088. import { Scene } from "babylonjs/scene";
  69089. /**
  69090. * Block used to implement the reflection module of the PBR material
  69091. */
  69092. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69093. /** @hidden */
  69094. _defineLODReflectionAlpha: string;
  69095. /** @hidden */
  69096. _defineLinearSpecularReflection: string;
  69097. private _vEnvironmentIrradianceName;
  69098. /** @hidden */
  69099. _vReflectionMicrosurfaceInfosName: string;
  69100. /** @hidden */
  69101. _vReflectionInfosName: string;
  69102. /** @hidden */
  69103. _vReflectionFilteringInfoName: string;
  69104. private _scene;
  69105. /**
  69106. * The properties below are set by the main PBR block prior to calling methods of this class.
  69107. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69108. * It's less burden on the user side in the editor part.
  69109. */
  69110. /** @hidden */
  69111. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69112. /** @hidden */
  69113. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69114. /** @hidden */
  69115. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69116. /** @hidden */
  69117. viewConnectionPoint: NodeMaterialConnectionPoint;
  69118. /**
  69119. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69120. * diffuse part of the IBL.
  69121. */
  69122. useSphericalHarmonics: boolean;
  69123. /**
  69124. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69125. */
  69126. forceIrradianceInFragment: boolean;
  69127. /**
  69128. * Create a new ReflectionBlock
  69129. * @param name defines the block name
  69130. */
  69131. constructor(name: string);
  69132. /**
  69133. * Gets the current class name
  69134. * @returns the class name
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * Gets the position input component
  69139. */
  69140. get position(): NodeMaterialConnectionPoint;
  69141. /**
  69142. * Gets the world position input component
  69143. */
  69144. get worldPosition(): NodeMaterialConnectionPoint;
  69145. /**
  69146. * Gets the world normal input component
  69147. */
  69148. get worldNormal(): NodeMaterialConnectionPoint;
  69149. /**
  69150. * Gets the world input component
  69151. */
  69152. get world(): NodeMaterialConnectionPoint;
  69153. /**
  69154. * Gets the camera (or eye) position component
  69155. */
  69156. get cameraPosition(): NodeMaterialConnectionPoint;
  69157. /**
  69158. * Gets the view input component
  69159. */
  69160. get view(): NodeMaterialConnectionPoint;
  69161. /**
  69162. * Gets the color input component
  69163. */
  69164. get color(): NodeMaterialConnectionPoint;
  69165. /**
  69166. * Gets the reflection object output component
  69167. */
  69168. get reflection(): NodeMaterialConnectionPoint;
  69169. /**
  69170. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69171. */
  69172. get hasTexture(): boolean;
  69173. /**
  69174. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69175. */
  69176. get reflectionColor(): string;
  69177. protected _getTexture(): Nullable<BaseTexture>;
  69178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69180. /**
  69181. * Gets the code to inject in the vertex shader
  69182. * @param state current state of the node material building
  69183. * @returns the shader code
  69184. */
  69185. handleVertexSide(state: NodeMaterialBuildState): string;
  69186. /**
  69187. * Gets the main code of the block (fragment side)
  69188. * @param state current state of the node material building
  69189. * @param normalVarName name of the existing variable corresponding to the normal
  69190. * @returns the shader code
  69191. */
  69192. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69193. protected _buildBlock(state: NodeMaterialBuildState): this;
  69194. protected _dumpPropertiesCode(): string;
  69195. serialize(): any;
  69196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69197. }
  69198. }
  69199. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69203. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69205. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69206. import { Scene } from "babylonjs/scene";
  69207. import { Nullable } from "babylonjs/types";
  69208. /**
  69209. * Block used to implement the sheen module of the PBR material
  69210. */
  69211. export class SheenBlock extends NodeMaterialBlock {
  69212. /**
  69213. * Create a new SheenBlock
  69214. * @param name defines the block name
  69215. */
  69216. constructor(name: string);
  69217. /**
  69218. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69219. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69220. * making it easier to setup and tweak the effect
  69221. */
  69222. albedoScaling: boolean;
  69223. /**
  69224. * Defines if the sheen is linked to the sheen color.
  69225. */
  69226. linkSheenWithAlbedo: boolean;
  69227. /**
  69228. * Initialize the block and prepare the context for build
  69229. * @param state defines the state that will be used for the build
  69230. */
  69231. initialize(state: NodeMaterialBuildState): void;
  69232. /**
  69233. * Gets the current class name
  69234. * @returns the class name
  69235. */
  69236. getClassName(): string;
  69237. /**
  69238. * Gets the intensity input component
  69239. */
  69240. get intensity(): NodeMaterialConnectionPoint;
  69241. /**
  69242. * Gets the color input component
  69243. */
  69244. get color(): NodeMaterialConnectionPoint;
  69245. /**
  69246. * Gets the roughness input component
  69247. */
  69248. get roughness(): NodeMaterialConnectionPoint;
  69249. /**
  69250. * Gets the sheen object output component
  69251. */
  69252. get sheen(): NodeMaterialConnectionPoint;
  69253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69254. /**
  69255. * Gets the main code of the block (fragment side)
  69256. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69257. * @returns the shader code
  69258. */
  69259. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69260. protected _buildBlock(state: NodeMaterialBuildState): this;
  69261. protected _dumpPropertiesCode(): string;
  69262. serialize(): any;
  69263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69264. }
  69265. }
  69266. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69267. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69272. /**
  69273. * Block used to implement the anisotropy module of the PBR material
  69274. */
  69275. export class AnisotropyBlock extends NodeMaterialBlock {
  69276. /**
  69277. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69278. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69279. * It's less burden on the user side in the editor part.
  69280. */
  69281. /** @hidden */
  69282. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69283. /** @hidden */
  69284. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69285. /**
  69286. * Create a new AnisotropyBlock
  69287. * @param name defines the block name
  69288. */
  69289. constructor(name: string);
  69290. /**
  69291. * Initialize the block and prepare the context for build
  69292. * @param state defines the state that will be used for the build
  69293. */
  69294. initialize(state: NodeMaterialBuildState): void;
  69295. /**
  69296. * Gets the current class name
  69297. * @returns the class name
  69298. */
  69299. getClassName(): string;
  69300. /**
  69301. * Gets the intensity input component
  69302. */
  69303. get intensity(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the direction input component
  69306. */
  69307. get direction(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the uv input component
  69310. */
  69311. get uv(): NodeMaterialConnectionPoint;
  69312. /**
  69313. * Gets the worldTangent input component
  69314. */
  69315. get worldTangent(): NodeMaterialConnectionPoint;
  69316. /**
  69317. * Gets the anisotropy object output component
  69318. */
  69319. get anisotropy(): NodeMaterialConnectionPoint;
  69320. private _generateTBNSpace;
  69321. /**
  69322. * Gets the main code of the block (fragment side)
  69323. * @param state current state of the node material building
  69324. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69325. * @returns the shader code
  69326. */
  69327. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69329. protected _buildBlock(state: NodeMaterialBuildState): this;
  69330. }
  69331. }
  69332. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69336. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69338. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69339. import { Scene } from "babylonjs/scene";
  69340. import { Nullable } from "babylonjs/types";
  69341. import { Mesh } from "babylonjs/Meshes/mesh";
  69342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69343. import { Effect } from "babylonjs/Materials/effect";
  69344. /**
  69345. * Block used to implement the clear coat module of the PBR material
  69346. */
  69347. export class ClearCoatBlock extends NodeMaterialBlock {
  69348. private _scene;
  69349. /**
  69350. * Create a new ClearCoatBlock
  69351. * @param name defines the block name
  69352. */
  69353. constructor(name: string);
  69354. /**
  69355. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69356. */
  69357. remapF0OnInterfaceChange: boolean;
  69358. /**
  69359. * Initialize the block and prepare the context for build
  69360. * @param state defines the state that will be used for the build
  69361. */
  69362. initialize(state: NodeMaterialBuildState): void;
  69363. /**
  69364. * Gets the current class name
  69365. * @returns the class name
  69366. */
  69367. getClassName(): string;
  69368. /**
  69369. * Gets the intensity input component
  69370. */
  69371. get intensity(): NodeMaterialConnectionPoint;
  69372. /**
  69373. * Gets the roughness input component
  69374. */
  69375. get roughness(): NodeMaterialConnectionPoint;
  69376. /**
  69377. * Gets the ior input component
  69378. */
  69379. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the bump texture input component
  69382. */
  69383. get normalMapColor(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the uv input component
  69386. */
  69387. get uv(): NodeMaterialConnectionPoint;
  69388. /**
  69389. * Gets the tint color input component
  69390. */
  69391. get tintColor(): NodeMaterialConnectionPoint;
  69392. /**
  69393. * Gets the tint "at distance" input component
  69394. */
  69395. get tintAtDistance(): NodeMaterialConnectionPoint;
  69396. /**
  69397. * Gets the tint thickness input component
  69398. */
  69399. get tintThickness(): NodeMaterialConnectionPoint;
  69400. /**
  69401. * Gets the world tangent input component
  69402. */
  69403. get worldTangent(): NodeMaterialConnectionPoint;
  69404. /**
  69405. * Gets the clear coat object output component
  69406. */
  69407. get clearcoat(): NodeMaterialConnectionPoint;
  69408. autoConfigure(material: NodeMaterial): void;
  69409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69411. private _generateTBNSpace;
  69412. /**
  69413. * Gets the main code of the block (fragment side)
  69414. * @param state current state of the node material building
  69415. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69416. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69417. * @param worldPosVarName name of the variable holding the world position
  69418. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69419. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69420. * @param worldNormalVarName name of the variable holding the world normal
  69421. * @returns the shader code
  69422. */
  69423. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69424. protected _buildBlock(state: NodeMaterialBuildState): this;
  69425. protected _dumpPropertiesCode(): string;
  69426. serialize(): any;
  69427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69428. }
  69429. }
  69430. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69436. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69437. import { Nullable } from "babylonjs/types";
  69438. /**
  69439. * Block used to implement the sub surface module of the PBR material
  69440. */
  69441. export class SubSurfaceBlock extends NodeMaterialBlock {
  69442. /**
  69443. * Create a new SubSurfaceBlock
  69444. * @param name defines the block name
  69445. */
  69446. constructor(name: string);
  69447. /**
  69448. * Initialize the block and prepare the context for build
  69449. * @param state defines the state that will be used for the build
  69450. */
  69451. initialize(state: NodeMaterialBuildState): void;
  69452. /**
  69453. * Gets the current class name
  69454. * @returns the class name
  69455. */
  69456. getClassName(): string;
  69457. /**
  69458. * Gets the thickness component
  69459. */
  69460. get thickness(): NodeMaterialConnectionPoint;
  69461. /**
  69462. * Gets the tint color input component
  69463. */
  69464. get tintColor(): NodeMaterialConnectionPoint;
  69465. /**
  69466. * Gets the translucency intensity input component
  69467. */
  69468. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69469. /**
  69470. * Gets the translucency diffusion distance input component
  69471. */
  69472. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69473. /**
  69474. * Gets the refraction object parameters
  69475. */
  69476. get refraction(): NodeMaterialConnectionPoint;
  69477. /**
  69478. * Gets the sub surface object output component
  69479. */
  69480. get subsurface(): NodeMaterialConnectionPoint;
  69481. autoConfigure(material: NodeMaterial): void;
  69482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69483. /**
  69484. * Gets the main code of the block (fragment side)
  69485. * @param state current state of the node material building
  69486. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69487. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69488. * @param worldPosVarName name of the variable holding the world position
  69489. * @returns the shader code
  69490. */
  69491. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69492. protected _buildBlock(state: NodeMaterialBuildState): this;
  69493. }
  69494. }
  69495. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69499. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69500. import { Light } from "babylonjs/Lights/light";
  69501. import { Nullable } from "babylonjs/types";
  69502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69503. import { Effect } from "babylonjs/Materials/effect";
  69504. import { Mesh } from "babylonjs/Meshes/mesh";
  69505. import { Scene } from "babylonjs/scene";
  69506. /**
  69507. * Block used to implement the PBR metallic/roughness model
  69508. */
  69509. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69510. /**
  69511. * Gets or sets the light associated with this block
  69512. */
  69513. light: Nullable<Light>;
  69514. private _lightId;
  69515. private _scene;
  69516. private _environmentBRDFTexture;
  69517. private _environmentBrdfSamplerName;
  69518. private _vNormalWName;
  69519. private _invertNormalName;
  69520. private _metallicReflectanceColor;
  69521. private _metallicF0Factor;
  69522. private _vMetallicReflectanceFactorsName;
  69523. /**
  69524. * Create a new ReflectionBlock
  69525. * @param name defines the block name
  69526. */
  69527. constructor(name: string);
  69528. /**
  69529. * Intensity of the direct lights e.g. the four lights available in your scene.
  69530. * This impacts both the direct diffuse and specular highlights.
  69531. */
  69532. directIntensity: number;
  69533. /**
  69534. * Intensity of the environment e.g. how much the environment will light the object
  69535. * either through harmonics for rough material or through the refelction for shiny ones.
  69536. */
  69537. environmentIntensity: number;
  69538. /**
  69539. * This is a special control allowing the reduction of the specular highlights coming from the
  69540. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69541. */
  69542. specularIntensity: number;
  69543. /**
  69544. * Defines the falloff type used in this material.
  69545. * It by default is Physical.
  69546. */
  69547. lightFalloff: number;
  69548. /**
  69549. * Specifies that alpha test should be used
  69550. */
  69551. useAlphaTest: boolean;
  69552. /**
  69553. * Defines the alpha limits in alpha test mode.
  69554. */
  69555. alphaTestCutoff: number;
  69556. /**
  69557. * Specifies that alpha blending should be used
  69558. */
  69559. useAlphaBlending: boolean;
  69560. /**
  69561. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69562. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69563. */
  69564. useRadianceOverAlpha: boolean;
  69565. /**
  69566. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69567. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69568. */
  69569. useSpecularOverAlpha: boolean;
  69570. /**
  69571. * Enables specular anti aliasing in the PBR shader.
  69572. * It will both interacts on the Geometry for analytical and IBL lighting.
  69573. * It also prefilter the roughness map based on the bump values.
  69574. */
  69575. enableSpecularAntiAliasing: boolean;
  69576. /**
  69577. * Enables realtime filtering on the texture.
  69578. */
  69579. realTimeFiltering: boolean;
  69580. /**
  69581. * Quality switch for realtime filtering
  69582. */
  69583. realTimeFilteringQuality: number;
  69584. /**
  69585. * Defines if the material uses energy conservation.
  69586. */
  69587. useEnergyConservation: boolean;
  69588. /**
  69589. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69590. * too much the area relying on ambient texture to define their ambient occlusion.
  69591. */
  69592. useRadianceOcclusion: boolean;
  69593. /**
  69594. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69595. * makes the reflect vector face the model (under horizon).
  69596. */
  69597. useHorizonOcclusion: boolean;
  69598. /**
  69599. * If set to true, no lighting calculations will be applied.
  69600. */
  69601. unlit: boolean;
  69602. /**
  69603. * Force normal to face away from face.
  69604. */
  69605. forceNormalForward: boolean;
  69606. /**
  69607. * Defines the material debug mode.
  69608. * It helps seeing only some components of the material while troubleshooting.
  69609. */
  69610. debugMode: number;
  69611. /**
  69612. * Specify from where on screen the debug mode should start.
  69613. * The value goes from -1 (full screen) to 1 (not visible)
  69614. * It helps with side by side comparison against the final render
  69615. * This defaults to 0
  69616. */
  69617. debugLimit: number;
  69618. /**
  69619. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69620. * You can use the factor to better multiply the final value.
  69621. */
  69622. debugFactor: number;
  69623. /**
  69624. * Initialize the block and prepare the context for build
  69625. * @param state defines the state that will be used for the build
  69626. */
  69627. initialize(state: NodeMaterialBuildState): void;
  69628. /**
  69629. * Gets the current class name
  69630. * @returns the class name
  69631. */
  69632. getClassName(): string;
  69633. /**
  69634. * Gets the world position input component
  69635. */
  69636. get worldPosition(): NodeMaterialConnectionPoint;
  69637. /**
  69638. * Gets the world normal input component
  69639. */
  69640. get worldNormal(): NodeMaterialConnectionPoint;
  69641. /**
  69642. * Gets the view matrix parameter
  69643. */
  69644. get view(): NodeMaterialConnectionPoint;
  69645. /**
  69646. * Gets the camera position input component
  69647. */
  69648. get cameraPosition(): NodeMaterialConnectionPoint;
  69649. /**
  69650. * Gets the perturbed normal input component
  69651. */
  69652. get perturbedNormal(): NodeMaterialConnectionPoint;
  69653. /**
  69654. * Gets the base color input component
  69655. */
  69656. get baseColor(): NodeMaterialConnectionPoint;
  69657. /**
  69658. * Gets the metallic input component
  69659. */
  69660. get metallic(): NodeMaterialConnectionPoint;
  69661. /**
  69662. * Gets the roughness input component
  69663. */
  69664. get roughness(): NodeMaterialConnectionPoint;
  69665. /**
  69666. * Gets the ambient occlusion input component
  69667. */
  69668. get ambientOcc(): NodeMaterialConnectionPoint;
  69669. /**
  69670. * Gets the opacity input component
  69671. */
  69672. get opacity(): NodeMaterialConnectionPoint;
  69673. /**
  69674. * Gets the index of refraction input component
  69675. */
  69676. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69677. /**
  69678. * Gets the ambient color input component
  69679. */
  69680. get ambientColor(): NodeMaterialConnectionPoint;
  69681. /**
  69682. * Gets the reflection object parameters
  69683. */
  69684. get reflection(): NodeMaterialConnectionPoint;
  69685. /**
  69686. * Gets the clear coat object parameters
  69687. */
  69688. get clearcoat(): NodeMaterialConnectionPoint;
  69689. /**
  69690. * Gets the sheen object parameters
  69691. */
  69692. get sheen(): NodeMaterialConnectionPoint;
  69693. /**
  69694. * Gets the sub surface object parameters
  69695. */
  69696. get subsurface(): NodeMaterialConnectionPoint;
  69697. /**
  69698. * Gets the anisotropy object parameters
  69699. */
  69700. get anisotropy(): NodeMaterialConnectionPoint;
  69701. /**
  69702. * Gets the ambient output component
  69703. */
  69704. get ambientClr(): NodeMaterialConnectionPoint;
  69705. /**
  69706. * Gets the diffuse output component
  69707. */
  69708. get diffuseDir(): NodeMaterialConnectionPoint;
  69709. /**
  69710. * Gets the specular output component
  69711. */
  69712. get specularDir(): NodeMaterialConnectionPoint;
  69713. /**
  69714. * Gets the clear coat output component
  69715. */
  69716. get clearcoatDir(): NodeMaterialConnectionPoint;
  69717. /**
  69718. * Gets the sheen output component
  69719. */
  69720. get sheenDir(): NodeMaterialConnectionPoint;
  69721. /**
  69722. * Gets the indirect diffuse output component
  69723. */
  69724. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69725. /**
  69726. * Gets the indirect specular output component
  69727. */
  69728. get specularIndirect(): NodeMaterialConnectionPoint;
  69729. /**
  69730. * Gets the indirect clear coat output component
  69731. */
  69732. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69733. /**
  69734. * Gets the indirect sheen output component
  69735. */
  69736. get sheenIndirect(): NodeMaterialConnectionPoint;
  69737. /**
  69738. * Gets the refraction output component
  69739. */
  69740. get refraction(): NodeMaterialConnectionPoint;
  69741. /**
  69742. * Gets the global lighting output component
  69743. */
  69744. get lighting(): NodeMaterialConnectionPoint;
  69745. /**
  69746. * Gets the shadow output component
  69747. */
  69748. get shadow(): NodeMaterialConnectionPoint;
  69749. /**
  69750. * Gets the alpha output component
  69751. */
  69752. get alpha(): NodeMaterialConnectionPoint;
  69753. autoConfigure(material: NodeMaterial): void;
  69754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69755. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69757. private _injectVertexCode;
  69758. private _getAlbedoOpacityCode;
  69759. private _getAmbientOcclusionCode;
  69760. private _getReflectivityCode;
  69761. protected _buildBlock(state: NodeMaterialBuildState): this;
  69762. protected _dumpPropertiesCode(): string;
  69763. serialize(): any;
  69764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69765. }
  69766. }
  69767. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69768. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69769. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69770. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69771. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69772. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69773. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69774. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69775. }
  69776. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69777. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69778. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69779. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69780. }
  69781. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69785. /**
  69786. * Block used to compute value of one parameter modulo another
  69787. */
  69788. export class ModBlock extends NodeMaterialBlock {
  69789. /**
  69790. * Creates a new ModBlock
  69791. * @param name defines the block name
  69792. */
  69793. constructor(name: string);
  69794. /**
  69795. * Gets the current class name
  69796. * @returns the class name
  69797. */
  69798. getClassName(): string;
  69799. /**
  69800. * Gets the left operand input component
  69801. */
  69802. get left(): NodeMaterialConnectionPoint;
  69803. /**
  69804. * Gets the right operand input component
  69805. */
  69806. get right(): NodeMaterialConnectionPoint;
  69807. /**
  69808. * Gets the output component
  69809. */
  69810. get output(): NodeMaterialConnectionPoint;
  69811. protected _buildBlock(state: NodeMaterialBuildState): this;
  69812. }
  69813. }
  69814. declare module "babylonjs/Materials/Node/Blocks/index" {
  69815. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69816. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69817. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69818. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69819. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69820. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69821. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69822. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69823. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69824. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69825. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69826. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69827. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69828. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69829. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69830. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69831. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69832. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69833. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69834. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69835. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69836. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69837. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69838. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69839. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69840. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69841. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69842. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69843. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69844. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69845. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69846. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69847. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69848. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69849. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69850. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69851. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69852. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69853. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69854. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69855. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69856. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69857. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69858. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69859. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69860. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69861. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69862. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69863. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69864. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69865. }
  69866. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69867. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69868. }
  69869. declare module "babylonjs/Materials/Node/index" {
  69870. export * from "babylonjs/Materials/Node/Enums/index";
  69871. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69872. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69873. export * from "babylonjs/Materials/Node/nodeMaterial";
  69874. export * from "babylonjs/Materials/Node/Blocks/index";
  69875. export * from "babylonjs/Materials/Node/Optimizers/index";
  69876. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69877. }
  69878. declare module "babylonjs/Materials/index" {
  69879. export * from "babylonjs/Materials/Background/index";
  69880. export * from "babylonjs/Materials/colorCurves";
  69881. export * from "babylonjs/Materials/iEffectFallbacks";
  69882. export * from "babylonjs/Materials/effectFallbacks";
  69883. export * from "babylonjs/Materials/effect";
  69884. export * from "babylonjs/Materials/fresnelParameters";
  69885. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69886. export * from "babylonjs/Materials/material";
  69887. export * from "babylonjs/Materials/materialDefines";
  69888. export * from "babylonjs/Materials/thinMaterialHelper";
  69889. export * from "babylonjs/Materials/materialHelper";
  69890. export * from "babylonjs/Materials/multiMaterial";
  69891. export * from "babylonjs/Materials/PBR/index";
  69892. export * from "babylonjs/Materials/pushMaterial";
  69893. export * from "babylonjs/Materials/shaderMaterial";
  69894. export * from "babylonjs/Materials/standardMaterial";
  69895. export * from "babylonjs/Materials/Textures/index";
  69896. export * from "babylonjs/Materials/uniformBuffer";
  69897. export * from "babylonjs/Materials/materialFlags";
  69898. export * from "babylonjs/Materials/Node/index";
  69899. export * from "babylonjs/Materials/effectRenderer";
  69900. export * from "babylonjs/Materials/shadowDepthWrapper";
  69901. }
  69902. declare module "babylonjs/Maths/index" {
  69903. export * from "babylonjs/Maths/math.scalar";
  69904. export * from "babylonjs/Maths/math.functions";
  69905. export * from "babylonjs/Maths/math";
  69906. export * from "babylonjs/Maths/sphericalPolynomial";
  69907. }
  69908. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69909. import { IDisposable } from "babylonjs/scene";
  69910. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69911. /**
  69912. * Configuration for Draco compression
  69913. */
  69914. export interface IDracoCompressionConfiguration {
  69915. /**
  69916. * Configuration for the decoder.
  69917. */
  69918. decoder: {
  69919. /**
  69920. * The url to the WebAssembly module.
  69921. */
  69922. wasmUrl?: string;
  69923. /**
  69924. * The url to the WebAssembly binary.
  69925. */
  69926. wasmBinaryUrl?: string;
  69927. /**
  69928. * The url to the fallback JavaScript module.
  69929. */
  69930. fallbackUrl?: string;
  69931. };
  69932. }
  69933. /**
  69934. * Draco compression (https://google.github.io/draco/)
  69935. *
  69936. * This class wraps the Draco module.
  69937. *
  69938. * **Encoder**
  69939. *
  69940. * The encoder is not currently implemented.
  69941. *
  69942. * **Decoder**
  69943. *
  69944. * 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.
  69945. *
  69946. * To update the configuration, use the following code:
  69947. * ```javascript
  69948. * DracoCompression.Configuration = {
  69949. * decoder: {
  69950. * wasmUrl: "<url to the WebAssembly library>",
  69951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69952. * fallbackUrl: "<url to the fallback JavaScript library>",
  69953. * }
  69954. * };
  69955. * ```
  69956. *
  69957. * 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.
  69958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69960. *
  69961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69962. * ```javascript
  69963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69964. * ```
  69965. *
  69966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69967. */
  69968. export class DracoCompression implements IDisposable {
  69969. private _workerPoolPromise?;
  69970. private _decoderModulePromise?;
  69971. /**
  69972. * The configuration. Defaults to the following urls:
  69973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69976. */
  69977. static Configuration: IDracoCompressionConfiguration;
  69978. /**
  69979. * Returns true if the decoder configuration is available.
  69980. */
  69981. static get DecoderAvailable(): boolean;
  69982. /**
  69983. * Default number of workers to create when creating the draco compression object.
  69984. */
  69985. static DefaultNumWorkers: number;
  69986. private static GetDefaultNumWorkers;
  69987. private static _Default;
  69988. /**
  69989. * Default instance for the draco compression object.
  69990. */
  69991. static get Default(): DracoCompression;
  69992. /**
  69993. * Constructor
  69994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69995. */
  69996. constructor(numWorkers?: number);
  69997. /**
  69998. * Stop all async operations and release resources.
  69999. */
  70000. dispose(): void;
  70001. /**
  70002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70003. * @returns a promise that resolves when ready
  70004. */
  70005. whenReadyAsync(): Promise<void>;
  70006. /**
  70007. * Decode Draco compressed mesh data to vertex data.
  70008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70010. * @returns A promise that resolves with the decoded vertex data
  70011. */
  70012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70013. [kind: string]: number;
  70014. }): Promise<VertexData>;
  70015. }
  70016. }
  70017. declare module "babylonjs/Meshes/Compression/index" {
  70018. export * from "babylonjs/Meshes/Compression/dracoCompression";
  70019. }
  70020. declare module "babylonjs/Meshes/csg" {
  70021. import { Nullable } from "babylonjs/types";
  70022. import { Scene } from "babylonjs/scene";
  70023. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  70024. import { Mesh } from "babylonjs/Meshes/mesh";
  70025. import { Material } from "babylonjs/Materials/material";
  70026. /**
  70027. * Class for building Constructive Solid Geometry
  70028. */
  70029. export class CSG {
  70030. private polygons;
  70031. /**
  70032. * The world matrix
  70033. */
  70034. matrix: Matrix;
  70035. /**
  70036. * Stores the position
  70037. */
  70038. position: Vector3;
  70039. /**
  70040. * Stores the rotation
  70041. */
  70042. rotation: Vector3;
  70043. /**
  70044. * Stores the rotation quaternion
  70045. */
  70046. rotationQuaternion: Nullable<Quaternion>;
  70047. /**
  70048. * Stores the scaling vector
  70049. */
  70050. scaling: Vector3;
  70051. /**
  70052. * Convert the Mesh to CSG
  70053. * @param mesh The Mesh to convert to CSG
  70054. * @returns A new CSG from the Mesh
  70055. */
  70056. static FromMesh(mesh: Mesh): CSG;
  70057. /**
  70058. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70059. * @param polygons Polygons used to construct a CSG solid
  70060. */
  70061. private static FromPolygons;
  70062. /**
  70063. * Clones, or makes a deep copy, of the CSG
  70064. * @returns A new CSG
  70065. */
  70066. clone(): CSG;
  70067. /**
  70068. * Unions this CSG with another CSG
  70069. * @param csg The CSG to union against this CSG
  70070. * @returns The unioned CSG
  70071. */
  70072. union(csg: CSG): CSG;
  70073. /**
  70074. * Unions this CSG with another CSG in place
  70075. * @param csg The CSG to union against this CSG
  70076. */
  70077. unionInPlace(csg: CSG): void;
  70078. /**
  70079. * Subtracts this CSG with another CSG
  70080. * @param csg The CSG to subtract against this CSG
  70081. * @returns A new CSG
  70082. */
  70083. subtract(csg: CSG): CSG;
  70084. /**
  70085. * Subtracts this CSG with another CSG in place
  70086. * @param csg The CSG to subtact against this CSG
  70087. */
  70088. subtractInPlace(csg: CSG): void;
  70089. /**
  70090. * Intersect this CSG with another CSG
  70091. * @param csg The CSG to intersect against this CSG
  70092. * @returns A new CSG
  70093. */
  70094. intersect(csg: CSG): CSG;
  70095. /**
  70096. * Intersects this CSG with another CSG in place
  70097. * @param csg The CSG to intersect against this CSG
  70098. */
  70099. intersectInPlace(csg: CSG): void;
  70100. /**
  70101. * Return a new CSG solid with solid and empty space switched. This solid is
  70102. * not modified.
  70103. * @returns A new CSG solid with solid and empty space switched
  70104. */
  70105. inverse(): CSG;
  70106. /**
  70107. * Inverses the CSG in place
  70108. */
  70109. inverseInPlace(): void;
  70110. /**
  70111. * This is used to keep meshes transformations so they can be restored
  70112. * when we build back a Babylon Mesh
  70113. * NB : All CSG operations are performed in world coordinates
  70114. * @param csg The CSG to copy the transform attributes from
  70115. * @returns This CSG
  70116. */
  70117. copyTransformAttributes(csg: CSG): CSG;
  70118. /**
  70119. * Build Raw mesh from CSG
  70120. * Coordinates here are in world space
  70121. * @param name The name of the mesh geometry
  70122. * @param scene The Scene
  70123. * @param keepSubMeshes Specifies if the submeshes should be kept
  70124. * @returns A new Mesh
  70125. */
  70126. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70127. /**
  70128. * Build Mesh from CSG taking material and transforms into account
  70129. * @param name The name of the Mesh
  70130. * @param material The material of the Mesh
  70131. * @param scene The Scene
  70132. * @param keepSubMeshes Specifies if submeshes should be kept
  70133. * @returns The new Mesh
  70134. */
  70135. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70136. }
  70137. }
  70138. declare module "babylonjs/Meshes/trailMesh" {
  70139. import { Mesh } from "babylonjs/Meshes/mesh";
  70140. import { Scene } from "babylonjs/scene";
  70141. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70142. /**
  70143. * Class used to create a trail following a mesh
  70144. */
  70145. export class TrailMesh extends Mesh {
  70146. private _generator;
  70147. private _autoStart;
  70148. private _running;
  70149. private _diameter;
  70150. private _length;
  70151. private _sectionPolygonPointsCount;
  70152. private _sectionVectors;
  70153. private _sectionNormalVectors;
  70154. private _beforeRenderObserver;
  70155. /**
  70156. * @constructor
  70157. * @param name The value used by scene.getMeshByName() to do a lookup.
  70158. * @param generator The mesh or transform node to generate a trail.
  70159. * @param scene The scene to add this mesh to.
  70160. * @param diameter Diameter of trailing mesh. Default is 1.
  70161. * @param length Length of trailing mesh. Default is 60.
  70162. * @param autoStart Automatically start trailing mesh. Default true.
  70163. */
  70164. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70165. /**
  70166. * "TrailMesh"
  70167. * @returns "TrailMesh"
  70168. */
  70169. getClassName(): string;
  70170. private _createMesh;
  70171. /**
  70172. * Start trailing mesh.
  70173. */
  70174. start(): void;
  70175. /**
  70176. * Stop trailing mesh.
  70177. */
  70178. stop(): void;
  70179. /**
  70180. * Update trailing mesh geometry.
  70181. */
  70182. update(): void;
  70183. /**
  70184. * Returns a new TrailMesh object.
  70185. * @param name is a string, the name given to the new mesh
  70186. * @param newGenerator use new generator object for cloned trail mesh
  70187. * @returns a new mesh
  70188. */
  70189. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70190. /**
  70191. * Serializes this trail mesh
  70192. * @param serializationObject object to write serialization to
  70193. */
  70194. serialize(serializationObject: any): void;
  70195. /**
  70196. * Parses a serialized trail mesh
  70197. * @param parsedMesh the serialized mesh
  70198. * @param scene the scene to create the trail mesh in
  70199. * @returns the created trail mesh
  70200. */
  70201. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70202. }
  70203. }
  70204. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70205. import { Nullable } from "babylonjs/types";
  70206. import { Scene } from "babylonjs/scene";
  70207. import { Vector4 } from "babylonjs/Maths/math.vector";
  70208. import { Color4 } from "babylonjs/Maths/math.color";
  70209. import { Mesh } from "babylonjs/Meshes/mesh";
  70210. /**
  70211. * Class containing static functions to help procedurally build meshes
  70212. */
  70213. export class TiledBoxBuilder {
  70214. /**
  70215. * Creates a box mesh
  70216. * 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)
  70217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70221. * @param name defines the name of the mesh
  70222. * @param options defines the options used to create the mesh
  70223. * @param scene defines the hosting scene
  70224. * @returns the box mesh
  70225. */
  70226. static CreateTiledBox(name: string, options: {
  70227. pattern?: number;
  70228. width?: number;
  70229. height?: number;
  70230. depth?: number;
  70231. tileSize?: number;
  70232. tileWidth?: number;
  70233. tileHeight?: number;
  70234. alignHorizontal?: number;
  70235. alignVertical?: number;
  70236. faceUV?: Vector4[];
  70237. faceColors?: Color4[];
  70238. sideOrientation?: number;
  70239. updatable?: boolean;
  70240. }, scene?: Nullable<Scene>): Mesh;
  70241. }
  70242. }
  70243. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70244. import { Vector4 } from "babylonjs/Maths/math.vector";
  70245. import { Mesh } from "babylonjs/Meshes/mesh";
  70246. /**
  70247. * Class containing static functions to help procedurally build meshes
  70248. */
  70249. export class TorusKnotBuilder {
  70250. /**
  70251. * Creates a torus knot mesh
  70252. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70253. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70254. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70255. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70259. * @param name defines the name of the mesh
  70260. * @param options defines the options used to create the mesh
  70261. * @param scene defines the hosting scene
  70262. * @returns the torus knot mesh
  70263. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70264. */
  70265. static CreateTorusKnot(name: string, options: {
  70266. radius?: number;
  70267. tube?: number;
  70268. radialSegments?: number;
  70269. tubularSegments?: number;
  70270. p?: number;
  70271. q?: number;
  70272. updatable?: boolean;
  70273. sideOrientation?: number;
  70274. frontUVs?: Vector4;
  70275. backUVs?: Vector4;
  70276. }, scene: any): Mesh;
  70277. }
  70278. }
  70279. declare module "babylonjs/Meshes/polygonMesh" {
  70280. import { Scene } from "babylonjs/scene";
  70281. import { Vector2 } from "babylonjs/Maths/math.vector";
  70282. import { Mesh } from "babylonjs/Meshes/mesh";
  70283. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70284. import { Path2 } from "babylonjs/Maths/math.path";
  70285. /**
  70286. * Polygon
  70287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70288. */
  70289. export class Polygon {
  70290. /**
  70291. * Creates a rectangle
  70292. * @param xmin bottom X coord
  70293. * @param ymin bottom Y coord
  70294. * @param xmax top X coord
  70295. * @param ymax top Y coord
  70296. * @returns points that make the resulting rectation
  70297. */
  70298. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70299. /**
  70300. * Creates a circle
  70301. * @param radius radius of circle
  70302. * @param cx scale in x
  70303. * @param cy scale in y
  70304. * @param numberOfSides number of sides that make up the circle
  70305. * @returns points that make the resulting circle
  70306. */
  70307. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70308. /**
  70309. * Creates a polygon from input string
  70310. * @param input Input polygon data
  70311. * @returns the parsed points
  70312. */
  70313. static Parse(input: string): Vector2[];
  70314. /**
  70315. * Starts building a polygon from x and y coordinates
  70316. * @param x x coordinate
  70317. * @param y y coordinate
  70318. * @returns the started path2
  70319. */
  70320. static StartingAt(x: number, y: number): Path2;
  70321. }
  70322. /**
  70323. * Builds a polygon
  70324. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70325. */
  70326. export class PolygonMeshBuilder {
  70327. private _points;
  70328. private _outlinepoints;
  70329. private _holes;
  70330. private _name;
  70331. private _scene;
  70332. private _epoints;
  70333. private _eholes;
  70334. private _addToepoint;
  70335. /**
  70336. * Babylon reference to the earcut plugin.
  70337. */
  70338. bjsEarcut: any;
  70339. /**
  70340. * Creates a PolygonMeshBuilder
  70341. * @param name name of the builder
  70342. * @param contours Path of the polygon
  70343. * @param scene scene to add to when creating the mesh
  70344. * @param earcutInjection can be used to inject your own earcut reference
  70345. */
  70346. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70347. /**
  70348. * Adds a whole within the polygon
  70349. * @param hole Array of points defining the hole
  70350. * @returns this
  70351. */
  70352. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70353. /**
  70354. * Creates the polygon
  70355. * @param updatable If the mesh should be updatable
  70356. * @param depth The depth of the mesh created
  70357. * @returns the created mesh
  70358. */
  70359. build(updatable?: boolean, depth?: number): Mesh;
  70360. /**
  70361. * Creates the polygon
  70362. * @param depth The depth of the mesh created
  70363. * @returns the created VertexData
  70364. */
  70365. buildVertexData(depth?: number): VertexData;
  70366. /**
  70367. * Adds a side to the polygon
  70368. * @param positions points that make the polygon
  70369. * @param normals normals of the polygon
  70370. * @param uvs uvs of the polygon
  70371. * @param indices indices of the polygon
  70372. * @param bounds bounds of the polygon
  70373. * @param points points of the polygon
  70374. * @param depth depth of the polygon
  70375. * @param flip flip of the polygon
  70376. */
  70377. private addSide;
  70378. }
  70379. }
  70380. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70381. import { Scene } from "babylonjs/scene";
  70382. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70383. import { Color4 } from "babylonjs/Maths/math.color";
  70384. import { Mesh } from "babylonjs/Meshes/mesh";
  70385. import { Nullable } from "babylonjs/types";
  70386. /**
  70387. * Class containing static functions to help procedurally build meshes
  70388. */
  70389. export class PolygonBuilder {
  70390. /**
  70391. * Creates a polygon mesh
  70392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70393. * * 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
  70394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70397. * * Remember you can only change the shape positions, not their number when updating a polygon
  70398. * @param name defines the name of the mesh
  70399. * @param options defines the options used to create the mesh
  70400. * @param scene defines the hosting scene
  70401. * @param earcutInjection can be used to inject your own earcut reference
  70402. * @returns the polygon mesh
  70403. */
  70404. static CreatePolygon(name: string, options: {
  70405. shape: Vector3[];
  70406. holes?: Vector3[][];
  70407. depth?: number;
  70408. faceUV?: Vector4[];
  70409. faceColors?: Color4[];
  70410. updatable?: boolean;
  70411. sideOrientation?: number;
  70412. frontUVs?: Vector4;
  70413. backUVs?: Vector4;
  70414. wrap?: boolean;
  70415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70416. /**
  70417. * Creates an extruded polygon mesh, with depth in the Y direction.
  70418. * * 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)
  70419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70420. * @param name defines the name of the mesh
  70421. * @param options defines the options used to create the mesh
  70422. * @param scene defines the hosting scene
  70423. * @param earcutInjection can be used to inject your own earcut reference
  70424. * @returns the polygon mesh
  70425. */
  70426. static ExtrudePolygon(name: string, options: {
  70427. shape: Vector3[];
  70428. holes?: Vector3[][];
  70429. depth?: number;
  70430. faceUV?: Vector4[];
  70431. faceColors?: Color4[];
  70432. updatable?: boolean;
  70433. sideOrientation?: number;
  70434. frontUVs?: Vector4;
  70435. backUVs?: Vector4;
  70436. wrap?: boolean;
  70437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70438. }
  70439. }
  70440. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70441. import { Scene } from "babylonjs/scene";
  70442. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70443. import { Mesh } from "babylonjs/Meshes/mesh";
  70444. import { Nullable } from "babylonjs/types";
  70445. /**
  70446. * Class containing static functions to help procedurally build meshes
  70447. */
  70448. export class LatheBuilder {
  70449. /**
  70450. * Creates lathe mesh.
  70451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70452. * * 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
  70453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70456. * * 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
  70457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70458. * * 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
  70459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70463. * @param name defines the name of the mesh
  70464. * @param options defines the options used to create the mesh
  70465. * @param scene defines the hosting scene
  70466. * @returns the lathe mesh
  70467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70468. */
  70469. static CreateLathe(name: string, options: {
  70470. shape: Vector3[];
  70471. radius?: number;
  70472. tessellation?: number;
  70473. clip?: number;
  70474. arc?: number;
  70475. closed?: boolean;
  70476. updatable?: boolean;
  70477. sideOrientation?: number;
  70478. frontUVs?: Vector4;
  70479. backUVs?: Vector4;
  70480. cap?: number;
  70481. invertUV?: boolean;
  70482. }, scene?: Nullable<Scene>): Mesh;
  70483. }
  70484. }
  70485. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70486. import { Nullable } from "babylonjs/types";
  70487. import { Scene } from "babylonjs/scene";
  70488. import { Vector4 } from "babylonjs/Maths/math.vector";
  70489. import { Mesh } from "babylonjs/Meshes/mesh";
  70490. /**
  70491. * Class containing static functions to help procedurally build meshes
  70492. */
  70493. export class TiledPlaneBuilder {
  70494. /**
  70495. * Creates a tiled plane mesh
  70496. * * The parameter `pattern` will, depending on value, do nothing or
  70497. * * * flip (reflect about central vertical) alternate tiles across and up
  70498. * * * flip every tile on alternate rows
  70499. * * * rotate (180 degs) alternate tiles across and up
  70500. * * * rotate every tile on alternate rows
  70501. * * * flip and rotate alternate tiles across and up
  70502. * * * flip and rotate every tile on alternate rows
  70503. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70504. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70507. * * 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)
  70508. * * 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)
  70509. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70510. * @param name defines the name of the mesh
  70511. * @param options defines the options used to create the mesh
  70512. * @param scene defines the hosting scene
  70513. * @returns the box mesh
  70514. */
  70515. static CreateTiledPlane(name: string, options: {
  70516. pattern?: number;
  70517. tileSize?: number;
  70518. tileWidth?: number;
  70519. tileHeight?: number;
  70520. size?: number;
  70521. width?: number;
  70522. height?: number;
  70523. alignHorizontal?: number;
  70524. alignVertical?: number;
  70525. sideOrientation?: number;
  70526. frontUVs?: Vector4;
  70527. backUVs?: Vector4;
  70528. updatable?: boolean;
  70529. }, scene?: Nullable<Scene>): Mesh;
  70530. }
  70531. }
  70532. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70533. import { Nullable } from "babylonjs/types";
  70534. import { Scene } from "babylonjs/scene";
  70535. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70536. import { Mesh } from "babylonjs/Meshes/mesh";
  70537. /**
  70538. * Class containing static functions to help procedurally build meshes
  70539. */
  70540. export class TubeBuilder {
  70541. /**
  70542. * Creates a tube mesh.
  70543. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70544. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70545. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70546. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70547. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70548. * * 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)
  70549. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70550. * * 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
  70551. * * 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
  70552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70556. * @param name defines the name of the mesh
  70557. * @param options defines the options used to create the mesh
  70558. * @param scene defines the hosting scene
  70559. * @returns the tube mesh
  70560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70561. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70562. */
  70563. static CreateTube(name: string, options: {
  70564. path: Vector3[];
  70565. radius?: number;
  70566. tessellation?: number;
  70567. radiusFunction?: {
  70568. (i: number, distance: number): number;
  70569. };
  70570. cap?: number;
  70571. arc?: number;
  70572. updatable?: boolean;
  70573. sideOrientation?: number;
  70574. frontUVs?: Vector4;
  70575. backUVs?: Vector4;
  70576. instance?: Mesh;
  70577. invertUV?: boolean;
  70578. }, scene?: Nullable<Scene>): Mesh;
  70579. }
  70580. }
  70581. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70582. import { Scene } from "babylonjs/scene";
  70583. import { Vector4 } from "babylonjs/Maths/math.vector";
  70584. import { Mesh } from "babylonjs/Meshes/mesh";
  70585. import { Nullable } from "babylonjs/types";
  70586. /**
  70587. * Class containing static functions to help procedurally build meshes
  70588. */
  70589. export class IcoSphereBuilder {
  70590. /**
  70591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70593. * * 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`)
  70594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70595. * * 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
  70596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70599. * @param name defines the name of the mesh
  70600. * @param options defines the options used to create the mesh
  70601. * @param scene defines the hosting scene
  70602. * @returns the icosahedron mesh
  70603. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70604. */
  70605. static CreateIcoSphere(name: string, options: {
  70606. radius?: number;
  70607. radiusX?: number;
  70608. radiusY?: number;
  70609. radiusZ?: number;
  70610. flat?: boolean;
  70611. subdivisions?: number;
  70612. sideOrientation?: number;
  70613. frontUVs?: Vector4;
  70614. backUVs?: Vector4;
  70615. updatable?: boolean;
  70616. }, scene?: Nullable<Scene>): Mesh;
  70617. }
  70618. }
  70619. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70620. import { Vector3 } from "babylonjs/Maths/math.vector";
  70621. import { Mesh } from "babylonjs/Meshes/mesh";
  70622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70623. /**
  70624. * Class containing static functions to help procedurally build meshes
  70625. */
  70626. export class DecalBuilder {
  70627. /**
  70628. * Creates a decal mesh.
  70629. * 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
  70630. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70631. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70632. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70633. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70634. * @param name defines the name of the mesh
  70635. * @param sourceMesh defines the mesh where the decal must be applied
  70636. * @param options defines the options used to create the mesh
  70637. * @param scene defines the hosting scene
  70638. * @returns the decal mesh
  70639. * @see https://doc.babylonjs.com/how_to/decals
  70640. */
  70641. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70642. position?: Vector3;
  70643. normal?: Vector3;
  70644. size?: Vector3;
  70645. angle?: number;
  70646. }): Mesh;
  70647. }
  70648. }
  70649. declare module "babylonjs/Meshes/meshBuilder" {
  70650. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70651. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70652. import { Nullable } from "babylonjs/types";
  70653. import { Scene } from "babylonjs/scene";
  70654. import { Mesh } from "babylonjs/Meshes/mesh";
  70655. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70656. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70659. import { Plane } from "babylonjs/Maths/math.plane";
  70660. /**
  70661. * Class containing static functions to help procedurally build meshes
  70662. */
  70663. export class MeshBuilder {
  70664. /**
  70665. * Creates a box mesh
  70666. * * The parameter `size` sets the size (float) of each box side (default 1)
  70667. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70668. * * 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)
  70669. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70673. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70674. * @param name defines the name of the mesh
  70675. * @param options defines the options used to create the mesh
  70676. * @param scene defines the hosting scene
  70677. * @returns the box mesh
  70678. */
  70679. static CreateBox(name: string, options: {
  70680. size?: number;
  70681. width?: number;
  70682. height?: number;
  70683. depth?: number;
  70684. faceUV?: Vector4[];
  70685. faceColors?: Color4[];
  70686. sideOrientation?: number;
  70687. frontUVs?: Vector4;
  70688. backUVs?: Vector4;
  70689. wrap?: boolean;
  70690. topBaseAt?: number;
  70691. bottomBaseAt?: number;
  70692. updatable?: boolean;
  70693. }, scene?: Nullable<Scene>): Mesh;
  70694. /**
  70695. * Creates a tiled box mesh
  70696. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70698. * @param name defines the name of the mesh
  70699. * @param options defines the options used to create the mesh
  70700. * @param scene defines the hosting scene
  70701. * @returns the tiled box mesh
  70702. */
  70703. static CreateTiledBox(name: string, options: {
  70704. pattern?: number;
  70705. size?: number;
  70706. width?: number;
  70707. height?: number;
  70708. depth: number;
  70709. tileSize?: number;
  70710. tileWidth?: number;
  70711. tileHeight?: number;
  70712. faceUV?: Vector4[];
  70713. faceColors?: Color4[];
  70714. alignHorizontal?: number;
  70715. alignVertical?: number;
  70716. sideOrientation?: number;
  70717. updatable?: boolean;
  70718. }, scene?: Nullable<Scene>): Mesh;
  70719. /**
  70720. * Creates a sphere mesh
  70721. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70722. * * 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`)
  70723. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70724. * * 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
  70725. * * 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)
  70726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70729. * @param name defines the name of the mesh
  70730. * @param options defines the options used to create the mesh
  70731. * @param scene defines the hosting scene
  70732. * @returns the sphere mesh
  70733. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70734. */
  70735. static CreateSphere(name: string, options: {
  70736. segments?: number;
  70737. diameter?: number;
  70738. diameterX?: number;
  70739. diameterY?: number;
  70740. diameterZ?: number;
  70741. arc?: number;
  70742. slice?: number;
  70743. sideOrientation?: number;
  70744. frontUVs?: Vector4;
  70745. backUVs?: Vector4;
  70746. updatable?: boolean;
  70747. }, scene?: Nullable<Scene>): Mesh;
  70748. /**
  70749. * Creates a plane polygonal mesh. By default, this is a disc
  70750. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70751. * * 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
  70752. * * 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
  70753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70756. * @param name defines the name of the mesh
  70757. * @param options defines the options used to create the mesh
  70758. * @param scene defines the hosting scene
  70759. * @returns the plane polygonal mesh
  70760. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70761. */
  70762. static CreateDisc(name: string, options: {
  70763. radius?: number;
  70764. tessellation?: number;
  70765. arc?: number;
  70766. updatable?: boolean;
  70767. sideOrientation?: number;
  70768. frontUVs?: Vector4;
  70769. backUVs?: Vector4;
  70770. }, scene?: Nullable<Scene>): Mesh;
  70771. /**
  70772. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70773. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70774. * * 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`)
  70775. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70776. * * 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
  70777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70780. * @param name defines the name of the mesh
  70781. * @param options defines the options used to create the mesh
  70782. * @param scene defines the hosting scene
  70783. * @returns the icosahedron mesh
  70784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70785. */
  70786. static CreateIcoSphere(name: string, options: {
  70787. radius?: number;
  70788. radiusX?: number;
  70789. radiusY?: number;
  70790. radiusZ?: number;
  70791. flat?: boolean;
  70792. subdivisions?: number;
  70793. sideOrientation?: number;
  70794. frontUVs?: Vector4;
  70795. backUVs?: Vector4;
  70796. updatable?: boolean;
  70797. }, scene?: Nullable<Scene>): Mesh;
  70798. /**
  70799. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70800. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70801. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70802. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70803. * * 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
  70804. * * 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
  70805. * * 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
  70806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70809. * * 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
  70810. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70811. * * 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
  70812. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70814. * @param name defines the name of the mesh
  70815. * @param options defines the options used to create the mesh
  70816. * @param scene defines the hosting scene
  70817. * @returns the ribbon mesh
  70818. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70820. */
  70821. static CreateRibbon(name: string, options: {
  70822. pathArray: Vector3[][];
  70823. closeArray?: boolean;
  70824. closePath?: boolean;
  70825. offset?: number;
  70826. updatable?: boolean;
  70827. sideOrientation?: number;
  70828. frontUVs?: Vector4;
  70829. backUVs?: Vector4;
  70830. instance?: Mesh;
  70831. invertUV?: boolean;
  70832. uvs?: Vector2[];
  70833. colors?: Color4[];
  70834. }, scene?: Nullable<Scene>): Mesh;
  70835. /**
  70836. * Creates a cylinder or a cone mesh
  70837. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70838. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70839. * * 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.
  70840. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70841. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70842. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70843. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70844. * * 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).
  70845. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70846. * * 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).
  70847. * * 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
  70848. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70849. * * 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
  70850. * * 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.
  70851. * * If `enclose` is false, a ring surface is one element.
  70852. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70853. * * 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
  70854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70857. * @param name defines the name of the mesh
  70858. * @param options defines the options used to create the mesh
  70859. * @param scene defines the hosting scene
  70860. * @returns the cylinder mesh
  70861. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70862. */
  70863. static CreateCylinder(name: string, options: {
  70864. height?: number;
  70865. diameterTop?: number;
  70866. diameterBottom?: number;
  70867. diameter?: number;
  70868. tessellation?: number;
  70869. subdivisions?: number;
  70870. arc?: number;
  70871. faceColors?: Color4[];
  70872. faceUV?: Vector4[];
  70873. updatable?: boolean;
  70874. hasRings?: boolean;
  70875. enclose?: boolean;
  70876. cap?: number;
  70877. sideOrientation?: number;
  70878. frontUVs?: Vector4;
  70879. backUVs?: Vector4;
  70880. }, scene?: Nullable<Scene>): Mesh;
  70881. /**
  70882. * Creates a torus mesh
  70883. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70884. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70885. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70889. * @param name defines the name of the mesh
  70890. * @param options defines the options used to create the mesh
  70891. * @param scene defines the hosting scene
  70892. * @returns the torus mesh
  70893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70894. */
  70895. static CreateTorus(name: string, options: {
  70896. diameter?: number;
  70897. thickness?: number;
  70898. tessellation?: number;
  70899. updatable?: boolean;
  70900. sideOrientation?: number;
  70901. frontUVs?: Vector4;
  70902. backUVs?: Vector4;
  70903. }, scene?: Nullable<Scene>): Mesh;
  70904. /**
  70905. * Creates a torus knot mesh
  70906. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70907. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70908. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70909. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70913. * @param name defines the name of the mesh
  70914. * @param options defines the options used to create the mesh
  70915. * @param scene defines the hosting scene
  70916. * @returns the torus knot mesh
  70917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70918. */
  70919. static CreateTorusKnot(name: string, options: {
  70920. radius?: number;
  70921. tube?: number;
  70922. radialSegments?: number;
  70923. tubularSegments?: number;
  70924. p?: number;
  70925. q?: number;
  70926. updatable?: boolean;
  70927. sideOrientation?: number;
  70928. frontUVs?: Vector4;
  70929. backUVs?: Vector4;
  70930. }, scene?: Nullable<Scene>): Mesh;
  70931. /**
  70932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70933. * * 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
  70934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70939. * * 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
  70940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70943. * @param name defines the name of the new line system
  70944. * @param options defines the options used to create the line system
  70945. * @param scene defines the hosting scene
  70946. * @returns a new line system mesh
  70947. */
  70948. static CreateLineSystem(name: string, options: {
  70949. lines: Vector3[][];
  70950. updatable?: boolean;
  70951. instance?: Nullable<LinesMesh>;
  70952. colors?: Nullable<Color4[][]>;
  70953. useVertexAlpha?: boolean;
  70954. }, scene: Nullable<Scene>): LinesMesh;
  70955. /**
  70956. * Creates a line mesh
  70957. * 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
  70958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70959. * * The parameter `points` is an array successive Vector3
  70960. * * 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
  70961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70963. * * When updating an instance, remember that only point positions can change, not the number of points
  70964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70966. * @param name defines the name of the new line system
  70967. * @param options defines the options used to create the line system
  70968. * @param scene defines the hosting scene
  70969. * @returns a new line mesh
  70970. */
  70971. static CreateLines(name: string, options: {
  70972. points: Vector3[];
  70973. updatable?: boolean;
  70974. instance?: Nullable<LinesMesh>;
  70975. colors?: Color4[];
  70976. useVertexAlpha?: boolean;
  70977. }, scene?: Nullable<Scene>): LinesMesh;
  70978. /**
  70979. * Creates a dashed line mesh
  70980. * * 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
  70981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70982. * * The parameter `points` is an array successive Vector3
  70983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70986. * * 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
  70987. * * When updating an instance, remember that only point positions can change, not the number of points
  70988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70989. * @param name defines the name of the mesh
  70990. * @param options defines the options used to create the mesh
  70991. * @param scene defines the hosting scene
  70992. * @returns the dashed line mesh
  70993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70994. */
  70995. static CreateDashedLines(name: string, options: {
  70996. points: Vector3[];
  70997. dashSize?: number;
  70998. gapSize?: number;
  70999. dashNb?: number;
  71000. updatable?: boolean;
  71001. instance?: LinesMesh;
  71002. }, scene?: Nullable<Scene>): LinesMesh;
  71003. /**
  71004. * 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.
  71005. * * 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.
  71006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71007. * * 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.
  71008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71009. * * 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
  71010. * * 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
  71011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71016. * @param name defines the name of the mesh
  71017. * @param options defines the options used to create the mesh
  71018. * @param scene defines the hosting scene
  71019. * @returns the extruded shape mesh
  71020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71022. */
  71023. static ExtrudeShape(name: string, options: {
  71024. shape: Vector3[];
  71025. path: Vector3[];
  71026. scale?: number;
  71027. rotation?: number;
  71028. cap?: number;
  71029. updatable?: boolean;
  71030. sideOrientation?: number;
  71031. frontUVs?: Vector4;
  71032. backUVs?: Vector4;
  71033. instance?: Mesh;
  71034. invertUV?: boolean;
  71035. }, scene?: Nullable<Scene>): Mesh;
  71036. /**
  71037. * Creates an custom extruded shape mesh.
  71038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71039. * * 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.
  71040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71041. * * 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
  71042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71043. * * 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
  71044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71047. * * 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
  71048. * * 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
  71049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71054. * @param name defines the name of the mesh
  71055. * @param options defines the options used to create the mesh
  71056. * @param scene defines the hosting scene
  71057. * @returns the custom extruded shape mesh
  71058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71061. */
  71062. static ExtrudeShapeCustom(name: string, options: {
  71063. shape: Vector3[];
  71064. path: Vector3[];
  71065. scaleFunction?: any;
  71066. rotationFunction?: any;
  71067. ribbonCloseArray?: boolean;
  71068. ribbonClosePath?: boolean;
  71069. cap?: number;
  71070. updatable?: boolean;
  71071. sideOrientation?: number;
  71072. frontUVs?: Vector4;
  71073. backUVs?: Vector4;
  71074. instance?: Mesh;
  71075. invertUV?: boolean;
  71076. }, scene?: Nullable<Scene>): Mesh;
  71077. /**
  71078. * Creates lathe mesh.
  71079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  71080. * * 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
  71081. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71082. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71083. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71084. * * 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
  71085. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71086. * * 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
  71087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71091. * @param name defines the name of the mesh
  71092. * @param options defines the options used to create the mesh
  71093. * @param scene defines the hosting scene
  71094. * @returns the lathe mesh
  71095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71096. */
  71097. static CreateLathe(name: string, options: {
  71098. shape: Vector3[];
  71099. radius?: number;
  71100. tessellation?: number;
  71101. clip?: number;
  71102. arc?: number;
  71103. closed?: boolean;
  71104. updatable?: boolean;
  71105. sideOrientation?: number;
  71106. frontUVs?: Vector4;
  71107. backUVs?: Vector4;
  71108. cap?: number;
  71109. invertUV?: boolean;
  71110. }, scene?: Nullable<Scene>): Mesh;
  71111. /**
  71112. * Creates a tiled plane mesh
  71113. * * You can set a limited pattern arrangement with the tiles
  71114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71117. * @param name defines the name of the mesh
  71118. * @param options defines the options used to create the mesh
  71119. * @param scene defines the hosting scene
  71120. * @returns the plane mesh
  71121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71122. */
  71123. static CreateTiledPlane(name: string, options: {
  71124. pattern?: number;
  71125. tileSize?: number;
  71126. tileWidth?: number;
  71127. tileHeight?: number;
  71128. size?: number;
  71129. width?: number;
  71130. height?: number;
  71131. alignHorizontal?: number;
  71132. alignVertical?: number;
  71133. sideOrientation?: number;
  71134. frontUVs?: Vector4;
  71135. backUVs?: Vector4;
  71136. updatable?: boolean;
  71137. }, scene?: Nullable<Scene>): Mesh;
  71138. /**
  71139. * Creates a plane mesh
  71140. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71141. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71142. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71146. * @param name defines the name of the mesh
  71147. * @param options defines the options used to create the mesh
  71148. * @param scene defines the hosting scene
  71149. * @returns the plane mesh
  71150. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71151. */
  71152. static CreatePlane(name: string, options: {
  71153. size?: number;
  71154. width?: number;
  71155. height?: number;
  71156. sideOrientation?: number;
  71157. frontUVs?: Vector4;
  71158. backUVs?: Vector4;
  71159. updatable?: boolean;
  71160. sourcePlane?: Plane;
  71161. }, scene?: Nullable<Scene>): Mesh;
  71162. /**
  71163. * Creates a ground mesh
  71164. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71165. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71167. * @param name defines the name of the mesh
  71168. * @param options defines the options used to create the mesh
  71169. * @param scene defines the hosting scene
  71170. * @returns the ground mesh
  71171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71172. */
  71173. static CreateGround(name: string, options: {
  71174. width?: number;
  71175. height?: number;
  71176. subdivisions?: number;
  71177. subdivisionsX?: number;
  71178. subdivisionsY?: number;
  71179. updatable?: boolean;
  71180. }, scene?: Nullable<Scene>): Mesh;
  71181. /**
  71182. * Creates a tiled ground mesh
  71183. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71184. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71185. * * 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
  71186. * * 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
  71187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71188. * @param name defines the name of the mesh
  71189. * @param options defines the options used to create the mesh
  71190. * @param scene defines the hosting scene
  71191. * @returns the tiled ground mesh
  71192. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71193. */
  71194. static CreateTiledGround(name: string, options: {
  71195. xmin: number;
  71196. zmin: number;
  71197. xmax: number;
  71198. zmax: number;
  71199. subdivisions?: {
  71200. w: number;
  71201. h: number;
  71202. };
  71203. precision?: {
  71204. w: number;
  71205. h: number;
  71206. };
  71207. updatable?: boolean;
  71208. }, scene?: Nullable<Scene>): Mesh;
  71209. /**
  71210. * Creates a ground mesh from a height map
  71211. * * The parameter `url` sets the URL of the height map image resource.
  71212. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71213. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71214. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71215. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71216. * * 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.
  71217. * * 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).
  71218. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71220. * @param name defines the name of the mesh
  71221. * @param url defines the url to the height map
  71222. * @param options defines the options used to create the mesh
  71223. * @param scene defines the hosting scene
  71224. * @returns the ground mesh
  71225. * @see https://doc.babylonjs.com/babylon101/height_map
  71226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71227. */
  71228. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71229. width?: number;
  71230. height?: number;
  71231. subdivisions?: number;
  71232. minHeight?: number;
  71233. maxHeight?: number;
  71234. colorFilter?: Color3;
  71235. alphaFilter?: number;
  71236. updatable?: boolean;
  71237. onReady?: (mesh: GroundMesh) => void;
  71238. }, scene?: Nullable<Scene>): GroundMesh;
  71239. /**
  71240. * Creates a polygon mesh
  71241. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71242. * * 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
  71243. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71246. * * Remember you can only change the shape positions, not their number when updating a polygon
  71247. * @param name defines the name of the mesh
  71248. * @param options defines the options used to create the mesh
  71249. * @param scene defines the hosting scene
  71250. * @param earcutInjection can be used to inject your own earcut reference
  71251. * @returns the polygon mesh
  71252. */
  71253. static CreatePolygon(name: string, options: {
  71254. shape: Vector3[];
  71255. holes?: Vector3[][];
  71256. depth?: number;
  71257. faceUV?: Vector4[];
  71258. faceColors?: Color4[];
  71259. updatable?: boolean;
  71260. sideOrientation?: number;
  71261. frontUVs?: Vector4;
  71262. backUVs?: Vector4;
  71263. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71264. /**
  71265. * Creates an extruded polygon mesh, with depth in the Y direction.
  71266. * * 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)
  71267. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71268. * @param name defines the name of the mesh
  71269. * @param options defines the options used to create the mesh
  71270. * @param scene defines the hosting scene
  71271. * @param earcutInjection can be used to inject your own earcut reference
  71272. * @returns the polygon mesh
  71273. */
  71274. static ExtrudePolygon(name: string, options: {
  71275. shape: Vector3[];
  71276. holes?: Vector3[][];
  71277. depth?: number;
  71278. faceUV?: Vector4[];
  71279. faceColors?: Color4[];
  71280. updatable?: boolean;
  71281. sideOrientation?: number;
  71282. frontUVs?: Vector4;
  71283. backUVs?: Vector4;
  71284. wrap?: boolean;
  71285. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71286. /**
  71287. * Creates a tube mesh.
  71288. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71289. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71290. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71291. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71292. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71293. * * 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)
  71294. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71295. * * 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
  71296. * * 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
  71297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71301. * @param name defines the name of the mesh
  71302. * @param options defines the options used to create the mesh
  71303. * @param scene defines the hosting scene
  71304. * @returns the tube mesh
  71305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71306. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71307. */
  71308. static CreateTube(name: string, options: {
  71309. path: Vector3[];
  71310. radius?: number;
  71311. tessellation?: number;
  71312. radiusFunction?: {
  71313. (i: number, distance: number): number;
  71314. };
  71315. cap?: number;
  71316. arc?: number;
  71317. updatable?: boolean;
  71318. sideOrientation?: number;
  71319. frontUVs?: Vector4;
  71320. backUVs?: Vector4;
  71321. instance?: Mesh;
  71322. invertUV?: boolean;
  71323. }, scene?: Nullable<Scene>): Mesh;
  71324. /**
  71325. * Creates a polyhedron mesh
  71326. * * 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
  71327. * * The parameter `size` (positive float, default 1) sets the polygon size
  71328. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71329. * * 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`
  71330. * * 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
  71331. * * 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)`)
  71332. * * 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
  71333. * * 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
  71334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71337. * @param name defines the name of the mesh
  71338. * @param options defines the options used to create the mesh
  71339. * @param scene defines the hosting scene
  71340. * @returns the polyhedron mesh
  71341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71342. */
  71343. static CreatePolyhedron(name: string, options: {
  71344. type?: number;
  71345. size?: number;
  71346. sizeX?: number;
  71347. sizeY?: number;
  71348. sizeZ?: number;
  71349. custom?: any;
  71350. faceUV?: Vector4[];
  71351. faceColors?: Color4[];
  71352. flat?: boolean;
  71353. updatable?: boolean;
  71354. sideOrientation?: number;
  71355. frontUVs?: Vector4;
  71356. backUVs?: Vector4;
  71357. }, scene?: Nullable<Scene>): Mesh;
  71358. /**
  71359. * Creates a decal mesh.
  71360. * 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
  71361. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71362. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71363. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71364. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71365. * @param name defines the name of the mesh
  71366. * @param sourceMesh defines the mesh where the decal must be applied
  71367. * @param options defines the options used to create the mesh
  71368. * @param scene defines the hosting scene
  71369. * @returns the decal mesh
  71370. * @see https://doc.babylonjs.com/how_to/decals
  71371. */
  71372. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71373. position?: Vector3;
  71374. normal?: Vector3;
  71375. size?: Vector3;
  71376. angle?: number;
  71377. }): Mesh;
  71378. /**
  71379. * Creates a Capsule Mesh
  71380. * @param name defines the name of the mesh.
  71381. * @param options the constructors options used to shape the mesh.
  71382. * @param scene defines the scene the mesh is scoped to.
  71383. * @returns the capsule mesh
  71384. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71385. */
  71386. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71387. }
  71388. }
  71389. declare module "babylonjs/Meshes/meshSimplification" {
  71390. import { Mesh } from "babylonjs/Meshes/mesh";
  71391. /**
  71392. * A simplifier interface for future simplification implementations
  71393. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71394. */
  71395. export interface ISimplifier {
  71396. /**
  71397. * Simplification of a given mesh according to the given settings.
  71398. * Since this requires computation, it is assumed that the function runs async.
  71399. * @param settings The settings of the simplification, including quality and distance
  71400. * @param successCallback A callback that will be called after the mesh was simplified.
  71401. * @param errorCallback in case of an error, this callback will be called. optional.
  71402. */
  71403. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71404. }
  71405. /**
  71406. * Expected simplification settings.
  71407. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71408. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71409. */
  71410. export interface ISimplificationSettings {
  71411. /**
  71412. * Gets or sets the expected quality
  71413. */
  71414. quality: number;
  71415. /**
  71416. * Gets or sets the distance when this optimized version should be used
  71417. */
  71418. distance: number;
  71419. /**
  71420. * Gets an already optimized mesh
  71421. */
  71422. optimizeMesh?: boolean;
  71423. }
  71424. /**
  71425. * Class used to specify simplification options
  71426. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71427. */
  71428. export class SimplificationSettings implements ISimplificationSettings {
  71429. /** expected quality */
  71430. quality: number;
  71431. /** distance when this optimized version should be used */
  71432. distance: number;
  71433. /** already optimized mesh */
  71434. optimizeMesh?: boolean | undefined;
  71435. /**
  71436. * Creates a SimplificationSettings
  71437. * @param quality expected quality
  71438. * @param distance distance when this optimized version should be used
  71439. * @param optimizeMesh already optimized mesh
  71440. */
  71441. constructor(
  71442. /** expected quality */
  71443. quality: number,
  71444. /** distance when this optimized version should be used */
  71445. distance: number,
  71446. /** already optimized mesh */
  71447. optimizeMesh?: boolean | undefined);
  71448. }
  71449. /**
  71450. * Interface used to define a simplification task
  71451. */
  71452. export interface ISimplificationTask {
  71453. /**
  71454. * Array of settings
  71455. */
  71456. settings: Array<ISimplificationSettings>;
  71457. /**
  71458. * Simplification type
  71459. */
  71460. simplificationType: SimplificationType;
  71461. /**
  71462. * Mesh to simplify
  71463. */
  71464. mesh: Mesh;
  71465. /**
  71466. * Callback called on success
  71467. */
  71468. successCallback?: () => void;
  71469. /**
  71470. * Defines if parallel processing can be used
  71471. */
  71472. parallelProcessing: boolean;
  71473. }
  71474. /**
  71475. * Queue used to order the simplification tasks
  71476. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71477. */
  71478. export class SimplificationQueue {
  71479. private _simplificationArray;
  71480. /**
  71481. * Gets a boolean indicating that the process is still running
  71482. */
  71483. running: boolean;
  71484. /**
  71485. * Creates a new queue
  71486. */
  71487. constructor();
  71488. /**
  71489. * Adds a new simplification task
  71490. * @param task defines a task to add
  71491. */
  71492. addTask(task: ISimplificationTask): void;
  71493. /**
  71494. * Execute next task
  71495. */
  71496. executeNext(): void;
  71497. /**
  71498. * Execute a simplification task
  71499. * @param task defines the task to run
  71500. */
  71501. runSimplification(task: ISimplificationTask): void;
  71502. private getSimplifier;
  71503. }
  71504. /**
  71505. * The implemented types of simplification
  71506. * At the moment only Quadratic Error Decimation is implemented
  71507. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71508. */
  71509. export enum SimplificationType {
  71510. /** Quadratic error decimation */
  71511. QUADRATIC = 0
  71512. }
  71513. /**
  71514. * An implementation of the Quadratic Error simplification algorithm.
  71515. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71516. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71517. * @author RaananW
  71518. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71519. */
  71520. export class QuadraticErrorSimplification implements ISimplifier {
  71521. private _mesh;
  71522. private triangles;
  71523. private vertices;
  71524. private references;
  71525. private _reconstructedMesh;
  71526. /** Gets or sets the number pf sync interations */
  71527. syncIterations: number;
  71528. /** Gets or sets the aggressiveness of the simplifier */
  71529. aggressiveness: number;
  71530. /** Gets or sets the number of allowed iterations for decimation */
  71531. decimationIterations: number;
  71532. /** Gets or sets the espilon to use for bounding box computation */
  71533. boundingBoxEpsilon: number;
  71534. /**
  71535. * Creates a new QuadraticErrorSimplification
  71536. * @param _mesh defines the target mesh
  71537. */
  71538. constructor(_mesh: Mesh);
  71539. /**
  71540. * Simplification of a given mesh according to the given settings.
  71541. * Since this requires computation, it is assumed that the function runs async.
  71542. * @param settings The settings of the simplification, including quality and distance
  71543. * @param successCallback A callback that will be called after the mesh was simplified.
  71544. */
  71545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71546. private runDecimation;
  71547. private initWithMesh;
  71548. private init;
  71549. private reconstructMesh;
  71550. private initDecimatedMesh;
  71551. private isFlipped;
  71552. private updateTriangles;
  71553. private identifyBorder;
  71554. private updateMesh;
  71555. private vertexError;
  71556. private calculateError;
  71557. }
  71558. }
  71559. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71560. import { Scene } from "babylonjs/scene";
  71561. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71562. import { ISceneComponent } from "babylonjs/sceneComponent";
  71563. module "babylonjs/scene" {
  71564. interface Scene {
  71565. /** @hidden (Backing field) */
  71566. _simplificationQueue: SimplificationQueue;
  71567. /**
  71568. * Gets or sets the simplification queue attached to the scene
  71569. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71570. */
  71571. simplificationQueue: SimplificationQueue;
  71572. }
  71573. }
  71574. module "babylonjs/Meshes/mesh" {
  71575. interface Mesh {
  71576. /**
  71577. * Simplify the mesh according to the given array of settings.
  71578. * Function will return immediately and will simplify async
  71579. * @param settings a collection of simplification settings
  71580. * @param parallelProcessing should all levels calculate parallel or one after the other
  71581. * @param simplificationType the type of simplification to run
  71582. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71583. * @returns the current mesh
  71584. */
  71585. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71586. }
  71587. }
  71588. /**
  71589. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71590. * created in a scene
  71591. */
  71592. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71593. /**
  71594. * The component name helpfull to identify the component in the list of scene components.
  71595. */
  71596. readonly name: string;
  71597. /**
  71598. * The scene the component belongs to.
  71599. */
  71600. scene: Scene;
  71601. /**
  71602. * Creates a new instance of the component for the given scene
  71603. * @param scene Defines the scene to register the component in
  71604. */
  71605. constructor(scene: Scene);
  71606. /**
  71607. * Registers the component in a given scene
  71608. */
  71609. register(): void;
  71610. /**
  71611. * Rebuilds the elements related to this component in case of
  71612. * context lost for instance.
  71613. */
  71614. rebuild(): void;
  71615. /**
  71616. * Disposes the component and the associated ressources
  71617. */
  71618. dispose(): void;
  71619. private _beforeCameraUpdate;
  71620. }
  71621. }
  71622. declare module "babylonjs/Meshes/Builders/index" {
  71623. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71624. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71625. export * from "babylonjs/Meshes/Builders/discBuilder";
  71626. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71627. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71628. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71629. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71630. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71631. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71632. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71633. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71634. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71635. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71636. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71637. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71638. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71639. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71640. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71641. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71642. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71643. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71644. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71645. }
  71646. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71647. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71648. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71649. import { Matrix } from "babylonjs/Maths/math.vector";
  71650. module "babylonjs/Meshes/mesh" {
  71651. interface Mesh {
  71652. /**
  71653. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71654. */
  71655. thinInstanceEnablePicking: boolean;
  71656. /**
  71657. * Creates a new thin instance
  71658. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71659. * @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
  71660. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71661. */
  71662. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71663. /**
  71664. * Adds the transformation (matrix) of the current mesh as a thin instance
  71665. * @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
  71666. * @returns the thin instance index number
  71667. */
  71668. thinInstanceAddSelf(refresh: boolean): number;
  71669. /**
  71670. * Registers a custom attribute to be used with thin instances
  71671. * @param kind name of the attribute
  71672. * @param stride size in floats of the attribute
  71673. */
  71674. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71675. /**
  71676. * Sets the matrix of a thin instance
  71677. * @param index index of the thin instance
  71678. * @param matrix matrix to set
  71679. * @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
  71680. */
  71681. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71682. /**
  71683. * Sets the value of a custom attribute for a thin instance
  71684. * @param kind name of the attribute
  71685. * @param index index of the thin instance
  71686. * @param value value to set
  71687. * @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
  71688. */
  71689. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71690. /**
  71691. * 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.
  71692. */
  71693. thinInstanceCount: number;
  71694. /**
  71695. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71696. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71697. * @param buffer buffer to set
  71698. * @param stride size in floats of each value of the buffer
  71699. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71700. */
  71701. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71702. /**
  71703. * Gets the list of world matrices
  71704. * @return an array containing all the world matrices from the thin instances
  71705. */
  71706. thinInstanceGetWorldMatrices(): Matrix[];
  71707. /**
  71708. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71709. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71710. */
  71711. thinInstanceBufferUpdated(kind: string): void;
  71712. /**
  71713. * Applies a partial update to a buffer directly on the GPU
  71714. * 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
  71715. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71716. * @param data the data to set in the GPU buffer
  71717. * @param offset the offset in the GPU buffer where to update the data
  71718. */
  71719. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71720. /**
  71721. * Refreshes the bounding info, taking into account all the thin instances defined
  71722. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71723. */
  71724. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71725. /** @hidden */
  71726. _thinInstanceInitializeUserStorage(): void;
  71727. /** @hidden */
  71728. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71729. /** @hidden */
  71730. _userThinInstanceBuffersStorage: {
  71731. data: {
  71732. [key: string]: Float32Array;
  71733. };
  71734. sizes: {
  71735. [key: string]: number;
  71736. };
  71737. vertexBuffers: {
  71738. [key: string]: Nullable<VertexBuffer>;
  71739. };
  71740. strides: {
  71741. [key: string]: number;
  71742. };
  71743. };
  71744. }
  71745. }
  71746. }
  71747. declare module "babylonjs/Meshes/index" {
  71748. export * from "babylonjs/Meshes/abstractMesh";
  71749. export * from "babylonjs/Meshes/buffer";
  71750. export * from "babylonjs/Meshes/Compression/index";
  71751. export * from "babylonjs/Meshes/csg";
  71752. export * from "babylonjs/Meshes/geometry";
  71753. export * from "babylonjs/Meshes/groundMesh";
  71754. export * from "babylonjs/Meshes/trailMesh";
  71755. export * from "babylonjs/Meshes/instancedMesh";
  71756. export * from "babylonjs/Meshes/linesMesh";
  71757. export * from "babylonjs/Meshes/mesh";
  71758. export * from "babylonjs/Meshes/mesh.vertexData";
  71759. export * from "babylonjs/Meshes/meshBuilder";
  71760. export * from "babylonjs/Meshes/meshSimplification";
  71761. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71762. export * from "babylonjs/Meshes/polygonMesh";
  71763. export * from "babylonjs/Meshes/subMesh";
  71764. export * from "babylonjs/Meshes/meshLODLevel";
  71765. export * from "babylonjs/Meshes/transformNode";
  71766. export * from "babylonjs/Meshes/Builders/index";
  71767. export * from "babylonjs/Meshes/dataBuffer";
  71768. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71769. import "babylonjs/Meshes/thinInstanceMesh";
  71770. export * from "babylonjs/Meshes/thinInstanceMesh";
  71771. }
  71772. declare module "babylonjs/Morph/index" {
  71773. export * from "babylonjs/Morph/morphTarget";
  71774. export * from "babylonjs/Morph/morphTargetManager";
  71775. }
  71776. declare module "babylonjs/Navigation/INavigationEngine" {
  71777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71778. import { Vector3 } from "babylonjs/Maths/math";
  71779. import { Mesh } from "babylonjs/Meshes/mesh";
  71780. import { Scene } from "babylonjs/scene";
  71781. /**
  71782. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71783. */
  71784. export interface INavigationEnginePlugin {
  71785. /**
  71786. * plugin name
  71787. */
  71788. name: string;
  71789. /**
  71790. * Creates a navigation mesh
  71791. * @param meshes array of all the geometry used to compute the navigatio mesh
  71792. * @param parameters bunch of parameters used to filter geometry
  71793. */
  71794. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71795. /**
  71796. * Create a navigation mesh debug mesh
  71797. * @param scene is where the mesh will be added
  71798. * @returns debug display mesh
  71799. */
  71800. createDebugNavMesh(scene: Scene): Mesh;
  71801. /**
  71802. * Get a navigation mesh constrained position, closest to the parameter position
  71803. * @param position world position
  71804. * @returns the closest point to position constrained by the navigation mesh
  71805. */
  71806. getClosestPoint(position: Vector3): Vector3;
  71807. /**
  71808. * Get a navigation mesh constrained position, closest to the parameter position
  71809. * @param position world position
  71810. * @param result output the closest point to position constrained by the navigation mesh
  71811. */
  71812. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71813. /**
  71814. * Get a navigation mesh constrained position, within a particular radius
  71815. * @param position world position
  71816. * @param maxRadius the maximum distance to the constrained world position
  71817. * @returns the closest point to position constrained by the navigation mesh
  71818. */
  71819. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71820. /**
  71821. * Get a navigation mesh constrained position, within a particular radius
  71822. * @param position world position
  71823. * @param maxRadius the maximum distance to the constrained world position
  71824. * @param result output the closest point to position constrained by the navigation mesh
  71825. */
  71826. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71827. /**
  71828. * Compute the final position from a segment made of destination-position
  71829. * @param position world position
  71830. * @param destination world position
  71831. * @returns the resulting point along the navmesh
  71832. */
  71833. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71834. /**
  71835. * Compute the final position from a segment made of destination-position
  71836. * @param position world position
  71837. * @param destination world position
  71838. * @param result output the resulting point along the navmesh
  71839. */
  71840. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71841. /**
  71842. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71843. * @param start world position
  71844. * @param end world position
  71845. * @returns array containing world position composing the path
  71846. */
  71847. computePath(start: Vector3, end: Vector3): Vector3[];
  71848. /**
  71849. * If this plugin is supported
  71850. * @returns true if plugin is supported
  71851. */
  71852. isSupported(): boolean;
  71853. /**
  71854. * Create a new Crowd so you can add agents
  71855. * @param maxAgents the maximum agent count in the crowd
  71856. * @param maxAgentRadius the maximum radius an agent can have
  71857. * @param scene to attach the crowd to
  71858. * @returns the crowd you can add agents to
  71859. */
  71860. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71861. /**
  71862. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71863. * The queries will try to find a solution within those bounds
  71864. * default is (1,1,1)
  71865. * @param extent x,y,z value that define the extent around the queries point of reference
  71866. */
  71867. setDefaultQueryExtent(extent: Vector3): void;
  71868. /**
  71869. * Get the Bounding box extent specified by setDefaultQueryExtent
  71870. * @returns the box extent values
  71871. */
  71872. getDefaultQueryExtent(): Vector3;
  71873. /**
  71874. * build the navmesh from a previously saved state using getNavmeshData
  71875. * @param data the Uint8Array returned by getNavmeshData
  71876. */
  71877. buildFromNavmeshData(data: Uint8Array): void;
  71878. /**
  71879. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71880. * @returns data the Uint8Array that can be saved and reused
  71881. */
  71882. getNavmeshData(): Uint8Array;
  71883. /**
  71884. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71885. * @param result output the box extent values
  71886. */
  71887. getDefaultQueryExtentToRef(result: Vector3): void;
  71888. /**
  71889. * Set the time step of the navigation tick update.
  71890. * Default is 1/60.
  71891. * A value of 0 will disable fixed time update
  71892. * @param newTimeStep the new timestep to apply to this world.
  71893. */
  71894. setTimeStep(newTimeStep: number): void;
  71895. /**
  71896. * Get the time step of the navigation tick update.
  71897. * @returns the current time step
  71898. */
  71899. getTimeStep(): number;
  71900. /**
  71901. * If delta time in navigation tick update is greater than the time step
  71902. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71903. * they will be discarded.
  71904. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71905. * @param newStepCount the maximum number of iterations
  71906. */
  71907. setMaximumSubStepCount(newStepCount: number): void;
  71908. /**
  71909. * Get the maximum number of iterations per navigation tick update
  71910. * @returns the maximum number of iterations
  71911. */
  71912. getMaximumSubStepCount(): number;
  71913. /**
  71914. * Release all resources
  71915. */
  71916. dispose(): void;
  71917. }
  71918. /**
  71919. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71920. */
  71921. export interface ICrowd {
  71922. /**
  71923. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71924. * You can attach anything to that node. The node position is updated in the scene update tick.
  71925. * @param pos world position that will be constrained by the navigation mesh
  71926. * @param parameters agent parameters
  71927. * @param transform hooked to the agent that will be update by the scene
  71928. * @returns agent index
  71929. */
  71930. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71931. /**
  71932. * Returns the agent position in world space
  71933. * @param index agent index returned by addAgent
  71934. * @returns world space position
  71935. */
  71936. getAgentPosition(index: number): Vector3;
  71937. /**
  71938. * Gets the agent position result in world space
  71939. * @param index agent index returned by addAgent
  71940. * @param result output world space position
  71941. */
  71942. getAgentPositionToRef(index: number, result: Vector3): void;
  71943. /**
  71944. * Gets the agent velocity in world space
  71945. * @param index agent index returned by addAgent
  71946. * @returns world space velocity
  71947. */
  71948. getAgentVelocity(index: number): Vector3;
  71949. /**
  71950. * Gets the agent velocity result in world space
  71951. * @param index agent index returned by addAgent
  71952. * @param result output world space velocity
  71953. */
  71954. getAgentVelocityToRef(index: number, result: Vector3): void;
  71955. /**
  71956. * Gets the agent next target point on the path
  71957. * @param index agent index returned by addAgent
  71958. * @returns world space position
  71959. */
  71960. getAgentNextTargetPath(index: number): Vector3;
  71961. /**
  71962. * Gets the agent state
  71963. * @param index agent index returned by addAgent
  71964. * @returns agent state
  71965. */
  71966. getAgentState(index: number): number;
  71967. /**
  71968. * returns true if the agent in over an off mesh link connection
  71969. * @param index agent index returned by addAgent
  71970. * @returns true if over an off mesh link connection
  71971. */
  71972. overOffmeshConnection(index: number): boolean;
  71973. /**
  71974. * Gets the agent next target point on the path
  71975. * @param index agent index returned by addAgent
  71976. * @param result output world space position
  71977. */
  71978. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71979. /**
  71980. * remove a particular agent previously created
  71981. * @param index agent index returned by addAgent
  71982. */
  71983. removeAgent(index: number): void;
  71984. /**
  71985. * get the list of all agents attached to this crowd
  71986. * @returns list of agent indices
  71987. */
  71988. getAgents(): number[];
  71989. /**
  71990. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71991. * @param deltaTime in seconds
  71992. */
  71993. update(deltaTime: number): void;
  71994. /**
  71995. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71996. * @param index agent index returned by addAgent
  71997. * @param destination targeted world position
  71998. */
  71999. agentGoto(index: number, destination: Vector3): void;
  72000. /**
  72001. * Teleport the agent to a new position
  72002. * @param index agent index returned by addAgent
  72003. * @param destination targeted world position
  72004. */
  72005. agentTeleport(index: number, destination: Vector3): void;
  72006. /**
  72007. * Update agent parameters
  72008. * @param index agent index returned by addAgent
  72009. * @param parameters agent parameters
  72010. */
  72011. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72012. /**
  72013. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72014. * The queries will try to find a solution within those bounds
  72015. * default is (1,1,1)
  72016. * @param extent x,y,z value that define the extent around the queries point of reference
  72017. */
  72018. setDefaultQueryExtent(extent: Vector3): void;
  72019. /**
  72020. * Get the Bounding box extent specified by setDefaultQueryExtent
  72021. * @returns the box extent values
  72022. */
  72023. getDefaultQueryExtent(): Vector3;
  72024. /**
  72025. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72026. * @param result output the box extent values
  72027. */
  72028. getDefaultQueryExtentToRef(result: Vector3): void;
  72029. /**
  72030. * Release all resources
  72031. */
  72032. dispose(): void;
  72033. }
  72034. /**
  72035. * Configures an agent
  72036. */
  72037. export interface IAgentParameters {
  72038. /**
  72039. * Agent radius. [Limit: >= 0]
  72040. */
  72041. radius: number;
  72042. /**
  72043. * Agent height. [Limit: > 0]
  72044. */
  72045. height: number;
  72046. /**
  72047. * Maximum allowed acceleration. [Limit: >= 0]
  72048. */
  72049. maxAcceleration: number;
  72050. /**
  72051. * Maximum allowed speed. [Limit: >= 0]
  72052. */
  72053. maxSpeed: number;
  72054. /**
  72055. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72056. */
  72057. collisionQueryRange: number;
  72058. /**
  72059. * The path visibility optimization range. [Limit: > 0]
  72060. */
  72061. pathOptimizationRange: number;
  72062. /**
  72063. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72064. */
  72065. separationWeight: number;
  72066. }
  72067. /**
  72068. * Configures the navigation mesh creation
  72069. */
  72070. export interface INavMeshParameters {
  72071. /**
  72072. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72073. */
  72074. cs: number;
  72075. /**
  72076. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72077. */
  72078. ch: number;
  72079. /**
  72080. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72081. */
  72082. walkableSlopeAngle: number;
  72083. /**
  72084. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72085. * be considered walkable. [Limit: >= 3] [Units: vx]
  72086. */
  72087. walkableHeight: number;
  72088. /**
  72089. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72090. */
  72091. walkableClimb: number;
  72092. /**
  72093. * The distance to erode/shrink the walkable area of the heightfield away from
  72094. * obstructions. [Limit: >=0] [Units: vx]
  72095. */
  72096. walkableRadius: number;
  72097. /**
  72098. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72099. */
  72100. maxEdgeLen: number;
  72101. /**
  72102. * The maximum distance a simplfied contour's border edges should deviate
  72103. * the original raw contour. [Limit: >=0] [Units: vx]
  72104. */
  72105. maxSimplificationError: number;
  72106. /**
  72107. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72108. */
  72109. minRegionArea: number;
  72110. /**
  72111. * Any regions with a span count smaller than this value will, if possible,
  72112. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72113. */
  72114. mergeRegionArea: number;
  72115. /**
  72116. * The maximum number of vertices allowed for polygons generated during the
  72117. * contour to polygon conversion process. [Limit: >= 3]
  72118. */
  72119. maxVertsPerPoly: number;
  72120. /**
  72121. * Sets the sampling distance to use when generating the detail mesh.
  72122. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72123. */
  72124. detailSampleDist: number;
  72125. /**
  72126. * The maximum distance the detail mesh surface should deviate from heightfield
  72127. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72128. */
  72129. detailSampleMaxError: number;
  72130. }
  72131. }
  72132. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  72133. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  72134. import { Mesh } from "babylonjs/Meshes/mesh";
  72135. import { Scene } from "babylonjs/scene";
  72136. import { Vector3 } from "babylonjs/Maths/math";
  72137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72138. /**
  72139. * RecastJS navigation plugin
  72140. */
  72141. export class RecastJSPlugin implements INavigationEnginePlugin {
  72142. /**
  72143. * Reference to the Recast library
  72144. */
  72145. bjsRECAST: any;
  72146. /**
  72147. * plugin name
  72148. */
  72149. name: string;
  72150. /**
  72151. * the first navmesh created. We might extend this to support multiple navmeshes
  72152. */
  72153. navMesh: any;
  72154. private _maximumSubStepCount;
  72155. private _timeStep;
  72156. /**
  72157. * Initializes the recastJS plugin
  72158. * @param recastInjection can be used to inject your own recast reference
  72159. */
  72160. constructor(recastInjection?: any);
  72161. /**
  72162. * Set the time step of the navigation tick update.
  72163. * Default is 1/60.
  72164. * A value of 0 will disable fixed time update
  72165. * @param newTimeStep the new timestep to apply to this world.
  72166. */
  72167. setTimeStep(newTimeStep?: number): void;
  72168. /**
  72169. * Get the time step of the navigation tick update.
  72170. * @returns the current time step
  72171. */
  72172. getTimeStep(): number;
  72173. /**
  72174. * If delta time in navigation tick update is greater than the time step
  72175. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72176. * they will be discarded.
  72177. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72178. * @param newStepCount the maximum number of iterations
  72179. */
  72180. setMaximumSubStepCount(newStepCount?: number): void;
  72181. /**
  72182. * Get the maximum number of iterations per navigation tick update
  72183. * @returns the maximum number of iterations
  72184. */
  72185. getMaximumSubStepCount(): number;
  72186. /**
  72187. * Creates a navigation mesh
  72188. * @param meshes array of all the geometry used to compute the navigatio mesh
  72189. * @param parameters bunch of parameters used to filter geometry
  72190. */
  72191. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72192. /**
  72193. * Create a navigation mesh debug mesh
  72194. * @param scene is where the mesh will be added
  72195. * @returns debug display mesh
  72196. */
  72197. createDebugNavMesh(scene: Scene): Mesh;
  72198. /**
  72199. * Get a navigation mesh constrained position, closest to the parameter position
  72200. * @param position world position
  72201. * @returns the closest point to position constrained by the navigation mesh
  72202. */
  72203. getClosestPoint(position: Vector3): Vector3;
  72204. /**
  72205. * Get a navigation mesh constrained position, closest to the parameter position
  72206. * @param position world position
  72207. * @param result output the closest point to position constrained by the navigation mesh
  72208. */
  72209. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72210. /**
  72211. * Get a navigation mesh constrained position, within a particular radius
  72212. * @param position world position
  72213. * @param maxRadius the maximum distance to the constrained world position
  72214. * @returns the closest point to position constrained by the navigation mesh
  72215. */
  72216. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72217. /**
  72218. * Get a navigation mesh constrained position, within a particular radius
  72219. * @param position world position
  72220. * @param maxRadius the maximum distance to the constrained world position
  72221. * @param result output the closest point to position constrained by the navigation mesh
  72222. */
  72223. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72224. /**
  72225. * Compute the final position from a segment made of destination-position
  72226. * @param position world position
  72227. * @param destination world position
  72228. * @returns the resulting point along the navmesh
  72229. */
  72230. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72231. /**
  72232. * Compute the final position from a segment made of destination-position
  72233. * @param position world position
  72234. * @param destination world position
  72235. * @param result output the resulting point along the navmesh
  72236. */
  72237. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72238. /**
  72239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72240. * @param start world position
  72241. * @param end world position
  72242. * @returns array containing world position composing the path
  72243. */
  72244. computePath(start: Vector3, end: Vector3): Vector3[];
  72245. /**
  72246. * Create a new Crowd so you can add agents
  72247. * @param maxAgents the maximum agent count in the crowd
  72248. * @param maxAgentRadius the maximum radius an agent can have
  72249. * @param scene to attach the crowd to
  72250. * @returns the crowd you can add agents to
  72251. */
  72252. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72253. /**
  72254. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72255. * The queries will try to find a solution within those bounds
  72256. * default is (1,1,1)
  72257. * @param extent x,y,z value that define the extent around the queries point of reference
  72258. */
  72259. setDefaultQueryExtent(extent: Vector3): void;
  72260. /**
  72261. * Get the Bounding box extent specified by setDefaultQueryExtent
  72262. * @returns the box extent values
  72263. */
  72264. getDefaultQueryExtent(): Vector3;
  72265. /**
  72266. * build the navmesh from a previously saved state using getNavmeshData
  72267. * @param data the Uint8Array returned by getNavmeshData
  72268. */
  72269. buildFromNavmeshData(data: Uint8Array): void;
  72270. /**
  72271. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72272. * @returns data the Uint8Array that can be saved and reused
  72273. */
  72274. getNavmeshData(): Uint8Array;
  72275. /**
  72276. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72277. * @param result output the box extent values
  72278. */
  72279. getDefaultQueryExtentToRef(result: Vector3): void;
  72280. /**
  72281. * Disposes
  72282. */
  72283. dispose(): void;
  72284. /**
  72285. * If this plugin is supported
  72286. * @returns true if plugin is supported
  72287. */
  72288. isSupported(): boolean;
  72289. }
  72290. /**
  72291. * Recast detour crowd implementation
  72292. */
  72293. export class RecastJSCrowd implements ICrowd {
  72294. /**
  72295. * Recast/detour plugin
  72296. */
  72297. bjsRECASTPlugin: RecastJSPlugin;
  72298. /**
  72299. * Link to the detour crowd
  72300. */
  72301. recastCrowd: any;
  72302. /**
  72303. * One transform per agent
  72304. */
  72305. transforms: TransformNode[];
  72306. /**
  72307. * All agents created
  72308. */
  72309. agents: number[];
  72310. /**
  72311. * Link to the scene is kept to unregister the crowd from the scene
  72312. */
  72313. private _scene;
  72314. /**
  72315. * Observer for crowd updates
  72316. */
  72317. private _onBeforeAnimationsObserver;
  72318. /**
  72319. * Constructor
  72320. * @param plugin recastJS plugin
  72321. * @param maxAgents the maximum agent count in the crowd
  72322. * @param maxAgentRadius the maximum radius an agent can have
  72323. * @param scene to attach the crowd to
  72324. * @returns the crowd you can add agents to
  72325. */
  72326. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72327. /**
  72328. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72329. * You can attach anything to that node. The node position is updated in the scene update tick.
  72330. * @param pos world position that will be constrained by the navigation mesh
  72331. * @param parameters agent parameters
  72332. * @param transform hooked to the agent that will be update by the scene
  72333. * @returns agent index
  72334. */
  72335. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72336. /**
  72337. * Returns the agent position in world space
  72338. * @param index agent index returned by addAgent
  72339. * @returns world space position
  72340. */
  72341. getAgentPosition(index: number): Vector3;
  72342. /**
  72343. * Returns the agent position result in world space
  72344. * @param index agent index returned by addAgent
  72345. * @param result output world space position
  72346. */
  72347. getAgentPositionToRef(index: number, result: Vector3): void;
  72348. /**
  72349. * Returns the agent velocity in world space
  72350. * @param index agent index returned by addAgent
  72351. * @returns world space velocity
  72352. */
  72353. getAgentVelocity(index: number): Vector3;
  72354. /**
  72355. * Returns the agent velocity result in world space
  72356. * @param index agent index returned by addAgent
  72357. * @param result output world space velocity
  72358. */
  72359. getAgentVelocityToRef(index: number, result: Vector3): void;
  72360. /**
  72361. * Returns the agent next target point on the path
  72362. * @param index agent index returned by addAgent
  72363. * @returns world space position
  72364. */
  72365. getAgentNextTargetPath(index: number): Vector3;
  72366. /**
  72367. * Returns the agent next target point on the path
  72368. * @param index agent index returned by addAgent
  72369. * @param result output world space position
  72370. */
  72371. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72372. /**
  72373. * Gets the agent state
  72374. * @param index agent index returned by addAgent
  72375. * @returns agent state
  72376. */
  72377. getAgentState(index: number): number;
  72378. /**
  72379. * returns true if the agent in over an off mesh link connection
  72380. * @param index agent index returned by addAgent
  72381. * @returns true if over an off mesh link connection
  72382. */
  72383. overOffmeshConnection(index: number): boolean;
  72384. /**
  72385. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72386. * @param index agent index returned by addAgent
  72387. * @param destination targeted world position
  72388. */
  72389. agentGoto(index: number, destination: Vector3): void;
  72390. /**
  72391. * Teleport the agent to a new position
  72392. * @param index agent index returned by addAgent
  72393. * @param destination targeted world position
  72394. */
  72395. agentTeleport(index: number, destination: Vector3): void;
  72396. /**
  72397. * Update agent parameters
  72398. * @param index agent index returned by addAgent
  72399. * @param parameters agent parameters
  72400. */
  72401. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72402. /**
  72403. * remove a particular agent previously created
  72404. * @param index agent index returned by addAgent
  72405. */
  72406. removeAgent(index: number): void;
  72407. /**
  72408. * get the list of all agents attached to this crowd
  72409. * @returns list of agent indices
  72410. */
  72411. getAgents(): number[];
  72412. /**
  72413. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72414. * @param deltaTime in seconds
  72415. */
  72416. update(deltaTime: number): void;
  72417. /**
  72418. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72419. * The queries will try to find a solution within those bounds
  72420. * default is (1,1,1)
  72421. * @param extent x,y,z value that define the extent around the queries point of reference
  72422. */
  72423. setDefaultQueryExtent(extent: Vector3): void;
  72424. /**
  72425. * Get the Bounding box extent specified by setDefaultQueryExtent
  72426. * @returns the box extent values
  72427. */
  72428. getDefaultQueryExtent(): Vector3;
  72429. /**
  72430. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72431. * @param result output the box extent values
  72432. */
  72433. getDefaultQueryExtentToRef(result: Vector3): void;
  72434. /**
  72435. * Release all resources
  72436. */
  72437. dispose(): void;
  72438. }
  72439. }
  72440. declare module "babylonjs/Navigation/Plugins/index" {
  72441. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72442. }
  72443. declare module "babylonjs/Navigation/index" {
  72444. export * from "babylonjs/Navigation/INavigationEngine";
  72445. export * from "babylonjs/Navigation/Plugins/index";
  72446. }
  72447. declare module "babylonjs/Offline/database" {
  72448. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72449. /**
  72450. * Class used to enable access to IndexedDB
  72451. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72452. */
  72453. export class Database implements IOfflineProvider {
  72454. private _callbackManifestChecked;
  72455. private _currentSceneUrl;
  72456. private _db;
  72457. private _enableSceneOffline;
  72458. private _enableTexturesOffline;
  72459. private _manifestVersionFound;
  72460. private _mustUpdateRessources;
  72461. private _hasReachedQuota;
  72462. private _isSupported;
  72463. private _idbFactory;
  72464. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72465. private static IsUASupportingBlobStorage;
  72466. /**
  72467. * Gets a boolean indicating if Database storate is enabled (off by default)
  72468. */
  72469. static IDBStorageEnabled: boolean;
  72470. /**
  72471. * Gets a boolean indicating if scene must be saved in the database
  72472. */
  72473. get enableSceneOffline(): boolean;
  72474. /**
  72475. * Gets a boolean indicating if textures must be saved in the database
  72476. */
  72477. get enableTexturesOffline(): boolean;
  72478. /**
  72479. * Creates a new Database
  72480. * @param urlToScene defines the url to load the scene
  72481. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72482. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72483. */
  72484. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72485. private static _ParseURL;
  72486. private static _ReturnFullUrlLocation;
  72487. private _checkManifestFile;
  72488. /**
  72489. * Open the database and make it available
  72490. * @param successCallback defines the callback to call on success
  72491. * @param errorCallback defines the callback to call on error
  72492. */
  72493. open(successCallback: () => void, errorCallback: () => void): void;
  72494. /**
  72495. * Loads an image from the database
  72496. * @param url defines the url to load from
  72497. * @param image defines the target DOM image
  72498. */
  72499. loadImage(url: string, image: HTMLImageElement): void;
  72500. private _loadImageFromDBAsync;
  72501. private _saveImageIntoDBAsync;
  72502. private _checkVersionFromDB;
  72503. private _loadVersionFromDBAsync;
  72504. private _saveVersionIntoDBAsync;
  72505. /**
  72506. * Loads a file from database
  72507. * @param url defines the URL to load from
  72508. * @param sceneLoaded defines a callback to call on success
  72509. * @param progressCallBack defines a callback to call when progress changed
  72510. * @param errorCallback defines a callback to call on error
  72511. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72512. */
  72513. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72514. private _loadFileAsync;
  72515. private _saveFileAsync;
  72516. /**
  72517. * Validates if xhr data is correct
  72518. * @param xhr defines the request to validate
  72519. * @param dataType defines the expected data type
  72520. * @returns true if data is correct
  72521. */
  72522. private static _ValidateXHRData;
  72523. }
  72524. }
  72525. declare module "babylonjs/Offline/index" {
  72526. export * from "babylonjs/Offline/database";
  72527. export * from "babylonjs/Offline/IOfflineProvider";
  72528. }
  72529. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72530. /** @hidden */
  72531. export var gpuUpdateParticlesPixelShader: {
  72532. name: string;
  72533. shader: string;
  72534. };
  72535. }
  72536. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72537. /** @hidden */
  72538. export var gpuUpdateParticlesVertexShader: {
  72539. name: string;
  72540. shader: string;
  72541. };
  72542. }
  72543. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72544. /** @hidden */
  72545. export var clipPlaneFragmentDeclaration2: {
  72546. name: string;
  72547. shader: string;
  72548. };
  72549. }
  72550. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72555. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72556. /** @hidden */
  72557. export var gpuRenderParticlesPixelShader: {
  72558. name: string;
  72559. shader: string;
  72560. };
  72561. }
  72562. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72563. /** @hidden */
  72564. export var clipPlaneVertexDeclaration2: {
  72565. name: string;
  72566. shader: string;
  72567. };
  72568. }
  72569. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72572. /** @hidden */
  72573. export var gpuRenderParticlesVertexShader: {
  72574. name: string;
  72575. shader: string;
  72576. };
  72577. }
  72578. declare module "babylonjs/Particles/gpuParticleSystem" {
  72579. import { Nullable } from "babylonjs/types";
  72580. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72581. import { Observable } from "babylonjs/Misc/observable";
  72582. import { Matrix } from "babylonjs/Maths/math.vector";
  72583. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72585. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72586. import { IDisposable } from "babylonjs/scene";
  72587. import { Effect } from "babylonjs/Materials/effect";
  72588. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72590. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72591. import { Scene } from "babylonjs/scene";
  72592. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72593. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72594. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72595. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72596. /**
  72597. * This represents a GPU particle system in Babylon
  72598. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72599. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72600. */
  72601. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72602. /**
  72603. * The layer mask we are rendering the particles through.
  72604. */
  72605. layerMask: number;
  72606. private _capacity;
  72607. private _activeCount;
  72608. private _currentActiveCount;
  72609. private _accumulatedCount;
  72610. private _renderEffect;
  72611. private _updateEffect;
  72612. private _buffer0;
  72613. private _buffer1;
  72614. private _spriteBuffer;
  72615. private _updateVAO;
  72616. private _renderVAO;
  72617. private _targetIndex;
  72618. private _sourceBuffer;
  72619. private _targetBuffer;
  72620. private _currentRenderId;
  72621. private _started;
  72622. private _stopped;
  72623. private _timeDelta;
  72624. private _randomTexture;
  72625. private _randomTexture2;
  72626. private _attributesStrideSize;
  72627. private _updateEffectOptions;
  72628. private _randomTextureSize;
  72629. private _actualFrame;
  72630. private _customEffect;
  72631. private readonly _rawTextureWidth;
  72632. /**
  72633. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72634. */
  72635. static get IsSupported(): boolean;
  72636. /**
  72637. * An event triggered when the system is disposed.
  72638. */
  72639. onDisposeObservable: Observable<IParticleSystem>;
  72640. /**
  72641. * An event triggered when the system is stopped
  72642. */
  72643. onStoppedObservable: Observable<IParticleSystem>;
  72644. /**
  72645. * Gets the maximum number of particles active at the same time.
  72646. * @returns The max number of active particles.
  72647. */
  72648. getCapacity(): number;
  72649. /**
  72650. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72651. * to override the particles.
  72652. */
  72653. forceDepthWrite: boolean;
  72654. /**
  72655. * Gets or set the number of active particles
  72656. */
  72657. get activeParticleCount(): number;
  72658. set activeParticleCount(value: number);
  72659. private _preWarmDone;
  72660. /**
  72661. * Specifies if the particles are updated in emitter local space or world space.
  72662. */
  72663. isLocal: boolean;
  72664. /** Gets or sets a matrix to use to compute projection */
  72665. defaultProjectionMatrix: Matrix;
  72666. /**
  72667. * Is this system ready to be used/rendered
  72668. * @return true if the system is ready
  72669. */
  72670. isReady(): boolean;
  72671. /**
  72672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72673. * @returns True if it has been started, otherwise false.
  72674. */
  72675. isStarted(): boolean;
  72676. /**
  72677. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72678. * @returns True if it has been stopped, otherwise false.
  72679. */
  72680. isStopped(): boolean;
  72681. /**
  72682. * Gets a boolean indicating that the system is stopping
  72683. * @returns true if the system is currently stopping
  72684. */
  72685. isStopping(): boolean;
  72686. /**
  72687. * Gets the number of particles active at the same time.
  72688. * @returns The number of active particles.
  72689. */
  72690. getActiveCount(): number;
  72691. /**
  72692. * Starts the particle system and begins to emit
  72693. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72694. */
  72695. start(delay?: number): void;
  72696. /**
  72697. * Stops the particle system.
  72698. */
  72699. stop(): void;
  72700. /**
  72701. * Remove all active particles
  72702. */
  72703. reset(): void;
  72704. /**
  72705. * Returns the string "GPUParticleSystem"
  72706. * @returns a string containing the class name
  72707. */
  72708. getClassName(): string;
  72709. /**
  72710. * Gets the custom effect used to render the particles
  72711. * @param blendMode Blend mode for which the effect should be retrieved
  72712. * @returns The effect
  72713. */
  72714. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72715. /**
  72716. * Sets the custom effect used to render the particles
  72717. * @param effect The effect to set
  72718. * @param blendMode Blend mode for which the effect should be set
  72719. */
  72720. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72721. /** @hidden */
  72722. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72723. /**
  72724. * Observable that will be called just before the particles are drawn
  72725. */
  72726. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72727. /**
  72728. * Gets the name of the particle vertex shader
  72729. */
  72730. get vertexShaderName(): string;
  72731. private _colorGradientsTexture;
  72732. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72733. /**
  72734. * Adds a new color gradient
  72735. * @param gradient defines the gradient to use (between 0 and 1)
  72736. * @param color1 defines the color to affect to the specified gradient
  72737. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72738. * @returns the current particle system
  72739. */
  72740. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72741. private _refreshColorGradient;
  72742. /** Force the system to rebuild all gradients that need to be resync */
  72743. forceRefreshGradients(): void;
  72744. /**
  72745. * Remove a specific color gradient
  72746. * @param gradient defines the gradient to remove
  72747. * @returns the current particle system
  72748. */
  72749. removeColorGradient(gradient: number): GPUParticleSystem;
  72750. private _angularSpeedGradientsTexture;
  72751. private _sizeGradientsTexture;
  72752. private _velocityGradientsTexture;
  72753. private _limitVelocityGradientsTexture;
  72754. private _dragGradientsTexture;
  72755. private _addFactorGradient;
  72756. /**
  72757. * Adds a new size gradient
  72758. * @param gradient defines the gradient to use (between 0 and 1)
  72759. * @param factor defines the size factor to affect to the specified gradient
  72760. * @returns the current particle system
  72761. */
  72762. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72763. /**
  72764. * Remove a specific size gradient
  72765. * @param gradient defines the gradient to remove
  72766. * @returns the current particle system
  72767. */
  72768. removeSizeGradient(gradient: number): GPUParticleSystem;
  72769. private _refreshFactorGradient;
  72770. /**
  72771. * Adds a new angular speed gradient
  72772. * @param gradient defines the gradient to use (between 0 and 1)
  72773. * @param factor defines the angular speed to affect to the specified gradient
  72774. * @returns the current particle system
  72775. */
  72776. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72777. /**
  72778. * Remove a specific angular speed gradient
  72779. * @param gradient defines the gradient to remove
  72780. * @returns the current particle system
  72781. */
  72782. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72783. /**
  72784. * Adds a new velocity gradient
  72785. * @param gradient defines the gradient to use (between 0 and 1)
  72786. * @param factor defines the velocity to affect to the specified gradient
  72787. * @returns the current particle system
  72788. */
  72789. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72790. /**
  72791. * Remove a specific velocity gradient
  72792. * @param gradient defines the gradient to remove
  72793. * @returns the current particle system
  72794. */
  72795. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72796. /**
  72797. * Adds a new limit velocity gradient
  72798. * @param gradient defines the gradient to use (between 0 and 1)
  72799. * @param factor defines the limit velocity value to affect to the specified gradient
  72800. * @returns the current particle system
  72801. */
  72802. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72803. /**
  72804. * Remove a specific limit velocity gradient
  72805. * @param gradient defines the gradient to remove
  72806. * @returns the current particle system
  72807. */
  72808. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72809. /**
  72810. * Adds a new drag gradient
  72811. * @param gradient defines the gradient to use (between 0 and 1)
  72812. * @param factor defines the drag value to affect to the specified gradient
  72813. * @returns the current particle system
  72814. */
  72815. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72816. /**
  72817. * Remove a specific drag gradient
  72818. * @param gradient defines the gradient to remove
  72819. * @returns the current particle system
  72820. */
  72821. removeDragGradient(gradient: number): GPUParticleSystem;
  72822. /**
  72823. * Not supported by GPUParticleSystem
  72824. * @param gradient defines the gradient to use (between 0 and 1)
  72825. * @param factor defines the emit rate value to affect to the specified gradient
  72826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72827. * @returns the current particle system
  72828. */
  72829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72830. /**
  72831. * Not supported by GPUParticleSystem
  72832. * @param gradient defines the gradient to remove
  72833. * @returns the current particle system
  72834. */
  72835. removeEmitRateGradient(gradient: number): IParticleSystem;
  72836. /**
  72837. * Not supported by GPUParticleSystem
  72838. * @param gradient defines the gradient to use (between 0 and 1)
  72839. * @param factor defines the start size value to affect to the specified gradient
  72840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72841. * @returns the current particle system
  72842. */
  72843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72844. /**
  72845. * Not supported by GPUParticleSystem
  72846. * @param gradient defines the gradient to remove
  72847. * @returns the current particle system
  72848. */
  72849. removeStartSizeGradient(gradient: number): IParticleSystem;
  72850. /**
  72851. * Not supported by GPUParticleSystem
  72852. * @param gradient defines the gradient to use (between 0 and 1)
  72853. * @param min defines the color remap minimal range
  72854. * @param max defines the color remap maximal range
  72855. * @returns the current particle system
  72856. */
  72857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72858. /**
  72859. * Not supported by GPUParticleSystem
  72860. * @param gradient defines the gradient to remove
  72861. * @returns the current particle system
  72862. */
  72863. removeColorRemapGradient(): IParticleSystem;
  72864. /**
  72865. * Not supported by GPUParticleSystem
  72866. * @param gradient defines the gradient to use (between 0 and 1)
  72867. * @param min defines the alpha remap minimal range
  72868. * @param max defines the alpha remap maximal range
  72869. * @returns the current particle system
  72870. */
  72871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72872. /**
  72873. * Not supported by GPUParticleSystem
  72874. * @param gradient defines the gradient to remove
  72875. * @returns the current particle system
  72876. */
  72877. removeAlphaRemapGradient(): IParticleSystem;
  72878. /**
  72879. * Not supported by GPUParticleSystem
  72880. * @param gradient defines the gradient to use (between 0 and 1)
  72881. * @param color defines the color to affect to the specified gradient
  72882. * @returns the current particle system
  72883. */
  72884. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72885. /**
  72886. * Not supported by GPUParticleSystem
  72887. * @param gradient defines the gradient to remove
  72888. * @returns the current particle system
  72889. */
  72890. removeRampGradient(): IParticleSystem;
  72891. /**
  72892. * Not supported by GPUParticleSystem
  72893. * @returns the list of ramp gradients
  72894. */
  72895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72896. /**
  72897. * Not supported by GPUParticleSystem
  72898. * Gets or sets a boolean indicating that ramp gradients must be used
  72899. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72900. */
  72901. get useRampGradients(): boolean;
  72902. set useRampGradients(value: boolean);
  72903. /**
  72904. * Not supported by GPUParticleSystem
  72905. * @param gradient defines the gradient to use (between 0 and 1)
  72906. * @param factor defines the life time factor to affect to the specified gradient
  72907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72908. * @returns the current particle system
  72909. */
  72910. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72911. /**
  72912. * Not supported by GPUParticleSystem
  72913. * @param gradient defines the gradient to remove
  72914. * @returns the current particle system
  72915. */
  72916. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72917. /**
  72918. * Instantiates a GPU particle system.
  72919. * 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.
  72920. * @param name The name of the particle system
  72921. * @param options The options used to create the system
  72922. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72924. * @param customEffect a custom effect used to change the way particles are rendered by default
  72925. */
  72926. constructor(name: string, options: Partial<{
  72927. capacity: number;
  72928. randomTextureSize: number;
  72929. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72930. protected _reset(): void;
  72931. private _createUpdateVAO;
  72932. private _createRenderVAO;
  72933. private _initialize;
  72934. /** @hidden */
  72935. _recreateUpdateEffect(): void;
  72936. private _getEffect;
  72937. /**
  72938. * Fill the defines array according to the current settings of the particle system
  72939. * @param defines Array to be updated
  72940. * @param blendMode blend mode to take into account when updating the array
  72941. */
  72942. fillDefines(defines: Array<string>, blendMode?: number): void;
  72943. /**
  72944. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72945. * @param uniforms Uniforms array to fill
  72946. * @param attributes Attributes array to fill
  72947. * @param samplers Samplers array to fill
  72948. */
  72949. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72950. /** @hidden */
  72951. _recreateRenderEffect(): Effect;
  72952. /**
  72953. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72954. * @param preWarm defines if we are in the pre-warmimg phase
  72955. */
  72956. animate(preWarm?: boolean): void;
  72957. private _createFactorGradientTexture;
  72958. private _createSizeGradientTexture;
  72959. private _createAngularSpeedGradientTexture;
  72960. private _createVelocityGradientTexture;
  72961. private _createLimitVelocityGradientTexture;
  72962. private _createDragGradientTexture;
  72963. private _createColorGradientTexture;
  72964. /**
  72965. * Renders the particle system in its current state
  72966. * @param preWarm defines if the system should only update the particles but not render them
  72967. * @returns the current number of particles
  72968. */
  72969. render(preWarm?: boolean): number;
  72970. /**
  72971. * Rebuilds the particle system
  72972. */
  72973. rebuild(): void;
  72974. private _releaseBuffers;
  72975. private _releaseVAOs;
  72976. /**
  72977. * Disposes the particle system and free the associated resources
  72978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72979. */
  72980. dispose(disposeTexture?: boolean): void;
  72981. /**
  72982. * Clones the particle system.
  72983. * @param name The name of the cloned object
  72984. * @param newEmitter The new emitter to use
  72985. * @returns the cloned particle system
  72986. */
  72987. clone(name: string, newEmitter: any): GPUParticleSystem;
  72988. /**
  72989. * Serializes the particle system to a JSON object
  72990. * @param serializeTexture defines if the texture must be serialized as well
  72991. * @returns the JSON object
  72992. */
  72993. serialize(serializeTexture?: boolean): any;
  72994. /**
  72995. * Parses a JSON object to create a GPU particle system.
  72996. * @param parsedParticleSystem The JSON object to parse
  72997. * @param sceneOrEngine The scene or the engine to create the particle system in
  72998. * @param rootUrl The root url to use to load external dependencies like texture
  72999. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73000. * @returns the parsed GPU particle system
  73001. */
  73002. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73003. }
  73004. }
  73005. declare module "babylonjs/Particles/particleSystemSet" {
  73006. import { Nullable } from "babylonjs/types";
  73007. import { Color3 } from "babylonjs/Maths/math.color";
  73008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73010. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73011. import { Scene, IDisposable } from "babylonjs/scene";
  73012. /**
  73013. * Represents a set of particle systems working together to create a specific effect
  73014. */
  73015. export class ParticleSystemSet implements IDisposable {
  73016. /**
  73017. * Gets or sets base Assets URL
  73018. */
  73019. static BaseAssetsUrl: string;
  73020. private _emitterCreationOptions;
  73021. private _emitterNode;
  73022. /**
  73023. * Gets the particle system list
  73024. */
  73025. systems: IParticleSystem[];
  73026. /**
  73027. * Gets the emitter node used with this set
  73028. */
  73029. get emitterNode(): Nullable<TransformNode>;
  73030. /**
  73031. * Creates a new emitter mesh as a sphere
  73032. * @param options defines the options used to create the sphere
  73033. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73034. * @param scene defines the hosting scene
  73035. */
  73036. setEmitterAsSphere(options: {
  73037. diameter: number;
  73038. segments: number;
  73039. color: Color3;
  73040. }, renderingGroupId: number, scene: Scene): void;
  73041. /**
  73042. * Starts all particle systems of the set
  73043. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73044. */
  73045. start(emitter?: AbstractMesh): void;
  73046. /**
  73047. * Release all associated resources
  73048. */
  73049. dispose(): void;
  73050. /**
  73051. * Serialize the set into a JSON compatible object
  73052. * @param serializeTexture defines if the texture must be serialized as well
  73053. * @returns a JSON compatible representation of the set
  73054. */
  73055. serialize(serializeTexture?: boolean): any;
  73056. /**
  73057. * Parse a new ParticleSystemSet from a serialized source
  73058. * @param data defines a JSON compatible representation of the set
  73059. * @param scene defines the hosting scene
  73060. * @param gpu defines if we want GPU particles or CPU particles
  73061. * @returns a new ParticleSystemSet
  73062. */
  73063. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73064. }
  73065. }
  73066. declare module "babylonjs/Particles/particleHelper" {
  73067. import { Nullable } from "babylonjs/types";
  73068. import { Scene } from "babylonjs/scene";
  73069. import { Vector3 } from "babylonjs/Maths/math.vector";
  73070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73071. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73072. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  73073. /**
  73074. * This class is made for on one-liner static method to help creating particle system set.
  73075. */
  73076. export class ParticleHelper {
  73077. /**
  73078. * Gets or sets base Assets URL
  73079. */
  73080. static BaseAssetsUrl: string;
  73081. /** Define the Url to load snippets */
  73082. static SnippetUrl: string;
  73083. /**
  73084. * Create a default particle system that you can tweak
  73085. * @param emitter defines the emitter to use
  73086. * @param capacity defines the system capacity (default is 500 particles)
  73087. * @param scene defines the hosting scene
  73088. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73089. * @returns the new Particle system
  73090. */
  73091. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73092. /**
  73093. * This is the main static method (one-liner) of this helper to create different particle systems
  73094. * @param type This string represents the type to the particle system to create
  73095. * @param scene The scene where the particle system should live
  73096. * @param gpu If the system will use gpu
  73097. * @returns the ParticleSystemSet created
  73098. */
  73099. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73100. /**
  73101. * Static function used to export a particle system to a ParticleSystemSet variable.
  73102. * Please note that the emitter shape is not exported
  73103. * @param systems defines the particle systems to export
  73104. * @returns the created particle system set
  73105. */
  73106. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73107. /**
  73108. * Creates a particle system from a snippet saved in a remote file
  73109. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73110. * @param url defines the url to load from
  73111. * @param scene defines the hosting scene
  73112. * @param gpu If the system will use gpu
  73113. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73114. * @returns a promise that will resolve to the new particle system
  73115. */
  73116. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73117. /**
  73118. * Creates a particle system from a snippet saved by the particle system editor
  73119. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73120. * @param scene defines the hosting scene
  73121. * @param gpu If the system will use gpu
  73122. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73123. * @returns a promise that will resolve to the new particle system
  73124. */
  73125. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73126. }
  73127. }
  73128. declare module "babylonjs/Particles/particleSystemComponent" {
  73129. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73130. import { Effect } from "babylonjs/Materials/effect";
  73131. import "babylonjs/Shaders/particles.vertex";
  73132. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  73133. module "babylonjs/Engines/engine" {
  73134. interface Engine {
  73135. /**
  73136. * Create an effect to use with particle systems.
  73137. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73138. * the particle system for which you want to create a custom effect in the last parameter
  73139. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73140. * @param uniformsNames defines a list of attribute names
  73141. * @param samplers defines an array of string used to represent textures
  73142. * @param defines defines the string containing the defines to use to compile the shaders
  73143. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  73144. * @param onCompiled defines a function to call when the effect creation is successful
  73145. * @param onError defines a function to call when the effect creation has failed
  73146. * @param particleSystem the particle system you want to create the effect for
  73147. * @returns the new Effect
  73148. */
  73149. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73150. }
  73151. }
  73152. module "babylonjs/Meshes/mesh" {
  73153. interface Mesh {
  73154. /**
  73155. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73156. * @returns an array of IParticleSystem
  73157. */
  73158. getEmittedParticleSystems(): IParticleSystem[];
  73159. /**
  73160. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73161. * @returns an array of IParticleSystem
  73162. */
  73163. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73164. }
  73165. }
  73166. }
  73167. declare module "babylonjs/Particles/pointsCloudSystem" {
  73168. import { Color4 } from "babylonjs/Maths/math";
  73169. import { Mesh } from "babylonjs/Meshes/mesh";
  73170. import { Scene, IDisposable } from "babylonjs/scene";
  73171. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73172. /** Defines the 4 color options */
  73173. export enum PointColor {
  73174. /** color value */
  73175. Color = 2,
  73176. /** uv value */
  73177. UV = 1,
  73178. /** random value */
  73179. Random = 0,
  73180. /** stated value */
  73181. Stated = 3
  73182. }
  73183. /**
  73184. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73185. * 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.
  73186. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73187. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73188. *
  73189. * Full documentation here : TO BE ENTERED
  73190. */
  73191. export class PointsCloudSystem implements IDisposable {
  73192. /**
  73193. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73194. * Example : var p = SPS.particles[i];
  73195. */
  73196. particles: CloudPoint[];
  73197. /**
  73198. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73199. */
  73200. nbParticles: number;
  73201. /**
  73202. * This a counter for your own usage. It's not set by any SPS functions.
  73203. */
  73204. counter: number;
  73205. /**
  73206. * The PCS name. This name is also given to the underlying mesh.
  73207. */
  73208. name: string;
  73209. /**
  73210. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73211. */
  73212. mesh: Mesh;
  73213. /**
  73214. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73215. * Please read :
  73216. */
  73217. vars: any;
  73218. /**
  73219. * @hidden
  73220. */
  73221. _size: number;
  73222. private _scene;
  73223. private _promises;
  73224. private _positions;
  73225. private _indices;
  73226. private _normals;
  73227. private _colors;
  73228. private _uvs;
  73229. private _indices32;
  73230. private _positions32;
  73231. private _colors32;
  73232. private _uvs32;
  73233. private _updatable;
  73234. private _isVisibilityBoxLocked;
  73235. private _alwaysVisible;
  73236. private _groups;
  73237. private _groupCounter;
  73238. private _computeParticleColor;
  73239. private _computeParticleTexture;
  73240. private _computeParticleRotation;
  73241. private _computeBoundingBox;
  73242. private _isReady;
  73243. /**
  73244. * Creates a PCS (Points Cloud System) object
  73245. * @param name (String) is the PCS name, this will be the underlying mesh name
  73246. * @param pointSize (number) is the size for each point
  73247. * @param scene (Scene) is the scene in which the PCS is added
  73248. * @param options defines the options of the PCS e.g.
  73249. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73250. */
  73251. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73252. updatable?: boolean;
  73253. });
  73254. /**
  73255. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73256. * If no points were added to the PCS, the returned mesh is just a single point.
  73257. * @returns a promise for the created mesh
  73258. */
  73259. buildMeshAsync(): Promise<Mesh>;
  73260. /**
  73261. * @hidden
  73262. */
  73263. private _buildMesh;
  73264. private _addParticle;
  73265. private _randomUnitVector;
  73266. private _getColorIndicesForCoord;
  73267. private _setPointsColorOrUV;
  73268. private _colorFromTexture;
  73269. private _calculateDensity;
  73270. /**
  73271. * Adds points to the PCS in random positions within a unit sphere
  73272. * @param nb (positive integer) the number of particles to be created from this model
  73273. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73274. * @returns the number of groups in the system
  73275. */
  73276. addPoints(nb: number, pointFunction?: any): number;
  73277. /**
  73278. * Adds points to the PCS from the surface of the model shape
  73279. * @param mesh is any Mesh object that will be used as a surface model for the points
  73280. * @param nb (positive integer) the number of particles to be created from this model
  73281. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73282. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73283. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73284. * @returns the number of groups in the system
  73285. */
  73286. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73287. /**
  73288. * Adds points to the PCS inside the model shape
  73289. * @param mesh is any Mesh object that will be used as a surface model for the points
  73290. * @param nb (positive integer) the number of particles to be created from this model
  73291. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73292. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73293. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73294. * @returns the number of groups in the system
  73295. */
  73296. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73297. /**
  73298. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73299. * This method calls `updateParticle()` for each particle of the SPS.
  73300. * For an animated SPS, it is usually called within the render loop.
  73301. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73302. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73303. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73304. * @returns the PCS.
  73305. */
  73306. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73307. /**
  73308. * Disposes the PCS.
  73309. */
  73310. dispose(): void;
  73311. /**
  73312. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73313. * doc :
  73314. * @returns the PCS.
  73315. */
  73316. refreshVisibleSize(): PointsCloudSystem;
  73317. /**
  73318. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73319. * @param size the size (float) of the visibility box
  73320. * note : this doesn't lock the PCS mesh bounding box.
  73321. * doc :
  73322. */
  73323. setVisibilityBox(size: number): void;
  73324. /**
  73325. * Gets whether the PCS is always visible or not
  73326. * doc :
  73327. */
  73328. get isAlwaysVisible(): boolean;
  73329. /**
  73330. * Sets the PCS as always visible or not
  73331. * doc :
  73332. */
  73333. set isAlwaysVisible(val: boolean);
  73334. /**
  73335. * Tells to `setParticles()` to compute the particle rotations or not
  73336. * Default value : false. The PCS is faster when it's set to false
  73337. * Note : particle rotations are only applied to parent particles
  73338. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73339. */
  73340. set computeParticleRotation(val: boolean);
  73341. /**
  73342. * Tells to `setParticles()` to compute the particle colors or not.
  73343. * Default value : true. The PCS is faster when it's set to false.
  73344. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73345. */
  73346. set computeParticleColor(val: boolean);
  73347. set computeParticleTexture(val: boolean);
  73348. /**
  73349. * Gets if `setParticles()` computes the particle colors or not.
  73350. * Default value : false. The PCS is faster when it's set to false.
  73351. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73352. */
  73353. get computeParticleColor(): boolean;
  73354. /**
  73355. * Gets if `setParticles()` computes the particle textures or not.
  73356. * Default value : false. The PCS is faster when it's set to false.
  73357. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73358. */
  73359. get computeParticleTexture(): boolean;
  73360. /**
  73361. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73362. */
  73363. set computeBoundingBox(val: boolean);
  73364. /**
  73365. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73366. */
  73367. get computeBoundingBox(): boolean;
  73368. /**
  73369. * This function does nothing. It may be overwritten to set all the particle first values.
  73370. * The PCS doesn't call this function, you may have to call it by your own.
  73371. * doc :
  73372. */
  73373. initParticles(): void;
  73374. /**
  73375. * This function does nothing. It may be overwritten to recycle a particle
  73376. * The PCS doesn't call this function, you can to call it
  73377. * doc :
  73378. * @param particle The particle to recycle
  73379. * @returns the recycled particle
  73380. */
  73381. recycleParticle(particle: CloudPoint): CloudPoint;
  73382. /**
  73383. * Updates a particle : this function should be overwritten by the user.
  73384. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73385. * doc :
  73386. * @example : just set a particle position or velocity and recycle conditions
  73387. * @param particle The particle to update
  73388. * @returns the updated particle
  73389. */
  73390. updateParticle(particle: CloudPoint): CloudPoint;
  73391. /**
  73392. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73393. * This does nothing and may be overwritten by the user.
  73394. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73395. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73396. * @param update the boolean update value actually passed to setParticles()
  73397. */
  73398. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73399. /**
  73400. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73401. * This will be passed three parameters.
  73402. * This does nothing and may be overwritten by the user.
  73403. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73404. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73405. * @param update the boolean update value actually passed to setParticles()
  73406. */
  73407. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73408. }
  73409. }
  73410. declare module "babylonjs/Particles/cloudPoint" {
  73411. import { Nullable } from "babylonjs/types";
  73412. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73413. import { Mesh } from "babylonjs/Meshes/mesh";
  73414. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73415. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73416. /**
  73417. * Represents one particle of a points cloud system.
  73418. */
  73419. export class CloudPoint {
  73420. /**
  73421. * particle global index
  73422. */
  73423. idx: number;
  73424. /**
  73425. * The color of the particle
  73426. */
  73427. color: Nullable<Color4>;
  73428. /**
  73429. * The world space position of the particle.
  73430. */
  73431. position: Vector3;
  73432. /**
  73433. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73434. */
  73435. rotation: Vector3;
  73436. /**
  73437. * The world space rotation quaternion of the particle.
  73438. */
  73439. rotationQuaternion: Nullable<Quaternion>;
  73440. /**
  73441. * The uv of the particle.
  73442. */
  73443. uv: Nullable<Vector2>;
  73444. /**
  73445. * The current speed of the particle.
  73446. */
  73447. velocity: Vector3;
  73448. /**
  73449. * The pivot point in the particle local space.
  73450. */
  73451. pivot: Vector3;
  73452. /**
  73453. * Must the particle be translated from its pivot point in its local space ?
  73454. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73455. * Default : false
  73456. */
  73457. translateFromPivot: boolean;
  73458. /**
  73459. * Index of this particle in the global "positions" array (Internal use)
  73460. * @hidden
  73461. */
  73462. _pos: number;
  73463. /**
  73464. * @hidden Index of this particle in the global "indices" array (Internal use)
  73465. */
  73466. _ind: number;
  73467. /**
  73468. * Group this particle belongs to
  73469. */
  73470. _group: PointsGroup;
  73471. /**
  73472. * Group id of this particle
  73473. */
  73474. groupId: number;
  73475. /**
  73476. * Index of the particle in its group id (Internal use)
  73477. */
  73478. idxInGroup: number;
  73479. /**
  73480. * @hidden Particle BoundingInfo object (Internal use)
  73481. */
  73482. _boundingInfo: BoundingInfo;
  73483. /**
  73484. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73485. */
  73486. _pcs: PointsCloudSystem;
  73487. /**
  73488. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73489. */
  73490. _stillInvisible: boolean;
  73491. /**
  73492. * @hidden Last computed particle rotation matrix
  73493. */
  73494. _rotationMatrix: number[];
  73495. /**
  73496. * Parent particle Id, if any.
  73497. * Default null.
  73498. */
  73499. parentId: Nullable<number>;
  73500. /**
  73501. * @hidden Internal global position in the PCS.
  73502. */
  73503. _globalPosition: Vector3;
  73504. /**
  73505. * Creates a Point Cloud object.
  73506. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73507. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73508. * @param group (PointsGroup) is the group the particle belongs to
  73509. * @param groupId (integer) is the group identifier in the PCS.
  73510. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73511. * @param pcs defines the PCS it is associated to
  73512. */
  73513. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73514. /**
  73515. * get point size
  73516. */
  73517. get size(): Vector3;
  73518. /**
  73519. * Set point size
  73520. */
  73521. set size(scale: Vector3);
  73522. /**
  73523. * Legacy support, changed quaternion to rotationQuaternion
  73524. */
  73525. get quaternion(): Nullable<Quaternion>;
  73526. /**
  73527. * Legacy support, changed quaternion to rotationQuaternion
  73528. */
  73529. set quaternion(q: Nullable<Quaternion>);
  73530. /**
  73531. * Returns a boolean. True if the particle intersects a mesh, else false
  73532. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73533. * @param target is the object (point or mesh) what the intersection is computed against
  73534. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73535. * @returns true if it intersects
  73536. */
  73537. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73538. /**
  73539. * get the rotation matrix of the particle
  73540. * @hidden
  73541. */
  73542. getRotationMatrix(m: Matrix): void;
  73543. }
  73544. /**
  73545. * Represents a group of points in a points cloud system
  73546. * * PCS internal tool, don't use it manually.
  73547. */
  73548. export class PointsGroup {
  73549. /**
  73550. * The group id
  73551. * @hidden
  73552. */
  73553. groupID: number;
  73554. /**
  73555. * image data for group (internal use)
  73556. * @hidden
  73557. */
  73558. _groupImageData: Nullable<ArrayBufferView>;
  73559. /**
  73560. * Image Width (internal use)
  73561. * @hidden
  73562. */
  73563. _groupImgWidth: number;
  73564. /**
  73565. * Image Height (internal use)
  73566. * @hidden
  73567. */
  73568. _groupImgHeight: number;
  73569. /**
  73570. * Custom position function (internal use)
  73571. * @hidden
  73572. */
  73573. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73574. /**
  73575. * density per facet for surface points
  73576. * @hidden
  73577. */
  73578. _groupDensity: number[];
  73579. /**
  73580. * Only when points are colored by texture carries pointer to texture list array
  73581. * @hidden
  73582. */
  73583. _textureNb: number;
  73584. /**
  73585. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73586. * PCS internal tool, don't use it manually.
  73587. * @hidden
  73588. */
  73589. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73590. }
  73591. }
  73592. declare module "babylonjs/Particles/index" {
  73593. export * from "babylonjs/Particles/baseParticleSystem";
  73594. export * from "babylonjs/Particles/EmitterTypes/index";
  73595. export * from "babylonjs/Particles/gpuParticleSystem";
  73596. export * from "babylonjs/Particles/IParticleSystem";
  73597. export * from "babylonjs/Particles/particle";
  73598. export * from "babylonjs/Particles/particleHelper";
  73599. export * from "babylonjs/Particles/particleSystem";
  73600. import "babylonjs/Particles/particleSystemComponent";
  73601. export * from "babylonjs/Particles/particleSystemComponent";
  73602. export * from "babylonjs/Particles/particleSystemSet";
  73603. export * from "babylonjs/Particles/solidParticle";
  73604. export * from "babylonjs/Particles/solidParticleSystem";
  73605. export * from "babylonjs/Particles/cloudPoint";
  73606. export * from "babylonjs/Particles/pointsCloudSystem";
  73607. export * from "babylonjs/Particles/subEmitter";
  73608. }
  73609. declare module "babylonjs/Physics/physicsEngineComponent" {
  73610. import { Nullable } from "babylonjs/types";
  73611. import { Observable, Observer } from "babylonjs/Misc/observable";
  73612. import { Vector3 } from "babylonjs/Maths/math.vector";
  73613. import { Mesh } from "babylonjs/Meshes/mesh";
  73614. import { ISceneComponent } from "babylonjs/sceneComponent";
  73615. import { Scene } from "babylonjs/scene";
  73616. import { Node } from "babylonjs/node";
  73617. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73618. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73619. module "babylonjs/scene" {
  73620. interface Scene {
  73621. /** @hidden (Backing field) */
  73622. _physicsEngine: Nullable<IPhysicsEngine>;
  73623. /** @hidden */
  73624. _physicsTimeAccumulator: number;
  73625. /**
  73626. * Gets the current physics engine
  73627. * @returns a IPhysicsEngine or null if none attached
  73628. */
  73629. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73630. /**
  73631. * Enables physics to the current scene
  73632. * @param gravity defines the scene's gravity for the physics engine
  73633. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73634. * @return a boolean indicating if the physics engine was initialized
  73635. */
  73636. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73637. /**
  73638. * Disables and disposes the physics engine associated with the scene
  73639. */
  73640. disablePhysicsEngine(): void;
  73641. /**
  73642. * Gets a boolean indicating if there is an active physics engine
  73643. * @returns a boolean indicating if there is an active physics engine
  73644. */
  73645. isPhysicsEnabled(): boolean;
  73646. /**
  73647. * Deletes a physics compound impostor
  73648. * @param compound defines the compound to delete
  73649. */
  73650. deleteCompoundImpostor(compound: any): void;
  73651. /**
  73652. * An event triggered when physic simulation is about to be run
  73653. */
  73654. onBeforePhysicsObservable: Observable<Scene>;
  73655. /**
  73656. * An event triggered when physic simulation has been done
  73657. */
  73658. onAfterPhysicsObservable: Observable<Scene>;
  73659. }
  73660. }
  73661. module "babylonjs/Meshes/abstractMesh" {
  73662. interface AbstractMesh {
  73663. /** @hidden */
  73664. _physicsImpostor: Nullable<PhysicsImpostor>;
  73665. /**
  73666. * Gets or sets impostor used for physic simulation
  73667. * @see https://doc.babylonjs.com/features/physics_engine
  73668. */
  73669. physicsImpostor: Nullable<PhysicsImpostor>;
  73670. /**
  73671. * Gets the current physics impostor
  73672. * @see https://doc.babylonjs.com/features/physics_engine
  73673. * @returns a physics impostor or null
  73674. */
  73675. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73676. /** Apply a physic impulse to the mesh
  73677. * @param force defines the force to apply
  73678. * @param contactPoint defines where to apply the force
  73679. * @returns the current mesh
  73680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73681. */
  73682. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73683. /**
  73684. * Creates a physic joint between two meshes
  73685. * @param otherMesh defines the other mesh to use
  73686. * @param pivot1 defines the pivot to use on this mesh
  73687. * @param pivot2 defines the pivot to use on the other mesh
  73688. * @param options defines additional options (can be plugin dependent)
  73689. * @returns the current mesh
  73690. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73691. */
  73692. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73693. /** @hidden */
  73694. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73695. }
  73696. }
  73697. /**
  73698. * Defines the physics engine scene component responsible to manage a physics engine
  73699. */
  73700. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73701. /**
  73702. * The component name helpful to identify the component in the list of scene components.
  73703. */
  73704. readonly name: string;
  73705. /**
  73706. * The scene the component belongs to.
  73707. */
  73708. scene: Scene;
  73709. /**
  73710. * Creates a new instance of the component for the given scene
  73711. * @param scene Defines the scene to register the component in
  73712. */
  73713. constructor(scene: Scene);
  73714. /**
  73715. * Registers the component in a given scene
  73716. */
  73717. register(): void;
  73718. /**
  73719. * Rebuilds the elements related to this component in case of
  73720. * context lost for instance.
  73721. */
  73722. rebuild(): void;
  73723. /**
  73724. * Disposes the component and the associated ressources
  73725. */
  73726. dispose(): void;
  73727. }
  73728. }
  73729. declare module "babylonjs/Physics/physicsHelper" {
  73730. import { Nullable } from "babylonjs/types";
  73731. import { Vector3 } from "babylonjs/Maths/math.vector";
  73732. import { Mesh } from "babylonjs/Meshes/mesh";
  73733. import { Scene } from "babylonjs/scene";
  73734. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73735. /**
  73736. * A helper for physics simulations
  73737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73738. */
  73739. export class PhysicsHelper {
  73740. private _scene;
  73741. private _physicsEngine;
  73742. /**
  73743. * Initializes the Physics helper
  73744. * @param scene Babylon.js scene
  73745. */
  73746. constructor(scene: Scene);
  73747. /**
  73748. * Applies a radial explosion impulse
  73749. * @param origin the origin of the explosion
  73750. * @param radiusOrEventOptions the radius or the options of radial explosion
  73751. * @param strength the explosion strength
  73752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73753. * @returns A physics radial explosion event, or null
  73754. */
  73755. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73756. /**
  73757. * Applies a radial explosion force
  73758. * @param origin the origin of the explosion
  73759. * @param radiusOrEventOptions the radius or the options of radial explosion
  73760. * @param strength the explosion strength
  73761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73762. * @returns A physics radial explosion event, or null
  73763. */
  73764. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73765. /**
  73766. * Creates a gravitational field
  73767. * @param origin the origin of the explosion
  73768. * @param radiusOrEventOptions the radius or the options of radial explosion
  73769. * @param strength the explosion strength
  73770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73771. * @returns A physics gravitational field event, or null
  73772. */
  73773. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73774. /**
  73775. * Creates a physics updraft event
  73776. * @param origin the origin of the updraft
  73777. * @param radiusOrEventOptions the radius or the options of the updraft
  73778. * @param strength the strength of the updraft
  73779. * @param height the height of the updraft
  73780. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73781. * @returns A physics updraft event, or null
  73782. */
  73783. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73784. /**
  73785. * Creates a physics vortex event
  73786. * @param origin the of the vortex
  73787. * @param radiusOrEventOptions the radius or the options of the vortex
  73788. * @param strength the strength of the vortex
  73789. * @param height the height of the vortex
  73790. * @returns a Physics vortex event, or null
  73791. * A physics vortex event or null
  73792. */
  73793. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73794. }
  73795. /**
  73796. * Represents a physics radial explosion event
  73797. */
  73798. class PhysicsRadialExplosionEvent {
  73799. private _scene;
  73800. private _options;
  73801. private _sphere;
  73802. private _dataFetched;
  73803. /**
  73804. * Initializes a radial explosioin event
  73805. * @param _scene BabylonJS scene
  73806. * @param _options The options for the vortex event
  73807. */
  73808. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73809. /**
  73810. * Returns the data related to the radial explosion event (sphere).
  73811. * @returns The radial explosion event data
  73812. */
  73813. getData(): PhysicsRadialExplosionEventData;
  73814. /**
  73815. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73816. * @param impostor A physics imposter
  73817. * @param origin the origin of the explosion
  73818. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73819. */
  73820. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73821. /**
  73822. * Triggers affecterd impostors callbacks
  73823. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73824. */
  73825. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73826. /**
  73827. * Disposes the sphere.
  73828. * @param force Specifies if the sphere should be disposed by force
  73829. */
  73830. dispose(force?: boolean): void;
  73831. /*** Helpers ***/
  73832. private _prepareSphere;
  73833. private _intersectsWithSphere;
  73834. }
  73835. /**
  73836. * Represents a gravitational field event
  73837. */
  73838. class PhysicsGravitationalFieldEvent {
  73839. private _physicsHelper;
  73840. private _scene;
  73841. private _origin;
  73842. private _options;
  73843. private _tickCallback;
  73844. private _sphere;
  73845. private _dataFetched;
  73846. /**
  73847. * Initializes the physics gravitational field event
  73848. * @param _physicsHelper A physics helper
  73849. * @param _scene BabylonJS scene
  73850. * @param _origin The origin position of the gravitational field event
  73851. * @param _options The options for the vortex event
  73852. */
  73853. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73854. /**
  73855. * Returns the data related to the gravitational field event (sphere).
  73856. * @returns A gravitational field event
  73857. */
  73858. getData(): PhysicsGravitationalFieldEventData;
  73859. /**
  73860. * Enables the gravitational field.
  73861. */
  73862. enable(): void;
  73863. /**
  73864. * Disables the gravitational field.
  73865. */
  73866. disable(): void;
  73867. /**
  73868. * Disposes the sphere.
  73869. * @param force The force to dispose from the gravitational field event
  73870. */
  73871. dispose(force?: boolean): void;
  73872. private _tick;
  73873. }
  73874. /**
  73875. * Represents a physics updraft event
  73876. */
  73877. class PhysicsUpdraftEvent {
  73878. private _scene;
  73879. private _origin;
  73880. private _options;
  73881. private _physicsEngine;
  73882. private _originTop;
  73883. private _originDirection;
  73884. private _tickCallback;
  73885. private _cylinder;
  73886. private _cylinderPosition;
  73887. private _dataFetched;
  73888. /**
  73889. * Initializes the physics updraft event
  73890. * @param _scene BabylonJS scene
  73891. * @param _origin The origin position of the updraft
  73892. * @param _options The options for the updraft event
  73893. */
  73894. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73895. /**
  73896. * Returns the data related to the updraft event (cylinder).
  73897. * @returns A physics updraft event
  73898. */
  73899. getData(): PhysicsUpdraftEventData;
  73900. /**
  73901. * Enables the updraft.
  73902. */
  73903. enable(): void;
  73904. /**
  73905. * Disables the updraft.
  73906. */
  73907. disable(): void;
  73908. /**
  73909. * Disposes the cylinder.
  73910. * @param force Specifies if the updraft should be disposed by force
  73911. */
  73912. dispose(force?: boolean): void;
  73913. private getImpostorHitData;
  73914. private _tick;
  73915. /*** Helpers ***/
  73916. private _prepareCylinder;
  73917. private _intersectsWithCylinder;
  73918. }
  73919. /**
  73920. * Represents a physics vortex event
  73921. */
  73922. class PhysicsVortexEvent {
  73923. private _scene;
  73924. private _origin;
  73925. private _options;
  73926. private _physicsEngine;
  73927. private _originTop;
  73928. private _tickCallback;
  73929. private _cylinder;
  73930. private _cylinderPosition;
  73931. private _dataFetched;
  73932. /**
  73933. * Initializes the physics vortex event
  73934. * @param _scene The BabylonJS scene
  73935. * @param _origin The origin position of the vortex
  73936. * @param _options The options for the vortex event
  73937. */
  73938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73939. /**
  73940. * Returns the data related to the vortex event (cylinder).
  73941. * @returns The physics vortex event data
  73942. */
  73943. getData(): PhysicsVortexEventData;
  73944. /**
  73945. * Enables the vortex.
  73946. */
  73947. enable(): void;
  73948. /**
  73949. * Disables the cortex.
  73950. */
  73951. disable(): void;
  73952. /**
  73953. * Disposes the sphere.
  73954. * @param force
  73955. */
  73956. dispose(force?: boolean): void;
  73957. private getImpostorHitData;
  73958. private _tick;
  73959. /*** Helpers ***/
  73960. private _prepareCylinder;
  73961. private _intersectsWithCylinder;
  73962. }
  73963. /**
  73964. * Options fot the radial explosion event
  73965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73966. */
  73967. export class PhysicsRadialExplosionEventOptions {
  73968. /**
  73969. * The radius of the sphere for the radial explosion.
  73970. */
  73971. radius: number;
  73972. /**
  73973. * The strenth of the explosion.
  73974. */
  73975. strength: number;
  73976. /**
  73977. * The strenght of the force in correspondence to the distance of the affected object
  73978. */
  73979. falloff: PhysicsRadialImpulseFalloff;
  73980. /**
  73981. * Sphere options for the radial explosion.
  73982. */
  73983. sphere: {
  73984. segments: number;
  73985. diameter: number;
  73986. };
  73987. /**
  73988. * Sphere options for the radial explosion.
  73989. */
  73990. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73991. }
  73992. /**
  73993. * Options fot the updraft event
  73994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73995. */
  73996. export class PhysicsUpdraftEventOptions {
  73997. /**
  73998. * The radius of the cylinder for the vortex
  73999. */
  74000. radius: number;
  74001. /**
  74002. * The strenth of the updraft.
  74003. */
  74004. strength: number;
  74005. /**
  74006. * The height of the cylinder for the updraft.
  74007. */
  74008. height: number;
  74009. /**
  74010. * The mode for the the updraft.
  74011. */
  74012. updraftMode: PhysicsUpdraftMode;
  74013. }
  74014. /**
  74015. * Options fot the vortex event
  74016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74017. */
  74018. export class PhysicsVortexEventOptions {
  74019. /**
  74020. * The radius of the cylinder for the vortex
  74021. */
  74022. radius: number;
  74023. /**
  74024. * The strenth of the vortex.
  74025. */
  74026. strength: number;
  74027. /**
  74028. * The height of the cylinder for the vortex.
  74029. */
  74030. height: number;
  74031. /**
  74032. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74033. */
  74034. centripetalForceThreshold: number;
  74035. /**
  74036. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  74037. */
  74038. centripetalForceMultiplier: number;
  74039. /**
  74040. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  74041. */
  74042. centrifugalForceMultiplier: number;
  74043. /**
  74044. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74045. */
  74046. updraftForceMultiplier: number;
  74047. }
  74048. /**
  74049. * The strenght of the force in correspondence to the distance of the affected object
  74050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74051. */
  74052. export enum PhysicsRadialImpulseFalloff {
  74053. /** Defines that impulse is constant in strength across it's whole radius */
  74054. Constant = 0,
  74055. /** Defines that impulse gets weaker if it's further from the origin */
  74056. Linear = 1
  74057. }
  74058. /**
  74059. * The strength of the force in correspondence to the distance of the affected object
  74060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74061. */
  74062. export enum PhysicsUpdraftMode {
  74063. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74064. Center = 0,
  74065. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74066. Perpendicular = 1
  74067. }
  74068. /**
  74069. * Interface for a physics hit data
  74070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74071. */
  74072. export interface PhysicsHitData {
  74073. /**
  74074. * The force applied at the contact point
  74075. */
  74076. force: Vector3;
  74077. /**
  74078. * The contact point
  74079. */
  74080. contactPoint: Vector3;
  74081. /**
  74082. * The distance from the origin to the contact point
  74083. */
  74084. distanceFromOrigin: number;
  74085. }
  74086. /**
  74087. * Interface for radial explosion event data
  74088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74089. */
  74090. export interface PhysicsRadialExplosionEventData {
  74091. /**
  74092. * A sphere used for the radial explosion event
  74093. */
  74094. sphere: Mesh;
  74095. }
  74096. /**
  74097. * Interface for gravitational field event data
  74098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74099. */
  74100. export interface PhysicsGravitationalFieldEventData {
  74101. /**
  74102. * A sphere mesh used for the gravitational field event
  74103. */
  74104. sphere: Mesh;
  74105. }
  74106. /**
  74107. * Interface for updraft event data
  74108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74109. */
  74110. export interface PhysicsUpdraftEventData {
  74111. /**
  74112. * A cylinder used for the updraft event
  74113. */
  74114. cylinder: Mesh;
  74115. }
  74116. /**
  74117. * Interface for vortex event data
  74118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74119. */
  74120. export interface PhysicsVortexEventData {
  74121. /**
  74122. * A cylinder used for the vortex event
  74123. */
  74124. cylinder: Mesh;
  74125. }
  74126. /**
  74127. * Interface for an affected physics impostor
  74128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74129. */
  74130. export interface PhysicsAffectedImpostorWithData {
  74131. /**
  74132. * The impostor affected by the effect
  74133. */
  74134. impostor: PhysicsImpostor;
  74135. /**
  74136. * The data about the hit/horce from the explosion
  74137. */
  74138. hitData: PhysicsHitData;
  74139. }
  74140. }
  74141. declare module "babylonjs/Physics/Plugins/index" {
  74142. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  74143. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  74144. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  74145. }
  74146. declare module "babylonjs/Physics/index" {
  74147. export * from "babylonjs/Physics/IPhysicsEngine";
  74148. export * from "babylonjs/Physics/physicsEngine";
  74149. export * from "babylonjs/Physics/physicsEngineComponent";
  74150. export * from "babylonjs/Physics/physicsHelper";
  74151. export * from "babylonjs/Physics/physicsImpostor";
  74152. export * from "babylonjs/Physics/physicsJoint";
  74153. export * from "babylonjs/Physics/Plugins/index";
  74154. }
  74155. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  74156. /** @hidden */
  74157. export var blackAndWhitePixelShader: {
  74158. name: string;
  74159. shader: string;
  74160. };
  74161. }
  74162. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  74163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74164. import { Camera } from "babylonjs/Cameras/camera";
  74165. import { Engine } from "babylonjs/Engines/engine";
  74166. import "babylonjs/Shaders/blackAndWhite.fragment";
  74167. import { Nullable } from "babylonjs/types";
  74168. import { Scene } from "babylonjs/scene";
  74169. /**
  74170. * Post process used to render in black and white
  74171. */
  74172. export class BlackAndWhitePostProcess extends PostProcess {
  74173. /**
  74174. * Linear about to convert he result to black and white (default: 1)
  74175. */
  74176. degree: number;
  74177. /**
  74178. * Gets a string identifying the name of the class
  74179. * @returns "BlackAndWhitePostProcess" string
  74180. */
  74181. getClassName(): string;
  74182. /**
  74183. * Creates a black and white post process
  74184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74185. * @param name The name of the effect.
  74186. * @param options The required width/height ratio to downsize to before computing the render pass.
  74187. * @param camera The camera to apply the render pass to.
  74188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74189. * @param engine The engine which the post process will be applied. (default: current engine)
  74190. * @param reusable If the post process can be reused on the same frame. (default: false)
  74191. */
  74192. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74193. /** @hidden */
  74194. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74195. }
  74196. }
  74197. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74198. import { Nullable } from "babylonjs/types";
  74199. import { Camera } from "babylonjs/Cameras/camera";
  74200. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74201. import { Engine } from "babylonjs/Engines/engine";
  74202. /**
  74203. * This represents a set of one or more post processes in Babylon.
  74204. * A post process can be used to apply a shader to a texture after it is rendered.
  74205. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74206. */
  74207. export class PostProcessRenderEffect {
  74208. private _postProcesses;
  74209. private _getPostProcesses;
  74210. private _singleInstance;
  74211. private _cameras;
  74212. private _indicesForCamera;
  74213. /**
  74214. * Name of the effect
  74215. * @hidden
  74216. */
  74217. _name: string;
  74218. /**
  74219. * Instantiates a post process render effect.
  74220. * A post process can be used to apply a shader to a texture after it is rendered.
  74221. * @param engine The engine the effect is tied to
  74222. * @param name The name of the effect
  74223. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74224. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74225. */
  74226. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74227. /**
  74228. * Checks if all the post processes in the effect are supported.
  74229. */
  74230. get isSupported(): boolean;
  74231. /**
  74232. * Updates the current state of the effect
  74233. * @hidden
  74234. */
  74235. _update(): void;
  74236. /**
  74237. * Attaches the effect on cameras
  74238. * @param cameras The camera to attach to.
  74239. * @hidden
  74240. */
  74241. _attachCameras(cameras: Camera): void;
  74242. /**
  74243. * Attaches the effect on cameras
  74244. * @param cameras The camera to attach to.
  74245. * @hidden
  74246. */
  74247. _attachCameras(cameras: Camera[]): void;
  74248. /**
  74249. * Detaches the effect on cameras
  74250. * @param cameras The camera to detatch from.
  74251. * @hidden
  74252. */
  74253. _detachCameras(cameras: Camera): void;
  74254. /**
  74255. * Detatches the effect on cameras
  74256. * @param cameras The camera to detatch from.
  74257. * @hidden
  74258. */
  74259. _detachCameras(cameras: Camera[]): void;
  74260. /**
  74261. * Enables the effect on given cameras
  74262. * @param cameras The camera to enable.
  74263. * @hidden
  74264. */
  74265. _enable(cameras: Camera): void;
  74266. /**
  74267. * Enables the effect on given cameras
  74268. * @param cameras The camera to enable.
  74269. * @hidden
  74270. */
  74271. _enable(cameras: Nullable<Camera[]>): void;
  74272. /**
  74273. * Disables the effect on the given cameras
  74274. * @param cameras The camera to disable.
  74275. * @hidden
  74276. */
  74277. _disable(cameras: Camera): void;
  74278. /**
  74279. * Disables the effect on the given cameras
  74280. * @param cameras The camera to disable.
  74281. * @hidden
  74282. */
  74283. _disable(cameras: Nullable<Camera[]>): void;
  74284. /**
  74285. * Gets a list of the post processes contained in the effect.
  74286. * @param camera The camera to get the post processes on.
  74287. * @returns The list of the post processes in the effect.
  74288. */
  74289. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74290. }
  74291. }
  74292. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74294. /** @hidden */
  74295. export var extractHighlightsPixelShader: {
  74296. name: string;
  74297. shader: string;
  74298. };
  74299. }
  74300. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74301. import { Nullable } from "babylonjs/types";
  74302. import { Camera } from "babylonjs/Cameras/camera";
  74303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74304. import { Engine } from "babylonjs/Engines/engine";
  74305. import "babylonjs/Shaders/extractHighlights.fragment";
  74306. /**
  74307. * 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.
  74308. */
  74309. export class ExtractHighlightsPostProcess extends PostProcess {
  74310. /**
  74311. * The luminance threshold, pixels below this value will be set to black.
  74312. */
  74313. threshold: number;
  74314. /** @hidden */
  74315. _exposure: number;
  74316. /**
  74317. * Post process which has the input texture to be used when performing highlight extraction
  74318. * @hidden
  74319. */
  74320. _inputPostProcess: Nullable<PostProcess>;
  74321. /**
  74322. * Gets a string identifying the name of the class
  74323. * @returns "ExtractHighlightsPostProcess" string
  74324. */
  74325. getClassName(): string;
  74326. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74327. }
  74328. }
  74329. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74330. /** @hidden */
  74331. export var bloomMergePixelShader: {
  74332. name: string;
  74333. shader: string;
  74334. };
  74335. }
  74336. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74338. import { Nullable } from "babylonjs/types";
  74339. import { Engine } from "babylonjs/Engines/engine";
  74340. import { Camera } from "babylonjs/Cameras/camera";
  74341. import "babylonjs/Shaders/bloomMerge.fragment";
  74342. /**
  74343. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74344. */
  74345. export class BloomMergePostProcess extends PostProcess {
  74346. /** Weight of the bloom to be added to the original input. */
  74347. weight: number;
  74348. /**
  74349. * Gets a string identifying the name of the class
  74350. * @returns "BloomMergePostProcess" string
  74351. */
  74352. getClassName(): string;
  74353. /**
  74354. * Creates a new instance of @see BloomMergePostProcess
  74355. * @param name The name of the effect.
  74356. * @param originalFromInput Post process which's input will be used for the merge.
  74357. * @param blurred Blurred highlights post process which's output will be used.
  74358. * @param weight Weight of the bloom to be added to the original input.
  74359. * @param options The required width/height ratio to downsize to before computing the render pass.
  74360. * @param camera The camera to apply the render pass to.
  74361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74362. * @param engine The engine which the post process will be applied. (default: current engine)
  74363. * @param reusable If the post process can be reused on the same frame. (default: false)
  74364. * @param textureType Type of textures used when performing the post process. (default: 0)
  74365. * @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)
  74366. */
  74367. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74368. /** Weight of the bloom to be added to the original input. */
  74369. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74370. }
  74371. }
  74372. declare module "babylonjs/PostProcesses/bloomEffect" {
  74373. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74374. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74375. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74376. import { Camera } from "babylonjs/Cameras/camera";
  74377. import { Scene } from "babylonjs/scene";
  74378. /**
  74379. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74380. */
  74381. export class BloomEffect extends PostProcessRenderEffect {
  74382. private bloomScale;
  74383. /**
  74384. * @hidden Internal
  74385. */
  74386. _effects: Array<PostProcess>;
  74387. /**
  74388. * @hidden Internal
  74389. */
  74390. _downscale: ExtractHighlightsPostProcess;
  74391. private _blurX;
  74392. private _blurY;
  74393. private _merge;
  74394. /**
  74395. * The luminance threshold to find bright areas of the image to bloom.
  74396. */
  74397. get threshold(): number;
  74398. set threshold(value: number);
  74399. /**
  74400. * The strength of the bloom.
  74401. */
  74402. get weight(): number;
  74403. set weight(value: number);
  74404. /**
  74405. * Specifies the size of the bloom blur kernel, relative to the final output size
  74406. */
  74407. get kernel(): number;
  74408. set kernel(value: number);
  74409. /**
  74410. * Creates a new instance of @see BloomEffect
  74411. * @param scene The scene the effect belongs to.
  74412. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74413. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74414. * @param bloomWeight The the strength of bloom.
  74415. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74416. * @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)
  74417. */
  74418. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74419. /**
  74420. * Disposes each of the internal effects for a given camera.
  74421. * @param camera The camera to dispose the effect on.
  74422. */
  74423. disposeEffects(camera: Camera): void;
  74424. /**
  74425. * @hidden Internal
  74426. */
  74427. _updateEffects(): void;
  74428. /**
  74429. * Internal
  74430. * @returns if all the contained post processes are ready.
  74431. * @hidden
  74432. */
  74433. _isReady(): boolean;
  74434. }
  74435. }
  74436. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74437. /** @hidden */
  74438. export var chromaticAberrationPixelShader: {
  74439. name: string;
  74440. shader: string;
  74441. };
  74442. }
  74443. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74444. import { Vector2 } from "babylonjs/Maths/math.vector";
  74445. import { Nullable } from "babylonjs/types";
  74446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74447. import { Camera } from "babylonjs/Cameras/camera";
  74448. import { Engine } from "babylonjs/Engines/engine";
  74449. import "babylonjs/Shaders/chromaticAberration.fragment";
  74450. import { Scene } from "babylonjs/scene";
  74451. /**
  74452. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74453. */
  74454. export class ChromaticAberrationPostProcess extends PostProcess {
  74455. /**
  74456. * The amount of seperation of rgb channels (default: 30)
  74457. */
  74458. aberrationAmount: number;
  74459. /**
  74460. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74461. */
  74462. radialIntensity: number;
  74463. /**
  74464. * 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))
  74465. */
  74466. direction: Vector2;
  74467. /**
  74468. * 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))
  74469. */
  74470. centerPosition: Vector2;
  74471. /** The width of the screen to apply the effect on */
  74472. screenWidth: number;
  74473. /** The height of the screen to apply the effect on */
  74474. screenHeight: number;
  74475. /**
  74476. * Gets a string identifying the name of the class
  74477. * @returns "ChromaticAberrationPostProcess" string
  74478. */
  74479. getClassName(): string;
  74480. /**
  74481. * Creates a new instance ChromaticAberrationPostProcess
  74482. * @param name The name of the effect.
  74483. * @param screenWidth The width of the screen to apply the effect on.
  74484. * @param screenHeight The height of the screen to apply the effect on.
  74485. * @param options The required width/height ratio to downsize to before computing the render pass.
  74486. * @param camera The camera to apply the render pass to.
  74487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74488. * @param engine The engine which the post process will be applied. (default: current engine)
  74489. * @param reusable If the post process can be reused on the same frame. (default: false)
  74490. * @param textureType Type of textures used when performing the post process. (default: 0)
  74491. * @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)
  74492. */
  74493. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74494. /** @hidden */
  74495. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74496. }
  74497. }
  74498. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74499. /** @hidden */
  74500. export var circleOfConfusionPixelShader: {
  74501. name: string;
  74502. shader: string;
  74503. };
  74504. }
  74505. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74506. import { Nullable } from "babylonjs/types";
  74507. import { Engine } from "babylonjs/Engines/engine";
  74508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74509. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74510. import { Camera } from "babylonjs/Cameras/camera";
  74511. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74512. /**
  74513. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74514. */
  74515. export class CircleOfConfusionPostProcess extends PostProcess {
  74516. /**
  74517. * 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.
  74518. */
  74519. lensSize: number;
  74520. /**
  74521. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74522. */
  74523. fStop: number;
  74524. /**
  74525. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74526. */
  74527. focusDistance: number;
  74528. /**
  74529. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74530. */
  74531. focalLength: number;
  74532. /**
  74533. * Gets a string identifying the name of the class
  74534. * @returns "CircleOfConfusionPostProcess" string
  74535. */
  74536. getClassName(): string;
  74537. private _depthTexture;
  74538. /**
  74539. * Creates a new instance CircleOfConfusionPostProcess
  74540. * @param name The name of the effect.
  74541. * @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.
  74542. * @param options The required width/height ratio to downsize to before computing the render pass.
  74543. * @param camera The camera to apply the render pass to.
  74544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74545. * @param engine The engine which the post process will be applied. (default: current engine)
  74546. * @param reusable If the post process can be reused on the same frame. (default: false)
  74547. * @param textureType Type of textures used when performing the post process. (default: 0)
  74548. * @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)
  74549. */
  74550. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74551. /**
  74552. * 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.
  74553. */
  74554. set depthTexture(value: RenderTargetTexture);
  74555. }
  74556. }
  74557. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74558. /** @hidden */
  74559. export var colorCorrectionPixelShader: {
  74560. name: string;
  74561. shader: string;
  74562. };
  74563. }
  74564. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74566. import { Engine } from "babylonjs/Engines/engine";
  74567. import { Camera } from "babylonjs/Cameras/camera";
  74568. import "babylonjs/Shaders/colorCorrection.fragment";
  74569. import { Nullable } from "babylonjs/types";
  74570. import { Scene } from "babylonjs/scene";
  74571. /**
  74572. *
  74573. * This post-process allows the modification of rendered colors by using
  74574. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74575. *
  74576. * The object needs to be provided an url to a texture containing the color
  74577. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74578. * Use an image editing software to tweak the LUT to match your needs.
  74579. *
  74580. * For an example of a color LUT, see here:
  74581. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74582. * For explanations on color grading, see here:
  74583. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74584. *
  74585. */
  74586. export class ColorCorrectionPostProcess extends PostProcess {
  74587. private _colorTableTexture;
  74588. /**
  74589. * Gets the color table url used to create the LUT texture
  74590. */
  74591. colorTableUrl: string;
  74592. /**
  74593. * Gets a string identifying the name of the class
  74594. * @returns "ColorCorrectionPostProcess" string
  74595. */
  74596. getClassName(): string;
  74597. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74598. /** @hidden */
  74599. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74600. }
  74601. }
  74602. declare module "babylonjs/Shaders/convolution.fragment" {
  74603. /** @hidden */
  74604. export var convolutionPixelShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74611. import { Nullable } from "babylonjs/types";
  74612. import { Camera } from "babylonjs/Cameras/camera";
  74613. import { Engine } from "babylonjs/Engines/engine";
  74614. import "babylonjs/Shaders/convolution.fragment";
  74615. import { Scene } from "babylonjs/scene";
  74616. /**
  74617. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74618. * input texture to perform effects such as edge detection or sharpening
  74619. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74620. */
  74621. export class ConvolutionPostProcess extends PostProcess {
  74622. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74623. kernel: number[];
  74624. /**
  74625. * Gets a string identifying the name of the class
  74626. * @returns "ConvolutionPostProcess" string
  74627. */
  74628. getClassName(): string;
  74629. /**
  74630. * Creates a new instance ConvolutionPostProcess
  74631. * @param name The name of the effect.
  74632. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74633. * @param options The required width/height ratio to downsize to before computing the render pass.
  74634. * @param camera The camera to apply the render pass to.
  74635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74636. * @param engine The engine which the post process will be applied. (default: current engine)
  74637. * @param reusable If the post process can be reused on the same frame. (default: false)
  74638. * @param textureType Type of textures used when performing the post process. (default: 0)
  74639. */
  74640. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74641. /** @hidden */
  74642. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74643. /**
  74644. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74645. */
  74646. static EdgeDetect0Kernel: number[];
  74647. /**
  74648. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74649. */
  74650. static EdgeDetect1Kernel: number[];
  74651. /**
  74652. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74653. */
  74654. static EdgeDetect2Kernel: number[];
  74655. /**
  74656. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74657. */
  74658. static SharpenKernel: number[];
  74659. /**
  74660. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74661. */
  74662. static EmbossKernel: number[];
  74663. /**
  74664. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74665. */
  74666. static GaussianKernel: number[];
  74667. }
  74668. }
  74669. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74670. import { Nullable } from "babylonjs/types";
  74671. import { Vector2 } from "babylonjs/Maths/math.vector";
  74672. import { Camera } from "babylonjs/Cameras/camera";
  74673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74674. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74675. import { Engine } from "babylonjs/Engines/engine";
  74676. import { Scene } from "babylonjs/scene";
  74677. /**
  74678. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74679. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74680. * based on samples that have a large difference in distance than the center pixel.
  74681. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74682. */
  74683. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74684. /**
  74685. * The direction the blur should be applied
  74686. */
  74687. direction: Vector2;
  74688. /**
  74689. * Gets a string identifying the name of the class
  74690. * @returns "DepthOfFieldBlurPostProcess" string
  74691. */
  74692. getClassName(): string;
  74693. /**
  74694. * Creates a new instance CircleOfConfusionPostProcess
  74695. * @param name The name of the effect.
  74696. * @param scene The scene the effect belongs to.
  74697. * @param direction The direction the blur should be applied.
  74698. * @param kernel The size of the kernel used to blur.
  74699. * @param options The required width/height ratio to downsize to before computing the render pass.
  74700. * @param camera The camera to apply the render pass to.
  74701. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74702. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74704. * @param engine The engine which the post process will be applied. (default: current engine)
  74705. * @param reusable If the post process can be reused on the same frame. (default: false)
  74706. * @param textureType Type of textures used when performing the post process. (default: 0)
  74707. * @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)
  74708. */
  74709. 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);
  74710. }
  74711. }
  74712. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74713. /** @hidden */
  74714. export var depthOfFieldMergePixelShader: {
  74715. name: string;
  74716. shader: string;
  74717. };
  74718. }
  74719. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74720. import { Nullable } from "babylonjs/types";
  74721. import { Camera } from "babylonjs/Cameras/camera";
  74722. import { Effect } from "babylonjs/Materials/effect";
  74723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74724. import { Engine } from "babylonjs/Engines/engine";
  74725. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74726. /**
  74727. * Options to be set when merging outputs from the default pipeline.
  74728. */
  74729. export class DepthOfFieldMergePostProcessOptions {
  74730. /**
  74731. * The original image to merge on top of
  74732. */
  74733. originalFromInput: PostProcess;
  74734. /**
  74735. * Parameters to perform the merge of the depth of field effect
  74736. */
  74737. depthOfField?: {
  74738. circleOfConfusion: PostProcess;
  74739. blurSteps: Array<PostProcess>;
  74740. };
  74741. /**
  74742. * Parameters to perform the merge of bloom effect
  74743. */
  74744. bloom?: {
  74745. blurred: PostProcess;
  74746. weight: number;
  74747. };
  74748. }
  74749. /**
  74750. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74751. */
  74752. export class DepthOfFieldMergePostProcess extends PostProcess {
  74753. private blurSteps;
  74754. /**
  74755. * Gets a string identifying the name of the class
  74756. * @returns "DepthOfFieldMergePostProcess" string
  74757. */
  74758. getClassName(): string;
  74759. /**
  74760. * Creates a new instance of DepthOfFieldMergePostProcess
  74761. * @param name The name of the effect.
  74762. * @param originalFromInput Post process which's input will be used for the merge.
  74763. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74764. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74765. * @param options The required width/height ratio to downsize to before computing the render pass.
  74766. * @param camera The camera to apply the render pass to.
  74767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74768. * @param engine The engine which the post process will be applied. (default: current engine)
  74769. * @param reusable If the post process can be reused on the same frame. (default: false)
  74770. * @param textureType Type of textures used when performing the post process. (default: 0)
  74771. * @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)
  74772. */
  74773. 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);
  74774. /**
  74775. * Updates the effect with the current post process compile time values and recompiles the shader.
  74776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74779. * @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
  74780. * @param onCompiled Called when the shader has been compiled.
  74781. * @param onError Called if there is an error when compiling a shader.
  74782. */
  74783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74784. }
  74785. }
  74786. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74787. import { Nullable } from "babylonjs/types";
  74788. import { Camera } from "babylonjs/Cameras/camera";
  74789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74791. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74792. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74793. import { Scene } from "babylonjs/scene";
  74794. /**
  74795. * Specifies the level of max blur that should be applied when using the depth of field effect
  74796. */
  74797. export enum DepthOfFieldEffectBlurLevel {
  74798. /**
  74799. * Subtle blur
  74800. */
  74801. Low = 0,
  74802. /**
  74803. * Medium blur
  74804. */
  74805. Medium = 1,
  74806. /**
  74807. * Large blur
  74808. */
  74809. High = 2
  74810. }
  74811. /**
  74812. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74813. */
  74814. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74815. private _circleOfConfusion;
  74816. /**
  74817. * @hidden Internal, blurs from high to low
  74818. */
  74819. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74820. private _depthOfFieldBlurY;
  74821. private _dofMerge;
  74822. /**
  74823. * @hidden Internal post processes in depth of field effect
  74824. */
  74825. _effects: Array<PostProcess>;
  74826. /**
  74827. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74828. */
  74829. set focalLength(value: number);
  74830. get focalLength(): number;
  74831. /**
  74832. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74833. */
  74834. set fStop(value: number);
  74835. get fStop(): number;
  74836. /**
  74837. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74838. */
  74839. set focusDistance(value: number);
  74840. get focusDistance(): number;
  74841. /**
  74842. * 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.
  74843. */
  74844. set lensSize(value: number);
  74845. get lensSize(): number;
  74846. /**
  74847. * Creates a new instance DepthOfFieldEffect
  74848. * @param scene The scene the effect belongs to.
  74849. * @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.
  74850. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74851. * @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)
  74852. */
  74853. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74854. /**
  74855. * Get the current class name of the current effet
  74856. * @returns "DepthOfFieldEffect"
  74857. */
  74858. getClassName(): string;
  74859. /**
  74860. * 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.
  74861. */
  74862. set depthTexture(value: RenderTargetTexture);
  74863. /**
  74864. * Disposes each of the internal effects for a given camera.
  74865. * @param camera The camera to dispose the effect on.
  74866. */
  74867. disposeEffects(camera: Camera): void;
  74868. /**
  74869. * @hidden Internal
  74870. */
  74871. _updateEffects(): void;
  74872. /**
  74873. * Internal
  74874. * @returns if all the contained post processes are ready.
  74875. * @hidden
  74876. */
  74877. _isReady(): boolean;
  74878. }
  74879. }
  74880. declare module "babylonjs/Shaders/displayPass.fragment" {
  74881. /** @hidden */
  74882. export var displayPassPixelShader: {
  74883. name: string;
  74884. shader: string;
  74885. };
  74886. }
  74887. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74888. import { Nullable } from "babylonjs/types";
  74889. import { Camera } from "babylonjs/Cameras/camera";
  74890. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74891. import { Engine } from "babylonjs/Engines/engine";
  74892. import "babylonjs/Shaders/displayPass.fragment";
  74893. import { Scene } from "babylonjs/scene";
  74894. /**
  74895. * DisplayPassPostProcess which produces an output the same as it's input
  74896. */
  74897. export class DisplayPassPostProcess extends PostProcess {
  74898. /**
  74899. * Gets a string identifying the name of the class
  74900. * @returns "DisplayPassPostProcess" string
  74901. */
  74902. getClassName(): string;
  74903. /**
  74904. * Creates the DisplayPassPostProcess
  74905. * @param name The name of the effect.
  74906. * @param options The required width/height ratio to downsize to before computing the render pass.
  74907. * @param camera The camera to apply the render pass to.
  74908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74909. * @param engine The engine which the post process will be applied. (default: current engine)
  74910. * @param reusable If the post process can be reused on the same frame. (default: false)
  74911. */
  74912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74913. /** @hidden */
  74914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74915. }
  74916. }
  74917. declare module "babylonjs/Shaders/filter.fragment" {
  74918. /** @hidden */
  74919. export var filterPixelShader: {
  74920. name: string;
  74921. shader: string;
  74922. };
  74923. }
  74924. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74925. import { Nullable } from "babylonjs/types";
  74926. import { Matrix } from "babylonjs/Maths/math.vector";
  74927. import { Camera } from "babylonjs/Cameras/camera";
  74928. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74929. import { Engine } from "babylonjs/Engines/engine";
  74930. import "babylonjs/Shaders/filter.fragment";
  74931. import { Scene } from "babylonjs/scene";
  74932. /**
  74933. * Applies a kernel filter to the image
  74934. */
  74935. export class FilterPostProcess extends PostProcess {
  74936. /** The matrix to be applied to the image */
  74937. kernelMatrix: Matrix;
  74938. /**
  74939. * Gets a string identifying the name of the class
  74940. * @returns "FilterPostProcess" string
  74941. */
  74942. getClassName(): string;
  74943. /**
  74944. *
  74945. * @param name The name of the effect.
  74946. * @param kernelMatrix The matrix to be applied to the image
  74947. * @param options The required width/height ratio to downsize to before computing the render pass.
  74948. * @param camera The camera to apply the render pass to.
  74949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74950. * @param engine The engine which the post process will be applied. (default: current engine)
  74951. * @param reusable If the post process can be reused on the same frame. (default: false)
  74952. */
  74953. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74954. /** @hidden */
  74955. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74956. }
  74957. }
  74958. declare module "babylonjs/Shaders/fxaa.fragment" {
  74959. /** @hidden */
  74960. export var fxaaPixelShader: {
  74961. name: string;
  74962. shader: string;
  74963. };
  74964. }
  74965. declare module "babylonjs/Shaders/fxaa.vertex" {
  74966. /** @hidden */
  74967. export var fxaaVertexShader: {
  74968. name: string;
  74969. shader: string;
  74970. };
  74971. }
  74972. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74973. import { Nullable } from "babylonjs/types";
  74974. import { Camera } from "babylonjs/Cameras/camera";
  74975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74976. import { Engine } from "babylonjs/Engines/engine";
  74977. import "babylonjs/Shaders/fxaa.fragment";
  74978. import "babylonjs/Shaders/fxaa.vertex";
  74979. import { Scene } from "babylonjs/scene";
  74980. /**
  74981. * Fxaa post process
  74982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74983. */
  74984. export class FxaaPostProcess extends PostProcess {
  74985. /**
  74986. * Gets a string identifying the name of the class
  74987. * @returns "FxaaPostProcess" string
  74988. */
  74989. getClassName(): string;
  74990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74991. private _getDefines;
  74992. /** @hidden */
  74993. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74994. }
  74995. }
  74996. declare module "babylonjs/Shaders/grain.fragment" {
  74997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74998. /** @hidden */
  74999. export var grainPixelShader: {
  75000. name: string;
  75001. shader: string;
  75002. };
  75003. }
  75004. declare module "babylonjs/PostProcesses/grainPostProcess" {
  75005. import { Nullable } from "babylonjs/types";
  75006. import { Camera } from "babylonjs/Cameras/camera";
  75007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75008. import { Engine } from "babylonjs/Engines/engine";
  75009. import "babylonjs/Shaders/grain.fragment";
  75010. import { Scene } from "babylonjs/scene";
  75011. /**
  75012. * The GrainPostProcess adds noise to the image at mid luminance levels
  75013. */
  75014. export class GrainPostProcess extends PostProcess {
  75015. /**
  75016. * The intensity of the grain added (default: 30)
  75017. */
  75018. intensity: number;
  75019. /**
  75020. * If the grain should be randomized on every frame
  75021. */
  75022. animated: boolean;
  75023. /**
  75024. * Gets a string identifying the name of the class
  75025. * @returns "GrainPostProcess" string
  75026. */
  75027. getClassName(): string;
  75028. /**
  75029. * Creates a new instance of @see GrainPostProcess
  75030. * @param name The name of the effect.
  75031. * @param options The required width/height ratio to downsize to before computing the render pass.
  75032. * @param camera The camera to apply the render pass to.
  75033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75034. * @param engine The engine which the post process will be applied. (default: current engine)
  75035. * @param reusable If the post process can be reused on the same frame. (default: false)
  75036. * @param textureType Type of textures used when performing the post process. (default: 0)
  75037. * @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)
  75038. */
  75039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75040. /** @hidden */
  75041. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  75042. }
  75043. }
  75044. declare module "babylonjs/Shaders/highlights.fragment" {
  75045. /** @hidden */
  75046. export var highlightsPixelShader: {
  75047. name: string;
  75048. shader: string;
  75049. };
  75050. }
  75051. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  75052. import { Nullable } from "babylonjs/types";
  75053. import { Camera } from "babylonjs/Cameras/camera";
  75054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75055. import { Engine } from "babylonjs/Engines/engine";
  75056. import "babylonjs/Shaders/highlights.fragment";
  75057. /**
  75058. * Extracts highlights from the image
  75059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75060. */
  75061. export class HighlightsPostProcess extends PostProcess {
  75062. /**
  75063. * Gets a string identifying the name of the class
  75064. * @returns "HighlightsPostProcess" string
  75065. */
  75066. getClassName(): string;
  75067. /**
  75068. * Extracts highlights from the image
  75069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  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 texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75077. */
  75078. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75079. }
  75080. }
  75081. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  75082. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75083. /**
  75084. * Contains all parameters needed for the prepass to perform
  75085. * motion blur
  75086. */
  75087. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75088. /**
  75089. * Is motion blur enabled
  75090. */
  75091. enabled: boolean;
  75092. /**
  75093. * Name of the configuration
  75094. */
  75095. name: string;
  75096. /**
  75097. * Textures that should be present in the MRT for this effect to work
  75098. */
  75099. readonly texturesRequired: number[];
  75100. }
  75101. }
  75102. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  75103. import { Nullable } from "babylonjs/types";
  75104. import { Scene } from "babylonjs/scene";
  75105. import { ISceneComponent } from "babylonjs/sceneComponent";
  75106. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  75107. module "babylonjs/scene" {
  75108. interface Scene {
  75109. /** @hidden (Backing field) */
  75110. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75111. /**
  75112. * Gets or Sets the current geometry buffer associated to the scene.
  75113. */
  75114. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75115. /**
  75116. * Enables a GeometryBufferRender and associates it with the scene
  75117. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75118. * @returns the GeometryBufferRenderer
  75119. */
  75120. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75121. /**
  75122. * Disables the GeometryBufferRender associated with the scene
  75123. */
  75124. disableGeometryBufferRenderer(): void;
  75125. }
  75126. }
  75127. /**
  75128. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75129. * in several rendering techniques.
  75130. */
  75131. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75132. /**
  75133. * The component name helpful to identify the component in the list of scene components.
  75134. */
  75135. readonly name: string;
  75136. /**
  75137. * The scene the component belongs to.
  75138. */
  75139. scene: Scene;
  75140. /**
  75141. * Creates a new instance of the component for the given scene
  75142. * @param scene Defines the scene to register the component in
  75143. */
  75144. constructor(scene: Scene);
  75145. /**
  75146. * Registers the component in a given scene
  75147. */
  75148. register(): void;
  75149. /**
  75150. * Rebuilds the elements related to this component in case of
  75151. * context lost for instance.
  75152. */
  75153. rebuild(): void;
  75154. /**
  75155. * Disposes the component and the associated ressources
  75156. */
  75157. dispose(): void;
  75158. private _gatherRenderTargets;
  75159. }
  75160. }
  75161. declare module "babylonjs/Shaders/motionBlur.fragment" {
  75162. /** @hidden */
  75163. export var motionBlurPixelShader: {
  75164. name: string;
  75165. shader: string;
  75166. };
  75167. }
  75168. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  75169. import { Nullable } from "babylonjs/types";
  75170. import { Camera } from "babylonjs/Cameras/camera";
  75171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75173. import "babylonjs/Animations/animatable";
  75174. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75175. import "babylonjs/Shaders/motionBlur.fragment";
  75176. import { Engine } from "babylonjs/Engines/engine";
  75177. import { Scene } from "babylonjs/scene";
  75178. /**
  75179. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75180. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75181. * As an example, all you have to do is to create the post-process:
  75182. * var mb = new BABYLON.MotionBlurPostProcess(
  75183. * 'mb', // The name of the effect.
  75184. * scene, // The scene containing the objects to blur according to their velocity.
  75185. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75186. * camera // The camera to apply the render pass to.
  75187. * );
  75188. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75189. */
  75190. export class MotionBlurPostProcess extends PostProcess {
  75191. /**
  75192. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75193. */
  75194. motionStrength: number;
  75195. /**
  75196. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75197. */
  75198. get motionBlurSamples(): number;
  75199. /**
  75200. * Sets the number of iterations to be used for motion blur quality
  75201. */
  75202. set motionBlurSamples(samples: number);
  75203. private _motionBlurSamples;
  75204. /**
  75205. * Gets wether or not the motion blur post-process is in object based mode.
  75206. */
  75207. get isObjectBased(): boolean;
  75208. /**
  75209. * Sets wether or not the motion blur post-process is in object based mode.
  75210. */
  75211. set isObjectBased(value: boolean);
  75212. private _isObjectBased;
  75213. private _forceGeometryBuffer;
  75214. private _geometryBufferRenderer;
  75215. private _prePassRenderer;
  75216. private _invViewProjection;
  75217. private _previousViewProjection;
  75218. /**
  75219. * Gets a string identifying the name of the class
  75220. * @returns "MotionBlurPostProcess" string
  75221. */
  75222. getClassName(): string;
  75223. /**
  75224. * Creates a new instance MotionBlurPostProcess
  75225. * @param name The name of the effect.
  75226. * @param scene The scene containing the objects to blur according to their velocity.
  75227. * @param options The required width/height ratio to downsize to before computing the render pass.
  75228. * @param camera The camera to apply the render pass to.
  75229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75230. * @param engine The engine which the post process will be applied. (default: current engine)
  75231. * @param reusable If the post process can be reused on the same frame. (default: false)
  75232. * @param textureType Type of textures used when performing the post process. (default: 0)
  75233. * @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)
  75234. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75235. */
  75236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75237. /**
  75238. * Excludes the given skinned mesh from computing bones velocities.
  75239. * 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.
  75240. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75241. */
  75242. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75243. /**
  75244. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75245. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75246. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75247. */
  75248. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75249. /**
  75250. * Disposes the post process.
  75251. * @param camera The camera to dispose the post process on.
  75252. */
  75253. dispose(camera?: Camera): void;
  75254. /**
  75255. * Called on the mode changed (object based or screen based).
  75256. */
  75257. private _applyMode;
  75258. /**
  75259. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75260. */
  75261. private _onApplyObjectBased;
  75262. /**
  75263. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75264. */
  75265. private _onApplyScreenBased;
  75266. /**
  75267. * Called on the effect must be updated (changed mode, samples count, etc.).
  75268. */
  75269. private _updateEffect;
  75270. /** @hidden */
  75271. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75272. }
  75273. }
  75274. declare module "babylonjs/Shaders/refraction.fragment" {
  75275. /** @hidden */
  75276. export var refractionPixelShader: {
  75277. name: string;
  75278. shader: string;
  75279. };
  75280. }
  75281. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75282. import { Color3 } from "babylonjs/Maths/math.color";
  75283. import { Camera } from "babylonjs/Cameras/camera";
  75284. import { Texture } from "babylonjs/Materials/Textures/texture";
  75285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75286. import { Engine } from "babylonjs/Engines/engine";
  75287. import "babylonjs/Shaders/refraction.fragment";
  75288. import { Scene } from "babylonjs/scene";
  75289. /**
  75290. * Post process which applies a refractin texture
  75291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75292. */
  75293. export class RefractionPostProcess extends PostProcess {
  75294. private _refTexture;
  75295. private _ownRefractionTexture;
  75296. /** the base color of the refraction (used to taint the rendering) */
  75297. color: Color3;
  75298. /** simulated refraction depth */
  75299. depth: number;
  75300. /** the coefficient of the base color (0 to remove base color tainting) */
  75301. colorLevel: number;
  75302. /** Gets the url used to load the refraction texture */
  75303. refractionTextureUrl: string;
  75304. /**
  75305. * Gets or sets the refraction texture
  75306. * Please note that you are responsible for disposing the texture if you set it manually
  75307. */
  75308. get refractionTexture(): Texture;
  75309. set refractionTexture(value: Texture);
  75310. /**
  75311. * Gets a string identifying the name of the class
  75312. * @returns "RefractionPostProcess" string
  75313. */
  75314. getClassName(): string;
  75315. /**
  75316. * Initializes the RefractionPostProcess
  75317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75318. * @param name The name of the effect.
  75319. * @param refractionTextureUrl Url of the refraction texture to use
  75320. * @param color the base color of the refraction (used to taint the rendering)
  75321. * @param depth simulated refraction depth
  75322. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75323. * @param camera The camera to apply the render pass to.
  75324. * @param options The required width/height ratio to downsize to before computing the render pass.
  75325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75326. * @param engine The engine which the post process will be applied. (default: current engine)
  75327. * @param reusable If the post process can be reused on the same frame. (default: false)
  75328. */
  75329. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75330. /**
  75331. * Disposes of the post process
  75332. * @param camera Camera to dispose post process on
  75333. */
  75334. dispose(camera: Camera): void;
  75335. /** @hidden */
  75336. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75337. }
  75338. }
  75339. declare module "babylonjs/Shaders/sharpen.fragment" {
  75340. /** @hidden */
  75341. export var sharpenPixelShader: {
  75342. name: string;
  75343. shader: string;
  75344. };
  75345. }
  75346. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75347. import { Nullable } from "babylonjs/types";
  75348. import { Camera } from "babylonjs/Cameras/camera";
  75349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75350. import "babylonjs/Shaders/sharpen.fragment";
  75351. import { Engine } from "babylonjs/Engines/engine";
  75352. import { Scene } from "babylonjs/scene";
  75353. /**
  75354. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75355. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75356. */
  75357. export class SharpenPostProcess extends PostProcess {
  75358. /**
  75359. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75360. */
  75361. colorAmount: number;
  75362. /**
  75363. * How much sharpness should be applied (default: 0.3)
  75364. */
  75365. edgeAmount: number;
  75366. /**
  75367. * Gets a string identifying the name of the class
  75368. * @returns "SharpenPostProcess" string
  75369. */
  75370. getClassName(): string;
  75371. /**
  75372. * Creates a new instance ConvolutionPostProcess
  75373. * @param name The name of the effect.
  75374. * @param options The required width/height ratio to downsize to before computing the render pass.
  75375. * @param camera The camera to apply the render pass to.
  75376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75377. * @param engine The engine which the post process will be applied. (default: current engine)
  75378. * @param reusable If the post process can be reused on the same frame. (default: false)
  75379. * @param textureType Type of textures used when performing the post process. (default: 0)
  75380. * @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)
  75381. */
  75382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75383. /** @hidden */
  75384. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75385. }
  75386. }
  75387. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75388. import { Nullable } from "babylonjs/types";
  75389. import { Camera } from "babylonjs/Cameras/camera";
  75390. import { Engine } from "babylonjs/Engines/engine";
  75391. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75392. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75393. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75394. /**
  75395. * PostProcessRenderPipeline
  75396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75397. */
  75398. export class PostProcessRenderPipeline {
  75399. private engine;
  75400. private _renderEffects;
  75401. private _renderEffectsForIsolatedPass;
  75402. /**
  75403. * List of inspectable custom properties (used by the Inspector)
  75404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75405. */
  75406. inspectableCustomProperties: IInspectable[];
  75407. /**
  75408. * @hidden
  75409. */
  75410. protected _cameras: Camera[];
  75411. /** @hidden */
  75412. _name: string;
  75413. /**
  75414. * Gets pipeline name
  75415. */
  75416. get name(): string;
  75417. /** Gets the list of attached cameras */
  75418. get cameras(): Camera[];
  75419. /**
  75420. * Initializes a PostProcessRenderPipeline
  75421. * @param engine engine to add the pipeline to
  75422. * @param name name of the pipeline
  75423. */
  75424. constructor(engine: Engine, name: string);
  75425. /**
  75426. * Gets the class name
  75427. * @returns "PostProcessRenderPipeline"
  75428. */
  75429. getClassName(): string;
  75430. /**
  75431. * If all the render effects in the pipeline are supported
  75432. */
  75433. get isSupported(): boolean;
  75434. /**
  75435. * Adds an effect to the pipeline
  75436. * @param renderEffect the effect to add
  75437. */
  75438. addEffect(renderEffect: PostProcessRenderEffect): void;
  75439. /** @hidden */
  75440. _rebuild(): void;
  75441. /** @hidden */
  75442. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75443. /** @hidden */
  75444. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75445. /** @hidden */
  75446. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75447. /** @hidden */
  75448. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75449. /** @hidden */
  75450. _attachCameras(cameras: Camera, unique: boolean): void;
  75451. /** @hidden */
  75452. _attachCameras(cameras: Camera[], unique: boolean): void;
  75453. /** @hidden */
  75454. _detachCameras(cameras: Camera): void;
  75455. /** @hidden */
  75456. _detachCameras(cameras: Nullable<Camera[]>): void;
  75457. /** @hidden */
  75458. _update(): void;
  75459. /** @hidden */
  75460. _reset(): void;
  75461. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75462. /**
  75463. * Sets the required values to the prepass renderer.
  75464. * @param prePassRenderer defines the prepass renderer to setup.
  75465. * @returns true if the pre pass is needed.
  75466. */
  75467. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75468. /**
  75469. * Disposes of the pipeline
  75470. */
  75471. dispose(): void;
  75472. }
  75473. }
  75474. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75475. import { Camera } from "babylonjs/Cameras/camera";
  75476. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75477. /**
  75478. * PostProcessRenderPipelineManager class
  75479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75480. */
  75481. export class PostProcessRenderPipelineManager {
  75482. private _renderPipelines;
  75483. /**
  75484. * Initializes a PostProcessRenderPipelineManager
  75485. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75486. */
  75487. constructor();
  75488. /**
  75489. * Gets the list of supported render pipelines
  75490. */
  75491. get supportedPipelines(): PostProcessRenderPipeline[];
  75492. /**
  75493. * Adds a pipeline to the manager
  75494. * @param renderPipeline The pipeline to add
  75495. */
  75496. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75497. /**
  75498. * Attaches a camera to the pipeline
  75499. * @param renderPipelineName The name of the pipeline to attach to
  75500. * @param cameras the camera to attach
  75501. * @param unique if the camera can be attached multiple times to the pipeline
  75502. */
  75503. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75504. /**
  75505. * Detaches a camera from the pipeline
  75506. * @param renderPipelineName The name of the pipeline to detach from
  75507. * @param cameras the camera to detach
  75508. */
  75509. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75510. /**
  75511. * Enables an effect by name on a pipeline
  75512. * @param renderPipelineName the name of the pipeline to enable the effect in
  75513. * @param renderEffectName the name of the effect to enable
  75514. * @param cameras the cameras that the effect should be enabled on
  75515. */
  75516. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75517. /**
  75518. * Disables an effect by name on a pipeline
  75519. * @param renderPipelineName the name of the pipeline to disable the effect in
  75520. * @param renderEffectName the name of the effect to disable
  75521. * @param cameras the cameras that the effect should be disabled on
  75522. */
  75523. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75524. /**
  75525. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75526. */
  75527. update(): void;
  75528. /** @hidden */
  75529. _rebuild(): void;
  75530. /**
  75531. * Disposes of the manager and pipelines
  75532. */
  75533. dispose(): void;
  75534. }
  75535. }
  75536. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75537. import { ISceneComponent } from "babylonjs/sceneComponent";
  75538. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75539. import { Scene } from "babylonjs/scene";
  75540. module "babylonjs/scene" {
  75541. interface Scene {
  75542. /** @hidden (Backing field) */
  75543. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75544. /**
  75545. * Gets the postprocess render pipeline manager
  75546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75547. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75548. */
  75549. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75550. }
  75551. }
  75552. /**
  75553. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75554. */
  75555. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75556. /**
  75557. * The component name helpfull to identify the component in the list of scene components.
  75558. */
  75559. readonly name: string;
  75560. /**
  75561. * The scene the component belongs to.
  75562. */
  75563. scene: Scene;
  75564. /**
  75565. * Creates a new instance of the component for the given scene
  75566. * @param scene Defines the scene to register the component in
  75567. */
  75568. constructor(scene: Scene);
  75569. /**
  75570. * Registers the component in a given scene
  75571. */
  75572. register(): void;
  75573. /**
  75574. * Rebuilds the elements related to this component in case of
  75575. * context lost for instance.
  75576. */
  75577. rebuild(): void;
  75578. /**
  75579. * Disposes the component and the associated ressources
  75580. */
  75581. dispose(): void;
  75582. private _gatherRenderTargets;
  75583. }
  75584. }
  75585. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75586. import { Nullable } from "babylonjs/types";
  75587. import { Observable } from "babylonjs/Misc/observable";
  75588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75589. import { Camera } from "babylonjs/Cameras/camera";
  75590. import { IDisposable } from "babylonjs/scene";
  75591. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75592. import { Scene } from "babylonjs/scene";
  75593. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75594. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75595. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75596. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75597. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75598. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75599. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75600. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75601. import { Animation } from "babylonjs/Animations/animation";
  75602. /**
  75603. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75604. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75605. */
  75606. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75607. private _scene;
  75608. private _camerasToBeAttached;
  75609. /**
  75610. * ID of the sharpen post process,
  75611. */
  75612. private readonly SharpenPostProcessId;
  75613. /**
  75614. * @ignore
  75615. * ID of the image processing post process;
  75616. */
  75617. readonly ImageProcessingPostProcessId: string;
  75618. /**
  75619. * @ignore
  75620. * ID of the Fast Approximate Anti-Aliasing post process;
  75621. */
  75622. readonly FxaaPostProcessId: string;
  75623. /**
  75624. * ID of the chromatic aberration post process,
  75625. */
  75626. private readonly ChromaticAberrationPostProcessId;
  75627. /**
  75628. * ID of the grain post process
  75629. */
  75630. private readonly GrainPostProcessId;
  75631. /**
  75632. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75633. */
  75634. sharpen: SharpenPostProcess;
  75635. private _sharpenEffect;
  75636. private bloom;
  75637. /**
  75638. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75639. */
  75640. depthOfField: DepthOfFieldEffect;
  75641. /**
  75642. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75643. */
  75644. fxaa: FxaaPostProcess;
  75645. /**
  75646. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75647. */
  75648. imageProcessing: ImageProcessingPostProcess;
  75649. /**
  75650. * Chromatic aberration post process which will shift rgb colors in the image
  75651. */
  75652. chromaticAberration: ChromaticAberrationPostProcess;
  75653. private _chromaticAberrationEffect;
  75654. /**
  75655. * Grain post process which add noise to the image
  75656. */
  75657. grain: GrainPostProcess;
  75658. private _grainEffect;
  75659. /**
  75660. * Glow post process which adds a glow to emissive areas of the image
  75661. */
  75662. private _glowLayer;
  75663. /**
  75664. * Animations which can be used to tweak settings over a period of time
  75665. */
  75666. animations: Animation[];
  75667. private _imageProcessingConfigurationObserver;
  75668. private _sharpenEnabled;
  75669. private _bloomEnabled;
  75670. private _depthOfFieldEnabled;
  75671. private _depthOfFieldBlurLevel;
  75672. private _fxaaEnabled;
  75673. private _imageProcessingEnabled;
  75674. private _defaultPipelineTextureType;
  75675. private _bloomScale;
  75676. private _chromaticAberrationEnabled;
  75677. private _grainEnabled;
  75678. private _buildAllowed;
  75679. /**
  75680. * This is triggered each time the pipeline has been built.
  75681. */
  75682. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75683. /**
  75684. * Gets active scene
  75685. */
  75686. get scene(): Scene;
  75687. /**
  75688. * Enable or disable the sharpen process from the pipeline
  75689. */
  75690. set sharpenEnabled(enabled: boolean);
  75691. get sharpenEnabled(): boolean;
  75692. private _resizeObserver;
  75693. private _hardwareScaleLevel;
  75694. private _bloomKernel;
  75695. /**
  75696. * Specifies the size of the bloom blur kernel, relative to the final output size
  75697. */
  75698. get bloomKernel(): number;
  75699. set bloomKernel(value: number);
  75700. /**
  75701. * Specifies the weight of the bloom in the final rendering
  75702. */
  75703. private _bloomWeight;
  75704. /**
  75705. * Specifies the luma threshold for the area that will be blurred by the bloom
  75706. */
  75707. private _bloomThreshold;
  75708. private _hdr;
  75709. /**
  75710. * The strength of the bloom.
  75711. */
  75712. set bloomWeight(value: number);
  75713. get bloomWeight(): number;
  75714. /**
  75715. * The strength of the bloom.
  75716. */
  75717. set bloomThreshold(value: number);
  75718. get bloomThreshold(): number;
  75719. /**
  75720. * The scale of the bloom, lower value will provide better performance.
  75721. */
  75722. set bloomScale(value: number);
  75723. get bloomScale(): number;
  75724. /**
  75725. * Enable or disable the bloom from the pipeline
  75726. */
  75727. set bloomEnabled(enabled: boolean);
  75728. get bloomEnabled(): boolean;
  75729. private _rebuildBloom;
  75730. /**
  75731. * If the depth of field is enabled.
  75732. */
  75733. get depthOfFieldEnabled(): boolean;
  75734. set depthOfFieldEnabled(enabled: boolean);
  75735. /**
  75736. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75737. */
  75738. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75739. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75740. /**
  75741. * If the anti aliasing is enabled.
  75742. */
  75743. set fxaaEnabled(enabled: boolean);
  75744. get fxaaEnabled(): boolean;
  75745. private _samples;
  75746. /**
  75747. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75748. */
  75749. set samples(sampleCount: number);
  75750. get samples(): number;
  75751. /**
  75752. * If image processing is enabled.
  75753. */
  75754. set imageProcessingEnabled(enabled: boolean);
  75755. get imageProcessingEnabled(): boolean;
  75756. /**
  75757. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75758. */
  75759. set glowLayerEnabled(enabled: boolean);
  75760. get glowLayerEnabled(): boolean;
  75761. /**
  75762. * Gets the glow layer (or null if not defined)
  75763. */
  75764. get glowLayer(): Nullable<GlowLayer>;
  75765. /**
  75766. * Enable or disable the chromaticAberration process from the pipeline
  75767. */
  75768. set chromaticAberrationEnabled(enabled: boolean);
  75769. get chromaticAberrationEnabled(): boolean;
  75770. /**
  75771. * Enable or disable the grain process from the pipeline
  75772. */
  75773. set grainEnabled(enabled: boolean);
  75774. get grainEnabled(): boolean;
  75775. /**
  75776. * @constructor
  75777. * @param name - The rendering pipeline name (default: "")
  75778. * @param hdr - If high dynamic range textures should be used (default: true)
  75779. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75780. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75781. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75782. */
  75783. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75784. /**
  75785. * Get the class name
  75786. * @returns "DefaultRenderingPipeline"
  75787. */
  75788. getClassName(): string;
  75789. /**
  75790. * Force the compilation of the entire pipeline.
  75791. */
  75792. prepare(): void;
  75793. private _hasCleared;
  75794. private _prevPostProcess;
  75795. private _prevPrevPostProcess;
  75796. private _setAutoClearAndTextureSharing;
  75797. private _depthOfFieldSceneObserver;
  75798. private _buildPipeline;
  75799. private _disposePostProcesses;
  75800. /**
  75801. * Adds a camera to the pipeline
  75802. * @param camera the camera to be added
  75803. */
  75804. addCamera(camera: Camera): void;
  75805. /**
  75806. * Removes a camera from the pipeline
  75807. * @param camera the camera to remove
  75808. */
  75809. removeCamera(camera: Camera): void;
  75810. /**
  75811. * Dispose of the pipeline and stop all post processes
  75812. */
  75813. dispose(): void;
  75814. /**
  75815. * Serialize the rendering pipeline (Used when exporting)
  75816. * @returns the serialized object
  75817. */
  75818. serialize(): any;
  75819. /**
  75820. * Parse the serialized pipeline
  75821. * @param source Source pipeline.
  75822. * @param scene The scene to load the pipeline to.
  75823. * @param rootUrl The URL of the serialized pipeline.
  75824. * @returns An instantiated pipeline from the serialized object.
  75825. */
  75826. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75827. }
  75828. }
  75829. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75830. /** @hidden */
  75831. export var lensHighlightsPixelShader: {
  75832. name: string;
  75833. shader: string;
  75834. };
  75835. }
  75836. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75837. /** @hidden */
  75838. export var depthOfFieldPixelShader: {
  75839. name: string;
  75840. shader: string;
  75841. };
  75842. }
  75843. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75844. import { Camera } from "babylonjs/Cameras/camera";
  75845. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75846. import { Scene } from "babylonjs/scene";
  75847. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75848. import "babylonjs/Shaders/chromaticAberration.fragment";
  75849. import "babylonjs/Shaders/lensHighlights.fragment";
  75850. import "babylonjs/Shaders/depthOfField.fragment";
  75851. /**
  75852. * BABYLON.JS Chromatic Aberration GLSL Shader
  75853. * Author: Olivier Guyot
  75854. * Separates very slightly R, G and B colors on the edges of the screen
  75855. * Inspired by Francois Tarlier & Martins Upitis
  75856. */
  75857. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75858. /**
  75859. * @ignore
  75860. * The chromatic aberration PostProcess id in the pipeline
  75861. */
  75862. LensChromaticAberrationEffect: string;
  75863. /**
  75864. * @ignore
  75865. * The highlights enhancing PostProcess id in the pipeline
  75866. */
  75867. HighlightsEnhancingEffect: string;
  75868. /**
  75869. * @ignore
  75870. * The depth-of-field PostProcess id in the pipeline
  75871. */
  75872. LensDepthOfFieldEffect: string;
  75873. private _scene;
  75874. private _depthTexture;
  75875. private _grainTexture;
  75876. private _chromaticAberrationPostProcess;
  75877. private _highlightsPostProcess;
  75878. private _depthOfFieldPostProcess;
  75879. private _edgeBlur;
  75880. private _grainAmount;
  75881. private _chromaticAberration;
  75882. private _distortion;
  75883. private _highlightsGain;
  75884. private _highlightsThreshold;
  75885. private _dofDistance;
  75886. private _dofAperture;
  75887. private _dofDarken;
  75888. private _dofPentagon;
  75889. private _blurNoise;
  75890. /**
  75891. * @constructor
  75892. *
  75893. * Effect parameters are as follow:
  75894. * {
  75895. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75896. * edge_blur: number; // from 0 to x (1 for realism)
  75897. * distortion: number; // from 0 to x (1 for realism)
  75898. * grain_amount: number; // from 0 to 1
  75899. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75900. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75901. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75902. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75903. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75904. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75905. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75906. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75907. * }
  75908. * Note: if an effect parameter is unset, effect is disabled
  75909. *
  75910. * @param name The rendering pipeline name
  75911. * @param parameters - An object containing all parameters (see above)
  75912. * @param scene The scene linked to this pipeline
  75913. * @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)
  75914. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75915. */
  75916. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75917. /**
  75918. * Get the class name
  75919. * @returns "LensRenderingPipeline"
  75920. */
  75921. getClassName(): string;
  75922. /**
  75923. * Gets associated scene
  75924. */
  75925. get scene(): Scene;
  75926. /**
  75927. * Gets or sets the edge blur
  75928. */
  75929. get edgeBlur(): number;
  75930. set edgeBlur(value: number);
  75931. /**
  75932. * Gets or sets the grain amount
  75933. */
  75934. get grainAmount(): number;
  75935. set grainAmount(value: number);
  75936. /**
  75937. * Gets or sets the chromatic aberration amount
  75938. */
  75939. get chromaticAberration(): number;
  75940. set chromaticAberration(value: number);
  75941. /**
  75942. * Gets or sets the depth of field aperture
  75943. */
  75944. get dofAperture(): number;
  75945. set dofAperture(value: number);
  75946. /**
  75947. * Gets or sets the edge distortion
  75948. */
  75949. get edgeDistortion(): number;
  75950. set edgeDistortion(value: number);
  75951. /**
  75952. * Gets or sets the depth of field distortion
  75953. */
  75954. get dofDistortion(): number;
  75955. set dofDistortion(value: number);
  75956. /**
  75957. * Gets or sets the darken out of focus amount
  75958. */
  75959. get darkenOutOfFocus(): number;
  75960. set darkenOutOfFocus(value: number);
  75961. /**
  75962. * Gets or sets a boolean indicating if blur noise is enabled
  75963. */
  75964. get blurNoise(): boolean;
  75965. set blurNoise(value: boolean);
  75966. /**
  75967. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75968. */
  75969. get pentagonBokeh(): boolean;
  75970. set pentagonBokeh(value: boolean);
  75971. /**
  75972. * Gets or sets the highlight grain amount
  75973. */
  75974. get highlightsGain(): number;
  75975. set highlightsGain(value: number);
  75976. /**
  75977. * Gets or sets the highlight threshold
  75978. */
  75979. get highlightsThreshold(): number;
  75980. set highlightsThreshold(value: number);
  75981. /**
  75982. * Sets the amount of blur at the edges
  75983. * @param amount blur amount
  75984. */
  75985. setEdgeBlur(amount: number): void;
  75986. /**
  75987. * Sets edge blur to 0
  75988. */
  75989. disableEdgeBlur(): void;
  75990. /**
  75991. * Sets the amout of grain
  75992. * @param amount Amount of grain
  75993. */
  75994. setGrainAmount(amount: number): void;
  75995. /**
  75996. * Set grain amount to 0
  75997. */
  75998. disableGrain(): void;
  75999. /**
  76000. * Sets the chromatic aberration amount
  76001. * @param amount amount of chromatic aberration
  76002. */
  76003. setChromaticAberration(amount: number): void;
  76004. /**
  76005. * Sets chromatic aberration amount to 0
  76006. */
  76007. disableChromaticAberration(): void;
  76008. /**
  76009. * Sets the EdgeDistortion amount
  76010. * @param amount amount of EdgeDistortion
  76011. */
  76012. setEdgeDistortion(amount: number): void;
  76013. /**
  76014. * Sets edge distortion to 0
  76015. */
  76016. disableEdgeDistortion(): void;
  76017. /**
  76018. * Sets the FocusDistance amount
  76019. * @param amount amount of FocusDistance
  76020. */
  76021. setFocusDistance(amount: number): void;
  76022. /**
  76023. * Disables depth of field
  76024. */
  76025. disableDepthOfField(): void;
  76026. /**
  76027. * Sets the Aperture amount
  76028. * @param amount amount of Aperture
  76029. */
  76030. setAperture(amount: number): void;
  76031. /**
  76032. * Sets the DarkenOutOfFocus amount
  76033. * @param amount amount of DarkenOutOfFocus
  76034. */
  76035. setDarkenOutOfFocus(amount: number): void;
  76036. private _pentagonBokehIsEnabled;
  76037. /**
  76038. * Creates a pentagon bokeh effect
  76039. */
  76040. enablePentagonBokeh(): void;
  76041. /**
  76042. * Disables the pentagon bokeh effect
  76043. */
  76044. disablePentagonBokeh(): void;
  76045. /**
  76046. * Enables noise blur
  76047. */
  76048. enableNoiseBlur(): void;
  76049. /**
  76050. * Disables noise blur
  76051. */
  76052. disableNoiseBlur(): void;
  76053. /**
  76054. * Sets the HighlightsGain amount
  76055. * @param amount amount of HighlightsGain
  76056. */
  76057. setHighlightsGain(amount: number): void;
  76058. /**
  76059. * Sets the HighlightsThreshold amount
  76060. * @param amount amount of HighlightsThreshold
  76061. */
  76062. setHighlightsThreshold(amount: number): void;
  76063. /**
  76064. * Disables highlights
  76065. */
  76066. disableHighlights(): void;
  76067. /**
  76068. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76069. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  76070. */
  76071. dispose(disableDepthRender?: boolean): void;
  76072. private _createChromaticAberrationPostProcess;
  76073. private _createHighlightsPostProcess;
  76074. private _createDepthOfFieldPostProcess;
  76075. private _createGrainTexture;
  76076. }
  76077. }
  76078. declare module "babylonjs/Rendering/ssao2Configuration" {
  76079. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76080. /**
  76081. * Contains all parameters needed for the prepass to perform
  76082. * screen space subsurface scattering
  76083. */
  76084. export class SSAO2Configuration implements PrePassEffectConfiguration {
  76085. /**
  76086. * Is subsurface enabled
  76087. */
  76088. enabled: boolean;
  76089. /**
  76090. * Name of the configuration
  76091. */
  76092. name: string;
  76093. /**
  76094. * Textures that should be present in the MRT for this effect to work
  76095. */
  76096. readonly texturesRequired: number[];
  76097. }
  76098. }
  76099. declare module "babylonjs/Shaders/ssao2.fragment" {
  76100. /** @hidden */
  76101. export var ssao2PixelShader: {
  76102. name: string;
  76103. shader: string;
  76104. };
  76105. }
  76106. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  76107. /** @hidden */
  76108. export var ssaoCombinePixelShader: {
  76109. name: string;
  76110. shader: string;
  76111. };
  76112. }
  76113. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  76114. import { Camera } from "babylonjs/Cameras/camera";
  76115. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76116. import { Scene } from "babylonjs/scene";
  76117. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76118. import "babylonjs/Shaders/ssao2.fragment";
  76119. import "babylonjs/Shaders/ssaoCombine.fragment";
  76120. /**
  76121. * Render pipeline to produce ssao effect
  76122. */
  76123. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76124. /**
  76125. * @ignore
  76126. * The PassPostProcess id in the pipeline that contains the original scene color
  76127. */
  76128. SSAOOriginalSceneColorEffect: string;
  76129. /**
  76130. * @ignore
  76131. * The SSAO PostProcess id in the pipeline
  76132. */
  76133. SSAORenderEffect: string;
  76134. /**
  76135. * @ignore
  76136. * The horizontal blur PostProcess id in the pipeline
  76137. */
  76138. SSAOBlurHRenderEffect: string;
  76139. /**
  76140. * @ignore
  76141. * The vertical blur PostProcess id in the pipeline
  76142. */
  76143. SSAOBlurVRenderEffect: string;
  76144. /**
  76145. * @ignore
  76146. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76147. */
  76148. SSAOCombineRenderEffect: string;
  76149. /**
  76150. * The output strength of the SSAO post-process. Default value is 1.0.
  76151. */
  76152. totalStrength: number;
  76153. /**
  76154. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76155. */
  76156. maxZ: number;
  76157. /**
  76158. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76159. */
  76160. minZAspect: number;
  76161. private _samples;
  76162. /**
  76163. * Number of samples used for the SSAO calculations. Default value is 8
  76164. */
  76165. set samples(n: number);
  76166. get samples(): number;
  76167. private _textureSamples;
  76168. /**
  76169. * Number of samples to use for antialiasing
  76170. */
  76171. set textureSamples(n: number);
  76172. get textureSamples(): number;
  76173. /**
  76174. * Force rendering the geometry through geometry buffer
  76175. */
  76176. private _forceGeometryBuffer;
  76177. /**
  76178. * Ratio object used for SSAO ratio and blur ratio
  76179. */
  76180. private _ratio;
  76181. /**
  76182. * Dynamically generated sphere sampler.
  76183. */
  76184. private _sampleSphere;
  76185. /**
  76186. * Blur filter offsets
  76187. */
  76188. private _samplerOffsets;
  76189. private _expensiveBlur;
  76190. /**
  76191. * If bilateral blur should be used
  76192. */
  76193. set expensiveBlur(b: boolean);
  76194. get expensiveBlur(): boolean;
  76195. /**
  76196. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76197. */
  76198. radius: number;
  76199. /**
  76200. * The base color of the SSAO post-process
  76201. * The final result is "base + ssao" between [0, 1]
  76202. */
  76203. base: number;
  76204. /**
  76205. * Support test.
  76206. */
  76207. static get IsSupported(): boolean;
  76208. private _scene;
  76209. private _randomTexture;
  76210. private _originalColorPostProcess;
  76211. private _ssaoPostProcess;
  76212. private _blurHPostProcess;
  76213. private _blurVPostProcess;
  76214. private _ssaoCombinePostProcess;
  76215. private _prePassRenderer;
  76216. /**
  76217. * Gets active scene
  76218. */
  76219. get scene(): Scene;
  76220. /**
  76221. * @constructor
  76222. * @param name The rendering pipeline name
  76223. * @param scene The scene linked to this pipeline
  76224. * @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 }
  76225. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76226. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76227. */
  76228. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76229. /**
  76230. * Get the class name
  76231. * @returns "SSAO2RenderingPipeline"
  76232. */
  76233. getClassName(): string;
  76234. /**
  76235. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76236. */
  76237. dispose(disableGeometryBufferRenderer?: boolean): void;
  76238. private _createBlurPostProcess;
  76239. /** @hidden */
  76240. _rebuild(): void;
  76241. private _bits;
  76242. private _radicalInverse_VdC;
  76243. private _hammersley;
  76244. private _hemisphereSample_uniform;
  76245. private _generateHemisphere;
  76246. private _getDefinesForSSAO;
  76247. private _createSSAOPostProcess;
  76248. private _createSSAOCombinePostProcess;
  76249. private _createRandomTexture;
  76250. /**
  76251. * Serialize the rendering pipeline (Used when exporting)
  76252. * @returns the serialized object
  76253. */
  76254. serialize(): any;
  76255. /**
  76256. * Parse the serialized pipeline
  76257. * @param source Source pipeline.
  76258. * @param scene The scene to load the pipeline to.
  76259. * @param rootUrl The URL of the serialized pipeline.
  76260. * @returns An instantiated pipeline from the serialized object.
  76261. */
  76262. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76263. }
  76264. }
  76265. declare module "babylonjs/Shaders/ssao.fragment" {
  76266. /** @hidden */
  76267. export var ssaoPixelShader: {
  76268. name: string;
  76269. shader: string;
  76270. };
  76271. }
  76272. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76273. import { Camera } from "babylonjs/Cameras/camera";
  76274. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76275. import { Scene } from "babylonjs/scene";
  76276. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76277. import "babylonjs/Shaders/ssao.fragment";
  76278. import "babylonjs/Shaders/ssaoCombine.fragment";
  76279. /**
  76280. * Render pipeline to produce ssao effect
  76281. */
  76282. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76283. /**
  76284. * @ignore
  76285. * The PassPostProcess id in the pipeline that contains the original scene color
  76286. */
  76287. SSAOOriginalSceneColorEffect: string;
  76288. /**
  76289. * @ignore
  76290. * The SSAO PostProcess id in the pipeline
  76291. */
  76292. SSAORenderEffect: string;
  76293. /**
  76294. * @ignore
  76295. * The horizontal blur PostProcess id in the pipeline
  76296. */
  76297. SSAOBlurHRenderEffect: string;
  76298. /**
  76299. * @ignore
  76300. * The vertical blur PostProcess id in the pipeline
  76301. */
  76302. SSAOBlurVRenderEffect: string;
  76303. /**
  76304. * @ignore
  76305. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76306. */
  76307. SSAOCombineRenderEffect: string;
  76308. /**
  76309. * The output strength of the SSAO post-process. Default value is 1.0.
  76310. */
  76311. totalStrength: number;
  76312. /**
  76313. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76314. */
  76315. radius: number;
  76316. /**
  76317. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76318. * Must not be equal to fallOff and superior to fallOff.
  76319. * Default value is 0.0075
  76320. */
  76321. area: number;
  76322. /**
  76323. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76324. * Must not be equal to area and inferior to area.
  76325. * Default value is 0.000001
  76326. */
  76327. fallOff: number;
  76328. /**
  76329. * The base color of the SSAO post-process
  76330. * The final result is "base + ssao" between [0, 1]
  76331. */
  76332. base: number;
  76333. private _scene;
  76334. private _depthTexture;
  76335. private _randomTexture;
  76336. private _originalColorPostProcess;
  76337. private _ssaoPostProcess;
  76338. private _blurHPostProcess;
  76339. private _blurVPostProcess;
  76340. private _ssaoCombinePostProcess;
  76341. private _firstUpdate;
  76342. /**
  76343. * Gets active scene
  76344. */
  76345. get scene(): Scene;
  76346. /**
  76347. * @constructor
  76348. * @param name - The rendering pipeline name
  76349. * @param scene - The scene linked to this pipeline
  76350. * @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 }
  76351. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76352. */
  76353. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76354. /**
  76355. * Get the class name
  76356. * @returns "SSAORenderingPipeline"
  76357. */
  76358. getClassName(): string;
  76359. /**
  76360. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76361. */
  76362. dispose(disableDepthRender?: boolean): void;
  76363. private _createBlurPostProcess;
  76364. /** @hidden */
  76365. _rebuild(): void;
  76366. private _createSSAOPostProcess;
  76367. private _createSSAOCombinePostProcess;
  76368. private _createRandomTexture;
  76369. }
  76370. }
  76371. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76372. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76373. /**
  76374. * Contains all parameters needed for the prepass to perform
  76375. * screen space reflections
  76376. */
  76377. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76378. /**
  76379. * Is ssr enabled
  76380. */
  76381. enabled: boolean;
  76382. /**
  76383. * Name of the configuration
  76384. */
  76385. name: string;
  76386. /**
  76387. * Textures that should be present in the MRT for this effect to work
  76388. */
  76389. readonly texturesRequired: number[];
  76390. }
  76391. }
  76392. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76393. /** @hidden */
  76394. export var screenSpaceReflectionPixelShader: {
  76395. name: string;
  76396. shader: string;
  76397. };
  76398. }
  76399. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76400. import { Nullable } from "babylonjs/types";
  76401. import { Camera } from "babylonjs/Cameras/camera";
  76402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76403. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76404. import { Engine } from "babylonjs/Engines/engine";
  76405. import { Scene } from "babylonjs/scene";
  76406. /**
  76407. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76408. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76409. */
  76410. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76411. /**
  76412. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76413. */
  76414. threshold: number;
  76415. /**
  76416. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76417. */
  76418. strength: number;
  76419. /**
  76420. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76421. */
  76422. reflectionSpecularFalloffExponent: number;
  76423. /**
  76424. * 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]
  76425. */
  76426. step: number;
  76427. /**
  76428. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76429. */
  76430. roughnessFactor: number;
  76431. private _forceGeometryBuffer;
  76432. private _geometryBufferRenderer;
  76433. private _prePassRenderer;
  76434. private _enableSmoothReflections;
  76435. private _reflectionSamples;
  76436. private _smoothSteps;
  76437. /**
  76438. * Gets a string identifying the name of the class
  76439. * @returns "ScreenSpaceReflectionPostProcess" string
  76440. */
  76441. getClassName(): string;
  76442. /**
  76443. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76444. * @param name The name of the effect.
  76445. * @param scene The scene containing the objects to calculate reflections.
  76446. * @param options The required width/height ratio to downsize to before computing the render pass.
  76447. * @param camera The camera to apply the render pass to.
  76448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76449. * @param engine The engine which the post process will be applied. (default: current engine)
  76450. * @param reusable If the post process can be reused on the same frame. (default: false)
  76451. * @param textureType Type of textures used when performing the post process. (default: 0)
  76452. * @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)
  76453. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76454. */
  76455. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76456. /**
  76457. * Gets wether or not smoothing reflections is enabled.
  76458. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76459. */
  76460. get enableSmoothReflections(): boolean;
  76461. /**
  76462. * Sets wether or not smoothing reflections is enabled.
  76463. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76464. */
  76465. set enableSmoothReflections(enabled: boolean);
  76466. /**
  76467. * Gets the number of samples taken while computing reflections. More samples count is high,
  76468. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76469. */
  76470. get reflectionSamples(): number;
  76471. /**
  76472. * Sets the number of samples taken while computing reflections. More samples count is high,
  76473. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76474. */
  76475. set reflectionSamples(samples: number);
  76476. /**
  76477. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76478. * more the post-process will require GPU power and can generate a drop in FPS.
  76479. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76480. */
  76481. get smoothSteps(): number;
  76482. set smoothSteps(steps: number);
  76483. private _updateEffectDefines;
  76484. /** @hidden */
  76485. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76486. }
  76487. }
  76488. declare module "babylonjs/Shaders/standard.fragment" {
  76489. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76490. /** @hidden */
  76491. export var standardPixelShader: {
  76492. name: string;
  76493. shader: string;
  76494. };
  76495. }
  76496. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76497. import { Nullable } from "babylonjs/types";
  76498. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76499. import { Camera } from "babylonjs/Cameras/camera";
  76500. import { Texture } from "babylonjs/Materials/Textures/texture";
  76501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76502. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76503. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76504. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76505. import { IDisposable } from "babylonjs/scene";
  76506. import { SpotLight } from "babylonjs/Lights/spotLight";
  76507. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76508. import { Scene } from "babylonjs/scene";
  76509. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76510. import { Animation } from "babylonjs/Animations/animation";
  76511. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76512. import "babylonjs/Shaders/standard.fragment";
  76513. /**
  76514. * Standard rendering pipeline
  76515. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76516. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76517. */
  76518. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76519. /**
  76520. * Public members
  76521. */
  76522. /**
  76523. * Post-process which contains the original scene color before the pipeline applies all the effects
  76524. */
  76525. originalPostProcess: Nullable<PostProcess>;
  76526. /**
  76527. * Post-process used to down scale an image x4
  76528. */
  76529. downSampleX4PostProcess: Nullable<PostProcess>;
  76530. /**
  76531. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76532. */
  76533. brightPassPostProcess: Nullable<PostProcess>;
  76534. /**
  76535. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76536. */
  76537. blurHPostProcesses: PostProcess[];
  76538. /**
  76539. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76540. */
  76541. blurVPostProcesses: PostProcess[];
  76542. /**
  76543. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76544. */
  76545. textureAdderPostProcess: Nullable<PostProcess>;
  76546. /**
  76547. * Post-process used to create volumetric lighting effect
  76548. */
  76549. volumetricLightPostProcess: Nullable<PostProcess>;
  76550. /**
  76551. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76552. */
  76553. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76554. /**
  76555. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76556. */
  76557. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76558. /**
  76559. * Post-process used to merge the volumetric light effect and the real scene color
  76560. */
  76561. volumetricLightMergePostProces: Nullable<PostProcess>;
  76562. /**
  76563. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76564. */
  76565. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76566. /**
  76567. * Base post-process used to calculate the average luminance of the final image for HDR
  76568. */
  76569. luminancePostProcess: Nullable<PostProcess>;
  76570. /**
  76571. * Post-processes used to create down sample post-processes in order to get
  76572. * the average luminance of the final image for HDR
  76573. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76574. */
  76575. luminanceDownSamplePostProcesses: PostProcess[];
  76576. /**
  76577. * Post-process used to create a HDR effect (light adaptation)
  76578. */
  76579. hdrPostProcess: Nullable<PostProcess>;
  76580. /**
  76581. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76582. */
  76583. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76584. /**
  76585. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76586. */
  76587. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76588. /**
  76589. * Post-process used to merge the final HDR post-process and the real scene color
  76590. */
  76591. hdrFinalPostProcess: Nullable<PostProcess>;
  76592. /**
  76593. * Post-process used to create a lens flare effect
  76594. */
  76595. lensFlarePostProcess: Nullable<PostProcess>;
  76596. /**
  76597. * Post-process that merges the result of the lens flare post-process and the real scene color
  76598. */
  76599. lensFlareComposePostProcess: Nullable<PostProcess>;
  76600. /**
  76601. * Post-process used to create a motion blur effect
  76602. */
  76603. motionBlurPostProcess: Nullable<PostProcess>;
  76604. /**
  76605. * Post-process used to create a depth of field effect
  76606. */
  76607. depthOfFieldPostProcess: Nullable<PostProcess>;
  76608. /**
  76609. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76610. */
  76611. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76612. /**
  76613. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76614. */
  76615. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76616. /**
  76617. * Represents the brightness threshold in order to configure the illuminated surfaces
  76618. */
  76619. brightThreshold: number;
  76620. /**
  76621. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76622. */
  76623. blurWidth: number;
  76624. /**
  76625. * Sets if the blur for highlighted surfaces must be only horizontal
  76626. */
  76627. horizontalBlur: boolean;
  76628. /**
  76629. * Gets the overall exposure used by the pipeline
  76630. */
  76631. get exposure(): number;
  76632. /**
  76633. * Sets the overall exposure used by the pipeline
  76634. */
  76635. set exposure(value: number);
  76636. /**
  76637. * Texture used typically to simulate "dirty" on camera lens
  76638. */
  76639. lensTexture: Nullable<Texture>;
  76640. /**
  76641. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76642. */
  76643. volumetricLightCoefficient: number;
  76644. /**
  76645. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76646. */
  76647. volumetricLightPower: number;
  76648. /**
  76649. * Used the set the blur intensity to smooth the volumetric lights
  76650. */
  76651. volumetricLightBlurScale: number;
  76652. /**
  76653. * Light (spot or directional) used to generate the volumetric lights rays
  76654. * The source light must have a shadow generate so the pipeline can get its
  76655. * depth map
  76656. */
  76657. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76658. /**
  76659. * For eye adaptation, represents the minimum luminance the eye can see
  76660. */
  76661. hdrMinimumLuminance: number;
  76662. /**
  76663. * For eye adaptation, represents the decrease luminance speed
  76664. */
  76665. hdrDecreaseRate: number;
  76666. /**
  76667. * For eye adaptation, represents the increase luminance speed
  76668. */
  76669. hdrIncreaseRate: number;
  76670. /**
  76671. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76672. */
  76673. get hdrAutoExposure(): boolean;
  76674. /**
  76675. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76676. */
  76677. set hdrAutoExposure(value: boolean);
  76678. /**
  76679. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76680. */
  76681. lensColorTexture: Nullable<Texture>;
  76682. /**
  76683. * The overall strengh for the lens flare effect
  76684. */
  76685. lensFlareStrength: number;
  76686. /**
  76687. * Dispersion coefficient for lens flare ghosts
  76688. */
  76689. lensFlareGhostDispersal: number;
  76690. /**
  76691. * Main lens flare halo width
  76692. */
  76693. lensFlareHaloWidth: number;
  76694. /**
  76695. * Based on the lens distortion effect, defines how much the lens flare result
  76696. * is distorted
  76697. */
  76698. lensFlareDistortionStrength: number;
  76699. /**
  76700. * Configures the blur intensity used for for lens flare (halo)
  76701. */
  76702. lensFlareBlurWidth: number;
  76703. /**
  76704. * Lens star texture must be used to simulate rays on the flares and is available
  76705. * in the documentation
  76706. */
  76707. lensStarTexture: Nullable<Texture>;
  76708. /**
  76709. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76710. * flare effect by taking account of the dirt texture
  76711. */
  76712. lensFlareDirtTexture: Nullable<Texture>;
  76713. /**
  76714. * Represents the focal length for the depth of field effect
  76715. */
  76716. depthOfFieldDistance: number;
  76717. /**
  76718. * Represents the blur intensity for the blurred part of the depth of field effect
  76719. */
  76720. depthOfFieldBlurWidth: number;
  76721. /**
  76722. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76723. */
  76724. get motionStrength(): number;
  76725. /**
  76726. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76727. */
  76728. set motionStrength(strength: number);
  76729. /**
  76730. * Gets wether or not the motion blur post-process is object based or screen based.
  76731. */
  76732. get objectBasedMotionBlur(): boolean;
  76733. /**
  76734. * Sets wether or not the motion blur post-process should be object based or screen based
  76735. */
  76736. set objectBasedMotionBlur(value: boolean);
  76737. /**
  76738. * List of animations for the pipeline (IAnimatable implementation)
  76739. */
  76740. animations: Animation[];
  76741. /**
  76742. * Private members
  76743. */
  76744. private _scene;
  76745. private _currentDepthOfFieldSource;
  76746. private _basePostProcess;
  76747. private _fixedExposure;
  76748. private _currentExposure;
  76749. private _hdrAutoExposure;
  76750. private _hdrCurrentLuminance;
  76751. private _motionStrength;
  76752. private _isObjectBasedMotionBlur;
  76753. private _floatTextureType;
  76754. private _camerasToBeAttached;
  76755. private _ratio;
  76756. private _bloomEnabled;
  76757. private _depthOfFieldEnabled;
  76758. private _vlsEnabled;
  76759. private _lensFlareEnabled;
  76760. private _hdrEnabled;
  76761. private _motionBlurEnabled;
  76762. private _fxaaEnabled;
  76763. private _screenSpaceReflectionsEnabled;
  76764. private _motionBlurSamples;
  76765. private _volumetricLightStepsCount;
  76766. private _samples;
  76767. /**
  76768. * @ignore
  76769. * Specifies if the bloom pipeline is enabled
  76770. */
  76771. get BloomEnabled(): boolean;
  76772. set BloomEnabled(enabled: boolean);
  76773. /**
  76774. * @ignore
  76775. * Specifies if the depth of field pipeline is enabed
  76776. */
  76777. get DepthOfFieldEnabled(): boolean;
  76778. set DepthOfFieldEnabled(enabled: boolean);
  76779. /**
  76780. * @ignore
  76781. * Specifies if the lens flare pipeline is enabed
  76782. */
  76783. get LensFlareEnabled(): boolean;
  76784. set LensFlareEnabled(enabled: boolean);
  76785. /**
  76786. * @ignore
  76787. * Specifies if the HDR pipeline is enabled
  76788. */
  76789. get HDREnabled(): boolean;
  76790. set HDREnabled(enabled: boolean);
  76791. /**
  76792. * @ignore
  76793. * Specifies if the volumetric lights scattering effect is enabled
  76794. */
  76795. get VLSEnabled(): boolean;
  76796. set VLSEnabled(enabled: boolean);
  76797. /**
  76798. * @ignore
  76799. * Specifies if the motion blur effect is enabled
  76800. */
  76801. get MotionBlurEnabled(): boolean;
  76802. set MotionBlurEnabled(enabled: boolean);
  76803. /**
  76804. * Specifies if anti-aliasing is enabled
  76805. */
  76806. get fxaaEnabled(): boolean;
  76807. set fxaaEnabled(enabled: boolean);
  76808. /**
  76809. * Specifies if screen space reflections are enabled.
  76810. */
  76811. get screenSpaceReflectionsEnabled(): boolean;
  76812. set screenSpaceReflectionsEnabled(enabled: boolean);
  76813. /**
  76814. * Specifies the number of steps used to calculate the volumetric lights
  76815. * Typically in interval [50, 200]
  76816. */
  76817. get volumetricLightStepsCount(): number;
  76818. set volumetricLightStepsCount(count: number);
  76819. /**
  76820. * Specifies the number of samples used for the motion blur effect
  76821. * Typically in interval [16, 64]
  76822. */
  76823. get motionBlurSamples(): number;
  76824. set motionBlurSamples(samples: number);
  76825. /**
  76826. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76827. */
  76828. get samples(): number;
  76829. set samples(sampleCount: number);
  76830. /**
  76831. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76832. * @constructor
  76833. * @param name The rendering pipeline name
  76834. * @param scene The scene linked to this pipeline
  76835. * @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)
  76836. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76837. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76838. */
  76839. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76840. private _buildPipeline;
  76841. private _createDownSampleX4PostProcess;
  76842. private _createBrightPassPostProcess;
  76843. private _createBlurPostProcesses;
  76844. private _createTextureAdderPostProcess;
  76845. private _createVolumetricLightPostProcess;
  76846. private _createLuminancePostProcesses;
  76847. private _createHdrPostProcess;
  76848. private _createLensFlarePostProcess;
  76849. private _createDepthOfFieldPostProcess;
  76850. private _createMotionBlurPostProcess;
  76851. private _getDepthTexture;
  76852. private _disposePostProcesses;
  76853. /**
  76854. * Dispose of the pipeline and stop all post processes
  76855. */
  76856. dispose(): void;
  76857. /**
  76858. * Serialize the rendering pipeline (Used when exporting)
  76859. * @returns the serialized object
  76860. */
  76861. serialize(): any;
  76862. /**
  76863. * Parse the serialized pipeline
  76864. * @param source Source pipeline.
  76865. * @param scene The scene to load the pipeline to.
  76866. * @param rootUrl The URL of the serialized pipeline.
  76867. * @returns An instantiated pipeline from the serialized object.
  76868. */
  76869. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76870. /**
  76871. * Luminance steps
  76872. */
  76873. static LuminanceSteps: number;
  76874. }
  76875. }
  76876. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76877. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76878. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76879. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76880. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76881. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76882. }
  76883. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76884. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76885. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76886. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76887. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76888. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76889. }
  76890. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76891. /** @hidden */
  76892. export var stereoscopicInterlacePixelShader: {
  76893. name: string;
  76894. shader: string;
  76895. };
  76896. }
  76897. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76898. import { Camera } from "babylonjs/Cameras/camera";
  76899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76900. import { Engine } from "babylonjs/Engines/engine";
  76901. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76902. /**
  76903. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76904. */
  76905. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76906. private _stepSize;
  76907. private _passedProcess;
  76908. /**
  76909. * Gets a string identifying the name of the class
  76910. * @returns "StereoscopicInterlacePostProcessI" string
  76911. */
  76912. getClassName(): string;
  76913. /**
  76914. * Initializes a StereoscopicInterlacePostProcessI
  76915. * @param name The name of the effect.
  76916. * @param rigCameras The rig cameras to be appled to the post process
  76917. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76918. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76920. * @param engine The engine which the post process will be applied. (default: current engine)
  76921. * @param reusable If the post process can be reused on the same frame. (default: false)
  76922. */
  76923. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76924. }
  76925. /**
  76926. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76927. */
  76928. export class StereoscopicInterlacePostProcess extends PostProcess {
  76929. private _stepSize;
  76930. private _passedProcess;
  76931. /**
  76932. * Gets a string identifying the name of the class
  76933. * @returns "StereoscopicInterlacePostProcess" string
  76934. */
  76935. getClassName(): string;
  76936. /**
  76937. * Initializes a StereoscopicInterlacePostProcess
  76938. * @param name The name of the effect.
  76939. * @param rigCameras The rig cameras to be appled to the post process
  76940. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76942. * @param engine The engine which the post process will be applied. (default: current engine)
  76943. * @param reusable If the post process can be reused on the same frame. (default: false)
  76944. */
  76945. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76946. }
  76947. }
  76948. declare module "babylonjs/Shaders/tonemap.fragment" {
  76949. /** @hidden */
  76950. export var tonemapPixelShader: {
  76951. name: string;
  76952. shader: string;
  76953. };
  76954. }
  76955. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76956. import { Camera } from "babylonjs/Cameras/camera";
  76957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76958. import "babylonjs/Shaders/tonemap.fragment";
  76959. import { Engine } from "babylonjs/Engines/engine";
  76960. /** Defines operator used for tonemapping */
  76961. export enum TonemappingOperator {
  76962. /** Hable */
  76963. Hable = 0,
  76964. /** Reinhard */
  76965. Reinhard = 1,
  76966. /** HejiDawson */
  76967. HejiDawson = 2,
  76968. /** Photographic */
  76969. Photographic = 3
  76970. }
  76971. /**
  76972. * Defines a post process to apply tone mapping
  76973. */
  76974. export class TonemapPostProcess extends PostProcess {
  76975. private _operator;
  76976. /** Defines the required exposure adjustement */
  76977. exposureAdjustment: number;
  76978. /**
  76979. * Gets a string identifying the name of the class
  76980. * @returns "TonemapPostProcess" string
  76981. */
  76982. getClassName(): string;
  76983. /**
  76984. * Creates a new TonemapPostProcess
  76985. * @param name defines the name of the postprocess
  76986. * @param _operator defines the operator to use
  76987. * @param exposureAdjustment defines the required exposure adjustement
  76988. * @param camera defines the camera to use (can be null)
  76989. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76990. * @param engine defines the hosting engine (can be ignore if camera is set)
  76991. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76992. */
  76993. constructor(name: string, _operator: TonemappingOperator,
  76994. /** Defines the required exposure adjustement */
  76995. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76996. }
  76997. }
  76998. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76999. /** @hidden */
  77000. export var volumetricLightScatteringPixelShader: {
  77001. name: string;
  77002. shader: string;
  77003. };
  77004. }
  77005. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  77006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77009. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77013. /** @hidden */
  77014. export var volumetricLightScatteringPassVertexShader: {
  77015. name: string;
  77016. shader: string;
  77017. };
  77018. }
  77019. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  77020. /** @hidden */
  77021. export var volumetricLightScatteringPassPixelShader: {
  77022. name: string;
  77023. shader: string;
  77024. };
  77025. }
  77026. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  77027. import { Vector3 } from "babylonjs/Maths/math.vector";
  77028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77029. import { Mesh } from "babylonjs/Meshes/mesh";
  77030. import { Camera } from "babylonjs/Cameras/camera";
  77031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77033. import { Scene } from "babylonjs/scene";
  77034. import "babylonjs/Meshes/Builders/planeBuilder";
  77035. import "babylonjs/Shaders/depth.vertex";
  77036. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  77037. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  77038. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  77039. import { Engine } from "babylonjs/Engines/engine";
  77040. /**
  77041. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  77042. */
  77043. export class VolumetricLightScatteringPostProcess extends PostProcess {
  77044. private _volumetricLightScatteringPass;
  77045. private _volumetricLightScatteringRTT;
  77046. private _viewPort;
  77047. private _screenCoordinates;
  77048. private _cachedDefines;
  77049. /**
  77050. * If not undefined, the mesh position is computed from the attached node position
  77051. */
  77052. attachedNode: {
  77053. position: Vector3;
  77054. };
  77055. /**
  77056. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  77057. */
  77058. customMeshPosition: Vector3;
  77059. /**
  77060. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  77061. */
  77062. useCustomMeshPosition: boolean;
  77063. /**
  77064. * If the post-process should inverse the light scattering direction
  77065. */
  77066. invert: boolean;
  77067. /**
  77068. * The internal mesh used by the post-process
  77069. */
  77070. mesh: Mesh;
  77071. /**
  77072. * @hidden
  77073. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  77074. */
  77075. get useDiffuseColor(): boolean;
  77076. set useDiffuseColor(useDiffuseColor: boolean);
  77077. /**
  77078. * Array containing the excluded meshes not rendered in the internal pass
  77079. */
  77080. excludedMeshes: AbstractMesh[];
  77081. /**
  77082. * Controls the overall intensity of the post-process
  77083. */
  77084. exposure: number;
  77085. /**
  77086. * Dissipates each sample's contribution in range [0, 1]
  77087. */
  77088. decay: number;
  77089. /**
  77090. * Controls the overall intensity of each sample
  77091. */
  77092. weight: number;
  77093. /**
  77094. * Controls the density of each sample
  77095. */
  77096. density: number;
  77097. /**
  77098. * @constructor
  77099. * @param name The post-process name
  77100. * @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)
  77101. * @param camera The camera that the post-process will be attached to
  77102. * @param mesh The mesh used to create the light scattering
  77103. * @param samples The post-process quality, default 100
  77104. * @param samplingModeThe post-process filtering mode
  77105. * @param engine The babylon engine
  77106. * @param reusable If the post-process is reusable
  77107. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77108. */
  77109. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77110. /**
  77111. * Returns the string "VolumetricLightScatteringPostProcess"
  77112. * @returns "VolumetricLightScatteringPostProcess"
  77113. */
  77114. getClassName(): string;
  77115. private _isReady;
  77116. /**
  77117. * Sets the new light position for light scattering effect
  77118. * @param position The new custom light position
  77119. */
  77120. setCustomMeshPosition(position: Vector3): void;
  77121. /**
  77122. * Returns the light position for light scattering effect
  77123. * @return Vector3 The custom light position
  77124. */
  77125. getCustomMeshPosition(): Vector3;
  77126. /**
  77127. * Disposes the internal assets and detaches the post-process from the camera
  77128. */
  77129. dispose(camera: Camera): void;
  77130. /**
  77131. * Returns the render target texture used by the post-process
  77132. * @return the render target texture used by the post-process
  77133. */
  77134. getPass(): RenderTargetTexture;
  77135. private _meshExcluded;
  77136. private _createPass;
  77137. private _updateMeshScreenCoordinates;
  77138. /**
  77139. * Creates a default mesh for the Volumeric Light Scattering post-process
  77140. * @param name The mesh name
  77141. * @param scene The scene where to create the mesh
  77142. * @return the default mesh
  77143. */
  77144. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77145. }
  77146. }
  77147. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  77148. /** @hidden */
  77149. export var screenSpaceCurvaturePixelShader: {
  77150. name: string;
  77151. shader: string;
  77152. };
  77153. }
  77154. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  77155. import { Nullable } from "babylonjs/types";
  77156. import { Camera } from "babylonjs/Cameras/camera";
  77157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77158. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77159. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  77160. import { Engine } from "babylonjs/Engines/engine";
  77161. import { Scene } from "babylonjs/scene";
  77162. /**
  77163. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77164. */
  77165. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77166. /**
  77167. * Defines how much ridge the curvature effect displays.
  77168. */
  77169. ridge: number;
  77170. /**
  77171. * Defines how much valley the curvature effect displays.
  77172. */
  77173. valley: number;
  77174. private _geometryBufferRenderer;
  77175. /**
  77176. * Gets a string identifying the name of the class
  77177. * @returns "ScreenSpaceCurvaturePostProcess" string
  77178. */
  77179. getClassName(): string;
  77180. /**
  77181. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77182. * @param name The name of the effect.
  77183. * @param scene The scene containing the objects to blur according to their velocity.
  77184. * @param options The required width/height ratio to downsize to before computing the render pass.
  77185. * @param camera The camera to apply the render pass to.
  77186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77187. * @param engine The engine which the post process will be applied. (default: current engine)
  77188. * @param reusable If the post process can be reused on the same frame. (default: false)
  77189. * @param textureType Type of textures used when performing the post process. (default: 0)
  77190. * @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)
  77191. */
  77192. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77193. /**
  77194. * Support test.
  77195. */
  77196. static get IsSupported(): boolean;
  77197. /** @hidden */
  77198. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77199. }
  77200. }
  77201. declare module "babylonjs/PostProcesses/index" {
  77202. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77203. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77204. export * from "babylonjs/PostProcesses/bloomEffect";
  77205. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77206. export * from "babylonjs/PostProcesses/blurPostProcess";
  77207. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77208. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77209. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77210. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77211. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77212. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77213. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77214. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77215. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77216. export * from "babylonjs/PostProcesses/filterPostProcess";
  77217. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77218. export * from "babylonjs/PostProcesses/grainPostProcess";
  77219. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77220. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77221. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77222. export * from "babylonjs/PostProcesses/passPostProcess";
  77223. export * from "babylonjs/PostProcesses/postProcess";
  77224. export * from "babylonjs/PostProcesses/postProcessManager";
  77225. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77226. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77227. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77228. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77229. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77230. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77231. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77232. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77233. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77234. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77235. }
  77236. declare module "babylonjs/Probes/index" {
  77237. export * from "babylonjs/Probes/reflectionProbe";
  77238. }
  77239. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77240. import { Scene } from "babylonjs/scene";
  77241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77242. import { SmartArray } from "babylonjs/Misc/smartArray";
  77243. import { ISceneComponent } from "babylonjs/sceneComponent";
  77244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77245. import "babylonjs/Meshes/Builders/boxBuilder";
  77246. import "babylonjs/Shaders/color.fragment";
  77247. import "babylonjs/Shaders/color.vertex";
  77248. import { Color3 } from "babylonjs/Maths/math.color";
  77249. import { Observable } from "babylonjs/Misc/observable";
  77250. module "babylonjs/scene" {
  77251. interface Scene {
  77252. /** @hidden (Backing field) */
  77253. _boundingBoxRenderer: BoundingBoxRenderer;
  77254. /** @hidden (Backing field) */
  77255. _forceShowBoundingBoxes: boolean;
  77256. /**
  77257. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77258. */
  77259. forceShowBoundingBoxes: boolean;
  77260. /**
  77261. * Gets the bounding box renderer associated with the scene
  77262. * @returns a BoundingBoxRenderer
  77263. */
  77264. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77265. }
  77266. }
  77267. module "babylonjs/Meshes/abstractMesh" {
  77268. interface AbstractMesh {
  77269. /** @hidden (Backing field) */
  77270. _showBoundingBox: boolean;
  77271. /**
  77272. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77273. */
  77274. showBoundingBox: boolean;
  77275. }
  77276. }
  77277. /**
  77278. * Component responsible of rendering the bounding box of the meshes in a scene.
  77279. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77280. */
  77281. export class BoundingBoxRenderer implements ISceneComponent {
  77282. /**
  77283. * The component name helpfull to identify the component in the list of scene components.
  77284. */
  77285. readonly name: string;
  77286. /**
  77287. * The scene the component belongs to.
  77288. */
  77289. scene: Scene;
  77290. /**
  77291. * Color of the bounding box lines placed in front of an object
  77292. */
  77293. frontColor: Color3;
  77294. /**
  77295. * Color of the bounding box lines placed behind an object
  77296. */
  77297. backColor: Color3;
  77298. /**
  77299. * Defines if the renderer should show the back lines or not
  77300. */
  77301. showBackLines: boolean;
  77302. /**
  77303. * Observable raised before rendering a bounding box
  77304. */
  77305. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77306. /**
  77307. * Observable raised after rendering a bounding box
  77308. */
  77309. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77310. /**
  77311. * Observable raised after resources are created
  77312. */
  77313. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77314. /**
  77315. * When false, no bounding boxes will be rendered
  77316. */
  77317. enabled: boolean;
  77318. /**
  77319. * @hidden
  77320. */
  77321. renderList: SmartArray<BoundingBox>;
  77322. private _colorShader;
  77323. private _vertexBuffers;
  77324. private _indexBuffer;
  77325. private _fillIndexBuffer;
  77326. private _fillIndexData;
  77327. /**
  77328. * Instantiates a new bounding box renderer in a scene.
  77329. * @param scene the scene the renderer renders in
  77330. */
  77331. constructor(scene: Scene);
  77332. /**
  77333. * Registers the component in a given scene
  77334. */
  77335. register(): void;
  77336. private _evaluateSubMesh;
  77337. private _preActiveMesh;
  77338. private _prepareResources;
  77339. private _createIndexBuffer;
  77340. /**
  77341. * Rebuilds the elements related to this component in case of
  77342. * context lost for instance.
  77343. */
  77344. rebuild(): void;
  77345. /**
  77346. * @hidden
  77347. */
  77348. reset(): void;
  77349. /**
  77350. * Render the bounding boxes of a specific rendering group
  77351. * @param renderingGroupId defines the rendering group to render
  77352. */
  77353. render(renderingGroupId: number): void;
  77354. /**
  77355. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77356. * @param mesh Define the mesh to render the occlusion bounding box for
  77357. */
  77358. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77359. /**
  77360. * Dispose and release the resources attached to this renderer.
  77361. */
  77362. dispose(): void;
  77363. }
  77364. }
  77365. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77366. import { Nullable } from "babylonjs/types";
  77367. import { Scene } from "babylonjs/scene";
  77368. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77369. import { Camera } from "babylonjs/Cameras/camera";
  77370. import { ISceneComponent } from "babylonjs/sceneComponent";
  77371. module "babylonjs/scene" {
  77372. interface Scene {
  77373. /** @hidden (Backing field) */
  77374. _depthRenderer: {
  77375. [id: string]: DepthRenderer;
  77376. };
  77377. /**
  77378. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77379. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77380. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77381. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77382. * @returns the created depth renderer
  77383. */
  77384. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77385. /**
  77386. * Disables a depth renderer for a given camera
  77387. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77388. */
  77389. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77390. }
  77391. }
  77392. /**
  77393. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77394. * in several rendering techniques.
  77395. */
  77396. export class DepthRendererSceneComponent implements ISceneComponent {
  77397. /**
  77398. * The component name helpfull to identify the component in the list of scene components.
  77399. */
  77400. readonly name: string;
  77401. /**
  77402. * The scene the component belongs to.
  77403. */
  77404. scene: Scene;
  77405. /**
  77406. * Creates a new instance of the component for the given scene
  77407. * @param scene Defines the scene to register the component in
  77408. */
  77409. constructor(scene: Scene);
  77410. /**
  77411. * Registers the component in a given scene
  77412. */
  77413. register(): void;
  77414. /**
  77415. * Rebuilds the elements related to this component in case of
  77416. * context lost for instance.
  77417. */
  77418. rebuild(): void;
  77419. /**
  77420. * Disposes the component and the associated ressources
  77421. */
  77422. dispose(): void;
  77423. private _gatherRenderTargets;
  77424. private _gatherActiveCameraRenderTargets;
  77425. }
  77426. }
  77427. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77428. import { Nullable } from "babylonjs/types";
  77429. import { Scene } from "babylonjs/scene";
  77430. import { ISceneComponent } from "babylonjs/sceneComponent";
  77431. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77432. module "babylonjs/abstractScene" {
  77433. interface AbstractScene {
  77434. /** @hidden (Backing field) */
  77435. _prePassRenderer: Nullable<PrePassRenderer>;
  77436. /**
  77437. * Gets or Sets the current prepass renderer associated to the scene.
  77438. */
  77439. prePassRenderer: Nullable<PrePassRenderer>;
  77440. /**
  77441. * Enables the prepass and associates it with the scene
  77442. * @returns the PrePassRenderer
  77443. */
  77444. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77445. /**
  77446. * Disables the prepass associated with the scene
  77447. */
  77448. disablePrePassRenderer(): void;
  77449. }
  77450. }
  77451. /**
  77452. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77453. * in several rendering techniques.
  77454. */
  77455. export class PrePassRendererSceneComponent implements ISceneComponent {
  77456. /**
  77457. * The component name helpful to identify the component in the list of scene components.
  77458. */
  77459. readonly name: string;
  77460. /**
  77461. * The scene the component belongs to.
  77462. */
  77463. scene: Scene;
  77464. /**
  77465. * Creates a new instance of the component for the given scene
  77466. * @param scene Defines the scene to register the component in
  77467. */
  77468. constructor(scene: Scene);
  77469. /**
  77470. * Registers the component in a given scene
  77471. */
  77472. register(): void;
  77473. private _beforeCameraDraw;
  77474. private _afterCameraDraw;
  77475. private _beforeClearStage;
  77476. private _beforeRenderingMeshStage;
  77477. private _afterRenderingMeshStage;
  77478. /**
  77479. * Rebuilds the elements related to this component in case of
  77480. * context lost for instance.
  77481. */
  77482. rebuild(): void;
  77483. /**
  77484. * Disposes the component and the associated ressources
  77485. */
  77486. dispose(): void;
  77487. }
  77488. }
  77489. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77490. /** @hidden */
  77491. export var fibonacci: {
  77492. name: string;
  77493. shader: string;
  77494. };
  77495. }
  77496. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77497. /** @hidden */
  77498. export var diffusionProfile: {
  77499. name: string;
  77500. shader: string;
  77501. };
  77502. }
  77503. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77504. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77506. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77507. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77508. /** @hidden */
  77509. export var subSurfaceScatteringPixelShader: {
  77510. name: string;
  77511. shader: string;
  77512. };
  77513. }
  77514. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77515. import { Nullable } from "babylonjs/types";
  77516. import { Camera } from "babylonjs/Cameras/camera";
  77517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77518. import { Engine } from "babylonjs/Engines/engine";
  77519. import { Scene } from "babylonjs/scene";
  77520. import "babylonjs/Shaders/imageProcessing.fragment";
  77521. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77522. import "babylonjs/Shaders/postprocess.vertex";
  77523. /**
  77524. * Sub surface scattering post process
  77525. */
  77526. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77527. /**
  77528. * Gets a string identifying the name of the class
  77529. * @returns "SubSurfaceScatteringPostProcess" string
  77530. */
  77531. getClassName(): string;
  77532. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77533. }
  77534. }
  77535. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77536. import { Scene } from "babylonjs/scene";
  77537. import { Color3 } from "babylonjs/Maths/math.color";
  77538. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77539. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77540. /**
  77541. * Contains all parameters needed for the prepass to perform
  77542. * screen space subsurface scattering
  77543. */
  77544. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77545. /** @hidden */
  77546. static _SceneComponentInitialization: (scene: Scene) => void;
  77547. private _ssDiffusionS;
  77548. private _ssFilterRadii;
  77549. private _ssDiffusionD;
  77550. /**
  77551. * Post process to attach for screen space subsurface scattering
  77552. */
  77553. postProcess: SubSurfaceScatteringPostProcess;
  77554. /**
  77555. * Diffusion profile color for subsurface scattering
  77556. */
  77557. get ssDiffusionS(): number[];
  77558. /**
  77559. * Diffusion profile max color channel value for subsurface scattering
  77560. */
  77561. get ssDiffusionD(): number[];
  77562. /**
  77563. * Diffusion profile filter radius for subsurface scattering
  77564. */
  77565. get ssFilterRadii(): number[];
  77566. /**
  77567. * Is subsurface enabled
  77568. */
  77569. enabled: boolean;
  77570. /**
  77571. * Name of the configuration
  77572. */
  77573. name: string;
  77574. /**
  77575. * Diffusion profile colors for subsurface scattering
  77576. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77577. * See ...
  77578. * Note that you can only store up to 5 of them
  77579. */
  77580. ssDiffusionProfileColors: Color3[];
  77581. /**
  77582. * Defines the ratio real world => scene units.
  77583. * Used for subsurface scattering
  77584. */
  77585. metersPerUnit: number;
  77586. /**
  77587. * Textures that should be present in the MRT for this effect to work
  77588. */
  77589. readonly texturesRequired: number[];
  77590. private _scene;
  77591. /**
  77592. * Builds a subsurface configuration object
  77593. * @param scene The scene
  77594. */
  77595. constructor(scene: Scene);
  77596. /**
  77597. * Adds a new diffusion profile.
  77598. * Useful for more realistic subsurface scattering on diverse materials.
  77599. * @param color The color of the diffusion profile. Should be the average color of the material.
  77600. * @return The index of the diffusion profile for the material subsurface configuration
  77601. */
  77602. addDiffusionProfile(color: Color3): number;
  77603. /**
  77604. * Creates the sss post process
  77605. * @return The created post process
  77606. */
  77607. createPostProcess(): SubSurfaceScatteringPostProcess;
  77608. /**
  77609. * Deletes all diffusion profiles.
  77610. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77611. */
  77612. clearAllDiffusionProfiles(): void;
  77613. /**
  77614. * Disposes this object
  77615. */
  77616. dispose(): void;
  77617. /**
  77618. * @hidden
  77619. * https://zero-radiance.github.io/post/sampling-diffusion/
  77620. *
  77621. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77622. * ------------------------------------------------------------------------------------
  77623. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77624. * PDF[r, phi, s] = r * R[r, phi, s]
  77625. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77626. * ------------------------------------------------------------------------------------
  77627. * We importance sample the color channel with the widest scattering distance.
  77628. */
  77629. getDiffusionProfileParameters(color: Color3): number;
  77630. /**
  77631. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77632. * 'u' is the random number (the value of the CDF): [0, 1).
  77633. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77634. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77635. */
  77636. private _sampleBurleyDiffusionProfile;
  77637. }
  77638. }
  77639. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77640. import { Nullable } from "babylonjs/types";
  77641. import { Scene } from "babylonjs/scene";
  77642. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77643. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77644. import { AbstractScene } from "babylonjs/abstractScene";
  77645. module "babylonjs/abstractScene" {
  77646. interface AbstractScene {
  77647. /** @hidden (Backing field) */
  77648. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77649. /**
  77650. * Gets or Sets the current prepass renderer associated to the scene.
  77651. */
  77652. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77653. /**
  77654. * Enables the subsurface effect for prepass
  77655. * @returns the SubSurfaceConfiguration
  77656. */
  77657. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77658. /**
  77659. * Disables the subsurface effect for prepass
  77660. */
  77661. disableSubSurfaceForPrePass(): void;
  77662. }
  77663. }
  77664. /**
  77665. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77666. * in several rendering techniques.
  77667. */
  77668. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77669. /**
  77670. * The component name helpful to identify the component in the list of scene components.
  77671. */
  77672. readonly name: string;
  77673. /**
  77674. * The scene the component belongs to.
  77675. */
  77676. scene: Scene;
  77677. /**
  77678. * Creates a new instance of the component for the given scene
  77679. * @param scene Defines the scene to register the component in
  77680. */
  77681. constructor(scene: Scene);
  77682. /**
  77683. * Registers the component in a given scene
  77684. */
  77685. register(): void;
  77686. /**
  77687. * Serializes the component data to the specified json object
  77688. * @param serializationObject The object to serialize to
  77689. */
  77690. serialize(serializationObject: any): void;
  77691. /**
  77692. * Adds all the elements from the container to the scene
  77693. * @param container the container holding the elements
  77694. */
  77695. addFromContainer(container: AbstractScene): void;
  77696. /**
  77697. * Removes all the elements in the container from the scene
  77698. * @param container contains the elements to remove
  77699. * @param dispose if the removed element should be disposed (default: false)
  77700. */
  77701. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77702. /**
  77703. * Rebuilds the elements related to this component in case of
  77704. * context lost for instance.
  77705. */
  77706. rebuild(): void;
  77707. /**
  77708. * Disposes the component and the associated ressources
  77709. */
  77710. dispose(): void;
  77711. }
  77712. }
  77713. declare module "babylonjs/Shaders/outline.fragment" {
  77714. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77715. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77716. /** @hidden */
  77717. export var outlinePixelShader: {
  77718. name: string;
  77719. shader: string;
  77720. };
  77721. }
  77722. declare module "babylonjs/Shaders/outline.vertex" {
  77723. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77724. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77726. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77727. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77728. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77729. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77731. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77732. /** @hidden */
  77733. export var outlineVertexShader: {
  77734. name: string;
  77735. shader: string;
  77736. };
  77737. }
  77738. declare module "babylonjs/Rendering/outlineRenderer" {
  77739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77740. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77741. import { Scene } from "babylonjs/scene";
  77742. import { ISceneComponent } from "babylonjs/sceneComponent";
  77743. import "babylonjs/Shaders/outline.fragment";
  77744. import "babylonjs/Shaders/outline.vertex";
  77745. module "babylonjs/scene" {
  77746. interface Scene {
  77747. /** @hidden */
  77748. _outlineRenderer: OutlineRenderer;
  77749. /**
  77750. * Gets the outline renderer associated with the scene
  77751. * @returns a OutlineRenderer
  77752. */
  77753. getOutlineRenderer(): OutlineRenderer;
  77754. }
  77755. }
  77756. module "babylonjs/Meshes/abstractMesh" {
  77757. interface AbstractMesh {
  77758. /** @hidden (Backing field) */
  77759. _renderOutline: boolean;
  77760. /**
  77761. * Gets or sets a boolean indicating if the outline must be rendered as well
  77762. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77763. */
  77764. renderOutline: boolean;
  77765. /** @hidden (Backing field) */
  77766. _renderOverlay: boolean;
  77767. /**
  77768. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77769. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77770. */
  77771. renderOverlay: boolean;
  77772. }
  77773. }
  77774. /**
  77775. * This class is responsible to draw bothe outline/overlay of meshes.
  77776. * It should not be used directly but through the available method on mesh.
  77777. */
  77778. export class OutlineRenderer implements ISceneComponent {
  77779. /**
  77780. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77781. */
  77782. private static _StencilReference;
  77783. /**
  77784. * The name of the component. Each component must have a unique name.
  77785. */
  77786. name: string;
  77787. /**
  77788. * The scene the component belongs to.
  77789. */
  77790. scene: Scene;
  77791. /**
  77792. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77793. */
  77794. zOffset: number;
  77795. private _engine;
  77796. private _effect;
  77797. private _cachedDefines;
  77798. private _savedDepthWrite;
  77799. /**
  77800. * Instantiates a new outline renderer. (There could be only one per scene).
  77801. * @param scene Defines the scene it belongs to
  77802. */
  77803. constructor(scene: Scene);
  77804. /**
  77805. * Register the component to one instance of a scene.
  77806. */
  77807. register(): void;
  77808. /**
  77809. * Rebuilds the elements related to this component in case of
  77810. * context lost for instance.
  77811. */
  77812. rebuild(): void;
  77813. /**
  77814. * Disposes the component and the associated ressources.
  77815. */
  77816. dispose(): void;
  77817. /**
  77818. * Renders the outline in the canvas.
  77819. * @param subMesh Defines the sumesh to render
  77820. * @param batch Defines the batch of meshes in case of instances
  77821. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77822. */
  77823. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77824. /**
  77825. * Returns whether or not the outline renderer is ready for a given submesh.
  77826. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77827. * @param subMesh Defines the submesh to check readyness for
  77828. * @param useInstances Defines wheter wee are trying to render instances or not
  77829. * @returns true if ready otherwise false
  77830. */
  77831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77832. private _beforeRenderingMesh;
  77833. private _afterRenderingMesh;
  77834. }
  77835. }
  77836. declare module "babylonjs/Rendering/index" {
  77837. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77838. export * from "babylonjs/Rendering/depthRenderer";
  77839. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77840. export * from "babylonjs/Rendering/edgesRenderer";
  77841. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77842. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77843. export * from "babylonjs/Rendering/prePassRenderer";
  77844. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77845. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77846. export * from "babylonjs/Rendering/outlineRenderer";
  77847. export * from "babylonjs/Rendering/renderingGroup";
  77848. export * from "babylonjs/Rendering/renderingManager";
  77849. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77850. }
  77851. declare module "babylonjs/Sprites/ISprites" {
  77852. /**
  77853. * Defines the basic options interface of a Sprite Frame Source Size.
  77854. */
  77855. export interface ISpriteJSONSpriteSourceSize {
  77856. /**
  77857. * number of the original width of the Frame
  77858. */
  77859. w: number;
  77860. /**
  77861. * number of the original height of the Frame
  77862. */
  77863. h: number;
  77864. }
  77865. /**
  77866. * Defines the basic options interface of a Sprite Frame Data.
  77867. */
  77868. export interface ISpriteJSONSpriteFrameData {
  77869. /**
  77870. * number of the x offset of the Frame
  77871. */
  77872. x: number;
  77873. /**
  77874. * number of the y offset of the Frame
  77875. */
  77876. y: number;
  77877. /**
  77878. * number of the width of the Frame
  77879. */
  77880. w: number;
  77881. /**
  77882. * number of the height of the Frame
  77883. */
  77884. h: number;
  77885. }
  77886. /**
  77887. * Defines the basic options interface of a JSON Sprite.
  77888. */
  77889. export interface ISpriteJSONSprite {
  77890. /**
  77891. * string name of the Frame
  77892. */
  77893. filename: string;
  77894. /**
  77895. * ISpriteJSONSpriteFrame basic object of the frame data
  77896. */
  77897. frame: ISpriteJSONSpriteFrameData;
  77898. /**
  77899. * boolean to flag is the frame was rotated.
  77900. */
  77901. rotated: boolean;
  77902. /**
  77903. * boolean to flag is the frame was trimmed.
  77904. */
  77905. trimmed: boolean;
  77906. /**
  77907. * ISpriteJSONSpriteFrame basic object of the source data
  77908. */
  77909. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77910. /**
  77911. * ISpriteJSONSpriteFrame basic object of the source data
  77912. */
  77913. sourceSize: ISpriteJSONSpriteSourceSize;
  77914. }
  77915. /**
  77916. * Defines the basic options interface of a JSON atlas.
  77917. */
  77918. export interface ISpriteJSONAtlas {
  77919. /**
  77920. * Array of objects that contain the frame data.
  77921. */
  77922. frames: Array<ISpriteJSONSprite>;
  77923. /**
  77924. * object basic object containing the sprite meta data.
  77925. */
  77926. meta?: object;
  77927. }
  77928. }
  77929. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77930. /** @hidden */
  77931. export var spriteMapPixelShader: {
  77932. name: string;
  77933. shader: string;
  77934. };
  77935. }
  77936. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77937. /** @hidden */
  77938. export var spriteMapVertexShader: {
  77939. name: string;
  77940. shader: string;
  77941. };
  77942. }
  77943. declare module "babylonjs/Sprites/spriteMap" {
  77944. import { IDisposable, Scene } from "babylonjs/scene";
  77945. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77946. import { Texture } from "babylonjs/Materials/Textures/texture";
  77947. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77948. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77949. import "babylonjs/Meshes/Builders/planeBuilder";
  77950. import "babylonjs/Shaders/spriteMap.fragment";
  77951. import "babylonjs/Shaders/spriteMap.vertex";
  77952. /**
  77953. * Defines the basic options interface of a SpriteMap
  77954. */
  77955. export interface ISpriteMapOptions {
  77956. /**
  77957. * Vector2 of the number of cells in the grid.
  77958. */
  77959. stageSize?: Vector2;
  77960. /**
  77961. * Vector2 of the size of the output plane in World Units.
  77962. */
  77963. outputSize?: Vector2;
  77964. /**
  77965. * Vector3 of the position of the output plane in World Units.
  77966. */
  77967. outputPosition?: Vector3;
  77968. /**
  77969. * Vector3 of the rotation of the output plane.
  77970. */
  77971. outputRotation?: Vector3;
  77972. /**
  77973. * number of layers that the system will reserve in resources.
  77974. */
  77975. layerCount?: number;
  77976. /**
  77977. * number of max animation frames a single cell will reserve in resources.
  77978. */
  77979. maxAnimationFrames?: number;
  77980. /**
  77981. * number cell index of the base tile when the system compiles.
  77982. */
  77983. baseTile?: number;
  77984. /**
  77985. * boolean flip the sprite after its been repositioned by the framing data.
  77986. */
  77987. flipU?: boolean;
  77988. /**
  77989. * Vector3 scalar of the global RGB values of the SpriteMap.
  77990. */
  77991. colorMultiply?: Vector3;
  77992. }
  77993. /**
  77994. * Defines the IDisposable interface in order to be cleanable from resources.
  77995. */
  77996. export interface ISpriteMap extends IDisposable {
  77997. /**
  77998. * String name of the SpriteMap.
  77999. */
  78000. name: string;
  78001. /**
  78002. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  78003. */
  78004. atlasJSON: ISpriteJSONAtlas;
  78005. /**
  78006. * Texture of the SpriteMap.
  78007. */
  78008. spriteSheet: Texture;
  78009. /**
  78010. * The parameters to initialize the SpriteMap with.
  78011. */
  78012. options: ISpriteMapOptions;
  78013. }
  78014. /**
  78015. * Class used to manage a grid restricted sprite deployment on an Output plane.
  78016. */
  78017. export class SpriteMap implements ISpriteMap {
  78018. /** The Name of the spriteMap */
  78019. name: string;
  78020. /** The JSON file with the frame and meta data */
  78021. atlasJSON: ISpriteJSONAtlas;
  78022. /** The systems Sprite Sheet Texture */
  78023. spriteSheet: Texture;
  78024. /** Arguments passed with the Constructor */
  78025. options: ISpriteMapOptions;
  78026. /** Public Sprite Storage array, parsed from atlasJSON */
  78027. sprites: Array<ISpriteJSONSprite>;
  78028. /** Returns the Number of Sprites in the System */
  78029. get spriteCount(): number;
  78030. /** Returns the Position of Output Plane*/
  78031. get position(): Vector3;
  78032. /** Returns the Position of Output Plane*/
  78033. set position(v: Vector3);
  78034. /** Returns the Rotation of Output Plane*/
  78035. get rotation(): Vector3;
  78036. /** Returns the Rotation of Output Plane*/
  78037. set rotation(v: Vector3);
  78038. /** Sets the AnimationMap*/
  78039. get animationMap(): RawTexture;
  78040. /** Sets the AnimationMap*/
  78041. set animationMap(v: RawTexture);
  78042. /** Scene that the SpriteMap was created in */
  78043. private _scene;
  78044. /** Texture Buffer of Float32 that holds tile frame data*/
  78045. private _frameMap;
  78046. /** Texture Buffers of Float32 that holds tileMap data*/
  78047. private _tileMaps;
  78048. /** Texture Buffer of Float32 that holds Animation Data*/
  78049. private _animationMap;
  78050. /** Custom ShaderMaterial Central to the System*/
  78051. private _material;
  78052. /** Custom ShaderMaterial Central to the System*/
  78053. private _output;
  78054. /** Systems Time Ticker*/
  78055. private _time;
  78056. /**
  78057. * Creates a new SpriteMap
  78058. * @param name defines the SpriteMaps Name
  78059. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  78060. * @param spriteSheet is the Texture that the Sprites are on.
  78061. * @param options a basic deployment configuration
  78062. * @param scene The Scene that the map is deployed on
  78063. */
  78064. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  78065. /**
  78066. * Returns tileID location
  78067. * @returns Vector2 the cell position ID
  78068. */
  78069. getTileID(): Vector2;
  78070. /**
  78071. * Gets the UV location of the mouse over the SpriteMap.
  78072. * @returns Vector2 the UV position of the mouse interaction
  78073. */
  78074. getMousePosition(): Vector2;
  78075. /**
  78076. * Creates the "frame" texture Buffer
  78077. * -------------------------------------
  78078. * Structure of frames
  78079. * "filename": "Falling-Water-2.png",
  78080. * "frame": {"x":69,"y":103,"w":24,"h":32},
  78081. * "rotated": true,
  78082. * "trimmed": true,
  78083. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  78084. * "sourceSize": {"w":32,"h":32}
  78085. * @returns RawTexture of the frameMap
  78086. */
  78087. private _createFrameBuffer;
  78088. /**
  78089. * Creates the tileMap texture Buffer
  78090. * @param buffer normally and array of numbers, or a false to generate from scratch
  78091. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  78092. * @returns RawTexture of the tileMap
  78093. */
  78094. private _createTileBuffer;
  78095. /**
  78096. * Modifies the data of the tileMaps
  78097. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  78098. * @param pos is the iVector2 Coordinates of the Tile
  78099. * @param tile The SpriteIndex of the new Tile
  78100. */
  78101. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  78102. /**
  78103. * Creates the animationMap texture Buffer
  78104. * @param buffer normally and array of numbers, or a false to generate from scratch
  78105. * @returns RawTexture of the animationMap
  78106. */
  78107. private _createTileAnimationBuffer;
  78108. /**
  78109. * Modifies the data of the animationMap
  78110. * @param cellID is the Index of the Sprite
  78111. * @param _frame is the target Animation frame
  78112. * @param toCell is the Target Index of the next frame of the animation
  78113. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  78114. * @param speed is a global scalar of the time variable on the map.
  78115. */
  78116. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  78117. /**
  78118. * Exports the .tilemaps file
  78119. */
  78120. saveTileMaps(): void;
  78121. /**
  78122. * Imports the .tilemaps file
  78123. * @param url of the .tilemaps file
  78124. */
  78125. loadTileMaps(url: string): void;
  78126. /**
  78127. * Release associated resources
  78128. */
  78129. dispose(): void;
  78130. }
  78131. }
  78132. declare module "babylonjs/Sprites/spritePackedManager" {
  78133. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  78134. import { Scene } from "babylonjs/scene";
  78135. /**
  78136. * Class used to manage multiple sprites of different sizes on the same spritesheet
  78137. * @see https://doc.babylonjs.com/babylon101/sprites
  78138. */
  78139. export class SpritePackedManager extends SpriteManager {
  78140. /** defines the packed manager's name */
  78141. name: string;
  78142. /**
  78143. * Creates a new sprite manager from a packed sprite sheet
  78144. * @param name defines the manager's name
  78145. * @param imgUrl defines the sprite sheet url
  78146. * @param capacity defines the maximum allowed number of sprites
  78147. * @param scene defines the hosting scene
  78148. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  78149. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78150. * @param samplingMode defines the smapling mode to use with spritesheet
  78151. * @param fromPacked set to true; do not alter
  78152. */
  78153. constructor(
  78154. /** defines the packed manager's name */
  78155. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  78156. }
  78157. }
  78158. declare module "babylonjs/Sprites/index" {
  78159. export * from "babylonjs/Sprites/sprite";
  78160. export * from "babylonjs/Sprites/ISprites";
  78161. export * from "babylonjs/Sprites/spriteManager";
  78162. export * from "babylonjs/Sprites/spriteMap";
  78163. export * from "babylonjs/Sprites/spritePackedManager";
  78164. export * from "babylonjs/Sprites/spriteSceneComponent";
  78165. }
  78166. declare module "babylonjs/States/index" {
  78167. export * from "babylonjs/States/alphaCullingState";
  78168. export * from "babylonjs/States/depthCullingState";
  78169. export * from "babylonjs/States/stencilState";
  78170. }
  78171. declare module "babylonjs/Misc/assetsManager" {
  78172. import { Scene } from "babylonjs/scene";
  78173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  78175. import { Skeleton } from "babylonjs/Bones/skeleton";
  78176. import { Observable } from "babylonjs/Misc/observable";
  78177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  78178. import { Texture } from "babylonjs/Materials/Textures/texture";
  78179. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  78180. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  78181. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  78182. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  78183. import { AssetContainer } from "babylonjs/assetContainer";
  78184. /**
  78185. * Defines the list of states available for a task inside a AssetsManager
  78186. */
  78187. export enum AssetTaskState {
  78188. /**
  78189. * Initialization
  78190. */
  78191. INIT = 0,
  78192. /**
  78193. * Running
  78194. */
  78195. RUNNING = 1,
  78196. /**
  78197. * Done
  78198. */
  78199. DONE = 2,
  78200. /**
  78201. * Error
  78202. */
  78203. ERROR = 3
  78204. }
  78205. /**
  78206. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78207. */
  78208. export abstract class AbstractAssetTask {
  78209. /**
  78210. * Task name
  78211. */ name: string;
  78212. /**
  78213. * Callback called when the task is successful
  78214. */
  78215. onSuccess: (task: any) => void;
  78216. /**
  78217. * Callback called when the task is not successful
  78218. */
  78219. onError: (task: any, message?: string, exception?: any) => void;
  78220. /**
  78221. * Creates a new AssetsManager
  78222. * @param name defines the name of the task
  78223. */
  78224. constructor(
  78225. /**
  78226. * Task name
  78227. */ name: string);
  78228. private _isCompleted;
  78229. private _taskState;
  78230. private _errorObject;
  78231. /**
  78232. * Get if the task is completed
  78233. */
  78234. get isCompleted(): boolean;
  78235. /**
  78236. * Gets the current state of the task
  78237. */
  78238. get taskState(): AssetTaskState;
  78239. /**
  78240. * Gets the current error object (if task is in error)
  78241. */
  78242. get errorObject(): {
  78243. message?: string;
  78244. exception?: any;
  78245. };
  78246. /**
  78247. * Internal only
  78248. * @hidden
  78249. */
  78250. _setErrorObject(message?: string, exception?: any): void;
  78251. /**
  78252. * Execute the current task
  78253. * @param scene defines the scene where you want your assets to be loaded
  78254. * @param onSuccess is a callback called when the task is successfully executed
  78255. * @param onError is a callback called if an error occurs
  78256. */
  78257. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78258. /**
  78259. * Execute the current task
  78260. * @param scene defines the scene where you want your assets to be loaded
  78261. * @param onSuccess is a callback called when the task is successfully executed
  78262. * @param onError is a callback called if an error occurs
  78263. */
  78264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78265. /**
  78266. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78267. * This can be used with failed tasks that have the reason for failure fixed.
  78268. */
  78269. reset(): void;
  78270. private onErrorCallback;
  78271. private onDoneCallback;
  78272. }
  78273. /**
  78274. * Define the interface used by progress events raised during assets loading
  78275. */
  78276. export interface IAssetsProgressEvent {
  78277. /**
  78278. * Defines the number of remaining tasks to process
  78279. */
  78280. remainingCount: number;
  78281. /**
  78282. * Defines the total number of tasks
  78283. */
  78284. totalCount: number;
  78285. /**
  78286. * Defines the task that was just processed
  78287. */
  78288. task: AbstractAssetTask;
  78289. }
  78290. /**
  78291. * Class used to share progress information about assets loading
  78292. */
  78293. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78294. /**
  78295. * Defines the number of remaining tasks to process
  78296. */
  78297. remainingCount: number;
  78298. /**
  78299. * Defines the total number of tasks
  78300. */
  78301. totalCount: number;
  78302. /**
  78303. * Defines the task that was just processed
  78304. */
  78305. task: AbstractAssetTask;
  78306. /**
  78307. * Creates a AssetsProgressEvent
  78308. * @param remainingCount defines the number of remaining tasks to process
  78309. * @param totalCount defines the total number of tasks
  78310. * @param task defines the task that was just processed
  78311. */
  78312. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78313. }
  78314. /**
  78315. * Define a task used by AssetsManager to load assets into a container
  78316. */
  78317. export class ContainerAssetTask extends AbstractAssetTask {
  78318. /**
  78319. * Defines the name of the task
  78320. */
  78321. name: string;
  78322. /**
  78323. * Defines the list of mesh's names you want to load
  78324. */
  78325. meshesNames: any;
  78326. /**
  78327. * Defines the root url to use as a base to load your meshes and associated resources
  78328. */
  78329. rootUrl: string;
  78330. /**
  78331. * Defines the filename or File of the scene to load from
  78332. */
  78333. sceneFilename: string | File;
  78334. /**
  78335. * Get the loaded asset container
  78336. */
  78337. loadedContainer: AssetContainer;
  78338. /**
  78339. * Gets the list of loaded meshes
  78340. */
  78341. loadedMeshes: Array<AbstractMesh>;
  78342. /**
  78343. * Gets the list of loaded particle systems
  78344. */
  78345. loadedParticleSystems: Array<IParticleSystem>;
  78346. /**
  78347. * Gets the list of loaded skeletons
  78348. */
  78349. loadedSkeletons: Array<Skeleton>;
  78350. /**
  78351. * Gets the list of loaded animation groups
  78352. */
  78353. loadedAnimationGroups: Array<AnimationGroup>;
  78354. /**
  78355. * Callback called when the task is successful
  78356. */
  78357. onSuccess: (task: ContainerAssetTask) => void;
  78358. /**
  78359. * Callback called when the task is successful
  78360. */
  78361. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78362. /**
  78363. * Creates a new ContainerAssetTask
  78364. * @param name defines the name of the task
  78365. * @param meshesNames defines the list of mesh's names you want to load
  78366. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78367. * @param sceneFilename defines the filename or File of the scene to load from
  78368. */
  78369. constructor(
  78370. /**
  78371. * Defines the name of the task
  78372. */
  78373. name: string,
  78374. /**
  78375. * Defines the list of mesh's names you want to load
  78376. */
  78377. meshesNames: any,
  78378. /**
  78379. * Defines the root url to use as a base to load your meshes and associated resources
  78380. */
  78381. rootUrl: string,
  78382. /**
  78383. * Defines the filename or File of the scene to load from
  78384. */
  78385. sceneFilename: string | File);
  78386. /**
  78387. * Execute the current task
  78388. * @param scene defines the scene where you want your assets to be loaded
  78389. * @param onSuccess is a callback called when the task is successfully executed
  78390. * @param onError is a callback called if an error occurs
  78391. */
  78392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78393. }
  78394. /**
  78395. * Define a task used by AssetsManager to load meshes
  78396. */
  78397. export class MeshAssetTask extends AbstractAssetTask {
  78398. /**
  78399. * Defines the name of the task
  78400. */
  78401. name: string;
  78402. /**
  78403. * Defines the list of mesh's names you want to load
  78404. */
  78405. meshesNames: any;
  78406. /**
  78407. * Defines the root url to use as a base to load your meshes and associated resources
  78408. */
  78409. rootUrl: string;
  78410. /**
  78411. * Defines the filename or File of the scene to load from
  78412. */
  78413. sceneFilename: string | File;
  78414. /**
  78415. * Gets the list of loaded meshes
  78416. */
  78417. loadedMeshes: Array<AbstractMesh>;
  78418. /**
  78419. * Gets the list of loaded particle systems
  78420. */
  78421. loadedParticleSystems: Array<IParticleSystem>;
  78422. /**
  78423. * Gets the list of loaded skeletons
  78424. */
  78425. loadedSkeletons: Array<Skeleton>;
  78426. /**
  78427. * Gets the list of loaded animation groups
  78428. */
  78429. loadedAnimationGroups: Array<AnimationGroup>;
  78430. /**
  78431. * Callback called when the task is successful
  78432. */
  78433. onSuccess: (task: MeshAssetTask) => void;
  78434. /**
  78435. * Callback called when the task is successful
  78436. */
  78437. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78438. /**
  78439. * Creates a new MeshAssetTask
  78440. * @param name defines the name of the task
  78441. * @param meshesNames defines the list of mesh's names you want to load
  78442. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78443. * @param sceneFilename defines the filename or File of the scene to load from
  78444. */
  78445. constructor(
  78446. /**
  78447. * Defines the name of the task
  78448. */
  78449. name: string,
  78450. /**
  78451. * Defines the list of mesh's names you want to load
  78452. */
  78453. meshesNames: any,
  78454. /**
  78455. * Defines the root url to use as a base to load your meshes and associated resources
  78456. */
  78457. rootUrl: string,
  78458. /**
  78459. * Defines the filename or File of the scene to load from
  78460. */
  78461. sceneFilename: string | File);
  78462. /**
  78463. * Execute the current task
  78464. * @param scene defines the scene where you want your assets to be loaded
  78465. * @param onSuccess is a callback called when the task is successfully executed
  78466. * @param onError is a callback called if an error occurs
  78467. */
  78468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78469. }
  78470. /**
  78471. * Define a task used by AssetsManager to load text content
  78472. */
  78473. export class TextFileAssetTask extends AbstractAssetTask {
  78474. /**
  78475. * Defines the name of the task
  78476. */
  78477. name: string;
  78478. /**
  78479. * Defines the location of the file to load
  78480. */
  78481. url: string;
  78482. /**
  78483. * Gets the loaded text string
  78484. */
  78485. text: string;
  78486. /**
  78487. * Callback called when the task is successful
  78488. */
  78489. onSuccess: (task: TextFileAssetTask) => void;
  78490. /**
  78491. * Callback called when the task is successful
  78492. */
  78493. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78494. /**
  78495. * Creates a new TextFileAssetTask object
  78496. * @param name defines the name of the task
  78497. * @param url defines the location of the file to load
  78498. */
  78499. constructor(
  78500. /**
  78501. * Defines the name of the task
  78502. */
  78503. name: string,
  78504. /**
  78505. * Defines the location of the file to load
  78506. */
  78507. url: string);
  78508. /**
  78509. * Execute the current task
  78510. * @param scene defines the scene where you want your assets to be loaded
  78511. * @param onSuccess is a callback called when the task is successfully executed
  78512. * @param onError is a callback called if an error occurs
  78513. */
  78514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78515. }
  78516. /**
  78517. * Define a task used by AssetsManager to load binary data
  78518. */
  78519. export class BinaryFileAssetTask extends AbstractAssetTask {
  78520. /**
  78521. * Defines the name of the task
  78522. */
  78523. name: string;
  78524. /**
  78525. * Defines the location of the file to load
  78526. */
  78527. url: string;
  78528. /**
  78529. * Gets the lodaded data (as an array buffer)
  78530. */
  78531. data: ArrayBuffer;
  78532. /**
  78533. * Callback called when the task is successful
  78534. */
  78535. onSuccess: (task: BinaryFileAssetTask) => void;
  78536. /**
  78537. * Callback called when the task is successful
  78538. */
  78539. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78540. /**
  78541. * Creates a new BinaryFileAssetTask object
  78542. * @param name defines the name of the new task
  78543. * @param url defines the location of the file to load
  78544. */
  78545. constructor(
  78546. /**
  78547. * Defines the name of the task
  78548. */
  78549. name: string,
  78550. /**
  78551. * Defines the location of the file to load
  78552. */
  78553. url: string);
  78554. /**
  78555. * Execute the current task
  78556. * @param scene defines the scene where you want your assets to be loaded
  78557. * @param onSuccess is a callback called when the task is successfully executed
  78558. * @param onError is a callback called if an error occurs
  78559. */
  78560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78561. }
  78562. /**
  78563. * Define a task used by AssetsManager to load images
  78564. */
  78565. export class ImageAssetTask extends AbstractAssetTask {
  78566. /**
  78567. * Defines the name of the task
  78568. */
  78569. name: string;
  78570. /**
  78571. * Defines the location of the image to load
  78572. */
  78573. url: string;
  78574. /**
  78575. * Gets the loaded images
  78576. */
  78577. image: HTMLImageElement;
  78578. /**
  78579. * Callback called when the task is successful
  78580. */
  78581. onSuccess: (task: ImageAssetTask) => void;
  78582. /**
  78583. * Callback called when the task is successful
  78584. */
  78585. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78586. /**
  78587. * Creates a new ImageAssetTask
  78588. * @param name defines the name of the task
  78589. * @param url defines the location of the image to load
  78590. */
  78591. constructor(
  78592. /**
  78593. * Defines the name of the task
  78594. */
  78595. name: string,
  78596. /**
  78597. * Defines the location of the image to load
  78598. */
  78599. url: string);
  78600. /**
  78601. * Execute the current task
  78602. * @param scene defines the scene where you want your assets to be loaded
  78603. * @param onSuccess is a callback called when the task is successfully executed
  78604. * @param onError is a callback called if an error occurs
  78605. */
  78606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78607. }
  78608. /**
  78609. * Defines the interface used by texture loading tasks
  78610. */
  78611. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78612. /**
  78613. * Gets the loaded texture
  78614. */
  78615. texture: TEX;
  78616. }
  78617. /**
  78618. * Define a task used by AssetsManager to load 2D textures
  78619. */
  78620. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78621. /**
  78622. * Defines the name of the task
  78623. */
  78624. name: string;
  78625. /**
  78626. * Defines the location of the file to load
  78627. */
  78628. url: string;
  78629. /**
  78630. * Defines if mipmap should not be generated (default is false)
  78631. */
  78632. noMipmap?: boolean | undefined;
  78633. /**
  78634. * Defines if texture must be inverted on Y axis (default is true)
  78635. */
  78636. invertY: boolean;
  78637. /**
  78638. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78639. */
  78640. samplingMode: number;
  78641. /**
  78642. * Gets the loaded texture
  78643. */
  78644. texture: Texture;
  78645. /**
  78646. * Callback called when the task is successful
  78647. */
  78648. onSuccess: (task: TextureAssetTask) => void;
  78649. /**
  78650. * Callback called when the task is successful
  78651. */
  78652. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78653. /**
  78654. * Creates a new TextureAssetTask object
  78655. * @param name defines the name of the task
  78656. * @param url defines the location of the file to load
  78657. * @param noMipmap defines if mipmap should not be generated (default is false)
  78658. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78659. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78660. */
  78661. constructor(
  78662. /**
  78663. * Defines the name of the task
  78664. */
  78665. name: string,
  78666. /**
  78667. * Defines the location of the file to load
  78668. */
  78669. url: string,
  78670. /**
  78671. * Defines if mipmap should not be generated (default is false)
  78672. */
  78673. noMipmap?: boolean | undefined,
  78674. /**
  78675. * Defines if texture must be inverted on Y axis (default is true)
  78676. */
  78677. invertY?: boolean,
  78678. /**
  78679. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78680. */
  78681. samplingMode?: number);
  78682. /**
  78683. * Execute the current task
  78684. * @param scene defines the scene where you want your assets to be loaded
  78685. * @param onSuccess is a callback called when the task is successfully executed
  78686. * @param onError is a callback called if an error occurs
  78687. */
  78688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78689. }
  78690. /**
  78691. * Define a task used by AssetsManager to load cube textures
  78692. */
  78693. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78694. /**
  78695. * Defines the name of the task
  78696. */
  78697. name: string;
  78698. /**
  78699. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78700. */
  78701. url: string;
  78702. /**
  78703. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78704. */
  78705. extensions?: string[] | undefined;
  78706. /**
  78707. * Defines if mipmaps should not be generated (default is false)
  78708. */
  78709. noMipmap?: boolean | undefined;
  78710. /**
  78711. * Defines the explicit list of files (undefined by default)
  78712. */
  78713. files?: string[] | undefined;
  78714. /**
  78715. * Gets the loaded texture
  78716. */
  78717. texture: CubeTexture;
  78718. /**
  78719. * Callback called when the task is successful
  78720. */
  78721. onSuccess: (task: CubeTextureAssetTask) => void;
  78722. /**
  78723. * Callback called when the task is successful
  78724. */
  78725. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78726. /**
  78727. * Creates a new CubeTextureAssetTask
  78728. * @param name defines the name of the task
  78729. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78730. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78731. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78732. * @param files defines the explicit list of files (undefined by default)
  78733. */
  78734. constructor(
  78735. /**
  78736. * Defines the name of the task
  78737. */
  78738. name: string,
  78739. /**
  78740. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78741. */
  78742. url: string,
  78743. /**
  78744. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78745. */
  78746. extensions?: string[] | undefined,
  78747. /**
  78748. * Defines if mipmaps should not be generated (default is false)
  78749. */
  78750. noMipmap?: boolean | undefined,
  78751. /**
  78752. * Defines the explicit list of files (undefined by default)
  78753. */
  78754. files?: string[] | undefined);
  78755. /**
  78756. * Execute the current task
  78757. * @param scene defines the scene where you want your assets to be loaded
  78758. * @param onSuccess is a callback called when the task is successfully executed
  78759. * @param onError is a callback called if an error occurs
  78760. */
  78761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78762. }
  78763. /**
  78764. * Define a task used by AssetsManager to load HDR cube textures
  78765. */
  78766. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78767. /**
  78768. * Defines the name of the task
  78769. */
  78770. name: string;
  78771. /**
  78772. * Defines the location of the file to load
  78773. */
  78774. url: string;
  78775. /**
  78776. * Defines the desired size (the more it increases the longer the generation will be)
  78777. */
  78778. size: number;
  78779. /**
  78780. * Defines if mipmaps should not be generated (default is false)
  78781. */
  78782. noMipmap: boolean;
  78783. /**
  78784. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78785. */
  78786. generateHarmonics: boolean;
  78787. /**
  78788. * 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)
  78789. */
  78790. gammaSpace: boolean;
  78791. /**
  78792. * Internal Use Only
  78793. */
  78794. reserved: boolean;
  78795. /**
  78796. * Gets the loaded texture
  78797. */
  78798. texture: HDRCubeTexture;
  78799. /**
  78800. * Callback called when the task is successful
  78801. */
  78802. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78803. /**
  78804. * Callback called when the task is successful
  78805. */
  78806. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78807. /**
  78808. * Creates a new HDRCubeTextureAssetTask object
  78809. * @param name defines the name of the task
  78810. * @param url defines the location of the file to load
  78811. * @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.
  78812. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78813. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78814. * @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)
  78815. * @param reserved Internal use only
  78816. */
  78817. constructor(
  78818. /**
  78819. * Defines the name of the task
  78820. */
  78821. name: string,
  78822. /**
  78823. * Defines the location of the file to load
  78824. */
  78825. url: string,
  78826. /**
  78827. * Defines the desired size (the more it increases the longer the generation will be)
  78828. */
  78829. size: number,
  78830. /**
  78831. * Defines if mipmaps should not be generated (default is false)
  78832. */
  78833. noMipmap?: boolean,
  78834. /**
  78835. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78836. */
  78837. generateHarmonics?: boolean,
  78838. /**
  78839. * 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)
  78840. */
  78841. gammaSpace?: boolean,
  78842. /**
  78843. * Internal Use Only
  78844. */
  78845. reserved?: boolean);
  78846. /**
  78847. * Execute the current task
  78848. * @param scene defines the scene where you want your assets to be loaded
  78849. * @param onSuccess is a callback called when the task is successfully executed
  78850. * @param onError is a callback called if an error occurs
  78851. */
  78852. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78853. }
  78854. /**
  78855. * Define a task used by AssetsManager to load Equirectangular cube textures
  78856. */
  78857. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  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 if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78876. * but the standard material would require them in Gamma space) (default is true)
  78877. */
  78878. gammaSpace: boolean;
  78879. /**
  78880. * Gets the loaded texture
  78881. */
  78882. texture: EquiRectangularCubeTexture;
  78883. /**
  78884. * Callback called when the task is successful
  78885. */
  78886. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78887. /**
  78888. * Callback called when the task is successful
  78889. */
  78890. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78891. /**
  78892. * Creates a new EquiRectangularCubeTextureAssetTask object
  78893. * @param name defines the name of the task
  78894. * @param url defines the location of the file to load
  78895. * @param size defines the desired size (the more it increases the longer the generation will be)
  78896. * If the size is omitted this implies you are using a preprocessed cubemap.
  78897. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78898. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78899. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78900. * (default is true)
  78901. */
  78902. constructor(
  78903. /**
  78904. * Defines the name of the task
  78905. */
  78906. name: string,
  78907. /**
  78908. * Defines the location of the file to load
  78909. */
  78910. url: string,
  78911. /**
  78912. * Defines the desired size (the more it increases the longer the generation will be)
  78913. */
  78914. size: number,
  78915. /**
  78916. * Defines if mipmaps should not be generated (default is false)
  78917. */
  78918. noMipmap?: boolean,
  78919. /**
  78920. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78921. * but the standard material would require them in Gamma space) (default is true)
  78922. */
  78923. gammaSpace?: boolean);
  78924. /**
  78925. * Execute the current task
  78926. * @param scene defines the scene where you want your assets to be loaded
  78927. * @param onSuccess is a callback called when the task is successfully executed
  78928. * @param onError is a callback called if an error occurs
  78929. */
  78930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78931. }
  78932. /**
  78933. * This class can be used to easily import assets into a scene
  78934. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78935. */
  78936. export class AssetsManager {
  78937. private _scene;
  78938. private _isLoading;
  78939. protected _tasks: AbstractAssetTask[];
  78940. protected _waitingTasksCount: number;
  78941. protected _totalTasksCount: number;
  78942. /**
  78943. * Callback called when all tasks are processed
  78944. */
  78945. onFinish: (tasks: AbstractAssetTask[]) => void;
  78946. /**
  78947. * Callback called when a task is successful
  78948. */
  78949. onTaskSuccess: (task: AbstractAssetTask) => void;
  78950. /**
  78951. * Callback called when a task had an error
  78952. */
  78953. onTaskError: (task: AbstractAssetTask) => void;
  78954. /**
  78955. * Callback called when a task is done (whatever the result is)
  78956. */
  78957. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78958. /**
  78959. * Observable called when all tasks are processed
  78960. */
  78961. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78962. /**
  78963. * Observable called when a task had an error
  78964. */
  78965. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78966. /**
  78967. * Observable called when all tasks were executed
  78968. */
  78969. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78970. /**
  78971. * Observable called when a task is done (whatever the result is)
  78972. */
  78973. onProgressObservable: Observable<IAssetsProgressEvent>;
  78974. /**
  78975. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78976. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78977. */
  78978. useDefaultLoadingScreen: boolean;
  78979. /**
  78980. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78981. * when all assets have been downloaded.
  78982. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78983. */
  78984. autoHideLoadingUI: boolean;
  78985. /**
  78986. * Creates a new AssetsManager
  78987. * @param scene defines the scene to work on
  78988. */
  78989. constructor(scene: Scene);
  78990. /**
  78991. * Add a ContainerAssetTask to the list of active tasks
  78992. * @param taskName defines the name of the new task
  78993. * @param meshesNames defines the name of meshes to load
  78994. * @param rootUrl defines the root url to use to locate files
  78995. * @param sceneFilename defines the filename of the scene file
  78996. * @returns a new ContainerAssetTask object
  78997. */
  78998. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78999. /**
  79000. * Add a MeshAssetTask to the list of active tasks
  79001. * @param taskName defines the name of the new task
  79002. * @param meshesNames defines the name of meshes to load
  79003. * @param rootUrl defines the root url to use to locate files
  79004. * @param sceneFilename defines the filename of the scene file
  79005. * @returns a new MeshAssetTask object
  79006. */
  79007. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  79008. /**
  79009. * Add a TextFileAssetTask to the list of active tasks
  79010. * @param taskName defines the name of the new task
  79011. * @param url defines the url of the file to load
  79012. * @returns a new TextFileAssetTask object
  79013. */
  79014. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  79015. /**
  79016. * Add a BinaryFileAssetTask to the list of active tasks
  79017. * @param taskName defines the name of the new task
  79018. * @param url defines the url of the file to load
  79019. * @returns a new BinaryFileAssetTask object
  79020. */
  79021. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  79022. /**
  79023. * Add a ImageAssetTask to the list of active tasks
  79024. * @param taskName defines the name of the new task
  79025. * @param url defines the url of the file to load
  79026. * @returns a new ImageAssetTask object
  79027. */
  79028. addImageTask(taskName: string, url: string): ImageAssetTask;
  79029. /**
  79030. * Add a TextureAssetTask to the list of active tasks
  79031. * @param taskName defines the name of the new task
  79032. * @param url defines the url of the file to load
  79033. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79034. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  79035. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  79036. * @returns a new TextureAssetTask object
  79037. */
  79038. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  79039. /**
  79040. * Add a CubeTextureAssetTask to the list of active tasks
  79041. * @param taskName defines the name of the new task
  79042. * @param url defines the url of the file to load
  79043. * @param extensions defines the extension to use to load the cube map (can be null)
  79044. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79045. * @param files defines the list of files to load (can be null)
  79046. * @returns a new CubeTextureAssetTask object
  79047. */
  79048. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  79049. /**
  79050. *
  79051. * Add a HDRCubeTextureAssetTask to the list of active tasks
  79052. * @param taskName defines the name of the new task
  79053. * @param url defines the url of the file to load
  79054. * @param size defines the size you want for the cubemap (can be null)
  79055. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79056. * @param generateHarmonics defines if you want to automatically generate (true by default)
  79057. * @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)
  79058. * @param reserved Internal use only
  79059. * @returns a new HDRCubeTextureAssetTask object
  79060. */
  79061. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  79062. /**
  79063. *
  79064. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  79065. * @param taskName defines the name of the new task
  79066. * @param url defines the url of the file to load
  79067. * @param size defines the size you want for the cubemap (can be null)
  79068. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79069. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  79070. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  79071. * @returns a new EquiRectangularCubeTextureAssetTask object
  79072. */
  79073. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  79074. /**
  79075. * Remove a task from the assets manager.
  79076. * @param task the task to remove
  79077. */
  79078. removeTask(task: AbstractAssetTask): void;
  79079. private _decreaseWaitingTasksCount;
  79080. private _runTask;
  79081. /**
  79082. * Reset the AssetsManager and remove all tasks
  79083. * @return the current instance of the AssetsManager
  79084. */
  79085. reset(): AssetsManager;
  79086. /**
  79087. * Start the loading process
  79088. * @return the current instance of the AssetsManager
  79089. */
  79090. load(): AssetsManager;
  79091. /**
  79092. * Start the loading process as an async operation
  79093. * @return a promise returning the list of failed tasks
  79094. */
  79095. loadAsync(): Promise<void>;
  79096. }
  79097. }
  79098. declare module "babylonjs/Misc/deferred" {
  79099. /**
  79100. * Wrapper class for promise with external resolve and reject.
  79101. */
  79102. export class Deferred<T> {
  79103. /**
  79104. * The promise associated with this deferred object.
  79105. */
  79106. readonly promise: Promise<T>;
  79107. private _resolve;
  79108. private _reject;
  79109. /**
  79110. * The resolve method of the promise associated with this deferred object.
  79111. */
  79112. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  79113. /**
  79114. * The reject method of the promise associated with this deferred object.
  79115. */
  79116. get reject(): (reason?: any) => void;
  79117. /**
  79118. * Constructor for this deferred object.
  79119. */
  79120. constructor();
  79121. }
  79122. }
  79123. declare module "babylonjs/Misc/meshExploder" {
  79124. import { Mesh } from "babylonjs/Meshes/mesh";
  79125. /**
  79126. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  79127. */
  79128. export class MeshExploder {
  79129. private _centerMesh;
  79130. private _meshes;
  79131. private _meshesOrigins;
  79132. private _toCenterVectors;
  79133. private _scaledDirection;
  79134. private _newPosition;
  79135. private _centerPosition;
  79136. /**
  79137. * Explodes meshes from a center mesh.
  79138. * @param meshes The meshes to explode.
  79139. * @param centerMesh The mesh to be center of explosion.
  79140. */
  79141. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  79142. private _setCenterMesh;
  79143. /**
  79144. * Get class name
  79145. * @returns "MeshExploder"
  79146. */
  79147. getClassName(): string;
  79148. /**
  79149. * "Exploded meshes"
  79150. * @returns Array of meshes with the centerMesh at index 0.
  79151. */
  79152. getMeshes(): Array<Mesh>;
  79153. /**
  79154. * Explodes meshes giving a specific direction
  79155. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  79156. */
  79157. explode(direction?: number): void;
  79158. }
  79159. }
  79160. declare module "babylonjs/Misc/filesInput" {
  79161. import { Engine } from "babylonjs/Engines/engine";
  79162. import { Scene } from "babylonjs/scene";
  79163. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  79164. import { Nullable } from "babylonjs/types";
  79165. /**
  79166. * Class used to help managing file picking and drag'n'drop
  79167. */
  79168. export class FilesInput {
  79169. /**
  79170. * List of files ready to be loaded
  79171. */
  79172. static get FilesToLoad(): {
  79173. [key: string]: File;
  79174. };
  79175. /**
  79176. * Callback called when a file is processed
  79177. */
  79178. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  79179. private _engine;
  79180. private _currentScene;
  79181. private _sceneLoadedCallback;
  79182. private _progressCallback;
  79183. private _additionalRenderLoopLogicCallback;
  79184. private _textureLoadingCallback;
  79185. private _startingProcessingFilesCallback;
  79186. private _onReloadCallback;
  79187. private _errorCallback;
  79188. private _elementToMonitor;
  79189. private _sceneFileToLoad;
  79190. private _filesToLoad;
  79191. /**
  79192. * Creates a new FilesInput
  79193. * @param engine defines the rendering engine
  79194. * @param scene defines the hosting scene
  79195. * @param sceneLoadedCallback callback called when scene is loaded
  79196. * @param progressCallback callback called to track progress
  79197. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  79198. * @param textureLoadingCallback callback called when a texture is loading
  79199. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79200. * @param onReloadCallback callback called when a reload is requested
  79201. * @param errorCallback callback call if an error occurs
  79202. */
  79203. 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>);
  79204. private _dragEnterHandler;
  79205. private _dragOverHandler;
  79206. private _dropHandler;
  79207. /**
  79208. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79209. * @param elementToMonitor defines the DOM element to track
  79210. */
  79211. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79212. /** Gets the current list of files to load */
  79213. get filesToLoad(): File[];
  79214. /**
  79215. * Release all associated resources
  79216. */
  79217. dispose(): void;
  79218. private renderFunction;
  79219. private drag;
  79220. private drop;
  79221. private _traverseFolder;
  79222. private _processFiles;
  79223. /**
  79224. * Load files from a drop event
  79225. * @param event defines the drop event to use as source
  79226. */
  79227. loadFiles(event: any): void;
  79228. private _processReload;
  79229. /**
  79230. * Reload the current scene from the loaded files
  79231. */
  79232. reload(): void;
  79233. }
  79234. }
  79235. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79236. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79237. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79238. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79239. }
  79240. declare module "babylonjs/Misc/sceneOptimizer" {
  79241. import { Scene, IDisposable } from "babylonjs/scene";
  79242. import { Observable } from "babylonjs/Misc/observable";
  79243. /**
  79244. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79245. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79246. */
  79247. export class SceneOptimization {
  79248. /**
  79249. * Defines the priority of this optimization (0 by default which means first in the list)
  79250. */
  79251. priority: number;
  79252. /**
  79253. * Gets a string describing the action executed by the current optimization
  79254. * @returns description string
  79255. */
  79256. getDescription(): string;
  79257. /**
  79258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79259. * @param scene defines the current scene where to apply this optimization
  79260. * @param optimizer defines the current optimizer
  79261. * @returns true if everything that can be done was applied
  79262. */
  79263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79264. /**
  79265. * Creates the SceneOptimization object
  79266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79267. * @param desc defines the description associated with the optimization
  79268. */
  79269. constructor(
  79270. /**
  79271. * Defines the priority of this optimization (0 by default which means first in the list)
  79272. */
  79273. priority?: number);
  79274. }
  79275. /**
  79276. * Defines an optimization used to reduce the size of render target textures
  79277. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79278. */
  79279. export class TextureOptimization extends SceneOptimization {
  79280. /**
  79281. * Defines the priority of this optimization (0 by default which means first in the list)
  79282. */
  79283. priority: number;
  79284. /**
  79285. * 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
  79286. */
  79287. maximumSize: number;
  79288. /**
  79289. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79290. */
  79291. step: number;
  79292. /**
  79293. * Gets a string describing the action executed by the current optimization
  79294. * @returns description string
  79295. */
  79296. getDescription(): string;
  79297. /**
  79298. * Creates the TextureOptimization object
  79299. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79300. * @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
  79301. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79302. */
  79303. constructor(
  79304. /**
  79305. * Defines the priority of this optimization (0 by default which means first in the list)
  79306. */
  79307. priority?: number,
  79308. /**
  79309. * 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
  79310. */
  79311. maximumSize?: number,
  79312. /**
  79313. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79314. */
  79315. step?: number);
  79316. /**
  79317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79318. * @param scene defines the current scene where to apply this optimization
  79319. * @param optimizer defines the current optimizer
  79320. * @returns true if everything that can be done was applied
  79321. */
  79322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79323. }
  79324. /**
  79325. * Defines an optimization used to increase or decrease the rendering resolution
  79326. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79327. */
  79328. export class HardwareScalingOptimization extends SceneOptimization {
  79329. /**
  79330. * Defines the priority of this optimization (0 by default which means first in the list)
  79331. */
  79332. priority: number;
  79333. /**
  79334. * Defines the maximum scale to use (2 by default)
  79335. */
  79336. maximumScale: number;
  79337. /**
  79338. * Defines the step to use between two passes (0.5 by default)
  79339. */
  79340. step: number;
  79341. private _currentScale;
  79342. private _directionOffset;
  79343. /**
  79344. * Gets a string describing the action executed by the current optimization
  79345. * @return description string
  79346. */
  79347. getDescription(): string;
  79348. /**
  79349. * Creates the HardwareScalingOptimization object
  79350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79351. * @param maximumScale defines the maximum scale to use (2 by default)
  79352. * @param step defines the step to use between two passes (0.5 by default)
  79353. */
  79354. constructor(
  79355. /**
  79356. * Defines the priority of this optimization (0 by default which means first in the list)
  79357. */
  79358. priority?: number,
  79359. /**
  79360. * Defines the maximum scale to use (2 by default)
  79361. */
  79362. maximumScale?: number,
  79363. /**
  79364. * Defines the step to use between two passes (0.5 by default)
  79365. */
  79366. step?: number);
  79367. /**
  79368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79369. * @param scene defines the current scene where to apply this optimization
  79370. * @param optimizer defines the current optimizer
  79371. * @returns true if everything that can be done was applied
  79372. */
  79373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79374. }
  79375. /**
  79376. * Defines an optimization used to remove shadows
  79377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79378. */
  79379. export class ShadowsOptimization extends SceneOptimization {
  79380. /**
  79381. * Gets a string describing the action executed by the current optimization
  79382. * @return description string
  79383. */
  79384. getDescription(): string;
  79385. /**
  79386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79387. * @param scene defines the current scene where to apply this optimization
  79388. * @param optimizer defines the current optimizer
  79389. * @returns true if everything that can be done was applied
  79390. */
  79391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79392. }
  79393. /**
  79394. * Defines an optimization used to turn post-processes off
  79395. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79396. */
  79397. export class PostProcessesOptimization extends SceneOptimization {
  79398. /**
  79399. * Gets a string describing the action executed by the current optimization
  79400. * @return description string
  79401. */
  79402. getDescription(): string;
  79403. /**
  79404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79405. * @param scene defines the current scene where to apply this optimization
  79406. * @param optimizer defines the current optimizer
  79407. * @returns true if everything that can be done was applied
  79408. */
  79409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79410. }
  79411. /**
  79412. * Defines an optimization used to turn lens flares off
  79413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79414. */
  79415. export class LensFlaresOptimization extends SceneOptimization {
  79416. /**
  79417. * Gets a string describing the action executed by the current optimization
  79418. * @return description string
  79419. */
  79420. getDescription(): string;
  79421. /**
  79422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79423. * @param scene defines the current scene where to apply this optimization
  79424. * @param optimizer defines the current optimizer
  79425. * @returns true if everything that can be done was applied
  79426. */
  79427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79428. }
  79429. /**
  79430. * Defines an optimization based on user defined callback.
  79431. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79432. */
  79433. export class CustomOptimization extends SceneOptimization {
  79434. /**
  79435. * Callback called to apply the custom optimization.
  79436. */
  79437. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79438. /**
  79439. * Callback called to get custom description
  79440. */
  79441. onGetDescription: () => string;
  79442. /**
  79443. * Gets a string describing the action executed by the current optimization
  79444. * @returns description string
  79445. */
  79446. getDescription(): string;
  79447. /**
  79448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79449. * @param scene defines the current scene where to apply this optimization
  79450. * @param optimizer defines the current optimizer
  79451. * @returns true if everything that can be done was applied
  79452. */
  79453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79454. }
  79455. /**
  79456. * Defines an optimization used to turn particles off
  79457. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79458. */
  79459. export class ParticlesOptimization extends SceneOptimization {
  79460. /**
  79461. * Gets a string describing the action executed by the current optimization
  79462. * @return description string
  79463. */
  79464. getDescription(): string;
  79465. /**
  79466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79467. * @param scene defines the current scene where to apply this optimization
  79468. * @param optimizer defines the current optimizer
  79469. * @returns true if everything that can be done was applied
  79470. */
  79471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79472. }
  79473. /**
  79474. * Defines an optimization used to turn render targets off
  79475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79476. */
  79477. export class RenderTargetsOptimization extends SceneOptimization {
  79478. /**
  79479. * Gets a string describing the action executed by the current optimization
  79480. * @return description string
  79481. */
  79482. getDescription(): string;
  79483. /**
  79484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79485. * @param scene defines the current scene where to apply this optimization
  79486. * @param optimizer defines the current optimizer
  79487. * @returns true if everything that can be done was applied
  79488. */
  79489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79490. }
  79491. /**
  79492. * Defines an optimization used to merge meshes with compatible materials
  79493. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79494. */
  79495. export class MergeMeshesOptimization extends SceneOptimization {
  79496. private static _UpdateSelectionTree;
  79497. /**
  79498. * Gets or sets a boolean which defines if optimization octree has to be updated
  79499. */
  79500. static get UpdateSelectionTree(): boolean;
  79501. /**
  79502. * Gets or sets a boolean which defines if optimization octree has to be updated
  79503. */
  79504. static set UpdateSelectionTree(value: boolean);
  79505. /**
  79506. * Gets a string describing the action executed by the current optimization
  79507. * @return description string
  79508. */
  79509. getDescription(): string;
  79510. private _canBeMerged;
  79511. /**
  79512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79513. * @param scene defines the current scene where to apply this optimization
  79514. * @param optimizer defines the current optimizer
  79515. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79516. * @returns true if everything that can be done was applied
  79517. */
  79518. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79519. }
  79520. /**
  79521. * Defines a list of options used by SceneOptimizer
  79522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79523. */
  79524. export class SceneOptimizerOptions {
  79525. /**
  79526. * Defines the target frame rate to reach (60 by default)
  79527. */
  79528. targetFrameRate: number;
  79529. /**
  79530. * Defines the interval between two checkes (2000ms by default)
  79531. */
  79532. trackerDuration: number;
  79533. /**
  79534. * Gets the list of optimizations to apply
  79535. */
  79536. optimizations: SceneOptimization[];
  79537. /**
  79538. * Creates a new list of options used by SceneOptimizer
  79539. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79540. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79541. */
  79542. constructor(
  79543. /**
  79544. * Defines the target frame rate to reach (60 by default)
  79545. */
  79546. targetFrameRate?: number,
  79547. /**
  79548. * Defines the interval between two checkes (2000ms by default)
  79549. */
  79550. trackerDuration?: number);
  79551. /**
  79552. * Add a new optimization
  79553. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79554. * @returns the current SceneOptimizerOptions
  79555. */
  79556. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79557. /**
  79558. * Add a new custom optimization
  79559. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79560. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79561. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79562. * @returns the current SceneOptimizerOptions
  79563. */
  79564. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79565. /**
  79566. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79567. * @param targetFrameRate defines the target frame rate (60 by default)
  79568. * @returns a SceneOptimizerOptions object
  79569. */
  79570. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79571. /**
  79572. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79573. * @param targetFrameRate defines the target frame rate (60 by default)
  79574. * @returns a SceneOptimizerOptions object
  79575. */
  79576. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79577. /**
  79578. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79579. * @param targetFrameRate defines the target frame rate (60 by default)
  79580. * @returns a SceneOptimizerOptions object
  79581. */
  79582. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79583. }
  79584. /**
  79585. * Class used to run optimizations in order to reach a target frame rate
  79586. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79587. */
  79588. export class SceneOptimizer implements IDisposable {
  79589. private _isRunning;
  79590. private _options;
  79591. private _scene;
  79592. private _currentPriorityLevel;
  79593. private _targetFrameRate;
  79594. private _trackerDuration;
  79595. private _currentFrameRate;
  79596. private _sceneDisposeObserver;
  79597. private _improvementMode;
  79598. /**
  79599. * Defines an observable called when the optimizer reaches the target frame rate
  79600. */
  79601. onSuccessObservable: Observable<SceneOptimizer>;
  79602. /**
  79603. * Defines an observable called when the optimizer enables an optimization
  79604. */
  79605. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79606. /**
  79607. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79608. */
  79609. onFailureObservable: Observable<SceneOptimizer>;
  79610. /**
  79611. * Gets a boolean indicating if the optimizer is in improvement mode
  79612. */
  79613. get isInImprovementMode(): boolean;
  79614. /**
  79615. * Gets the current priority level (0 at start)
  79616. */
  79617. get currentPriorityLevel(): number;
  79618. /**
  79619. * Gets the current frame rate checked by the SceneOptimizer
  79620. */
  79621. get currentFrameRate(): number;
  79622. /**
  79623. * Gets or sets the current target frame rate (60 by default)
  79624. */
  79625. get targetFrameRate(): number;
  79626. /**
  79627. * Gets or sets the current target frame rate (60 by default)
  79628. */
  79629. set targetFrameRate(value: number);
  79630. /**
  79631. * Gets or sets the current interval between two checks (every 2000ms by default)
  79632. */
  79633. get trackerDuration(): number;
  79634. /**
  79635. * Gets or sets the current interval between two checks (every 2000ms by default)
  79636. */
  79637. set trackerDuration(value: number);
  79638. /**
  79639. * Gets the list of active optimizations
  79640. */
  79641. get optimizations(): SceneOptimization[];
  79642. /**
  79643. * Creates a new SceneOptimizer
  79644. * @param scene defines the scene to work on
  79645. * @param options defines the options to use with the SceneOptimizer
  79646. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79647. * @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)
  79648. */
  79649. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79650. /**
  79651. * Stops the current optimizer
  79652. */
  79653. stop(): void;
  79654. /**
  79655. * Reset the optimizer to initial step (current priority level = 0)
  79656. */
  79657. reset(): void;
  79658. /**
  79659. * Start the optimizer. By default it will try to reach a specific framerate
  79660. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79661. */
  79662. start(): void;
  79663. private _checkCurrentState;
  79664. /**
  79665. * Release all resources
  79666. */
  79667. dispose(): void;
  79668. /**
  79669. * Helper function to create a SceneOptimizer with one single line of code
  79670. * @param scene defines the scene to work on
  79671. * @param options defines the options to use with the SceneOptimizer
  79672. * @param onSuccess defines a callback to call on success
  79673. * @param onFailure defines a callback to call on failure
  79674. * @returns the new SceneOptimizer object
  79675. */
  79676. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79677. }
  79678. }
  79679. declare module "babylonjs/Misc/sceneSerializer" {
  79680. import { Scene } from "babylonjs/scene";
  79681. /**
  79682. * Class used to serialize a scene into a string
  79683. */
  79684. export class SceneSerializer {
  79685. /**
  79686. * Clear cache used by a previous serialization
  79687. */
  79688. static ClearCache(): void;
  79689. /**
  79690. * Serialize a scene into a JSON compatible object
  79691. * @param scene defines the scene to serialize
  79692. * @returns a JSON compatible object
  79693. */
  79694. static Serialize(scene: Scene): any;
  79695. /**
  79696. * Serialize a mesh into a JSON compatible object
  79697. * @param toSerialize defines the mesh to serialize
  79698. * @param withParents defines if parents must be serialized as well
  79699. * @param withChildren defines if children must be serialized as well
  79700. * @returns a JSON compatible object
  79701. */
  79702. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79703. }
  79704. }
  79705. declare module "babylonjs/Misc/textureTools" {
  79706. import { Texture } from "babylonjs/Materials/Textures/texture";
  79707. /**
  79708. * Class used to host texture specific utilities
  79709. */
  79710. export class TextureTools {
  79711. /**
  79712. * Uses the GPU to create a copy texture rescaled at a given size
  79713. * @param texture Texture to copy from
  79714. * @param width defines the desired width
  79715. * @param height defines the desired height
  79716. * @param useBilinearMode defines if bilinear mode has to be used
  79717. * @return the generated texture
  79718. */
  79719. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79720. }
  79721. }
  79722. declare module "babylonjs/Misc/videoRecorder" {
  79723. import { Nullable } from "babylonjs/types";
  79724. import { Engine } from "babylonjs/Engines/engine";
  79725. /**
  79726. * This represents the different options available for the video capture.
  79727. */
  79728. export interface VideoRecorderOptions {
  79729. /** Defines the mime type of the video. */
  79730. mimeType: string;
  79731. /** Defines the FPS the video should be recorded at. */
  79732. fps: number;
  79733. /** Defines the chunk size for the recording data. */
  79734. recordChunckSize: number;
  79735. /** The audio tracks to attach to the recording. */
  79736. audioTracks?: MediaStreamTrack[];
  79737. }
  79738. /**
  79739. * This can help with recording videos from BabylonJS.
  79740. * This is based on the available WebRTC functionalities of the browser.
  79741. *
  79742. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79743. */
  79744. export class VideoRecorder {
  79745. private static readonly _defaultOptions;
  79746. /**
  79747. * Returns whether or not the VideoRecorder is available in your browser.
  79748. * @param engine Defines the Babylon Engine.
  79749. * @returns true if supported otherwise false.
  79750. */
  79751. static IsSupported(engine: Engine): boolean;
  79752. private readonly _options;
  79753. private _canvas;
  79754. private _mediaRecorder;
  79755. private _recordedChunks;
  79756. private _fileName;
  79757. private _resolve;
  79758. private _reject;
  79759. /**
  79760. * True when a recording is already in progress.
  79761. */
  79762. get isRecording(): boolean;
  79763. /**
  79764. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79765. * @param engine Defines the BabylonJS Engine you wish to record.
  79766. * @param options Defines options that can be used to customize the capture.
  79767. */
  79768. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79769. /**
  79770. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79771. */
  79772. stopRecording(): void;
  79773. /**
  79774. * Starts recording the canvas for a max duration specified in parameters.
  79775. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79776. * If null no automatic download will start and you can rely on the promise to get the data back.
  79777. * @param maxDuration Defines the maximum recording time in seconds.
  79778. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79779. * @return A promise callback at the end of the recording with the video data in Blob.
  79780. */
  79781. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79782. /**
  79783. * Releases internal resources used during the recording.
  79784. */
  79785. dispose(): void;
  79786. private _handleDataAvailable;
  79787. private _handleError;
  79788. private _handleStop;
  79789. }
  79790. }
  79791. declare module "babylonjs/Misc/screenshotTools" {
  79792. import { Camera } from "babylonjs/Cameras/camera";
  79793. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79794. import { Engine } from "babylonjs/Engines/engine";
  79795. /**
  79796. * Class containing a set of static utilities functions for screenshots
  79797. */
  79798. export class ScreenshotTools {
  79799. /**
  79800. * Captures a screenshot of the current rendering
  79801. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79802. * @param engine defines the rendering engine
  79803. * @param camera defines the source camera
  79804. * @param size This parameter can be set to a single number or to an object with the
  79805. * following (optional) properties: precision, width, height. If a single number is passed,
  79806. * it will be used for both width and height. If an object is passed, the screenshot size
  79807. * will be derived from the parameters. The precision property is a multiplier allowing
  79808. * rendering at a higher or lower resolution
  79809. * @param successCallback defines the callback receives a single parameter which contains the
  79810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79811. * src parameter of an <img> to display it
  79812. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79813. * Check your browser for supported MIME types
  79814. */
  79815. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79816. /**
  79817. * Captures a screenshot of the current rendering
  79818. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79819. * @param engine defines the rendering engine
  79820. * @param camera defines the source camera
  79821. * @param size This parameter can be set to a single number or to an object with the
  79822. * following (optional) properties: precision, width, height. If a single number is passed,
  79823. * it will be used for both width and height. If an object is passed, the screenshot size
  79824. * will be derived from the parameters. The precision property is a multiplier allowing
  79825. * rendering at a higher or lower resolution
  79826. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79827. * Check your browser for supported MIME types
  79828. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79829. * to the src parameter of an <img> to display it
  79830. */
  79831. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79832. /**
  79833. * Generates an image screenshot from the specified camera.
  79834. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79835. * @param engine The engine to use for rendering
  79836. * @param camera The camera to use for rendering
  79837. * @param size This parameter can be set to a single number or to an object with the
  79838. * following (optional) properties: precision, width, height. If a single number is passed,
  79839. * it will be used for both width and height. If an object is passed, the screenshot size
  79840. * will be derived from the parameters. The precision property is a multiplier allowing
  79841. * rendering at a higher or lower resolution
  79842. * @param successCallback The callback receives a single parameter which contains the
  79843. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79844. * src parameter of an <img> to display it
  79845. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79846. * Check your browser for supported MIME types
  79847. * @param samples Texture samples (default: 1)
  79848. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79849. * @param fileName A name for for the downloaded file.
  79850. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79851. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79852. */
  79853. 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;
  79854. /**
  79855. * Generates an image screenshot from the specified camera.
  79856. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79857. * @param engine The engine to use for rendering
  79858. * @param camera The camera to use for rendering
  79859. * @param size This parameter can be set to a single number or to an object with the
  79860. * following (optional) properties: precision, width, height. If a single number is passed,
  79861. * it will be used for both width and height. If an object is passed, the screenshot size
  79862. * will be derived from the parameters. The precision property is a multiplier allowing
  79863. * rendering at a higher or lower resolution
  79864. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79865. * Check your browser for supported MIME types
  79866. * @param samples Texture samples (default: 1)
  79867. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79868. * @param fileName A name for for the downloaded file.
  79869. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79870. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79871. * to the src parameter of an <img> to display it
  79872. */
  79873. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79874. /**
  79875. * Gets height and width for screenshot size
  79876. * @private
  79877. */
  79878. private static _getScreenshotSize;
  79879. }
  79880. }
  79881. declare module "babylonjs/Misc/dataReader" {
  79882. /**
  79883. * Interface for a data buffer
  79884. */
  79885. export interface IDataBuffer {
  79886. /**
  79887. * Reads bytes from the data buffer.
  79888. * @param byteOffset The byte offset to read
  79889. * @param byteLength The byte length to read
  79890. * @returns A promise that resolves when the bytes are read
  79891. */
  79892. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79893. /**
  79894. * The byte length of the buffer.
  79895. */
  79896. readonly byteLength: number;
  79897. }
  79898. /**
  79899. * Utility class for reading from a data buffer
  79900. */
  79901. export class DataReader {
  79902. /**
  79903. * The data buffer associated with this data reader.
  79904. */
  79905. readonly buffer: IDataBuffer;
  79906. /**
  79907. * The current byte offset from the beginning of the data buffer.
  79908. */
  79909. byteOffset: number;
  79910. private _dataView;
  79911. private _dataByteOffset;
  79912. /**
  79913. * Constructor
  79914. * @param buffer The buffer to read
  79915. */
  79916. constructor(buffer: IDataBuffer);
  79917. /**
  79918. * Loads the given byte length.
  79919. * @param byteLength The byte length to load
  79920. * @returns A promise that resolves when the load is complete
  79921. */
  79922. loadAsync(byteLength: number): Promise<void>;
  79923. /**
  79924. * Read a unsigned 32-bit integer from the currently loaded data range.
  79925. * @returns The 32-bit integer read
  79926. */
  79927. readUint32(): number;
  79928. /**
  79929. * Read a byte array from the currently loaded data range.
  79930. * @param byteLength The byte length to read
  79931. * @returns The byte array read
  79932. */
  79933. readUint8Array(byteLength: number): Uint8Array;
  79934. /**
  79935. * Read a string from the currently loaded data range.
  79936. * @param byteLength The byte length to read
  79937. * @returns The string read
  79938. */
  79939. readString(byteLength: number): string;
  79940. /**
  79941. * Skips the given byte length the currently loaded data range.
  79942. * @param byteLength The byte length to skip
  79943. */
  79944. skipBytes(byteLength: number): void;
  79945. }
  79946. }
  79947. declare module "babylonjs/Misc/dataStorage" {
  79948. /**
  79949. * Class for storing data to local storage if available or in-memory storage otherwise
  79950. */
  79951. export class DataStorage {
  79952. private static _Storage;
  79953. private static _GetStorage;
  79954. /**
  79955. * Reads a string from the data storage
  79956. * @param key The key to read
  79957. * @param defaultValue The value if the key doesn't exist
  79958. * @returns The string value
  79959. */
  79960. static ReadString(key: string, defaultValue: string): string;
  79961. /**
  79962. * Writes a string to the data storage
  79963. * @param key The key to write
  79964. * @param value The value to write
  79965. */
  79966. static WriteString(key: string, value: string): void;
  79967. /**
  79968. * Reads a boolean from the data storage
  79969. * @param key The key to read
  79970. * @param defaultValue The value if the key doesn't exist
  79971. * @returns The boolean value
  79972. */
  79973. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79974. /**
  79975. * Writes a boolean to the data storage
  79976. * @param key The key to write
  79977. * @param value The value to write
  79978. */
  79979. static WriteBoolean(key: string, value: boolean): void;
  79980. /**
  79981. * Reads a number from the data storage
  79982. * @param key The key to read
  79983. * @param defaultValue The value if the key doesn't exist
  79984. * @returns The number value
  79985. */
  79986. static ReadNumber(key: string, defaultValue: number): number;
  79987. /**
  79988. * Writes a number to the data storage
  79989. * @param key The key to write
  79990. * @param value The value to write
  79991. */
  79992. static WriteNumber(key: string, value: number): void;
  79993. }
  79994. }
  79995. declare module "babylonjs/Misc/sceneRecorder" {
  79996. import { Scene } from "babylonjs/scene";
  79997. /**
  79998. * Class used to record delta files between 2 scene states
  79999. */
  80000. export class SceneRecorder {
  80001. private _trackedScene;
  80002. private _savedJSON;
  80003. /**
  80004. * Track a given scene. This means the current scene state will be considered the original state
  80005. * @param scene defines the scene to track
  80006. */
  80007. track(scene: Scene): void;
  80008. /**
  80009. * Get the delta between current state and original state
  80010. * @returns a string containing the delta
  80011. */
  80012. getDelta(): any;
  80013. private _compareArray;
  80014. private _compareObjects;
  80015. private _compareCollections;
  80016. private static GetShadowGeneratorById;
  80017. /**
  80018. * Apply a given delta to a given scene
  80019. * @param deltaJSON defines the JSON containing the delta
  80020. * @param scene defines the scene to apply the delta to
  80021. */
  80022. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  80023. private static _ApplyPropertiesToEntity;
  80024. private static _ApplyDeltaForEntity;
  80025. }
  80026. }
  80027. declare module "babylonjs/Misc/trajectoryClassifier" {
  80028. import { DeepImmutable, Nullable } from "babylonjs/types";
  80029. import { Vector3 } from "babylonjs/Maths/math.vector";
  80030. /**
  80031. * A 3D trajectory consisting of an order list of vectors describing a
  80032. * path of motion through 3D space.
  80033. */
  80034. export class Trajectory {
  80035. private _points;
  80036. private readonly _segmentLength;
  80037. /**
  80038. * Serialize to JSON.
  80039. * @returns serialized JSON string
  80040. */
  80041. serialize(): string;
  80042. /**
  80043. * Deserialize from JSON.
  80044. * @param json serialized JSON string
  80045. * @returns deserialized Trajectory
  80046. */
  80047. static Deserialize(json: string): Trajectory;
  80048. /**
  80049. * Create a new empty Trajectory.
  80050. * @param segmentLength radius of discretization for Trajectory points
  80051. */
  80052. constructor(segmentLength?: number);
  80053. /**
  80054. * Get the length of the Trajectory.
  80055. * @returns length of the Trajectory
  80056. */
  80057. getLength(): number;
  80058. /**
  80059. * Append a new point to the Trajectory.
  80060. * NOTE: This implementation has many allocations.
  80061. * @param point point to append to the Trajectory
  80062. */
  80063. add(point: DeepImmutable<Vector3>): void;
  80064. /**
  80065. * Create a new Trajectory with a segment length chosen to make it
  80066. * probable that the new Trajectory will have a specified number of
  80067. * segments. This operation is imprecise.
  80068. * @param targetResolution number of segments desired
  80069. * @returns new Trajectory with approximately the requested number of segments
  80070. */
  80071. resampleAtTargetResolution(targetResolution: number): Trajectory;
  80072. /**
  80073. * Convert Trajectory segments into tokenized representation. This
  80074. * representation is an array of numbers where each nth number is the
  80075. * index of the token which is most similar to the nth segment of the
  80076. * Trajectory.
  80077. * @param tokens list of vectors which serve as discrete tokens
  80078. * @returns list of indices of most similar token per segment
  80079. */
  80080. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  80081. private static _forwardDir;
  80082. private static _inverseFromVec;
  80083. private static _upDir;
  80084. private static _fromToVec;
  80085. private static _lookMatrix;
  80086. /**
  80087. * Transform the rotation (i.e., direction) of a segment to isolate
  80088. * the relative transformation represented by the segment. This operation
  80089. * may or may not succeed due to singularities in the equations that define
  80090. * motion relativity in this context.
  80091. * @param priorVec the origin of the prior segment
  80092. * @param fromVec the origin of the current segment
  80093. * @param toVec the destination of the current segment
  80094. * @param result reference to output variable
  80095. * @returns whether or not transformation was successful
  80096. */
  80097. private static _transformSegmentDirToRef;
  80098. private static _bestMatch;
  80099. private static _score;
  80100. private static _bestScore;
  80101. /**
  80102. * Determine which token vector is most similar to the
  80103. * segment vector.
  80104. * @param segment segment vector
  80105. * @param tokens token vector list
  80106. * @returns index of the most similar token to the segment
  80107. */
  80108. private static _tokenizeSegment;
  80109. }
  80110. /**
  80111. * Class representing a set of known, named trajectories to which Trajectories can be
  80112. * added and using which Trajectories can be recognized.
  80113. */
  80114. export class TrajectoryClassifier {
  80115. private _maximumAllowableMatchCost;
  80116. private _vector3Alphabet;
  80117. private _levenshteinAlphabet;
  80118. private _nameToDescribedTrajectory;
  80119. /**
  80120. * Serialize to JSON.
  80121. * @returns JSON serialization
  80122. */
  80123. serialize(): string;
  80124. /**
  80125. * Deserialize from JSON.
  80126. * @param json JSON serialization
  80127. * @returns deserialized TrajectorySet
  80128. */
  80129. static Deserialize(json: string): TrajectoryClassifier;
  80130. /**
  80131. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  80132. * VERY naive, need to be generating these things from known
  80133. * sets. Better version later, probably eliminating this one.
  80134. * @returns auto-generated TrajectorySet
  80135. */
  80136. static Generate(): TrajectoryClassifier;
  80137. private constructor();
  80138. /**
  80139. * Add a new Trajectory to the set with a given name.
  80140. * @param trajectory new Trajectory to be added
  80141. * @param classification name to which to add the Trajectory
  80142. */
  80143. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  80144. /**
  80145. * Remove a known named trajectory and all Trajectories associated with it.
  80146. * @param classification name to remove
  80147. * @returns whether anything was removed
  80148. */
  80149. deleteClassification(classification: string): boolean;
  80150. /**
  80151. * Attempt to recognize a Trajectory from among all the classifications
  80152. * already known to the classifier.
  80153. * @param trajectory Trajectory to be recognized
  80154. * @returns classification of Trajectory if recognized, null otherwise
  80155. */
  80156. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  80157. }
  80158. }
  80159. declare module "babylonjs/Misc/index" {
  80160. export * from "babylonjs/Misc/andOrNotEvaluator";
  80161. export * from "babylonjs/Misc/assetsManager";
  80162. export * from "babylonjs/Misc/basis";
  80163. export * from "babylonjs/Misc/dds";
  80164. export * from "babylonjs/Misc/decorators";
  80165. export * from "babylonjs/Misc/deferred";
  80166. export * from "babylonjs/Misc/environmentTextureTools";
  80167. export * from "babylonjs/Misc/meshExploder";
  80168. export * from "babylonjs/Misc/filesInput";
  80169. export * from "babylonjs/Misc/HighDynamicRange/index";
  80170. export * from "babylonjs/Misc/khronosTextureContainer";
  80171. export * from "babylonjs/Misc/observable";
  80172. export * from "babylonjs/Misc/performanceMonitor";
  80173. export * from "babylonjs/Misc/promise";
  80174. export * from "babylonjs/Misc/sceneOptimizer";
  80175. export * from "babylonjs/Misc/sceneSerializer";
  80176. export * from "babylonjs/Misc/smartArray";
  80177. export * from "babylonjs/Misc/stringDictionary";
  80178. export * from "babylonjs/Misc/tags";
  80179. export * from "babylonjs/Misc/textureTools";
  80180. export * from "babylonjs/Misc/tga";
  80181. export * from "babylonjs/Misc/tools";
  80182. export * from "babylonjs/Misc/videoRecorder";
  80183. export * from "babylonjs/Misc/virtualJoystick";
  80184. export * from "babylonjs/Misc/workerPool";
  80185. export * from "babylonjs/Misc/logger";
  80186. export * from "babylonjs/Misc/typeStore";
  80187. export * from "babylonjs/Misc/filesInputStore";
  80188. export * from "babylonjs/Misc/deepCopier";
  80189. export * from "babylonjs/Misc/pivotTools";
  80190. export * from "babylonjs/Misc/precisionDate";
  80191. export * from "babylonjs/Misc/screenshotTools";
  80192. export * from "babylonjs/Misc/typeStore";
  80193. export * from "babylonjs/Misc/webRequest";
  80194. export * from "babylonjs/Misc/iInspectable";
  80195. export * from "babylonjs/Misc/brdfTextureTools";
  80196. export * from "babylonjs/Misc/rgbdTextureTools";
  80197. export * from "babylonjs/Misc/gradients";
  80198. export * from "babylonjs/Misc/perfCounter";
  80199. export * from "babylonjs/Misc/fileRequest";
  80200. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80201. export * from "babylonjs/Misc/retryStrategy";
  80202. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80203. export * from "babylonjs/Misc/canvasGenerator";
  80204. export * from "babylonjs/Misc/fileTools";
  80205. export * from "babylonjs/Misc/stringTools";
  80206. export * from "babylonjs/Misc/dataReader";
  80207. export * from "babylonjs/Misc/minMaxReducer";
  80208. export * from "babylonjs/Misc/depthReducer";
  80209. export * from "babylonjs/Misc/dataStorage";
  80210. export * from "babylonjs/Misc/sceneRecorder";
  80211. export * from "babylonjs/Misc/khronosTextureContainer2";
  80212. export * from "babylonjs/Misc/trajectoryClassifier";
  80213. export * from "babylonjs/Misc/timer";
  80214. export * from "babylonjs/Misc/copyTools";
  80215. }
  80216. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80217. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80218. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80219. import { Observable } from "babylonjs/Misc/observable";
  80220. import { Matrix } from "babylonjs/Maths/math.vector";
  80221. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80222. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80223. /**
  80224. * An interface for all Hit test features
  80225. */
  80226. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80227. /**
  80228. * Triggered when new babylon (transformed) hit test results are available
  80229. */
  80230. onHitTestResultObservable: Observable<T[]>;
  80231. }
  80232. /**
  80233. * Options used for hit testing
  80234. */
  80235. export interface IWebXRLegacyHitTestOptions {
  80236. /**
  80237. * Only test when user interacted with the scene. Default - hit test every frame
  80238. */
  80239. testOnPointerDownOnly?: boolean;
  80240. /**
  80241. * The node to use to transform the local results to world coordinates
  80242. */
  80243. worldParentNode?: TransformNode;
  80244. }
  80245. /**
  80246. * Interface defining the babylon result of raycasting/hit-test
  80247. */
  80248. export interface IWebXRLegacyHitResult {
  80249. /**
  80250. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80251. */
  80252. transformationMatrix: Matrix;
  80253. /**
  80254. * The native hit test result
  80255. */
  80256. xrHitResult: XRHitResult | XRHitTestResult;
  80257. }
  80258. /**
  80259. * The currently-working hit-test module.
  80260. * Hit test (or Ray-casting) is used to interact with the real world.
  80261. * For further information read here - https://github.com/immersive-web/hit-test
  80262. */
  80263. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80264. /**
  80265. * options to use when constructing this feature
  80266. */
  80267. readonly options: IWebXRLegacyHitTestOptions;
  80268. private _direction;
  80269. private _mat;
  80270. private _onSelectEnabled;
  80271. private _origin;
  80272. /**
  80273. * The module's name
  80274. */
  80275. static readonly Name: string;
  80276. /**
  80277. * The (Babylon) version of this module.
  80278. * This is an integer representing the implementation version.
  80279. * This number does not correspond to the WebXR specs version
  80280. */
  80281. static readonly Version: number;
  80282. /**
  80283. * Populated with the last native XR Hit Results
  80284. */
  80285. lastNativeXRHitResults: XRHitResult[];
  80286. /**
  80287. * Triggered when new babylon (transformed) hit test results are available
  80288. */
  80289. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80290. /**
  80291. * Creates a new instance of the (legacy version) hit test feature
  80292. * @param _xrSessionManager an instance of WebXRSessionManager
  80293. * @param options options to use when constructing this feature
  80294. */
  80295. constructor(_xrSessionManager: WebXRSessionManager,
  80296. /**
  80297. * options to use when constructing this feature
  80298. */
  80299. options?: IWebXRLegacyHitTestOptions);
  80300. /**
  80301. * execute a hit test with an XR Ray
  80302. *
  80303. * @param xrSession a native xrSession that will execute this hit test
  80304. * @param xrRay the ray (position and direction) to use for ray-casting
  80305. * @param referenceSpace native XR reference space to use for the hit-test
  80306. * @param filter filter function that will filter the results
  80307. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80308. */
  80309. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80310. /**
  80311. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80312. * @param event the (select) event to use to select with
  80313. * @param referenceSpace the reference space to use for this hit test
  80314. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80315. */
  80316. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80317. /**
  80318. * attach this feature
  80319. * Will usually be called by the features manager
  80320. *
  80321. * @returns true if successful.
  80322. */
  80323. attach(): boolean;
  80324. /**
  80325. * detach this feature.
  80326. * Will usually be called by the features manager
  80327. *
  80328. * @returns true if successful.
  80329. */
  80330. detach(): boolean;
  80331. /**
  80332. * Dispose this feature and all of the resources attached
  80333. */
  80334. dispose(): void;
  80335. protected _onXRFrame(frame: XRFrame): void;
  80336. private _onHitTestResults;
  80337. private _onSelect;
  80338. }
  80339. }
  80340. declare module "babylonjs/XR/features/WebXRHitTest" {
  80341. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80342. import { Observable } from "babylonjs/Misc/observable";
  80343. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80344. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80345. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80346. /**
  80347. * Options used for hit testing (version 2)
  80348. */
  80349. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80350. /**
  80351. * Do not create a permanent hit test. Will usually be used when only
  80352. * transient inputs are needed.
  80353. */
  80354. disablePermanentHitTest?: boolean;
  80355. /**
  80356. * Enable transient (for example touch-based) hit test inspections
  80357. */
  80358. enableTransientHitTest?: boolean;
  80359. /**
  80360. * Offset ray for the permanent hit test
  80361. */
  80362. offsetRay?: Vector3;
  80363. /**
  80364. * Offset ray for the transient hit test
  80365. */
  80366. transientOffsetRay?: Vector3;
  80367. /**
  80368. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80369. */
  80370. useReferenceSpace?: boolean;
  80371. /**
  80372. * Override the default entity type(s) of the hit-test result
  80373. */
  80374. entityTypes?: XRHitTestTrackableType[];
  80375. }
  80376. /**
  80377. * Interface defining the babylon result of hit-test
  80378. */
  80379. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80380. /**
  80381. * The input source that generated this hit test (if transient)
  80382. */
  80383. inputSource?: XRInputSource;
  80384. /**
  80385. * Is this a transient hit test
  80386. */
  80387. isTransient?: boolean;
  80388. /**
  80389. * Position of the hit test result
  80390. */
  80391. position: Vector3;
  80392. /**
  80393. * Rotation of the hit test result
  80394. */
  80395. rotationQuaternion: Quaternion;
  80396. /**
  80397. * The native hit test result
  80398. */
  80399. xrHitResult: XRHitTestResult;
  80400. }
  80401. /**
  80402. * The currently-working hit-test module.
  80403. * Hit test (or Ray-casting) is used to interact with the real world.
  80404. * For further information read here - https://github.com/immersive-web/hit-test
  80405. *
  80406. * Tested on chrome (mobile) 80.
  80407. */
  80408. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80409. /**
  80410. * options to use when constructing this feature
  80411. */
  80412. readonly options: IWebXRHitTestOptions;
  80413. private _tmpMat;
  80414. private _tmpPos;
  80415. private _tmpQuat;
  80416. private _transientXrHitTestSource;
  80417. private _xrHitTestSource;
  80418. private initHitTestSource;
  80419. /**
  80420. * The module's name
  80421. */
  80422. static readonly Name: string;
  80423. /**
  80424. * The (Babylon) version of this module.
  80425. * This is an integer representing the implementation version.
  80426. * This number does not correspond to the WebXR specs version
  80427. */
  80428. static readonly Version: number;
  80429. /**
  80430. * When set to true, each hit test will have its own position/rotation objects
  80431. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80432. * the developers will clone them or copy them as they see fit.
  80433. */
  80434. autoCloneTransformation: boolean;
  80435. /**
  80436. * Triggered when new babylon (transformed) hit test results are available
  80437. * Note - this will be called when results come back from the device. It can be an empty array!!
  80438. */
  80439. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80440. /**
  80441. * Use this to temporarily pause hit test checks.
  80442. */
  80443. paused: boolean;
  80444. /**
  80445. * Creates a new instance of the hit test feature
  80446. * @param _xrSessionManager an instance of WebXRSessionManager
  80447. * @param options options to use when constructing this feature
  80448. */
  80449. constructor(_xrSessionManager: WebXRSessionManager,
  80450. /**
  80451. * options to use when constructing this feature
  80452. */
  80453. options?: IWebXRHitTestOptions);
  80454. /**
  80455. * attach this feature
  80456. * Will usually be called by the features manager
  80457. *
  80458. * @returns true if successful.
  80459. */
  80460. attach(): boolean;
  80461. /**
  80462. * detach this feature.
  80463. * Will usually be called by the features manager
  80464. *
  80465. * @returns true if successful.
  80466. */
  80467. detach(): boolean;
  80468. /**
  80469. * Dispose this feature and all of the resources attached
  80470. */
  80471. dispose(): void;
  80472. protected _onXRFrame(frame: XRFrame): void;
  80473. private _processWebXRHitTestResult;
  80474. }
  80475. }
  80476. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80477. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80478. import { Observable } from "babylonjs/Misc/observable";
  80479. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80481. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80482. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80483. /**
  80484. * Configuration options of the anchor system
  80485. */
  80486. export interface IWebXRAnchorSystemOptions {
  80487. /**
  80488. * a node that will be used to convert local to world coordinates
  80489. */
  80490. worldParentNode?: TransformNode;
  80491. /**
  80492. * If set to true a reference of the created anchors will be kept until the next session starts
  80493. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80494. */
  80495. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80496. }
  80497. /**
  80498. * A babylon container for an XR Anchor
  80499. */
  80500. export interface IWebXRAnchor {
  80501. /**
  80502. * A babylon-assigned ID for this anchor
  80503. */
  80504. id: number;
  80505. /**
  80506. * Transformation matrix to apply to an object attached to this anchor
  80507. */
  80508. transformationMatrix: Matrix;
  80509. /**
  80510. * The native anchor object
  80511. */
  80512. xrAnchor: XRAnchor;
  80513. /**
  80514. * if defined, this object will be constantly updated by the anchor's position and rotation
  80515. */
  80516. attachedNode?: TransformNode;
  80517. /**
  80518. * Remove this anchor from the scene
  80519. */
  80520. remove(): void;
  80521. }
  80522. /**
  80523. * An implementation of the anchor system for WebXR.
  80524. * For further information see https://github.com/immersive-web/anchors/
  80525. */
  80526. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80527. private _options;
  80528. private _lastFrameDetected;
  80529. private _trackedAnchors;
  80530. private _referenceSpaceForFrameAnchors;
  80531. private _futureAnchors;
  80532. /**
  80533. * The module's name
  80534. */
  80535. static readonly Name: string;
  80536. /**
  80537. * The (Babylon) version of this module.
  80538. * This is an integer representing the implementation version.
  80539. * This number does not correspond to the WebXR specs version
  80540. */
  80541. static readonly Version: number;
  80542. /**
  80543. * Observers registered here will be executed when a new anchor was added to the session
  80544. */
  80545. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80546. /**
  80547. * Observers registered here will be executed when an anchor was removed from the session
  80548. */
  80549. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80550. /**
  80551. * Observers registered here will be executed when an existing anchor updates
  80552. * This can execute N times every frame
  80553. */
  80554. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80555. /**
  80556. * Set the reference space to use for anchor creation, when not using a hit test.
  80557. * Will default to the session's reference space if not defined
  80558. */
  80559. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80560. /**
  80561. * constructs a new anchor system
  80562. * @param _xrSessionManager an instance of WebXRSessionManager
  80563. * @param _options configuration object for this feature
  80564. */
  80565. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80566. private _tmpVector;
  80567. private _tmpQuaternion;
  80568. private _populateTmpTransformation;
  80569. /**
  80570. * Create a new anchor point using a hit test result at a specific point in the scene
  80571. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80572. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80573. *
  80574. * @param hitTestResult The hit test result to use for this anchor creation
  80575. * @param position an optional position offset for this anchor
  80576. * @param rotationQuaternion an optional rotation offset for this anchor
  80577. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80578. */
  80579. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80580. /**
  80581. * Add a new anchor at a specific position and rotation
  80582. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80583. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80584. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80585. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80586. *
  80587. * @param position the position in which to add an anchor
  80588. * @param rotationQuaternion an optional rotation for the anchor transformation
  80589. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80590. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80591. */
  80592. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80593. /**
  80594. * Get the list of anchors currently being tracked by the system
  80595. */
  80596. get anchors(): IWebXRAnchor[];
  80597. /**
  80598. * detach this feature.
  80599. * Will usually be called by the features manager
  80600. *
  80601. * @returns true if successful.
  80602. */
  80603. detach(): boolean;
  80604. /**
  80605. * Dispose this feature and all of the resources attached
  80606. */
  80607. dispose(): void;
  80608. protected _onXRFrame(frame: XRFrame): void;
  80609. /**
  80610. * avoiding using Array.find for global support.
  80611. * @param xrAnchor the plane to find in the array
  80612. */
  80613. private _findIndexInAnchorArray;
  80614. private _updateAnchorWithXRFrame;
  80615. private _createAnchorAtTransformation;
  80616. }
  80617. }
  80618. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80620. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80621. import { Observable } from "babylonjs/Misc/observable";
  80622. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80623. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80624. /**
  80625. * Options used in the plane detector module
  80626. */
  80627. export interface IWebXRPlaneDetectorOptions {
  80628. /**
  80629. * The node to use to transform the local results to world coordinates
  80630. */
  80631. worldParentNode?: TransformNode;
  80632. /**
  80633. * If set to true a reference of the created planes will be kept until the next session starts
  80634. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80635. */
  80636. doNotRemovePlanesOnSessionEnded?: boolean;
  80637. }
  80638. /**
  80639. * A babylon interface for a WebXR plane.
  80640. * A Plane is actually a polygon, built from N points in space
  80641. *
  80642. * Supported in chrome 79, not supported in canary 81 ATM
  80643. */
  80644. export interface IWebXRPlane {
  80645. /**
  80646. * a babylon-assigned ID for this polygon
  80647. */
  80648. id: number;
  80649. /**
  80650. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80651. */
  80652. polygonDefinition: Array<Vector3>;
  80653. /**
  80654. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80655. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80656. */
  80657. transformationMatrix: Matrix;
  80658. /**
  80659. * the native xr-plane object
  80660. */
  80661. xrPlane: XRPlane;
  80662. }
  80663. /**
  80664. * The plane detector is used to detect planes in the real world when in AR
  80665. * For more information see https://github.com/immersive-web/real-world-geometry/
  80666. */
  80667. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80668. private _options;
  80669. private _detectedPlanes;
  80670. private _enabled;
  80671. private _lastFrameDetected;
  80672. /**
  80673. * The module's name
  80674. */
  80675. static readonly Name: string;
  80676. /**
  80677. * The (Babylon) version of this module.
  80678. * This is an integer representing the implementation version.
  80679. * This number does not correspond to the WebXR specs version
  80680. */
  80681. static readonly Version: number;
  80682. /**
  80683. * Observers registered here will be executed when a new plane was added to the session
  80684. */
  80685. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80686. /**
  80687. * Observers registered here will be executed when a plane is no longer detected in the session
  80688. */
  80689. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80690. /**
  80691. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80692. * This can execute N times every frame
  80693. */
  80694. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80695. /**
  80696. * construct a new Plane Detector
  80697. * @param _xrSessionManager an instance of xr Session manager
  80698. * @param _options configuration to use when constructing this feature
  80699. */
  80700. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80701. /**
  80702. * detach this feature.
  80703. * Will usually be called by the features manager
  80704. *
  80705. * @returns true if successful.
  80706. */
  80707. detach(): boolean;
  80708. /**
  80709. * Dispose this feature and all of the resources attached
  80710. */
  80711. dispose(): void;
  80712. /**
  80713. * Check if the needed objects are defined.
  80714. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80715. */
  80716. isCompatible(): boolean;
  80717. protected _onXRFrame(frame: XRFrame): void;
  80718. private _init;
  80719. private _updatePlaneWithXRPlane;
  80720. /**
  80721. * avoiding using Array.find for global support.
  80722. * @param xrPlane the plane to find in the array
  80723. */
  80724. private findIndexInPlaneArray;
  80725. }
  80726. }
  80727. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80730. import { Observable } from "babylonjs/Misc/observable";
  80731. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80732. /**
  80733. * Options interface for the background remover plugin
  80734. */
  80735. export interface IWebXRBackgroundRemoverOptions {
  80736. /**
  80737. * Further background meshes to disable when entering AR
  80738. */
  80739. backgroundMeshes?: AbstractMesh[];
  80740. /**
  80741. * flags to configure the removal of the environment helper.
  80742. * If not set, the entire background will be removed. If set, flags should be set as well.
  80743. */
  80744. environmentHelperRemovalFlags?: {
  80745. /**
  80746. * Should the skybox be removed (default false)
  80747. */
  80748. skyBox?: boolean;
  80749. /**
  80750. * Should the ground be removed (default false)
  80751. */
  80752. ground?: boolean;
  80753. };
  80754. /**
  80755. * don't disable the environment helper
  80756. */
  80757. ignoreEnvironmentHelper?: boolean;
  80758. }
  80759. /**
  80760. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80761. */
  80762. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80763. /**
  80764. * read-only options to be used in this module
  80765. */
  80766. readonly options: IWebXRBackgroundRemoverOptions;
  80767. /**
  80768. * The module's name
  80769. */
  80770. static readonly Name: string;
  80771. /**
  80772. * The (Babylon) version of this module.
  80773. * This is an integer representing the implementation version.
  80774. * This number does not correspond to the WebXR specs version
  80775. */
  80776. static readonly Version: number;
  80777. /**
  80778. * registered observers will be triggered when the background state changes
  80779. */
  80780. onBackgroundStateChangedObservable: Observable<boolean>;
  80781. /**
  80782. * constructs a new background remover module
  80783. * @param _xrSessionManager the session manager for this module
  80784. * @param options read-only options to be used in this module
  80785. */
  80786. constructor(_xrSessionManager: WebXRSessionManager,
  80787. /**
  80788. * read-only options to be used in this module
  80789. */
  80790. options?: IWebXRBackgroundRemoverOptions);
  80791. /**
  80792. * attach this feature
  80793. * Will usually be called by the features manager
  80794. *
  80795. * @returns true if successful.
  80796. */
  80797. attach(): boolean;
  80798. /**
  80799. * detach this feature.
  80800. * Will usually be called by the features manager
  80801. *
  80802. * @returns true if successful.
  80803. */
  80804. detach(): boolean;
  80805. /**
  80806. * Dispose this feature and all of the resources attached
  80807. */
  80808. dispose(): void;
  80809. protected _onXRFrame(_xrFrame: XRFrame): void;
  80810. private _setBackgroundState;
  80811. }
  80812. }
  80813. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80814. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80815. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80816. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80817. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80818. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80819. import { Nullable } from "babylonjs/types";
  80820. /**
  80821. * Options for the controller physics feature
  80822. */
  80823. export class IWebXRControllerPhysicsOptions {
  80824. /**
  80825. * Should the headset get its own impostor
  80826. */
  80827. enableHeadsetImpostor?: boolean;
  80828. /**
  80829. * Optional parameters for the headset impostor
  80830. */
  80831. headsetImpostorParams?: {
  80832. /**
  80833. * The type of impostor to create. Default is sphere
  80834. */
  80835. impostorType: number;
  80836. /**
  80837. * the size of the impostor. Defaults to 10cm
  80838. */
  80839. impostorSize?: number | {
  80840. width: number;
  80841. height: number;
  80842. depth: number;
  80843. };
  80844. /**
  80845. * Friction definitions
  80846. */
  80847. friction?: number;
  80848. /**
  80849. * Restitution
  80850. */
  80851. restitution?: number;
  80852. };
  80853. /**
  80854. * The physics properties of the future impostors
  80855. */
  80856. physicsProperties?: {
  80857. /**
  80858. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80859. * Note that this requires a physics engine that supports mesh impostors!
  80860. */
  80861. useControllerMesh?: boolean;
  80862. /**
  80863. * The type of impostor to create. Default is sphere
  80864. */
  80865. impostorType?: number;
  80866. /**
  80867. * the size of the impostor. Defaults to 10cm
  80868. */
  80869. impostorSize?: number | {
  80870. width: number;
  80871. height: number;
  80872. depth: number;
  80873. };
  80874. /**
  80875. * Friction definitions
  80876. */
  80877. friction?: number;
  80878. /**
  80879. * Restitution
  80880. */
  80881. restitution?: number;
  80882. };
  80883. /**
  80884. * the xr input to use with this pointer selection
  80885. */
  80886. xrInput: WebXRInput;
  80887. }
  80888. /**
  80889. * Add physics impostor to your webxr controllers,
  80890. * including naive calculation of their linear and angular velocity
  80891. */
  80892. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80893. private readonly _options;
  80894. private _attachController;
  80895. private _controllers;
  80896. private _debugMode;
  80897. private _delta;
  80898. private _headsetImpostor?;
  80899. private _headsetMesh?;
  80900. private _lastTimestamp;
  80901. private _tmpQuaternion;
  80902. private _tmpVector;
  80903. /**
  80904. * The module's name
  80905. */
  80906. static readonly Name: string;
  80907. /**
  80908. * The (Babylon) version of this module.
  80909. * This is an integer representing the implementation version.
  80910. * This number does not correspond to the webxr specs version
  80911. */
  80912. static readonly Version: number;
  80913. /**
  80914. * Construct a new Controller Physics Feature
  80915. * @param _xrSessionManager the corresponding xr session manager
  80916. * @param _options options to create this feature with
  80917. */
  80918. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80919. /**
  80920. * @hidden
  80921. * enable debugging - will show console outputs and the impostor mesh
  80922. */
  80923. _enablePhysicsDebug(): void;
  80924. /**
  80925. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80926. * @param xrController the controller to add
  80927. */
  80928. addController(xrController: WebXRInputSource): void;
  80929. /**
  80930. * attach this feature
  80931. * Will usually be called by the features manager
  80932. *
  80933. * @returns true if successful.
  80934. */
  80935. attach(): boolean;
  80936. /**
  80937. * detach this feature.
  80938. * Will usually be called by the features manager
  80939. *
  80940. * @returns true if successful.
  80941. */
  80942. detach(): boolean;
  80943. /**
  80944. * Get the headset impostor, if enabled
  80945. * @returns the impostor
  80946. */
  80947. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80948. /**
  80949. * Get the physics impostor of a specific controller.
  80950. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80951. * @param controller the controller or the controller id of which to get the impostor
  80952. * @returns the impostor or null
  80953. */
  80954. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80955. /**
  80956. * Update the physics properties provided in the constructor
  80957. * @param newProperties the new properties object
  80958. */
  80959. setPhysicsProperties(newProperties: {
  80960. impostorType?: number;
  80961. impostorSize?: number | {
  80962. width: number;
  80963. height: number;
  80964. depth: number;
  80965. };
  80966. friction?: number;
  80967. restitution?: number;
  80968. }): void;
  80969. protected _onXRFrame(_xrFrame: any): void;
  80970. private _detachController;
  80971. }
  80972. }
  80973. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80974. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80975. import { Observable } from "babylonjs/Misc/observable";
  80976. import { Vector3 } from "babylonjs/Maths/math.vector";
  80977. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80978. /**
  80979. * A babylon interface for a "WebXR" feature point.
  80980. * Represents the position and confidence value of a given feature point.
  80981. */
  80982. export interface IWebXRFeaturePoint {
  80983. /**
  80984. * Represents the position of the feature point in world space.
  80985. */
  80986. position: Vector3;
  80987. /**
  80988. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80989. */
  80990. confidenceValue: number;
  80991. }
  80992. /**
  80993. * The feature point system is used to detect feature points from real world geometry.
  80994. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80995. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80996. */
  80997. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80998. private _enabled;
  80999. private _featurePointCloud;
  81000. /**
  81001. * The module's name
  81002. */
  81003. static readonly Name: string;
  81004. /**
  81005. * The (Babylon) version of this module.
  81006. * This is an integer representing the implementation version.
  81007. * This number does not correspond to the WebXR specs version
  81008. */
  81009. static readonly Version: number;
  81010. /**
  81011. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  81012. * Will notify the observers about which feature points have been added.
  81013. */
  81014. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  81015. /**
  81016. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  81017. * Will notify the observers about which feature points have been updated.
  81018. */
  81019. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  81020. /**
  81021. * The current feature point cloud maintained across frames.
  81022. */
  81023. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  81024. /**
  81025. * construct the feature point system
  81026. * @param _xrSessionManager an instance of xr Session manager
  81027. */
  81028. constructor(_xrSessionManager: WebXRSessionManager);
  81029. /**
  81030. * Detach this feature.
  81031. * Will usually be called by the features manager
  81032. *
  81033. * @returns true if successful.
  81034. */
  81035. detach(): boolean;
  81036. /**
  81037. * Dispose this feature and all of the resources attached
  81038. */
  81039. dispose(): void;
  81040. /**
  81041. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  81042. */
  81043. protected _onXRFrame(frame: XRFrame): void;
  81044. /**
  81045. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  81046. */
  81047. private _init;
  81048. }
  81049. }
  81050. declare module "babylonjs/XR/features/WebXRHandTracking" {
  81051. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  81052. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  81053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81054. import { Mesh } from "babylonjs/Meshes/mesh";
  81055. import { WebXRInput } from "babylonjs/XR/webXRInput";
  81056. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  81057. import { Nullable } from "babylonjs/types";
  81058. import { IDisposable } from "babylonjs/scene";
  81059. import { Observable } from "babylonjs/Misc/observable";
  81060. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  81061. /**
  81062. * Configuration interface for the hand tracking feature
  81063. */
  81064. export interface IWebXRHandTrackingOptions {
  81065. /**
  81066. * The xrInput that will be used as source for new hands
  81067. */
  81068. xrInput: WebXRInput;
  81069. /**
  81070. * Configuration object for the joint meshes
  81071. */
  81072. jointMeshes?: {
  81073. /**
  81074. * Should the meshes created be invisible (defaults to false)
  81075. */
  81076. invisible?: boolean;
  81077. /**
  81078. * A source mesh to be used to create instances. Defaults to a sphere.
  81079. * This mesh will be the source for all other (25) meshes.
  81080. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  81081. */
  81082. sourceMesh?: Mesh;
  81083. /**
  81084. * This function will be called after a mesh was created for a specific joint.
  81085. * Using this function you can either manipulate the instance or return a new mesh.
  81086. * When returning a new mesh the instance created before will be disposed
  81087. */
  81088. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  81089. /**
  81090. * Should the source mesh stay visible. Defaults to false
  81091. */
  81092. keepOriginalVisible?: boolean;
  81093. /**
  81094. * Scale factor for all instances (defaults to 2)
  81095. */
  81096. scaleFactor?: number;
  81097. /**
  81098. * Should each instance have its own physics impostor
  81099. */
  81100. enablePhysics?: boolean;
  81101. /**
  81102. * If enabled, override default physics properties
  81103. */
  81104. physicsProps?: {
  81105. friction?: number;
  81106. restitution?: number;
  81107. impostorType?: number;
  81108. };
  81109. /**
  81110. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  81111. */
  81112. disableDefaultHandMesh?: boolean;
  81113. /**
  81114. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  81115. */
  81116. handMeshes?: {
  81117. right: AbstractMesh;
  81118. left: AbstractMesh;
  81119. };
  81120. /**
  81121. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  81122. */
  81123. rigMapping?: {
  81124. right: string[];
  81125. left: string[];
  81126. };
  81127. };
  81128. }
  81129. /**
  81130. * Parts of the hands divided to writs and finger names
  81131. */
  81132. export const enum HandPart {
  81133. /**
  81134. * HandPart - Wrist
  81135. */
  81136. WRIST = "wrist",
  81137. /**
  81138. * HandPart - The THumb
  81139. */
  81140. THUMB = "thumb",
  81141. /**
  81142. * HandPart - Index finger
  81143. */
  81144. INDEX = "index",
  81145. /**
  81146. * HandPart - Middle finger
  81147. */
  81148. MIDDLE = "middle",
  81149. /**
  81150. * HandPart - Ring finger
  81151. */
  81152. RING = "ring",
  81153. /**
  81154. * HandPart - Little finger
  81155. */
  81156. LITTLE = "little"
  81157. }
  81158. /**
  81159. * Representing a single hand (with its corresponding native XRHand object)
  81160. */
  81161. export class WebXRHand implements IDisposable {
  81162. /** the controller to which the hand correlates */
  81163. readonly xrController: WebXRInputSource;
  81164. /** the meshes to be used to track the hand joints */
  81165. readonly trackedMeshes: AbstractMesh[];
  81166. private _handMesh?;
  81167. private _rigMapping?;
  81168. private _scene;
  81169. private _defaultHandMesh;
  81170. private _transformNodeMapping;
  81171. /**
  81172. * Hand-parts definition (key is HandPart)
  81173. */
  81174. handPartsDefinition: {
  81175. [key: string]: number[];
  81176. };
  81177. /**
  81178. * Populate the HandPartsDefinition object.
  81179. * This is called as a side effect since certain browsers don't have XRHand defined.
  81180. */
  81181. private generateHandPartsDefinition;
  81182. /**
  81183. * Construct a new hand object
  81184. * @param xrController the controller to which the hand correlates
  81185. * @param trackedMeshes the meshes to be used to track the hand joints
  81186. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  81187. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  81188. * @param disableDefaultHandMesh should the default mesh creation be disabled
  81189. */
  81190. constructor(
  81191. /** the controller to which the hand correlates */
  81192. xrController: WebXRInputSource,
  81193. /** the meshes to be used to track the hand joints */
  81194. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  81195. /**
  81196. * Update this hand from the latest xr frame
  81197. * @param xrFrame xrFrame to update from
  81198. * @param referenceSpace The current viewer reference space
  81199. * @param scaleFactor optional scale factor for the meshes
  81200. */
  81201. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  81202. /**
  81203. * Get meshes of part of the hand
  81204. * @param part the part of hand to get
  81205. * @returns An array of meshes that correlate to the hand part requested
  81206. */
  81207. getHandPartMeshes(part: HandPart): AbstractMesh[];
  81208. /**
  81209. * Dispose this Hand object
  81210. */
  81211. dispose(): void;
  81212. private _generateDefaultHandMesh;
  81213. }
  81214. /**
  81215. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  81216. */
  81217. export class WebXRHandTracking extends WebXRAbstractFeature {
  81218. /**
  81219. * options to use when constructing this feature
  81220. */
  81221. readonly options: IWebXRHandTrackingOptions;
  81222. private static _idCounter;
  81223. /**
  81224. * The module's name
  81225. */
  81226. static readonly Name: string;
  81227. /**
  81228. * The (Babylon) version of this module.
  81229. * This is an integer representing the implementation version.
  81230. * This number does not correspond to the WebXR specs version
  81231. */
  81232. static readonly Version: number;
  81233. /**
  81234. * This observable will notify registered observers when a new hand object was added and initialized
  81235. */
  81236. onHandAddedObservable: Observable<WebXRHand>;
  81237. /**
  81238. * This observable will notify its observers right before the hand object is disposed
  81239. */
  81240. onHandRemovedObservable: Observable<WebXRHand>;
  81241. private _hands;
  81242. /**
  81243. * Creates a new instance of the hit test feature
  81244. * @param _xrSessionManager an instance of WebXRSessionManager
  81245. * @param options options to use when constructing this feature
  81246. */
  81247. constructor(_xrSessionManager: WebXRSessionManager,
  81248. /**
  81249. * options to use when constructing this feature
  81250. */
  81251. options: IWebXRHandTrackingOptions);
  81252. /**
  81253. * Check if the needed objects are defined.
  81254. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81255. */
  81256. isCompatible(): boolean;
  81257. /**
  81258. * attach this feature
  81259. * Will usually be called by the features manager
  81260. *
  81261. * @returns true if successful.
  81262. */
  81263. attach(): boolean;
  81264. /**
  81265. * detach this feature.
  81266. * Will usually be called by the features manager
  81267. *
  81268. * @returns true if successful.
  81269. */
  81270. detach(): boolean;
  81271. /**
  81272. * Dispose this feature and all of the resources attached
  81273. */
  81274. dispose(): void;
  81275. /**
  81276. * Get the hand object according to the controller id
  81277. * @param controllerId the controller id to which we want to get the hand
  81278. * @returns null if not found or the WebXRHand object if found
  81279. */
  81280. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81281. /**
  81282. * Get a hand object according to the requested handedness
  81283. * @param handedness the handedness to request
  81284. * @returns null if not found or the WebXRHand object if found
  81285. */
  81286. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81287. protected _onXRFrame(_xrFrame: XRFrame): void;
  81288. private _attachHand;
  81289. private _detachHand;
  81290. }
  81291. }
  81292. declare module "babylonjs/XR/features/index" {
  81293. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81294. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81295. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81296. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81297. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81298. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81299. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81300. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81301. export * from "babylonjs/XR/features/WebXRHitTest";
  81302. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81303. export * from "babylonjs/XR/features/WebXRHandTracking";
  81304. }
  81305. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81306. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81308. import { Scene } from "babylonjs/scene";
  81309. /**
  81310. * The motion controller class for all microsoft mixed reality controllers
  81311. */
  81312. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81313. protected readonly _mapping: {
  81314. defaultButton: {
  81315. valueNodeName: string;
  81316. unpressedNodeName: string;
  81317. pressedNodeName: string;
  81318. };
  81319. defaultAxis: {
  81320. valueNodeName: string;
  81321. minNodeName: string;
  81322. maxNodeName: string;
  81323. };
  81324. buttons: {
  81325. "xr-standard-trigger": {
  81326. rootNodeName: string;
  81327. componentProperty: string;
  81328. states: string[];
  81329. };
  81330. "xr-standard-squeeze": {
  81331. rootNodeName: string;
  81332. componentProperty: string;
  81333. states: string[];
  81334. };
  81335. "xr-standard-touchpad": {
  81336. rootNodeName: string;
  81337. labelAnchorNodeName: string;
  81338. touchPointNodeName: string;
  81339. };
  81340. "xr-standard-thumbstick": {
  81341. rootNodeName: string;
  81342. componentProperty: string;
  81343. states: string[];
  81344. };
  81345. };
  81346. axes: {
  81347. "xr-standard-touchpad": {
  81348. "x-axis": {
  81349. rootNodeName: string;
  81350. };
  81351. "y-axis": {
  81352. rootNodeName: string;
  81353. };
  81354. };
  81355. "xr-standard-thumbstick": {
  81356. "x-axis": {
  81357. rootNodeName: string;
  81358. };
  81359. "y-axis": {
  81360. rootNodeName: string;
  81361. };
  81362. };
  81363. };
  81364. };
  81365. /**
  81366. * The base url used to load the left and right controller models
  81367. */
  81368. static MODEL_BASE_URL: string;
  81369. /**
  81370. * The name of the left controller model file
  81371. */
  81372. static MODEL_LEFT_FILENAME: string;
  81373. /**
  81374. * The name of the right controller model file
  81375. */
  81376. static MODEL_RIGHT_FILENAME: string;
  81377. profileId: string;
  81378. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81379. protected _getFilenameAndPath(): {
  81380. filename: string;
  81381. path: string;
  81382. };
  81383. protected _getModelLoadingConstraints(): boolean;
  81384. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81386. protected _updateModel(): void;
  81387. }
  81388. }
  81389. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81390. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81392. import { Scene } from "babylonjs/scene";
  81393. /**
  81394. * The motion controller class for oculus touch (quest, rift).
  81395. * This class supports legacy mapping as well the standard xr mapping
  81396. */
  81397. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81398. private _forceLegacyControllers;
  81399. private _modelRootNode;
  81400. /**
  81401. * The base url used to load the left and right controller models
  81402. */
  81403. static MODEL_BASE_URL: string;
  81404. /**
  81405. * The name of the left controller model file
  81406. */
  81407. static MODEL_LEFT_FILENAME: string;
  81408. /**
  81409. * The name of the right controller model file
  81410. */
  81411. static MODEL_RIGHT_FILENAME: string;
  81412. /**
  81413. * Base Url for the Quest controller model.
  81414. */
  81415. static QUEST_MODEL_BASE_URL: string;
  81416. profileId: string;
  81417. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81418. protected _getFilenameAndPath(): {
  81419. filename: string;
  81420. path: string;
  81421. };
  81422. protected _getModelLoadingConstraints(): boolean;
  81423. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81424. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81425. protected _updateModel(): void;
  81426. /**
  81427. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81428. * between the touch and touch 2.
  81429. */
  81430. private _isQuest;
  81431. }
  81432. }
  81433. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81434. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81435. import { Scene } from "babylonjs/scene";
  81436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81437. /**
  81438. * The motion controller class for the standard HTC-Vive controllers
  81439. */
  81440. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81441. private _modelRootNode;
  81442. /**
  81443. * The base url used to load the left and right controller models
  81444. */
  81445. static MODEL_BASE_URL: string;
  81446. /**
  81447. * File name for the controller model.
  81448. */
  81449. static MODEL_FILENAME: string;
  81450. profileId: string;
  81451. /**
  81452. * Create a new Vive motion controller object
  81453. * @param scene the scene to use to create this controller
  81454. * @param gamepadObject the corresponding gamepad object
  81455. * @param handedness the handedness of the controller
  81456. */
  81457. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  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. }
  81468. declare module "babylonjs/XR/motionController/index" {
  81469. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81470. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81471. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81472. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81473. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81474. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81475. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81476. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81477. }
  81478. declare module "babylonjs/XR/index" {
  81479. export * from "babylonjs/XR/webXRCamera";
  81480. export * from "babylonjs/XR/webXREnterExitUI";
  81481. export * from "babylonjs/XR/webXRExperienceHelper";
  81482. export * from "babylonjs/XR/webXRInput";
  81483. export * from "babylonjs/XR/webXRInputSource";
  81484. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81485. export * from "babylonjs/XR/webXRTypes";
  81486. export * from "babylonjs/XR/webXRSessionManager";
  81487. export * from "babylonjs/XR/webXRDefaultExperience";
  81488. export * from "babylonjs/XR/webXRFeaturesManager";
  81489. export * from "babylonjs/XR/features/index";
  81490. export * from "babylonjs/XR/motionController/index";
  81491. }
  81492. declare module "babylonjs/index" {
  81493. export * from "babylonjs/abstractScene";
  81494. export * from "babylonjs/Actions/index";
  81495. export * from "babylonjs/Animations/index";
  81496. export * from "babylonjs/assetContainer";
  81497. export * from "babylonjs/Audio/index";
  81498. export * from "babylonjs/Behaviors/index";
  81499. export * from "babylonjs/Bones/index";
  81500. export * from "babylonjs/Cameras/index";
  81501. export * from "babylonjs/Collisions/index";
  81502. export * from "babylonjs/Culling/index";
  81503. export * from "babylonjs/Debug/index";
  81504. export * from "babylonjs/DeviceInput/index";
  81505. export * from "babylonjs/Engines/index";
  81506. export * from "babylonjs/Events/index";
  81507. export * from "babylonjs/Gamepads/index";
  81508. export * from "babylonjs/Gizmos/index";
  81509. export * from "babylonjs/Helpers/index";
  81510. export * from "babylonjs/Instrumentation/index";
  81511. export * from "babylonjs/Layers/index";
  81512. export * from "babylonjs/LensFlares/index";
  81513. export * from "babylonjs/Lights/index";
  81514. export * from "babylonjs/Loading/index";
  81515. export * from "babylonjs/Materials/index";
  81516. export * from "babylonjs/Maths/index";
  81517. export * from "babylonjs/Meshes/index";
  81518. export * from "babylonjs/Morph/index";
  81519. export * from "babylonjs/Navigation/index";
  81520. export * from "babylonjs/node";
  81521. export * from "babylonjs/Offline/index";
  81522. export * from "babylonjs/Particles/index";
  81523. export * from "babylonjs/Physics/index";
  81524. export * from "babylonjs/PostProcesses/index";
  81525. export * from "babylonjs/Probes/index";
  81526. export * from "babylonjs/Rendering/index";
  81527. export * from "babylonjs/scene";
  81528. export * from "babylonjs/sceneComponent";
  81529. export * from "babylonjs/Sprites/index";
  81530. export * from "babylonjs/States/index";
  81531. export * from "babylonjs/Misc/index";
  81532. export * from "babylonjs/XR/index";
  81533. export * from "babylonjs/types";
  81534. }
  81535. declare module "babylonjs/Animations/pathCursor" {
  81536. import { Vector3 } from "babylonjs/Maths/math.vector";
  81537. import { Path2 } from "babylonjs/Maths/math.path";
  81538. /**
  81539. * A cursor which tracks a point on a path
  81540. */
  81541. export class PathCursor {
  81542. private path;
  81543. /**
  81544. * Stores path cursor callbacks for when an onchange event is triggered
  81545. */
  81546. private _onchange;
  81547. /**
  81548. * The value of the path cursor
  81549. */
  81550. value: number;
  81551. /**
  81552. * The animation array of the path cursor
  81553. */
  81554. animations: Animation[];
  81555. /**
  81556. * Initializes the path cursor
  81557. * @param path The path to track
  81558. */
  81559. constructor(path: Path2);
  81560. /**
  81561. * Gets the cursor point on the path
  81562. * @returns A point on the path cursor at the cursor location
  81563. */
  81564. getPoint(): Vector3;
  81565. /**
  81566. * Moves the cursor ahead by the step amount
  81567. * @param step The amount to move the cursor forward
  81568. * @returns This path cursor
  81569. */
  81570. moveAhead(step?: number): PathCursor;
  81571. /**
  81572. * Moves the cursor behind by the step amount
  81573. * @param step The amount to move the cursor back
  81574. * @returns This path cursor
  81575. */
  81576. moveBack(step?: number): PathCursor;
  81577. /**
  81578. * Moves the cursor by the step amount
  81579. * If the step amount is greater than one, an exception is thrown
  81580. * @param step The amount to move the cursor
  81581. * @returns This path cursor
  81582. */
  81583. move(step: number): PathCursor;
  81584. /**
  81585. * Ensures that the value is limited between zero and one
  81586. * @returns This path cursor
  81587. */
  81588. private ensureLimits;
  81589. /**
  81590. * Runs onchange callbacks on change (used by the animation engine)
  81591. * @returns This path cursor
  81592. */
  81593. private raiseOnChange;
  81594. /**
  81595. * Executes a function on change
  81596. * @param f A path cursor onchange callback
  81597. * @returns This path cursor
  81598. */
  81599. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81600. }
  81601. }
  81602. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81603. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81604. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81605. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81606. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81607. }
  81608. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81609. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81610. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81611. }
  81612. declare module "babylonjs/Engines/Processors/index" {
  81613. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81614. export * from "babylonjs/Engines/Processors/Expressions/index";
  81615. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81616. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81617. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81618. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81619. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81620. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81621. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81622. }
  81623. declare module "babylonjs/Legacy/legacy" {
  81624. import * as Babylon from "babylonjs/index";
  81625. export * from "babylonjs/index";
  81626. }
  81627. declare module "babylonjs/Shaders/blur.fragment" {
  81628. /** @hidden */
  81629. export var blurPixelShader: {
  81630. name: string;
  81631. shader: string;
  81632. };
  81633. }
  81634. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81635. /** @hidden */
  81636. export var pointCloudVertexDeclaration: {
  81637. name: string;
  81638. shader: string;
  81639. };
  81640. }
  81641. declare module "babylonjs" {
  81642. export * from "babylonjs/Legacy/legacy";
  81643. }
  81644. declare module BABYLON {
  81645. /** Alias type for value that can be null */
  81646. export type Nullable<T> = T | null;
  81647. /**
  81648. * Alias type for number that are floats
  81649. * @ignorenaming
  81650. */
  81651. export type float = number;
  81652. /**
  81653. * Alias type for number that are doubles.
  81654. * @ignorenaming
  81655. */
  81656. export type double = number;
  81657. /**
  81658. * Alias type for number that are integer
  81659. * @ignorenaming
  81660. */
  81661. export type int = number;
  81662. /** Alias type for number array or Float32Array */
  81663. export type FloatArray = number[] | Float32Array;
  81664. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81665. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81666. /**
  81667. * Alias for types that can be used by a Buffer or VertexBuffer.
  81668. */
  81669. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81670. /**
  81671. * Alias type for primitive types
  81672. * @ignorenaming
  81673. */
  81674. type Primitive = undefined | null | boolean | string | number | Function;
  81675. /**
  81676. * Type modifier to make all the properties of an object Readonly
  81677. */
  81678. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81679. /**
  81680. * Type modifier to make all the properties of an object Readonly recursively
  81681. */
  81682. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81683. /**
  81684. * Type modifier to make object properties readonly.
  81685. */
  81686. export type DeepImmutableObject<T> = {
  81687. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81688. };
  81689. /** @hidden */
  81690. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * A class serves as a medium between the observable and its observers
  81696. */
  81697. export class EventState {
  81698. /**
  81699. * Create a new EventState
  81700. * @param mask defines the mask associated with this state
  81701. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81702. * @param target defines the original target of the state
  81703. * @param currentTarget defines the current target of the state
  81704. */
  81705. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81706. /**
  81707. * Initialize the current event state
  81708. * @param mask defines the mask associated with this state
  81709. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81710. * @param target defines the original target of the state
  81711. * @param currentTarget defines the current target of the state
  81712. * @returns the current event state
  81713. */
  81714. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81715. /**
  81716. * An Observer can set this property to true to prevent subsequent observers of being notified
  81717. */
  81718. skipNextObservers: boolean;
  81719. /**
  81720. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81721. */
  81722. mask: number;
  81723. /**
  81724. * The object that originally notified the event
  81725. */
  81726. target?: any;
  81727. /**
  81728. * The current object in the bubbling phase
  81729. */
  81730. currentTarget?: any;
  81731. /**
  81732. * This will be populated with the return value of the last function that was executed.
  81733. * If it is the first function in the callback chain it will be the event data.
  81734. */
  81735. lastReturnValue?: any;
  81736. /**
  81737. * User defined information that will be sent to observers
  81738. */
  81739. userInfo?: any;
  81740. }
  81741. /**
  81742. * Represent an Observer registered to a given Observable object.
  81743. */
  81744. export class Observer<T> {
  81745. /**
  81746. * Defines the callback to call when the observer is notified
  81747. */
  81748. callback: (eventData: T, eventState: EventState) => void;
  81749. /**
  81750. * Defines the mask of the observer (used to filter notifications)
  81751. */
  81752. mask: number;
  81753. /**
  81754. * Defines the current scope used to restore the JS context
  81755. */
  81756. scope: any;
  81757. /** @hidden */
  81758. _willBeUnregistered: boolean;
  81759. /**
  81760. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81761. */
  81762. unregisterOnNextCall: boolean;
  81763. /**
  81764. * Creates a new observer
  81765. * @param callback defines the callback to call when the observer is notified
  81766. * @param mask defines the mask of the observer (used to filter notifications)
  81767. * @param scope defines the current scope used to restore the JS context
  81768. */
  81769. constructor(
  81770. /**
  81771. * Defines the callback to call when the observer is notified
  81772. */
  81773. callback: (eventData: T, eventState: EventState) => void,
  81774. /**
  81775. * Defines the mask of the observer (used to filter notifications)
  81776. */
  81777. mask: number,
  81778. /**
  81779. * Defines the current scope used to restore the JS context
  81780. */
  81781. scope?: any);
  81782. }
  81783. /**
  81784. * Represent a list of observers registered to multiple Observables object.
  81785. */
  81786. export class MultiObserver<T> {
  81787. private _observers;
  81788. private _observables;
  81789. /**
  81790. * Release associated resources
  81791. */
  81792. dispose(): void;
  81793. /**
  81794. * Raise a callback when one of the observable will notify
  81795. * @param observables defines a list of observables to watch
  81796. * @param callback defines the callback to call on notification
  81797. * @param mask defines the mask used to filter notifications
  81798. * @param scope defines the current scope used to restore the JS context
  81799. * @returns the new MultiObserver
  81800. */
  81801. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81802. }
  81803. /**
  81804. * The Observable class is a simple implementation of the Observable pattern.
  81805. *
  81806. * 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.
  81807. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81808. * 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).
  81809. * 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.
  81810. */
  81811. export class Observable<T> {
  81812. private _observers;
  81813. private _eventState;
  81814. private _onObserverAdded;
  81815. /**
  81816. * Gets the list of observers
  81817. */
  81818. get observers(): Array<Observer<T>>;
  81819. /**
  81820. * Creates a new observable
  81821. * @param onObserverAdded defines a callback to call when a new observer is added
  81822. */
  81823. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81824. /**
  81825. * Create a new Observer with the specified callback
  81826. * @param callback the callback that will be executed for that Observer
  81827. * @param mask the mask used to filter observers
  81828. * @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.
  81829. * @param scope optional scope for the callback to be called from
  81830. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81831. * @returns the new observer created for the callback
  81832. */
  81833. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81834. /**
  81835. * Create a new Observer with the specified callback and unregisters after the next notification
  81836. * @param callback the callback that will be executed for that Observer
  81837. * @returns the new observer created for the callback
  81838. */
  81839. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81840. /**
  81841. * Remove an Observer from the Observable object
  81842. * @param observer the instance of the Observer to remove
  81843. * @returns false if it doesn't belong to this Observable
  81844. */
  81845. remove(observer: Nullable<Observer<T>>): boolean;
  81846. /**
  81847. * Remove a callback from the Observable object
  81848. * @param callback the callback to remove
  81849. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81850. * @returns false if it doesn't belong to this Observable
  81851. */
  81852. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81853. private _deferUnregister;
  81854. private _remove;
  81855. /**
  81856. * Moves the observable to the top of the observer list making it get called first when notified
  81857. * @param observer the observer to move
  81858. */
  81859. makeObserverTopPriority(observer: Observer<T>): void;
  81860. /**
  81861. * Moves the observable to the bottom of the observer list making it get called last when notified
  81862. * @param observer the observer to move
  81863. */
  81864. makeObserverBottomPriority(observer: Observer<T>): void;
  81865. /**
  81866. * Notify all Observers by calling their respective callback with the given data
  81867. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81868. * @param eventData defines the data to send to all observers
  81869. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81870. * @param target defines the original target of the state
  81871. * @param currentTarget defines the current target of the state
  81872. * @param userInfo defines any user info to send to observers
  81873. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81874. */
  81875. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81876. /**
  81877. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81878. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81879. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81880. * and it is crucial that all callbacks will be executed.
  81881. * The order of the callbacks is kept, callbacks are not executed parallel.
  81882. *
  81883. * @param eventData The data to be sent to each callback
  81884. * @param mask is used to filter observers defaults to -1
  81885. * @param target defines the callback target (see EventState)
  81886. * @param currentTarget defines he current object in the bubbling phase
  81887. * @param userInfo defines any user info to send to observers
  81888. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81889. */
  81890. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81891. /**
  81892. * Notify a specific observer
  81893. * @param observer defines the observer to notify
  81894. * @param eventData defines the data to be sent to each callback
  81895. * @param mask is used to filter observers defaults to -1
  81896. */
  81897. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81898. /**
  81899. * Gets a boolean indicating if the observable has at least one observer
  81900. * @returns true is the Observable has at least one Observer registered
  81901. */
  81902. hasObservers(): boolean;
  81903. /**
  81904. * Clear the list of observers
  81905. */
  81906. clear(): void;
  81907. /**
  81908. * Clone the current observable
  81909. * @returns a new observable
  81910. */
  81911. clone(): Observable<T>;
  81912. /**
  81913. * Does this observable handles observer registered with a given mask
  81914. * @param mask defines the mask to be tested
  81915. * @return whether or not one observer registered with the given mask is handeled
  81916. **/
  81917. hasSpecificMask(mask?: number): boolean;
  81918. }
  81919. }
  81920. declare module BABYLON {
  81921. /**
  81922. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81923. * Babylon.js
  81924. */
  81925. export class DomManagement {
  81926. /**
  81927. * Checks if the window object exists
  81928. * @returns true if the window object exists
  81929. */
  81930. static IsWindowObjectExist(): boolean;
  81931. /**
  81932. * Checks if the navigator object exists
  81933. * @returns true if the navigator object exists
  81934. */
  81935. static IsNavigatorAvailable(): boolean;
  81936. /**
  81937. * Check if the document object exists
  81938. * @returns true if the document object exists
  81939. */
  81940. static IsDocumentAvailable(): boolean;
  81941. /**
  81942. * Extracts text content from a DOM element hierarchy
  81943. * @param element defines the root element
  81944. * @returns a string
  81945. */
  81946. static GetDOMTextContent(element: HTMLElement): string;
  81947. }
  81948. }
  81949. declare module BABYLON {
  81950. /**
  81951. * Logger used througouht the application to allow configuration of
  81952. * the log level required for the messages.
  81953. */
  81954. export class Logger {
  81955. /**
  81956. * No log
  81957. */
  81958. static readonly NoneLogLevel: number;
  81959. /**
  81960. * Only message logs
  81961. */
  81962. static readonly MessageLogLevel: number;
  81963. /**
  81964. * Only warning logs
  81965. */
  81966. static readonly WarningLogLevel: number;
  81967. /**
  81968. * Only error logs
  81969. */
  81970. static readonly ErrorLogLevel: number;
  81971. /**
  81972. * All logs
  81973. */
  81974. static readonly AllLogLevel: number;
  81975. private static _LogCache;
  81976. /**
  81977. * Gets a value indicating the number of loading errors
  81978. * @ignorenaming
  81979. */
  81980. static errorsCount: number;
  81981. /**
  81982. * Callback called when a new log is added
  81983. */
  81984. static OnNewCacheEntry: (entry: string) => void;
  81985. private static _AddLogEntry;
  81986. private static _FormatMessage;
  81987. private static _LogDisabled;
  81988. private static _LogEnabled;
  81989. private static _WarnDisabled;
  81990. private static _WarnEnabled;
  81991. private static _ErrorDisabled;
  81992. private static _ErrorEnabled;
  81993. /**
  81994. * Log a message to the console
  81995. */
  81996. static Log: (message: string) => void;
  81997. /**
  81998. * Write a warning message to the console
  81999. */
  82000. static Warn: (message: string) => void;
  82001. /**
  82002. * Write an error message to the console
  82003. */
  82004. static Error: (message: string) => void;
  82005. /**
  82006. * Gets current log cache (list of logs)
  82007. */
  82008. static get LogCache(): string;
  82009. /**
  82010. * Clears the log cache
  82011. */
  82012. static ClearLogCache(): void;
  82013. /**
  82014. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  82015. */
  82016. static set LogLevels(level: number);
  82017. }
  82018. }
  82019. declare module BABYLON {
  82020. /** @hidden */
  82021. export class _TypeStore {
  82022. /** @hidden */
  82023. static RegisteredTypes: {
  82024. [key: string]: Object;
  82025. };
  82026. /** @hidden */
  82027. static GetClass(fqdn: string): any;
  82028. }
  82029. }
  82030. declare module BABYLON {
  82031. /**
  82032. * Helper to manipulate strings
  82033. */
  82034. export class StringTools {
  82035. /**
  82036. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  82037. * @param str Source string
  82038. * @param suffix Suffix to search for in the source string
  82039. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82040. */
  82041. static EndsWith(str: string, suffix: string): boolean;
  82042. /**
  82043. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  82044. * @param str Source string
  82045. * @param suffix Suffix to search for in the source string
  82046. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82047. */
  82048. static StartsWith(str: string, suffix: string): boolean;
  82049. /**
  82050. * Decodes a buffer into a string
  82051. * @param buffer The buffer to decode
  82052. * @returns The decoded string
  82053. */
  82054. static Decode(buffer: Uint8Array | Uint16Array): string;
  82055. /**
  82056. * Encode a buffer to a base64 string
  82057. * @param buffer defines the buffer to encode
  82058. * @returns the encoded string
  82059. */
  82060. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  82061. /**
  82062. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  82063. * @param num the number to convert and pad
  82064. * @param length the expected length of the string
  82065. * @returns the padded string
  82066. */
  82067. static PadNumber(num: number, length: number): string;
  82068. }
  82069. }
  82070. declare module BABYLON {
  82071. /**
  82072. * Class containing a set of static utilities functions for deep copy.
  82073. */
  82074. export class DeepCopier {
  82075. /**
  82076. * Tries to copy an object by duplicating every property
  82077. * @param source defines the source object
  82078. * @param destination defines the target object
  82079. * @param doNotCopyList defines a list of properties to avoid
  82080. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  82081. */
  82082. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  82083. }
  82084. }
  82085. declare module BABYLON {
  82086. /**
  82087. * Class containing a set of static utilities functions for precision date
  82088. */
  82089. export class PrecisionDate {
  82090. /**
  82091. * Gets either window.performance.now() if supported or Date.now() else
  82092. */
  82093. static get Now(): number;
  82094. }
  82095. }
  82096. declare module BABYLON {
  82097. /** @hidden */
  82098. export class _DevTools {
  82099. static WarnImport(name: string): string;
  82100. }
  82101. }
  82102. declare module BABYLON {
  82103. /**
  82104. * Interface used to define the mechanism to get data from the network
  82105. */
  82106. export interface IWebRequest {
  82107. /**
  82108. * Returns client's response url
  82109. */
  82110. responseURL: string;
  82111. /**
  82112. * Returns client's status
  82113. */
  82114. status: number;
  82115. /**
  82116. * Returns client's status as a text
  82117. */
  82118. statusText: string;
  82119. }
  82120. }
  82121. declare module BABYLON {
  82122. /**
  82123. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  82124. */
  82125. export class WebRequest implements IWebRequest {
  82126. private readonly _xhr;
  82127. /**
  82128. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  82129. * i.e. when loading files, where the server/service expects an Authorization header
  82130. */
  82131. static CustomRequestHeaders: {
  82132. [key: string]: string;
  82133. };
  82134. /**
  82135. * Add callback functions in this array to update all the requests before they get sent to the network
  82136. */
  82137. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  82138. private _injectCustomRequestHeaders;
  82139. /**
  82140. * Gets or sets a function to be called when loading progress changes
  82141. */
  82142. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  82143. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  82144. /**
  82145. * Returns client's state
  82146. */
  82147. get readyState(): number;
  82148. /**
  82149. * Returns client's status
  82150. */
  82151. get status(): number;
  82152. /**
  82153. * Returns client's status as a text
  82154. */
  82155. get statusText(): string;
  82156. /**
  82157. * Returns client's response
  82158. */
  82159. get response(): any;
  82160. /**
  82161. * Returns client's response url
  82162. */
  82163. get responseURL(): string;
  82164. /**
  82165. * Returns client's response as text
  82166. */
  82167. get responseText(): string;
  82168. /**
  82169. * Gets or sets the expected response type
  82170. */
  82171. get responseType(): XMLHttpRequestResponseType;
  82172. set responseType(value: XMLHttpRequestResponseType);
  82173. /** @hidden */
  82174. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  82175. /** @hidden */
  82176. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  82177. /**
  82178. * Cancels any network activity
  82179. */
  82180. abort(): void;
  82181. /**
  82182. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  82183. * @param body defines an optional request body
  82184. */
  82185. send(body?: Document | BodyInit | null): void;
  82186. /**
  82187. * Sets the request method, request URL
  82188. * @param method defines the method to use (GET, POST, etc..)
  82189. * @param url defines the url to connect with
  82190. */
  82191. open(method: string, url: string): void;
  82192. /**
  82193. * Sets the value of a request header.
  82194. * @param name The name of the header whose value is to be set
  82195. * @param value The value to set as the body of the header
  82196. */
  82197. setRequestHeader(name: string, value: string): void;
  82198. /**
  82199. * Get the string containing the text of a particular header's value.
  82200. * @param name The name of the header
  82201. * @returns The string containing the text of the given header name
  82202. */
  82203. getResponseHeader(name: string): Nullable<string>;
  82204. }
  82205. }
  82206. declare module BABYLON {
  82207. /**
  82208. * File request interface
  82209. */
  82210. export interface IFileRequest {
  82211. /**
  82212. * Raised when the request is complete (success or error).
  82213. */
  82214. onCompleteObservable: Observable<IFileRequest>;
  82215. /**
  82216. * Aborts the request for a file.
  82217. */
  82218. abort: () => void;
  82219. }
  82220. }
  82221. declare module BABYLON {
  82222. /**
  82223. * Define options used to create a render target texture
  82224. */
  82225. export class RenderTargetCreationOptions {
  82226. /**
  82227. * Specifies is mipmaps must be generated
  82228. */
  82229. generateMipMaps?: boolean;
  82230. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82231. generateDepthBuffer?: boolean;
  82232. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82233. generateStencilBuffer?: boolean;
  82234. /** Defines texture type (int by default) */
  82235. type?: number;
  82236. /** Defines sampling mode (trilinear by default) */
  82237. samplingMode?: number;
  82238. /** Defines format (RGBA by default) */
  82239. format?: number;
  82240. }
  82241. }
  82242. declare module BABYLON {
  82243. /** Defines the cross module used constants to avoid circular dependncies */
  82244. export class Constants {
  82245. /** Defines that alpha blending is disabled */
  82246. static readonly ALPHA_DISABLE: number;
  82247. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82248. static readonly ALPHA_ADD: number;
  82249. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82250. static readonly ALPHA_COMBINE: number;
  82251. /** Defines that alpha blending is DEST - SRC * DEST */
  82252. static readonly ALPHA_SUBTRACT: number;
  82253. /** Defines that alpha blending is SRC * DEST */
  82254. static readonly ALPHA_MULTIPLY: number;
  82255. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82256. static readonly ALPHA_MAXIMIZED: number;
  82257. /** Defines that alpha blending is SRC + DEST */
  82258. static readonly ALPHA_ONEONE: number;
  82259. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82260. static readonly ALPHA_PREMULTIPLIED: number;
  82261. /**
  82262. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82263. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82264. */
  82265. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82266. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82267. static readonly ALPHA_INTERPOLATE: number;
  82268. /**
  82269. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82270. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82271. */
  82272. static readonly ALPHA_SCREENMODE: number;
  82273. /**
  82274. * Defines that alpha blending is SRC + DST
  82275. * Alpha will be set to SRC ALPHA + DST ALPHA
  82276. */
  82277. static readonly ALPHA_ONEONE_ONEONE: number;
  82278. /**
  82279. * Defines that alpha blending is SRC * DST ALPHA + DST
  82280. * Alpha will be set to 0
  82281. */
  82282. static readonly ALPHA_ALPHATOCOLOR: number;
  82283. /**
  82284. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82285. */
  82286. static readonly ALPHA_REVERSEONEMINUS: number;
  82287. /**
  82288. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82289. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82290. */
  82291. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82292. /**
  82293. * Defines that alpha blending is SRC + DST
  82294. * Alpha will be set to SRC ALPHA
  82295. */
  82296. static readonly ALPHA_ONEONE_ONEZERO: number;
  82297. /**
  82298. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82299. * Alpha will be set to DST ALPHA
  82300. */
  82301. static readonly ALPHA_EXCLUSION: number;
  82302. /** Defines that alpha blending equation a SUM */
  82303. static readonly ALPHA_EQUATION_ADD: number;
  82304. /** Defines that alpha blending equation a SUBSTRACTION */
  82305. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82306. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82307. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82308. /** Defines that alpha blending equation a MAX operation */
  82309. static readonly ALPHA_EQUATION_MAX: number;
  82310. /** Defines that alpha blending equation a MIN operation */
  82311. static readonly ALPHA_EQUATION_MIN: number;
  82312. /**
  82313. * Defines that alpha blending equation a DARKEN operation:
  82314. * It takes the min of the src and sums the alpha channels.
  82315. */
  82316. static readonly ALPHA_EQUATION_DARKEN: number;
  82317. /** Defines that the ressource is not delayed*/
  82318. static readonly DELAYLOADSTATE_NONE: number;
  82319. /** Defines that the ressource was successfully delay loaded */
  82320. static readonly DELAYLOADSTATE_LOADED: number;
  82321. /** Defines that the ressource is currently delay loading */
  82322. static readonly DELAYLOADSTATE_LOADING: number;
  82323. /** Defines that the ressource is delayed and has not started loading */
  82324. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82326. static readonly NEVER: number;
  82327. /** 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 */
  82328. static readonly ALWAYS: number;
  82329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82330. static readonly LESS: number;
  82331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82332. static readonly EQUAL: number;
  82333. /** 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 */
  82334. static readonly LEQUAL: number;
  82335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82336. static readonly GREATER: number;
  82337. /** 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 */
  82338. static readonly GEQUAL: number;
  82339. /** 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 */
  82340. static readonly NOTEQUAL: number;
  82341. /** Passed to stencilOperation to specify that stencil value must be kept */
  82342. static readonly KEEP: number;
  82343. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82344. static readonly REPLACE: number;
  82345. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82346. static readonly INCR: number;
  82347. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82348. static readonly DECR: number;
  82349. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82350. static readonly INVERT: number;
  82351. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82352. static readonly INCR_WRAP: number;
  82353. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82354. static readonly DECR_WRAP: number;
  82355. /** Texture is not repeating outside of 0..1 UVs */
  82356. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82357. /** Texture is repeating outside of 0..1 UVs */
  82358. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82359. /** Texture is repeating and mirrored */
  82360. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82361. /** ALPHA */
  82362. static readonly TEXTUREFORMAT_ALPHA: number;
  82363. /** LUMINANCE */
  82364. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82365. /** LUMINANCE_ALPHA */
  82366. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82367. /** RGB */
  82368. static readonly TEXTUREFORMAT_RGB: number;
  82369. /** RGBA */
  82370. static readonly TEXTUREFORMAT_RGBA: number;
  82371. /** RED */
  82372. static readonly TEXTUREFORMAT_RED: number;
  82373. /** RED (2nd reference) */
  82374. static readonly TEXTUREFORMAT_R: number;
  82375. /** RG */
  82376. static readonly TEXTUREFORMAT_RG: number;
  82377. /** RED_INTEGER */
  82378. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82379. /** RED_INTEGER (2nd reference) */
  82380. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82381. /** RG_INTEGER */
  82382. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82383. /** RGB_INTEGER */
  82384. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82385. /** RGBA_INTEGER */
  82386. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82387. /** UNSIGNED_BYTE */
  82388. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82389. /** UNSIGNED_BYTE (2nd reference) */
  82390. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82391. /** FLOAT */
  82392. static readonly TEXTURETYPE_FLOAT: number;
  82393. /** HALF_FLOAT */
  82394. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82395. /** BYTE */
  82396. static readonly TEXTURETYPE_BYTE: number;
  82397. /** SHORT */
  82398. static readonly TEXTURETYPE_SHORT: number;
  82399. /** UNSIGNED_SHORT */
  82400. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82401. /** INT */
  82402. static readonly TEXTURETYPE_INT: number;
  82403. /** UNSIGNED_INT */
  82404. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82405. /** UNSIGNED_SHORT_4_4_4_4 */
  82406. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82407. /** UNSIGNED_SHORT_5_5_5_1 */
  82408. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82409. /** UNSIGNED_SHORT_5_6_5 */
  82410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82411. /** UNSIGNED_INT_2_10_10_10_REV */
  82412. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82413. /** UNSIGNED_INT_24_8 */
  82414. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82415. /** UNSIGNED_INT_10F_11F_11F_REV */
  82416. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82417. /** UNSIGNED_INT_5_9_9_9_REV */
  82418. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82419. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82420. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82421. /** nearest is mag = nearest and min = nearest and no mip */
  82422. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82423. /** mag = nearest and min = nearest and mip = none */
  82424. static readonly TEXTURE_NEAREST_NEAREST: number;
  82425. /** Bilinear is mag = linear and min = linear and no mip */
  82426. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82427. /** mag = linear and min = linear and mip = none */
  82428. static readonly TEXTURE_LINEAR_LINEAR: number;
  82429. /** Trilinear is mag = linear and min = linear and mip = linear */
  82430. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82431. /** Trilinear is mag = linear and min = linear and mip = linear */
  82432. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82433. /** mag = nearest and min = nearest and mip = nearest */
  82434. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82435. /** mag = nearest and min = linear and mip = nearest */
  82436. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82437. /** mag = nearest and min = linear and mip = linear */
  82438. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82439. /** mag = nearest and min = linear and mip = none */
  82440. static readonly TEXTURE_NEAREST_LINEAR: number;
  82441. /** nearest is mag = nearest and min = nearest and mip = linear */
  82442. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82443. /** mag = linear and min = nearest and mip = nearest */
  82444. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82445. /** mag = linear and min = nearest and mip = linear */
  82446. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82447. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82448. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82449. /** mag = linear and min = nearest and mip = none */
  82450. static readonly TEXTURE_LINEAR_NEAREST: number;
  82451. /** Explicit coordinates mode */
  82452. static readonly TEXTURE_EXPLICIT_MODE: number;
  82453. /** Spherical coordinates mode */
  82454. static readonly TEXTURE_SPHERICAL_MODE: number;
  82455. /** Planar coordinates mode */
  82456. static readonly TEXTURE_PLANAR_MODE: number;
  82457. /** Cubic coordinates mode */
  82458. static readonly TEXTURE_CUBIC_MODE: number;
  82459. /** Projection coordinates mode */
  82460. static readonly TEXTURE_PROJECTION_MODE: number;
  82461. /** Skybox coordinates mode */
  82462. static readonly TEXTURE_SKYBOX_MODE: number;
  82463. /** Inverse Cubic coordinates mode */
  82464. static readonly TEXTURE_INVCUBIC_MODE: number;
  82465. /** Equirectangular coordinates mode */
  82466. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82467. /** Equirectangular Fixed coordinates mode */
  82468. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82469. /** Equirectangular Fixed Mirrored coordinates mode */
  82470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82471. /** Offline (baking) quality for texture filtering */
  82472. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82473. /** High quality for texture filtering */
  82474. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82475. /** Medium quality for texture filtering */
  82476. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82477. /** Low quality for texture filtering */
  82478. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82479. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82480. static readonly SCALEMODE_FLOOR: number;
  82481. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82482. static readonly SCALEMODE_NEAREST: number;
  82483. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82484. static readonly SCALEMODE_CEILING: number;
  82485. /**
  82486. * The dirty texture flag value
  82487. */
  82488. static readonly MATERIAL_TextureDirtyFlag: number;
  82489. /**
  82490. * The dirty light flag value
  82491. */
  82492. static readonly MATERIAL_LightDirtyFlag: number;
  82493. /**
  82494. * The dirty fresnel flag value
  82495. */
  82496. static readonly MATERIAL_FresnelDirtyFlag: number;
  82497. /**
  82498. * The dirty attribute flag value
  82499. */
  82500. static readonly MATERIAL_AttributesDirtyFlag: number;
  82501. /**
  82502. * The dirty misc flag value
  82503. */
  82504. static readonly MATERIAL_MiscDirtyFlag: number;
  82505. /**
  82506. * The dirty prepass flag value
  82507. */
  82508. static readonly MATERIAL_PrePassDirtyFlag: number;
  82509. /**
  82510. * The all dirty flag value
  82511. */
  82512. static readonly MATERIAL_AllDirtyFlag: number;
  82513. /**
  82514. * Returns the triangle fill mode
  82515. */
  82516. static readonly MATERIAL_TriangleFillMode: number;
  82517. /**
  82518. * Returns the wireframe mode
  82519. */
  82520. static readonly MATERIAL_WireFrameFillMode: number;
  82521. /**
  82522. * Returns the point fill mode
  82523. */
  82524. static readonly MATERIAL_PointFillMode: number;
  82525. /**
  82526. * Returns the point list draw mode
  82527. */
  82528. static readonly MATERIAL_PointListDrawMode: number;
  82529. /**
  82530. * Returns the line list draw mode
  82531. */
  82532. static readonly MATERIAL_LineListDrawMode: number;
  82533. /**
  82534. * Returns the line loop draw mode
  82535. */
  82536. static readonly MATERIAL_LineLoopDrawMode: number;
  82537. /**
  82538. * Returns the line strip draw mode
  82539. */
  82540. static readonly MATERIAL_LineStripDrawMode: number;
  82541. /**
  82542. * Returns the triangle strip draw mode
  82543. */
  82544. static readonly MATERIAL_TriangleStripDrawMode: number;
  82545. /**
  82546. * Returns the triangle fan draw mode
  82547. */
  82548. static readonly MATERIAL_TriangleFanDrawMode: number;
  82549. /**
  82550. * Stores the clock-wise side orientation
  82551. */
  82552. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82553. /**
  82554. * Stores the counter clock-wise side orientation
  82555. */
  82556. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82557. /**
  82558. * Nothing
  82559. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82560. */
  82561. static readonly ACTION_NothingTrigger: number;
  82562. /**
  82563. * On pick
  82564. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82565. */
  82566. static readonly ACTION_OnPickTrigger: number;
  82567. /**
  82568. * On left pick
  82569. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82570. */
  82571. static readonly ACTION_OnLeftPickTrigger: number;
  82572. /**
  82573. * On right pick
  82574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82575. */
  82576. static readonly ACTION_OnRightPickTrigger: number;
  82577. /**
  82578. * On center pick
  82579. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82580. */
  82581. static readonly ACTION_OnCenterPickTrigger: number;
  82582. /**
  82583. * On pick down
  82584. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82585. */
  82586. static readonly ACTION_OnPickDownTrigger: number;
  82587. /**
  82588. * On double pick
  82589. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82590. */
  82591. static readonly ACTION_OnDoublePickTrigger: number;
  82592. /**
  82593. * On pick up
  82594. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82595. */
  82596. static readonly ACTION_OnPickUpTrigger: number;
  82597. /**
  82598. * On pick out.
  82599. * This trigger will only be raised if you also declared a OnPickDown
  82600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82601. */
  82602. static readonly ACTION_OnPickOutTrigger: number;
  82603. /**
  82604. * On long press
  82605. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82606. */
  82607. static readonly ACTION_OnLongPressTrigger: number;
  82608. /**
  82609. * On pointer over
  82610. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82611. */
  82612. static readonly ACTION_OnPointerOverTrigger: number;
  82613. /**
  82614. * On pointer out
  82615. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82616. */
  82617. static readonly ACTION_OnPointerOutTrigger: number;
  82618. /**
  82619. * On every frame
  82620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82621. */
  82622. static readonly ACTION_OnEveryFrameTrigger: number;
  82623. /**
  82624. * On intersection enter
  82625. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82626. */
  82627. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82628. /**
  82629. * On intersection exit
  82630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82631. */
  82632. static readonly ACTION_OnIntersectionExitTrigger: number;
  82633. /**
  82634. * On key down
  82635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82636. */
  82637. static readonly ACTION_OnKeyDownTrigger: number;
  82638. /**
  82639. * On key up
  82640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82641. */
  82642. static readonly ACTION_OnKeyUpTrigger: number;
  82643. /**
  82644. * Billboard mode will only apply to Y axis
  82645. */
  82646. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82647. /**
  82648. * Billboard mode will apply to all axes
  82649. */
  82650. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82651. /**
  82652. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82653. */
  82654. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82655. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82656. * Test order :
  82657. * Is the bounding sphere outside the frustum ?
  82658. * If not, are the bounding box vertices outside the frustum ?
  82659. * It not, then the cullable object is in the frustum.
  82660. */
  82661. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82662. /** Culling strategy : Bounding Sphere Only.
  82663. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82664. * It's also less accurate than the standard because some not visible objects can still be selected.
  82665. * Test : is the bounding sphere outside the frustum ?
  82666. * If not, then the cullable object is in the frustum.
  82667. */
  82668. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82669. /** Culling strategy : Optimistic Inclusion.
  82670. * This in an inclusion test first, then the standard exclusion test.
  82671. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82672. * 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.
  82673. * Anyway, it's as accurate as the standard strategy.
  82674. * Test :
  82675. * Is the cullable object bounding sphere center in the frustum ?
  82676. * If not, apply the default culling strategy.
  82677. */
  82678. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82679. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82680. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82681. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82682. * 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.
  82683. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82684. * Test :
  82685. * Is the cullable object bounding sphere center in the frustum ?
  82686. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82687. */
  82688. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82689. /**
  82690. * No logging while loading
  82691. */
  82692. static readonly SCENELOADER_NO_LOGGING: number;
  82693. /**
  82694. * Minimal logging while loading
  82695. */
  82696. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82697. /**
  82698. * Summary logging while loading
  82699. */
  82700. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82701. /**
  82702. * Detailled logging while loading
  82703. */
  82704. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82705. /**
  82706. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82707. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82708. */
  82709. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82710. /**
  82711. * Constant used to retrieve the position texture index in the textures array in the prepass
  82712. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82713. */
  82714. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82715. /**
  82716. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82717. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82718. */
  82719. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82720. /**
  82721. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82722. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82723. */
  82724. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82725. /**
  82726. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82727. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82728. */
  82729. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82730. /**
  82731. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82732. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82733. */
  82734. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82735. /**
  82736. * Constant used to retrieve albedo index in the textures array in the prepass
  82737. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82738. */
  82739. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82740. }
  82741. }
  82742. declare module BABYLON {
  82743. /**
  82744. * This represents the required contract to create a new type of texture loader.
  82745. */
  82746. export interface IInternalTextureLoader {
  82747. /**
  82748. * Defines wether the loader supports cascade loading the different faces.
  82749. */
  82750. supportCascades: boolean;
  82751. /**
  82752. * This returns if the loader support the current file information.
  82753. * @param extension defines the file extension of the file being loaded
  82754. * @param mimeType defines the optional mime type of the file being loaded
  82755. * @returns true if the loader can load the specified file
  82756. */
  82757. canLoad(extension: string, mimeType?: string): boolean;
  82758. /**
  82759. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82760. * @param data contains the texture data
  82761. * @param texture defines the BabylonJS internal texture
  82762. * @param createPolynomials will be true if polynomials have been requested
  82763. * @param onLoad defines the callback to trigger once the texture is ready
  82764. * @param onError defines the callback to trigger in case of error
  82765. * @param options options to be passed to the loader
  82766. */
  82767. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82768. /**
  82769. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82770. * @param data contains the texture data
  82771. * @param texture defines the BabylonJS internal texture
  82772. * @param callback defines the method to call once ready to upload
  82773. * @param options options to be passed to the loader
  82774. */
  82775. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82776. }
  82777. }
  82778. declare module BABYLON {
  82779. /**
  82780. * Class used to store and describe the pipeline context associated with an effect
  82781. */
  82782. export interface IPipelineContext {
  82783. /**
  82784. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82785. */
  82786. isAsync: boolean;
  82787. /**
  82788. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82789. */
  82790. isReady: boolean;
  82791. /** @hidden */
  82792. _getVertexShaderCode(): string | null;
  82793. /** @hidden */
  82794. _getFragmentShaderCode(): string | null;
  82795. /** @hidden */
  82796. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82797. }
  82798. }
  82799. declare module BABYLON {
  82800. /**
  82801. * Class used to store gfx data (like WebGLBuffer)
  82802. */
  82803. export class DataBuffer {
  82804. /**
  82805. * Gets or sets the number of objects referencing this buffer
  82806. */
  82807. references: number;
  82808. /** Gets or sets the size of the underlying buffer */
  82809. capacity: number;
  82810. /**
  82811. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82812. */
  82813. is32Bits: boolean;
  82814. /**
  82815. * Gets the underlying buffer
  82816. */
  82817. get underlyingResource(): any;
  82818. }
  82819. }
  82820. declare module BABYLON {
  82821. /** @hidden */
  82822. export interface IShaderProcessor {
  82823. attributeProcessor?: (attribute: string) => string;
  82824. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82825. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82826. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82827. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82828. lineProcessor?: (line: string, isFragment: boolean) => string;
  82829. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82830. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82831. }
  82832. }
  82833. declare module BABYLON {
  82834. /** @hidden */
  82835. export interface ProcessingOptions {
  82836. defines: string[];
  82837. indexParameters: any;
  82838. isFragment: boolean;
  82839. shouldUseHighPrecisionShader: boolean;
  82840. supportsUniformBuffers: boolean;
  82841. shadersRepository: string;
  82842. includesShadersStore: {
  82843. [key: string]: string;
  82844. };
  82845. processor?: IShaderProcessor;
  82846. version: string;
  82847. platformName: string;
  82848. lookForClosingBracketForUniformBuffer?: boolean;
  82849. }
  82850. }
  82851. declare module BABYLON {
  82852. /** @hidden */
  82853. export class ShaderCodeNode {
  82854. line: string;
  82855. children: ShaderCodeNode[];
  82856. additionalDefineKey?: string;
  82857. additionalDefineValue?: string;
  82858. isValid(preprocessors: {
  82859. [key: string]: string;
  82860. }): boolean;
  82861. process(preprocessors: {
  82862. [key: string]: string;
  82863. }, options: ProcessingOptions): string;
  82864. }
  82865. }
  82866. declare module BABYLON {
  82867. /** @hidden */
  82868. export class ShaderCodeCursor {
  82869. private _lines;
  82870. lineIndex: number;
  82871. get currentLine(): string;
  82872. get canRead(): boolean;
  82873. set lines(value: string[]);
  82874. }
  82875. }
  82876. declare module BABYLON {
  82877. /** @hidden */
  82878. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82879. process(preprocessors: {
  82880. [key: string]: string;
  82881. }, options: ProcessingOptions): string;
  82882. }
  82883. }
  82884. declare module BABYLON {
  82885. /** @hidden */
  82886. export class ShaderDefineExpression {
  82887. isTrue(preprocessors: {
  82888. [key: string]: string;
  82889. }): boolean;
  82890. private static _OperatorPriority;
  82891. private static _Stack;
  82892. static postfixToInfix(postfix: string[]): string;
  82893. static infixToPostfix(infix: string): string[];
  82894. }
  82895. }
  82896. declare module BABYLON {
  82897. /** @hidden */
  82898. export class ShaderCodeTestNode extends ShaderCodeNode {
  82899. testExpression: ShaderDefineExpression;
  82900. isValid(preprocessors: {
  82901. [key: string]: string;
  82902. }): boolean;
  82903. }
  82904. }
  82905. declare module BABYLON {
  82906. /** @hidden */
  82907. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82908. define: string;
  82909. not: boolean;
  82910. constructor(define: string, not?: boolean);
  82911. isTrue(preprocessors: {
  82912. [key: string]: string;
  82913. }): boolean;
  82914. }
  82915. }
  82916. declare module BABYLON {
  82917. /** @hidden */
  82918. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82919. leftOperand: ShaderDefineExpression;
  82920. rightOperand: ShaderDefineExpression;
  82921. isTrue(preprocessors: {
  82922. [key: string]: string;
  82923. }): boolean;
  82924. }
  82925. }
  82926. declare module BABYLON {
  82927. /** @hidden */
  82928. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82929. leftOperand: ShaderDefineExpression;
  82930. rightOperand: ShaderDefineExpression;
  82931. isTrue(preprocessors: {
  82932. [key: string]: string;
  82933. }): boolean;
  82934. }
  82935. }
  82936. declare module BABYLON {
  82937. /** @hidden */
  82938. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82939. define: string;
  82940. operand: string;
  82941. testValue: string;
  82942. constructor(define: string, operand: string, testValue: string);
  82943. isTrue(preprocessors: {
  82944. [key: string]: string;
  82945. }): boolean;
  82946. }
  82947. }
  82948. declare module BABYLON {
  82949. /**
  82950. * Class used to enable access to offline support
  82951. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82952. */
  82953. export interface IOfflineProvider {
  82954. /**
  82955. * Gets a boolean indicating if scene must be saved in the database
  82956. */
  82957. enableSceneOffline: boolean;
  82958. /**
  82959. * Gets a boolean indicating if textures must be saved in the database
  82960. */
  82961. enableTexturesOffline: boolean;
  82962. /**
  82963. * Open the offline support and make it available
  82964. * @param successCallback defines the callback to call on success
  82965. * @param errorCallback defines the callback to call on error
  82966. */
  82967. open(successCallback: () => void, errorCallback: () => void): void;
  82968. /**
  82969. * Loads an image from the offline support
  82970. * @param url defines the url to load from
  82971. * @param image defines the target DOM image
  82972. */
  82973. loadImage(url: string, image: HTMLImageElement): void;
  82974. /**
  82975. * Loads a file from offline support
  82976. * @param url defines the URL to load from
  82977. * @param sceneLoaded defines a callback to call on success
  82978. * @param progressCallBack defines a callback to call when progress changed
  82979. * @param errorCallback defines a callback to call on error
  82980. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82981. */
  82982. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82983. }
  82984. }
  82985. declare module BABYLON {
  82986. /**
  82987. * Class used to help managing file picking and drag'n'drop
  82988. * File Storage
  82989. */
  82990. export class FilesInputStore {
  82991. /**
  82992. * List of files ready to be loaded
  82993. */
  82994. static FilesToLoad: {
  82995. [key: string]: File;
  82996. };
  82997. }
  82998. }
  82999. declare module BABYLON {
  83000. /**
  83001. * Class used to define a retry strategy when error happens while loading assets
  83002. */
  83003. export class RetryStrategy {
  83004. /**
  83005. * Function used to defines an exponential back off strategy
  83006. * @param maxRetries defines the maximum number of retries (3 by default)
  83007. * @param baseInterval defines the interval between retries
  83008. * @returns the strategy function to use
  83009. */
  83010. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  83011. }
  83012. }
  83013. declare module BABYLON {
  83014. /**
  83015. * @ignore
  83016. * Application error to support additional information when loading a file
  83017. */
  83018. export abstract class BaseError extends Error {
  83019. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  83020. }
  83021. }
  83022. declare module BABYLON {
  83023. /** @ignore */
  83024. export class LoadFileError extends BaseError {
  83025. request?: WebRequest;
  83026. file?: File;
  83027. /**
  83028. * Creates a new LoadFileError
  83029. * @param message defines the message of the error
  83030. * @param request defines the optional web request
  83031. * @param file defines the optional file
  83032. */
  83033. constructor(message: string, object?: WebRequest | File);
  83034. }
  83035. /** @ignore */
  83036. export class RequestFileError extends BaseError {
  83037. request: WebRequest;
  83038. /**
  83039. * Creates a new LoadFileError
  83040. * @param message defines the message of the error
  83041. * @param request defines the optional web request
  83042. */
  83043. constructor(message: string, request: WebRequest);
  83044. }
  83045. /** @ignore */
  83046. export class ReadFileError extends BaseError {
  83047. file: File;
  83048. /**
  83049. * Creates a new ReadFileError
  83050. * @param message defines the message of the error
  83051. * @param file defines the optional file
  83052. */
  83053. constructor(message: string, file: File);
  83054. }
  83055. /**
  83056. * @hidden
  83057. */
  83058. export class FileTools {
  83059. /**
  83060. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  83061. */
  83062. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  83063. /**
  83064. * Gets or sets the base URL to use to load assets
  83065. */
  83066. static BaseUrl: string;
  83067. /**
  83068. * Default behaviour for cors in the application.
  83069. * It can be a string if the expected behavior is identical in the entire app.
  83070. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  83071. */
  83072. static CorsBehavior: string | ((url: string | string[]) => string);
  83073. /**
  83074. * Gets or sets a function used to pre-process url before using them to load assets
  83075. */
  83076. static PreprocessUrl: (url: string) => string;
  83077. /**
  83078. * Removes unwanted characters from an url
  83079. * @param url defines the url to clean
  83080. * @returns the cleaned url
  83081. */
  83082. private static _CleanUrl;
  83083. /**
  83084. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  83085. * @param url define the url we are trying
  83086. * @param element define the dom element where to configure the cors policy
  83087. */
  83088. static SetCorsBehavior(url: string | string[], element: {
  83089. crossOrigin: string | null;
  83090. }): void;
  83091. /**
  83092. * Loads an image as an HTMLImageElement.
  83093. * @param input url string, ArrayBuffer, or Blob to load
  83094. * @param onLoad callback called when the image successfully loads
  83095. * @param onError callback called when the image fails to load
  83096. * @param offlineProvider offline provider for caching
  83097. * @param mimeType optional mime type
  83098. * @returns the HTMLImageElement of the loaded image
  83099. */
  83100. 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>;
  83101. /**
  83102. * Reads a file from a File object
  83103. * @param file defines the file to load
  83104. * @param onSuccess defines the callback to call when data is loaded
  83105. * @param onProgress defines the callback to call during loading process
  83106. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  83107. * @param onError defines the callback to call when an error occurs
  83108. * @returns a file request object
  83109. */
  83110. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  83111. /**
  83112. * Loads a file from a url
  83113. * @param url url to load
  83114. * @param onSuccess callback called when the file successfully loads
  83115. * @param onProgress callback called while file is loading (if the server supports this mode)
  83116. * @param offlineProvider defines the offline provider for caching
  83117. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83118. * @param onError callback called when the file fails to load
  83119. * @returns a file request object
  83120. */
  83121. 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;
  83122. /**
  83123. * Loads a file
  83124. * @param url url to load
  83125. * @param onSuccess callback called when the file successfully loads
  83126. * @param onProgress callback called while file is loading (if the server supports this mode)
  83127. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83128. * @param onError callback called when the file fails to load
  83129. * @param onOpened callback called when the web request is opened
  83130. * @returns a file request object
  83131. */
  83132. 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;
  83133. /**
  83134. * Checks if the loaded document was accessed via `file:`-Protocol.
  83135. * @returns boolean
  83136. */
  83137. static IsFileURL(): boolean;
  83138. }
  83139. }
  83140. declare module BABYLON {
  83141. /** @hidden */
  83142. export class ShaderProcessor {
  83143. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  83144. private static _ProcessPrecision;
  83145. private static _ExtractOperation;
  83146. private static _BuildSubExpression;
  83147. private static _BuildExpression;
  83148. private static _MoveCursorWithinIf;
  83149. private static _MoveCursor;
  83150. private static _EvaluatePreProcessors;
  83151. private static _PreparePreProcessors;
  83152. private static _ProcessShaderConversion;
  83153. private static _ProcessIncludes;
  83154. /**
  83155. * Loads a file from a url
  83156. * @param url url to load
  83157. * @param onSuccess callback called when the file successfully loads
  83158. * @param onProgress callback called while file is loading (if the server supports this mode)
  83159. * @param offlineProvider defines the offline provider for caching
  83160. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83161. * @param onError callback called when the file fails to load
  83162. * @returns a file request object
  83163. * @hidden
  83164. */
  83165. 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;
  83166. }
  83167. }
  83168. declare module BABYLON {
  83169. /**
  83170. * @hidden
  83171. */
  83172. export interface IColor4Like {
  83173. r: float;
  83174. g: float;
  83175. b: float;
  83176. a: float;
  83177. }
  83178. /**
  83179. * @hidden
  83180. */
  83181. export interface IColor3Like {
  83182. r: float;
  83183. g: float;
  83184. b: float;
  83185. }
  83186. /**
  83187. * @hidden
  83188. */
  83189. export interface IVector4Like {
  83190. x: float;
  83191. y: float;
  83192. z: float;
  83193. w: float;
  83194. }
  83195. /**
  83196. * @hidden
  83197. */
  83198. export interface IVector3Like {
  83199. x: float;
  83200. y: float;
  83201. z: float;
  83202. }
  83203. /**
  83204. * @hidden
  83205. */
  83206. export interface IVector2Like {
  83207. x: float;
  83208. y: float;
  83209. }
  83210. /**
  83211. * @hidden
  83212. */
  83213. export interface IMatrixLike {
  83214. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83215. updateFlag: int;
  83216. }
  83217. /**
  83218. * @hidden
  83219. */
  83220. export interface IViewportLike {
  83221. x: float;
  83222. y: float;
  83223. width: float;
  83224. height: float;
  83225. }
  83226. /**
  83227. * @hidden
  83228. */
  83229. export interface IPlaneLike {
  83230. normal: IVector3Like;
  83231. d: float;
  83232. normalize(): void;
  83233. }
  83234. }
  83235. declare module BABYLON {
  83236. /**
  83237. * Interface used to define common properties for effect fallbacks
  83238. */
  83239. export interface IEffectFallbacks {
  83240. /**
  83241. * Removes the defines that should be removed when falling back.
  83242. * @param currentDefines defines the current define statements for the shader.
  83243. * @param effect defines the current effect we try to compile
  83244. * @returns The resulting defines with defines of the current rank removed.
  83245. */
  83246. reduce(currentDefines: string, effect: Effect): string;
  83247. /**
  83248. * Removes the fallback from the bound mesh.
  83249. */
  83250. unBindMesh(): void;
  83251. /**
  83252. * Checks to see if more fallbacks are still availible.
  83253. */
  83254. hasMoreFallbacks: boolean;
  83255. }
  83256. }
  83257. declare module BABYLON {
  83258. /**
  83259. * Interface for the size containing width and height
  83260. */
  83261. export interface ISize {
  83262. /**
  83263. * Width
  83264. */
  83265. width: number;
  83266. /**
  83267. * Heighht
  83268. */
  83269. height: number;
  83270. }
  83271. /**
  83272. * Size containing widht and height
  83273. */
  83274. export class Size implements ISize {
  83275. /**
  83276. * Width
  83277. */
  83278. width: number;
  83279. /**
  83280. * Height
  83281. */
  83282. height: number;
  83283. /**
  83284. * Creates a Size object from the given width and height (floats).
  83285. * @param width width of the new size
  83286. * @param height height of the new size
  83287. */
  83288. constructor(width: number, height: number);
  83289. /**
  83290. * Returns a string with the Size width and height
  83291. * @returns a string with the Size width and height
  83292. */
  83293. toString(): string;
  83294. /**
  83295. * "Size"
  83296. * @returns the string "Size"
  83297. */
  83298. getClassName(): string;
  83299. /**
  83300. * Returns the Size hash code.
  83301. * @returns a hash code for a unique width and height
  83302. */
  83303. getHashCode(): number;
  83304. /**
  83305. * Updates the current size from the given one.
  83306. * @param src the given size
  83307. */
  83308. copyFrom(src: Size): void;
  83309. /**
  83310. * Updates in place the current Size from the given floats.
  83311. * @param width width of the new size
  83312. * @param height height of the new size
  83313. * @returns the updated Size.
  83314. */
  83315. copyFromFloats(width: number, height: number): Size;
  83316. /**
  83317. * Updates in place the current Size from the given floats.
  83318. * @param width width to set
  83319. * @param height height to set
  83320. * @returns the updated Size.
  83321. */
  83322. set(width: number, height: number): Size;
  83323. /**
  83324. * Multiplies the width and height by numbers
  83325. * @param w factor to multiple the width by
  83326. * @param h factor to multiple the height by
  83327. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83328. */
  83329. multiplyByFloats(w: number, h: number): Size;
  83330. /**
  83331. * Clones the size
  83332. * @returns a new Size copied from the given one.
  83333. */
  83334. clone(): Size;
  83335. /**
  83336. * True if the current Size and the given one width and height are strictly equal.
  83337. * @param other the other size to compare against
  83338. * @returns True if the current Size and the given one width and height are strictly equal.
  83339. */
  83340. equals(other: Size): boolean;
  83341. /**
  83342. * The surface of the Size : width * height (float).
  83343. */
  83344. get surface(): number;
  83345. /**
  83346. * Create a new size of zero
  83347. * @returns a new Size set to (0.0, 0.0)
  83348. */
  83349. static Zero(): Size;
  83350. /**
  83351. * Sums the width and height of two sizes
  83352. * @param otherSize size to add to this size
  83353. * @returns a new Size set as the addition result of the current Size and the given one.
  83354. */
  83355. add(otherSize: Size): Size;
  83356. /**
  83357. * Subtracts the width and height of two
  83358. * @param otherSize size to subtract to this size
  83359. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83360. */
  83361. subtract(otherSize: Size): Size;
  83362. /**
  83363. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83364. * @param start starting size to lerp between
  83365. * @param end end size to lerp between
  83366. * @param amount amount to lerp between the start and end values
  83367. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83368. */
  83369. static Lerp(start: Size, end: Size, amount: number): Size;
  83370. }
  83371. }
  83372. declare module BABYLON {
  83373. /**
  83374. * Base class of all the textures in babylon.
  83375. * It groups all the common properties required to work with Thin Engine.
  83376. */
  83377. export class ThinTexture {
  83378. protected _wrapU: number;
  83379. /**
  83380. * | Value | Type | Description |
  83381. * | ----- | ------------------ | ----------- |
  83382. * | 0 | CLAMP_ADDRESSMODE | |
  83383. * | 1 | WRAP_ADDRESSMODE | |
  83384. * | 2 | MIRROR_ADDRESSMODE | |
  83385. */
  83386. get wrapU(): number;
  83387. set wrapU(value: number);
  83388. protected _wrapV: number;
  83389. /**
  83390. * | Value | Type | Description |
  83391. * | ----- | ------------------ | ----------- |
  83392. * | 0 | CLAMP_ADDRESSMODE | |
  83393. * | 1 | WRAP_ADDRESSMODE | |
  83394. * | 2 | MIRROR_ADDRESSMODE | |
  83395. */
  83396. get wrapV(): number;
  83397. set wrapV(value: number);
  83398. /**
  83399. * | Value | Type | Description |
  83400. * | ----- | ------------------ | ----------- |
  83401. * | 0 | CLAMP_ADDRESSMODE | |
  83402. * | 1 | WRAP_ADDRESSMODE | |
  83403. * | 2 | MIRROR_ADDRESSMODE | |
  83404. */
  83405. wrapR: number;
  83406. /**
  83407. * With compliant hardware and browser (supporting anisotropic filtering)
  83408. * this defines the level of anisotropic filtering in the texture.
  83409. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83410. */
  83411. anisotropicFilteringLevel: number;
  83412. /**
  83413. * Define the current state of the loading sequence when in delayed load mode.
  83414. */
  83415. delayLoadState: number;
  83416. /**
  83417. * How a texture is mapped.
  83418. * Unused in thin texture mode.
  83419. */
  83420. get coordinatesMode(): number;
  83421. /**
  83422. * Define if the texture is a cube texture or if false a 2d texture.
  83423. */
  83424. get isCube(): boolean;
  83425. set isCube(value: boolean);
  83426. /**
  83427. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83428. */
  83429. get is3D(): boolean;
  83430. set is3D(value: boolean);
  83431. /**
  83432. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83433. */
  83434. get is2DArray(): boolean;
  83435. set is2DArray(value: boolean);
  83436. /**
  83437. * Get the class name of the texture.
  83438. * @returns "ThinTexture"
  83439. */
  83440. getClassName(): string;
  83441. /** @hidden */
  83442. _texture: Nullable<InternalTexture>;
  83443. protected _engine: Nullable<ThinEngine>;
  83444. private _cachedSize;
  83445. private _cachedBaseSize;
  83446. /**
  83447. * Instantiates a new ThinTexture.
  83448. * Base class of all the textures in babylon.
  83449. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83450. * @param internalTexture Define the internalTexture to wrap
  83451. */
  83452. constructor(internalTexture: Nullable<InternalTexture>);
  83453. /**
  83454. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83455. * @returns true if fully ready
  83456. */
  83457. isReady(): boolean;
  83458. /**
  83459. * Triggers the load sequence in delayed load mode.
  83460. */
  83461. delayLoad(): void;
  83462. /**
  83463. * Get the underlying lower level texture from Babylon.
  83464. * @returns the insternal texture
  83465. */
  83466. getInternalTexture(): Nullable<InternalTexture>;
  83467. /**
  83468. * Get the size of the texture.
  83469. * @returns the texture size.
  83470. */
  83471. getSize(): ISize;
  83472. /**
  83473. * Get the base size of the texture.
  83474. * It can be different from the size if the texture has been resized for POT for instance
  83475. * @returns the base size
  83476. */
  83477. getBaseSize(): ISize;
  83478. /**
  83479. * Update the sampling mode of the texture.
  83480. * Default is Trilinear mode.
  83481. *
  83482. * | Value | Type | Description |
  83483. * | ----- | ------------------ | ----------- |
  83484. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83485. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83486. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83487. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83488. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83489. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83490. * | 7 | NEAREST_LINEAR | |
  83491. * | 8 | NEAREST_NEAREST | |
  83492. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83493. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83494. * | 11 | LINEAR_LINEAR | |
  83495. * | 12 | LINEAR_NEAREST | |
  83496. *
  83497. * > _mag_: magnification filter (close to the viewer)
  83498. * > _min_: minification filter (far from the viewer)
  83499. * > _mip_: filter used between mip map levels
  83500. *@param samplingMode Define the new sampling mode of the texture
  83501. */
  83502. updateSamplingMode(samplingMode: number): void;
  83503. /**
  83504. * Release and destroy the underlying lower level texture aka internalTexture.
  83505. */
  83506. releaseInternalTexture(): void;
  83507. /**
  83508. * Dispose the texture and release its associated resources.
  83509. */
  83510. dispose(): void;
  83511. }
  83512. }
  83513. declare module BABYLON {
  83514. /**
  83515. * Defines an array and its length.
  83516. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83517. */
  83518. export interface ISmartArrayLike<T> {
  83519. /**
  83520. * The data of the array.
  83521. */
  83522. data: Array<T>;
  83523. /**
  83524. * The active length of the array.
  83525. */
  83526. length: number;
  83527. }
  83528. /**
  83529. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83530. */
  83531. export class SmartArray<T> implements ISmartArrayLike<T> {
  83532. /**
  83533. * The full set of data from the array.
  83534. */
  83535. data: Array<T>;
  83536. /**
  83537. * The active length of the array.
  83538. */
  83539. length: number;
  83540. protected _id: number;
  83541. /**
  83542. * Instantiates a Smart Array.
  83543. * @param capacity defines the default capacity of the array.
  83544. */
  83545. constructor(capacity: number);
  83546. /**
  83547. * Pushes a value at the end of the active data.
  83548. * @param value defines the object to push in the array.
  83549. */
  83550. push(value: T): void;
  83551. /**
  83552. * Iterates over the active data and apply the lambda to them.
  83553. * @param func defines the action to apply on each value.
  83554. */
  83555. forEach(func: (content: T) => void): void;
  83556. /**
  83557. * Sorts the full sets of data.
  83558. * @param compareFn defines the comparison function to apply.
  83559. */
  83560. sort(compareFn: (a: T, b: T) => number): void;
  83561. /**
  83562. * Resets the active data to an empty array.
  83563. */
  83564. reset(): void;
  83565. /**
  83566. * Releases all the data from the array as well as the array.
  83567. */
  83568. dispose(): void;
  83569. /**
  83570. * Concats the active data with a given array.
  83571. * @param array defines the data to concatenate with.
  83572. */
  83573. concat(array: any): void;
  83574. /**
  83575. * Returns the position of a value in the active data.
  83576. * @param value defines the value to find the index for
  83577. * @returns the index if found in the active data otherwise -1
  83578. */
  83579. indexOf(value: T): number;
  83580. /**
  83581. * Returns whether an element is part of the active data.
  83582. * @param value defines the value to look for
  83583. * @returns true if found in the active data otherwise false
  83584. */
  83585. contains(value: T): boolean;
  83586. private static _GlobalId;
  83587. }
  83588. /**
  83589. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83590. * The data in this array can only be present once
  83591. */
  83592. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83593. private _duplicateId;
  83594. /**
  83595. * Pushes a value at the end of the active data.
  83596. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83597. * @param value defines the object to push in the array.
  83598. */
  83599. push(value: T): void;
  83600. /**
  83601. * Pushes a value at the end of the active data.
  83602. * If the data is already present, it won t be added again
  83603. * @param value defines the object to push in the array.
  83604. * @returns true if added false if it was already present
  83605. */
  83606. pushNoDuplicate(value: T): boolean;
  83607. /**
  83608. * Resets the active data to an empty array.
  83609. */
  83610. reset(): void;
  83611. /**
  83612. * Concats the active data with a given array.
  83613. * This ensures no dupplicate will be present in the result.
  83614. * @param array defines the data to concatenate with.
  83615. */
  83616. concatWithNoDuplicate(array: any): void;
  83617. }
  83618. }
  83619. declare module BABYLON {
  83620. /**
  83621. * Class used to evalaute queries containing `and` and `or` operators
  83622. */
  83623. export class AndOrNotEvaluator {
  83624. /**
  83625. * Evaluate a query
  83626. * @param query defines the query to evaluate
  83627. * @param evaluateCallback defines the callback used to filter result
  83628. * @returns true if the query matches
  83629. */
  83630. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83631. private static _HandleParenthesisContent;
  83632. private static _SimplifyNegation;
  83633. }
  83634. }
  83635. declare module BABYLON {
  83636. /**
  83637. * Class used to store custom tags
  83638. */
  83639. export class Tags {
  83640. /**
  83641. * Adds support for tags on the given object
  83642. * @param obj defines the object to use
  83643. */
  83644. static EnableFor(obj: any): void;
  83645. /**
  83646. * Removes tags support
  83647. * @param obj defines the object to use
  83648. */
  83649. static DisableFor(obj: any): void;
  83650. /**
  83651. * Gets a boolean indicating if the given object has tags
  83652. * @param obj defines the object to use
  83653. * @returns a boolean
  83654. */
  83655. static HasTags(obj: any): boolean;
  83656. /**
  83657. * Gets the tags available on a given object
  83658. * @param obj defines the object to use
  83659. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83660. * @returns the tags
  83661. */
  83662. static GetTags(obj: any, asString?: boolean): any;
  83663. /**
  83664. * Adds tags to an object
  83665. * @param obj defines the object to use
  83666. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83667. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83668. */
  83669. static AddTagsTo(obj: any, tagsString: string): void;
  83670. /**
  83671. * @hidden
  83672. */
  83673. static _AddTagTo(obj: any, tag: string): void;
  83674. /**
  83675. * Removes specific tags from a specific object
  83676. * @param obj defines the object to use
  83677. * @param tagsString defines the tags to remove
  83678. */
  83679. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83680. /**
  83681. * @hidden
  83682. */
  83683. static _RemoveTagFrom(obj: any, tag: string): void;
  83684. /**
  83685. * Defines if tags hosted on an object match a given query
  83686. * @param obj defines the object to use
  83687. * @param tagsQuery defines the tag query
  83688. * @returns a boolean
  83689. */
  83690. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83691. }
  83692. }
  83693. declare module BABYLON {
  83694. /**
  83695. * Scalar computation library
  83696. */
  83697. export class Scalar {
  83698. /**
  83699. * Two pi constants convenient for computation.
  83700. */
  83701. static TwoPi: number;
  83702. /**
  83703. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83704. * @param a number
  83705. * @param b number
  83706. * @param epsilon (default = 1.401298E-45)
  83707. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83708. */
  83709. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83710. /**
  83711. * Returns a string : the upper case translation of the number i to hexadecimal.
  83712. * @param i number
  83713. * @returns the upper case translation of the number i to hexadecimal.
  83714. */
  83715. static ToHex(i: number): string;
  83716. /**
  83717. * Returns -1 if value is negative and +1 is value is positive.
  83718. * @param value the value
  83719. * @returns the value itself if it's equal to zero.
  83720. */
  83721. static Sign(value: number): number;
  83722. /**
  83723. * Returns the value itself if it's between min and max.
  83724. * Returns min if the value is lower than min.
  83725. * Returns max if the value is greater than max.
  83726. * @param value the value to clmap
  83727. * @param min the min value to clamp to (default: 0)
  83728. * @param max the max value to clamp to (default: 1)
  83729. * @returns the clamped value
  83730. */
  83731. static Clamp(value: number, min?: number, max?: number): number;
  83732. /**
  83733. * the log2 of value.
  83734. * @param value the value to compute log2 of
  83735. * @returns the log2 of value.
  83736. */
  83737. static Log2(value: number): number;
  83738. /**
  83739. * Loops the value, so that it is never larger than length and never smaller than 0.
  83740. *
  83741. * This is similar to the modulo operator but it works with floating point numbers.
  83742. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83743. * With t = 5 and length = 2.5, the result would be 0.0.
  83744. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83745. * @param value the value
  83746. * @param length the length
  83747. * @returns the looped value
  83748. */
  83749. static Repeat(value: number, length: number): number;
  83750. /**
  83751. * Normalize the value between 0.0 and 1.0 using min and max values
  83752. * @param value value to normalize
  83753. * @param min max to normalize between
  83754. * @param max min to normalize between
  83755. * @returns the normalized value
  83756. */
  83757. static Normalize(value: number, min: number, max: number): number;
  83758. /**
  83759. * Denormalize the value from 0.0 and 1.0 using min and max values
  83760. * @param normalized value to denormalize
  83761. * @param min max to denormalize between
  83762. * @param max min to denormalize between
  83763. * @returns the denormalized value
  83764. */
  83765. static Denormalize(normalized: number, min: number, max: number): number;
  83766. /**
  83767. * Calculates the shortest difference between two given angles given in degrees.
  83768. * @param current current angle in degrees
  83769. * @param target target angle in degrees
  83770. * @returns the delta
  83771. */
  83772. static DeltaAngle(current: number, target: number): number;
  83773. /**
  83774. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83775. * @param tx value
  83776. * @param length length
  83777. * @returns The returned value will move back and forth between 0 and length
  83778. */
  83779. static PingPong(tx: number, length: number): number;
  83780. /**
  83781. * Interpolates between min and max with smoothing at the limits.
  83782. *
  83783. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83784. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83785. * @param from from
  83786. * @param to to
  83787. * @param tx value
  83788. * @returns the smooth stepped value
  83789. */
  83790. static SmoothStep(from: number, to: number, tx: number): number;
  83791. /**
  83792. * Moves a value current towards target.
  83793. *
  83794. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83795. * Negative values of maxDelta pushes the value away from target.
  83796. * @param current current value
  83797. * @param target target value
  83798. * @param maxDelta max distance to move
  83799. * @returns resulting value
  83800. */
  83801. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83802. /**
  83803. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83804. *
  83805. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83806. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83807. * @param current current value
  83808. * @param target target value
  83809. * @param maxDelta max distance to move
  83810. * @returns resulting angle
  83811. */
  83812. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83813. /**
  83814. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83815. * @param start start value
  83816. * @param end target value
  83817. * @param amount amount to lerp between
  83818. * @returns the lerped value
  83819. */
  83820. static Lerp(start: number, end: number, amount: number): number;
  83821. /**
  83822. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83823. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83824. * @param start start value
  83825. * @param end target value
  83826. * @param amount amount to lerp between
  83827. * @returns the lerped value
  83828. */
  83829. static LerpAngle(start: number, end: number, amount: number): number;
  83830. /**
  83831. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83832. * @param a start value
  83833. * @param b target value
  83834. * @param value value between a and b
  83835. * @returns the inverseLerp value
  83836. */
  83837. static InverseLerp(a: number, b: number, value: number): number;
  83838. /**
  83839. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83840. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83841. * @param value1 spline value
  83842. * @param tangent1 spline value
  83843. * @param value2 spline value
  83844. * @param tangent2 spline value
  83845. * @param amount input value
  83846. * @returns hermite result
  83847. */
  83848. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83849. /**
  83850. * Returns a random float number between and min and max values
  83851. * @param min min value of random
  83852. * @param max max value of random
  83853. * @returns random value
  83854. */
  83855. static RandomRange(min: number, max: number): number;
  83856. /**
  83857. * This function returns percentage of a number in a given range.
  83858. *
  83859. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83860. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83861. * @param number to convert to percentage
  83862. * @param min min range
  83863. * @param max max range
  83864. * @returns the percentage
  83865. */
  83866. static RangeToPercent(number: number, min: number, max: number): number;
  83867. /**
  83868. * This function returns number that corresponds to the percentage in a given range.
  83869. *
  83870. * PercentToRange(0.34,0,100) will return 34.
  83871. * @param percent to convert to number
  83872. * @param min min range
  83873. * @param max max range
  83874. * @returns the number
  83875. */
  83876. static PercentToRange(percent: number, min: number, max: number): number;
  83877. /**
  83878. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83879. * @param angle The angle to normalize in radian.
  83880. * @return The converted angle.
  83881. */
  83882. static NormalizeRadians(angle: number): number;
  83883. }
  83884. }
  83885. declare module BABYLON {
  83886. /**
  83887. * Constant used to convert a value to gamma space
  83888. * @ignorenaming
  83889. */
  83890. export const ToGammaSpace: number;
  83891. /**
  83892. * Constant used to convert a value to linear space
  83893. * @ignorenaming
  83894. */
  83895. export const ToLinearSpace = 2.2;
  83896. /**
  83897. * Constant used to define the minimal number value in Babylon.js
  83898. * @ignorenaming
  83899. */
  83900. let Epsilon: number;
  83901. }
  83902. declare module BABYLON {
  83903. /**
  83904. * Class used to represent a viewport on screen
  83905. */
  83906. export class Viewport {
  83907. /** viewport left coordinate */
  83908. x: number;
  83909. /** viewport top coordinate */
  83910. y: number;
  83911. /**viewport width */
  83912. width: number;
  83913. /** viewport height */
  83914. height: number;
  83915. /**
  83916. * Creates a Viewport object located at (x, y) and sized (width, height)
  83917. * @param x defines viewport left coordinate
  83918. * @param y defines viewport top coordinate
  83919. * @param width defines the viewport width
  83920. * @param height defines the viewport height
  83921. */
  83922. constructor(
  83923. /** viewport left coordinate */
  83924. x: number,
  83925. /** viewport top coordinate */
  83926. y: number,
  83927. /**viewport width */
  83928. width: number,
  83929. /** viewport height */
  83930. height: number);
  83931. /**
  83932. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83933. * @param renderWidth defines the rendering width
  83934. * @param renderHeight defines the rendering height
  83935. * @returns a new Viewport
  83936. */
  83937. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83938. /**
  83939. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83940. * @param renderWidth defines the rendering width
  83941. * @param renderHeight defines the rendering height
  83942. * @param ref defines the target viewport
  83943. * @returns the current viewport
  83944. */
  83945. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83946. /**
  83947. * Returns a new Viewport copied from the current one
  83948. * @returns a new Viewport
  83949. */
  83950. clone(): Viewport;
  83951. }
  83952. }
  83953. declare module BABYLON {
  83954. /**
  83955. * Class containing a set of static utilities functions for arrays.
  83956. */
  83957. export class ArrayTools {
  83958. /**
  83959. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83960. * @param size the number of element to construct and put in the array
  83961. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83962. * @returns a new array filled with new objects
  83963. */
  83964. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83965. }
  83966. }
  83967. declare module BABYLON {
  83968. /**
  83969. * Represents a plane by the equation ax + by + cz + d = 0
  83970. */
  83971. export class Plane {
  83972. private static _TmpMatrix;
  83973. /**
  83974. * Normal of the plane (a,b,c)
  83975. */
  83976. normal: Vector3;
  83977. /**
  83978. * d component of the plane
  83979. */
  83980. d: number;
  83981. /**
  83982. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83983. * @param a a component of the plane
  83984. * @param b b component of the plane
  83985. * @param c c component of the plane
  83986. * @param d d component of the plane
  83987. */
  83988. constructor(a: number, b: number, c: number, d: number);
  83989. /**
  83990. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83991. */
  83992. asArray(): number[];
  83993. /**
  83994. * @returns a new plane copied from the current Plane.
  83995. */
  83996. clone(): Plane;
  83997. /**
  83998. * @returns the string "Plane".
  83999. */
  84000. getClassName(): string;
  84001. /**
  84002. * @returns the Plane hash code.
  84003. */
  84004. getHashCode(): number;
  84005. /**
  84006. * Normalize the current Plane in place.
  84007. * @returns the updated Plane.
  84008. */
  84009. normalize(): Plane;
  84010. /**
  84011. * Applies a transformation the plane and returns the result
  84012. * @param transformation the transformation matrix to be applied to the plane
  84013. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  84014. */
  84015. transform(transformation: DeepImmutable<Matrix>): Plane;
  84016. /**
  84017. * Compute the dot product between the point and the plane normal
  84018. * @param point point to calculate the dot product with
  84019. * @returns the dot product (float) of the point coordinates and the plane normal.
  84020. */
  84021. dotCoordinate(point: DeepImmutable<Vector3>): number;
  84022. /**
  84023. * Updates the current Plane from the plane defined by the three given points.
  84024. * @param point1 one of the points used to contruct the plane
  84025. * @param point2 one of the points used to contruct the plane
  84026. * @param point3 one of the points used to contruct the plane
  84027. * @returns the updated Plane.
  84028. */
  84029. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84030. /**
  84031. * 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).
  84032. * Note that for this function to work as expected you should make sure that:
  84033. * - direction and the plane normal are normalized
  84034. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  84035. * @param direction the direction to check if the plane is facing
  84036. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  84037. * @returns True if the plane is facing the given direction
  84038. */
  84039. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  84040. /**
  84041. * Calculates the distance to a point
  84042. * @param point point to calculate distance to
  84043. * @returns the signed distance (float) from the given point to the Plane.
  84044. */
  84045. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  84046. /**
  84047. * Creates a plane from an array
  84048. * @param array the array to create a plane from
  84049. * @returns a new Plane from the given array.
  84050. */
  84051. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  84052. /**
  84053. * Creates a plane from three points
  84054. * @param point1 point used to create the plane
  84055. * @param point2 point used to create the plane
  84056. * @param point3 point used to create the plane
  84057. * @returns a new Plane defined by the three given points.
  84058. */
  84059. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84060. /**
  84061. * Creates a plane from an origin point and a normal
  84062. * @param origin origin of the plane to be constructed
  84063. * @param normal normal of the plane to be constructed
  84064. * @returns a new Plane the normal vector to this plane at the given origin point.
  84065. * Note : the vector "normal" is updated because normalized.
  84066. */
  84067. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  84068. /**
  84069. * Calculates the distance from a plane and a point
  84070. * @param origin origin of the plane to be constructed
  84071. * @param normal normal of the plane to be constructed
  84072. * @param point point to calculate distance to
  84073. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  84074. */
  84075. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  84076. }
  84077. }
  84078. declare module BABYLON {
  84079. /** @hidden */
  84080. export class PerformanceConfigurator {
  84081. /** @hidden */
  84082. static MatrixUse64Bits: boolean;
  84083. /** @hidden */
  84084. static MatrixTrackPrecisionChange: boolean;
  84085. /** @hidden */
  84086. static MatrixCurrentType: any;
  84087. /** @hidden */
  84088. static MatrixTrackedMatrices: Array<any> | null;
  84089. /** @hidden */
  84090. static SetMatrixPrecision(use64bits: boolean): void;
  84091. }
  84092. }
  84093. declare module BABYLON {
  84094. /**
  84095. * Class representing a vector containing 2 coordinates
  84096. */
  84097. export class Vector2 {
  84098. /** defines the first coordinate */
  84099. x: number;
  84100. /** defines the second coordinate */
  84101. y: number;
  84102. /**
  84103. * Creates a new Vector2 from the given x and y coordinates
  84104. * @param x defines the first coordinate
  84105. * @param y defines the second coordinate
  84106. */
  84107. constructor(
  84108. /** defines the first coordinate */
  84109. x?: number,
  84110. /** defines the second coordinate */
  84111. y?: number);
  84112. /**
  84113. * Gets a string with the Vector2 coordinates
  84114. * @returns a string with the Vector2 coordinates
  84115. */
  84116. toString(): string;
  84117. /**
  84118. * Gets class name
  84119. * @returns the string "Vector2"
  84120. */
  84121. getClassName(): string;
  84122. /**
  84123. * Gets current vector hash code
  84124. * @returns the Vector2 hash code as a number
  84125. */
  84126. getHashCode(): number;
  84127. /**
  84128. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  84129. * @param array defines the source array
  84130. * @param index defines the offset in source array
  84131. * @returns the current Vector2
  84132. */
  84133. toArray(array: FloatArray, index?: number): Vector2;
  84134. /**
  84135. * Update the current vector from an array
  84136. * @param array defines the destination array
  84137. * @param index defines the offset in the destination array
  84138. * @returns the current Vector3
  84139. */
  84140. fromArray(array: FloatArray, index?: number): Vector2;
  84141. /**
  84142. * Copy the current vector to an array
  84143. * @returns a new array with 2 elements: the Vector2 coordinates.
  84144. */
  84145. asArray(): number[];
  84146. /**
  84147. * Sets the Vector2 coordinates with the given Vector2 coordinates
  84148. * @param source defines the source Vector2
  84149. * @returns the current updated Vector2
  84150. */
  84151. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  84152. /**
  84153. * Sets the Vector2 coordinates with the given floats
  84154. * @param x defines the first coordinate
  84155. * @param y defines the second coordinate
  84156. * @returns the current updated Vector2
  84157. */
  84158. copyFromFloats(x: number, y: number): Vector2;
  84159. /**
  84160. * Sets the Vector2 coordinates with the given floats
  84161. * @param x defines the first coordinate
  84162. * @param y defines the second coordinate
  84163. * @returns the current updated Vector2
  84164. */
  84165. set(x: number, y: number): Vector2;
  84166. /**
  84167. * Add another vector with the current one
  84168. * @param otherVector defines the other vector
  84169. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  84170. */
  84171. add(otherVector: DeepImmutable<Vector2>): Vector2;
  84172. /**
  84173. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  84174. * @param otherVector defines the other vector
  84175. * @param result defines the target vector
  84176. * @returns the unmodified current Vector2
  84177. */
  84178. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84179. /**
  84180. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  84181. * @param otherVector defines the other vector
  84182. * @returns the current updated Vector2
  84183. */
  84184. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84185. /**
  84186. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  84187. * @param otherVector defines the other vector
  84188. * @returns a new Vector2
  84189. */
  84190. addVector3(otherVector: Vector3): Vector2;
  84191. /**
  84192. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  84193. * @param otherVector defines the other vector
  84194. * @returns a new Vector2
  84195. */
  84196. subtract(otherVector: Vector2): Vector2;
  84197. /**
  84198. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  84199. * @param otherVector defines the other vector
  84200. * @param result defines the target vector
  84201. * @returns the unmodified current Vector2
  84202. */
  84203. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84204. /**
  84205. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  84206. * @param otherVector defines the other vector
  84207. * @returns the current updated Vector2
  84208. */
  84209. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84210. /**
  84211. * Multiplies in place the current Vector2 coordinates by the given ones
  84212. * @param otherVector defines the other vector
  84213. * @returns the current updated Vector2
  84214. */
  84215. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84216. /**
  84217. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  84218. * @param otherVector defines the other vector
  84219. * @returns a new Vector2
  84220. */
  84221. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  84222. /**
  84223. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  84224. * @param otherVector defines the other vector
  84225. * @param result defines the target vector
  84226. * @returns the unmodified current Vector2
  84227. */
  84228. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84229. /**
  84230. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  84231. * @param x defines the first coordinate
  84232. * @param y defines the second coordinate
  84233. * @returns a new Vector2
  84234. */
  84235. multiplyByFloats(x: number, y: number): Vector2;
  84236. /**
  84237. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84238. * @param otherVector defines the other vector
  84239. * @returns a new Vector2
  84240. */
  84241. divide(otherVector: Vector2): Vector2;
  84242. /**
  84243. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84244. * @param otherVector defines the other vector
  84245. * @param result defines the target vector
  84246. * @returns the unmodified current Vector2
  84247. */
  84248. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84249. /**
  84250. * Divides the current Vector2 coordinates by the given ones
  84251. * @param otherVector defines the other vector
  84252. * @returns the current updated Vector2
  84253. */
  84254. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84255. /**
  84256. * Gets a new Vector2 with current Vector2 negated coordinates
  84257. * @returns a new Vector2
  84258. */
  84259. negate(): Vector2;
  84260. /**
  84261. * Negate this vector in place
  84262. * @returns this
  84263. */
  84264. negateInPlace(): Vector2;
  84265. /**
  84266. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84267. * @param result defines the Vector3 object where to store the result
  84268. * @returns the current Vector2
  84269. */
  84270. negateToRef(result: Vector2): Vector2;
  84271. /**
  84272. * Multiply the Vector2 coordinates by scale
  84273. * @param scale defines the scaling factor
  84274. * @returns the current updated Vector2
  84275. */
  84276. scaleInPlace(scale: number): Vector2;
  84277. /**
  84278. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84279. * @param scale defines the scaling factor
  84280. * @returns a new Vector2
  84281. */
  84282. scale(scale: number): Vector2;
  84283. /**
  84284. * Scale the current Vector2 values by a factor to a given Vector2
  84285. * @param scale defines the scale factor
  84286. * @param result defines the Vector2 object where to store the result
  84287. * @returns the unmodified current Vector2
  84288. */
  84289. scaleToRef(scale: number, result: Vector2): Vector2;
  84290. /**
  84291. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84292. * @param scale defines the scale factor
  84293. * @param result defines the Vector2 object where to store the result
  84294. * @returns the unmodified current Vector2
  84295. */
  84296. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84297. /**
  84298. * Gets a boolean if two vectors are equals
  84299. * @param otherVector defines the other vector
  84300. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84301. */
  84302. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84303. /**
  84304. * Gets a boolean if two vectors are equals (using an epsilon value)
  84305. * @param otherVector defines the other vector
  84306. * @param epsilon defines the minimal distance to consider equality
  84307. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84308. */
  84309. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84310. /**
  84311. * Gets a new Vector2 from current Vector2 floored values
  84312. * @returns a new Vector2
  84313. */
  84314. floor(): Vector2;
  84315. /**
  84316. * Gets a new Vector2 from current Vector2 floored values
  84317. * @returns a new Vector2
  84318. */
  84319. fract(): Vector2;
  84320. /**
  84321. * Gets the length of the vector
  84322. * @returns the vector length (float)
  84323. */
  84324. length(): number;
  84325. /**
  84326. * Gets the vector squared length
  84327. * @returns the vector squared length (float)
  84328. */
  84329. lengthSquared(): number;
  84330. /**
  84331. * Normalize the vector
  84332. * @returns the current updated Vector2
  84333. */
  84334. normalize(): Vector2;
  84335. /**
  84336. * Gets a new Vector2 copied from the Vector2
  84337. * @returns a new Vector2
  84338. */
  84339. clone(): Vector2;
  84340. /**
  84341. * Gets a new Vector2(0, 0)
  84342. * @returns a new Vector2
  84343. */
  84344. static Zero(): Vector2;
  84345. /**
  84346. * Gets a new Vector2(1, 1)
  84347. * @returns a new Vector2
  84348. */
  84349. static One(): Vector2;
  84350. /**
  84351. * Gets a new Vector2 set from the given index element of the given array
  84352. * @param array defines the data source
  84353. * @param offset defines the offset in the data source
  84354. * @returns a new Vector2
  84355. */
  84356. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84357. /**
  84358. * Sets "result" from the given index element of the given array
  84359. * @param array defines the data source
  84360. * @param offset defines the offset in the data source
  84361. * @param result defines the target vector
  84362. */
  84363. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84364. /**
  84365. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84366. * @param value1 defines 1st point of control
  84367. * @param value2 defines 2nd point of control
  84368. * @param value3 defines 3rd point of control
  84369. * @param value4 defines 4th point of control
  84370. * @param amount defines the interpolation factor
  84371. * @returns a new Vector2
  84372. */
  84373. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84374. /**
  84375. * 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".
  84376. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84377. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84378. * @param value defines the value to clamp
  84379. * @param min defines the lower limit
  84380. * @param max defines the upper limit
  84381. * @returns a new Vector2
  84382. */
  84383. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84384. /**
  84385. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84386. * @param value1 defines the 1st control point
  84387. * @param tangent1 defines the outgoing tangent
  84388. * @param value2 defines the 2nd control point
  84389. * @param tangent2 defines the incoming tangent
  84390. * @param amount defines the interpolation factor
  84391. * @returns a new Vector2
  84392. */
  84393. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84394. /**
  84395. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84396. * @param start defines the start vector
  84397. * @param end defines the end vector
  84398. * @param amount defines the interpolation factor
  84399. * @returns a new Vector2
  84400. */
  84401. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84402. /**
  84403. * Gets the dot product of the vector "left" and the vector "right"
  84404. * @param left defines first vector
  84405. * @param right defines second vector
  84406. * @returns the dot product (float)
  84407. */
  84408. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84409. /**
  84410. * Returns a new Vector2 equal to the normalized given vector
  84411. * @param vector defines the vector to normalize
  84412. * @returns a new Vector2
  84413. */
  84414. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84415. /**
  84416. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84417. * @param left defines 1st vector
  84418. * @param right defines 2nd vector
  84419. * @returns a new Vector2
  84420. */
  84421. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84422. /**
  84423. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84424. * @param left defines 1st vector
  84425. * @param right defines 2nd vector
  84426. * @returns a new Vector2
  84427. */
  84428. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84429. /**
  84430. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84431. * @param vector defines the vector to transform
  84432. * @param transformation defines the matrix to apply
  84433. * @returns a new Vector2
  84434. */
  84435. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84436. /**
  84437. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84438. * @param vector defines the vector to transform
  84439. * @param transformation defines the matrix to apply
  84440. * @param result defines the target vector
  84441. */
  84442. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84443. /**
  84444. * Determines if a given vector is included in a triangle
  84445. * @param p defines the vector to test
  84446. * @param p0 defines 1st triangle point
  84447. * @param p1 defines 2nd triangle point
  84448. * @param p2 defines 3rd triangle point
  84449. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84450. */
  84451. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84452. /**
  84453. * Gets the distance between the vectors "value1" and "value2"
  84454. * @param value1 defines first vector
  84455. * @param value2 defines second vector
  84456. * @returns the distance between vectors
  84457. */
  84458. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84459. /**
  84460. * Returns the squared distance between the vectors "value1" and "value2"
  84461. * @param value1 defines first vector
  84462. * @param value2 defines second vector
  84463. * @returns the squared distance between vectors
  84464. */
  84465. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84466. /**
  84467. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84468. * @param value1 defines first vector
  84469. * @param value2 defines second vector
  84470. * @returns a new Vector2
  84471. */
  84472. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84473. /**
  84474. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84475. * @param p defines the middle point
  84476. * @param segA defines one point of the segment
  84477. * @param segB defines the other point of the segment
  84478. * @returns the shortest distance
  84479. */
  84480. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84481. }
  84482. /**
  84483. * Class used to store (x,y,z) vector representation
  84484. * A Vector3 is the main object used in 3D geometry
  84485. * It can represent etiher the coordinates of a point the space, either a direction
  84486. * Reminder: js uses a left handed forward facing system
  84487. */
  84488. export class Vector3 {
  84489. private static _UpReadOnly;
  84490. private static _ZeroReadOnly;
  84491. /** @hidden */
  84492. _x: number;
  84493. /** @hidden */
  84494. _y: number;
  84495. /** @hidden */
  84496. _z: number;
  84497. /** @hidden */
  84498. _isDirty: boolean;
  84499. /** Gets or sets the x coordinate */
  84500. get x(): number;
  84501. set x(value: number);
  84502. /** Gets or sets the y coordinate */
  84503. get y(): number;
  84504. set y(value: number);
  84505. /** Gets or sets the z coordinate */
  84506. get z(): number;
  84507. set z(value: number);
  84508. /**
  84509. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84510. * @param x defines the first coordinates (on X axis)
  84511. * @param y defines the second coordinates (on Y axis)
  84512. * @param z defines the third coordinates (on Z axis)
  84513. */
  84514. constructor(x?: number, y?: number, z?: number);
  84515. /**
  84516. * Creates a string representation of the Vector3
  84517. * @returns a string with the Vector3 coordinates.
  84518. */
  84519. toString(): string;
  84520. /**
  84521. * Gets the class name
  84522. * @returns the string "Vector3"
  84523. */
  84524. getClassName(): string;
  84525. /**
  84526. * Creates the Vector3 hash code
  84527. * @returns a number which tends to be unique between Vector3 instances
  84528. */
  84529. getHashCode(): number;
  84530. /**
  84531. * Creates an array containing three elements : the coordinates of the Vector3
  84532. * @returns a new array of numbers
  84533. */
  84534. asArray(): number[];
  84535. /**
  84536. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84537. * @param array defines the destination array
  84538. * @param index defines the offset in the destination array
  84539. * @returns the current Vector3
  84540. */
  84541. toArray(array: FloatArray, index?: number): Vector3;
  84542. /**
  84543. * Update the current vector from an array
  84544. * @param array defines the destination array
  84545. * @param index defines the offset in the destination array
  84546. * @returns the current Vector3
  84547. */
  84548. fromArray(array: FloatArray, index?: number): Vector3;
  84549. /**
  84550. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84551. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84552. */
  84553. toQuaternion(): Quaternion;
  84554. /**
  84555. * Adds the given vector to the current Vector3
  84556. * @param otherVector defines the second operand
  84557. * @returns the current updated Vector3
  84558. */
  84559. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84560. /**
  84561. * Adds the given coordinates to the current Vector3
  84562. * @param x defines the x coordinate of the operand
  84563. * @param y defines the y coordinate of the operand
  84564. * @param z defines the z coordinate of the operand
  84565. * @returns the current updated Vector3
  84566. */
  84567. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84568. /**
  84569. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84570. * @param otherVector defines the second operand
  84571. * @returns the resulting Vector3
  84572. */
  84573. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84574. /**
  84575. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84576. * @param otherVector defines the second operand
  84577. * @param result defines the Vector3 object where to store the result
  84578. * @returns the current Vector3
  84579. */
  84580. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84581. /**
  84582. * Subtract the given vector from the current Vector3
  84583. * @param otherVector defines the second operand
  84584. * @returns the current updated Vector3
  84585. */
  84586. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84587. /**
  84588. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84589. * @param otherVector defines the second operand
  84590. * @returns the resulting Vector3
  84591. */
  84592. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84593. /**
  84594. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84595. * @param otherVector defines the second operand
  84596. * @param result defines the Vector3 object where to store the result
  84597. * @returns the current Vector3
  84598. */
  84599. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84600. /**
  84601. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84602. * @param x defines the x coordinate of the operand
  84603. * @param y defines the y coordinate of the operand
  84604. * @param z defines the z coordinate of the operand
  84605. * @returns the resulting Vector3
  84606. */
  84607. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84608. /**
  84609. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  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. * @param result defines the Vector3 object where to store the result
  84614. * @returns the current Vector3
  84615. */
  84616. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84617. /**
  84618. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84619. * @returns a new Vector3
  84620. */
  84621. negate(): Vector3;
  84622. /**
  84623. * Negate this vector in place
  84624. * @returns this
  84625. */
  84626. negateInPlace(): Vector3;
  84627. /**
  84628. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84629. * @param result defines the Vector3 object where to store the result
  84630. * @returns the current Vector3
  84631. */
  84632. negateToRef(result: Vector3): Vector3;
  84633. /**
  84634. * Multiplies the Vector3 coordinates by the float "scale"
  84635. * @param scale defines the multiplier factor
  84636. * @returns the current updated Vector3
  84637. */
  84638. scaleInPlace(scale: number): Vector3;
  84639. /**
  84640. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84641. * @param scale defines the multiplier factor
  84642. * @returns a new Vector3
  84643. */
  84644. scale(scale: number): Vector3;
  84645. /**
  84646. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84647. * @param scale defines the multiplier factor
  84648. * @param result defines the Vector3 object where to store the result
  84649. * @returns the current Vector3
  84650. */
  84651. scaleToRef(scale: number, result: Vector3): Vector3;
  84652. /**
  84653. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84654. * @param scale defines the scale factor
  84655. * @param result defines the Vector3 object where to store the result
  84656. * @returns the unmodified current Vector3
  84657. */
  84658. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84659. /**
  84660. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84661. * @param origin defines the origin of the projection ray
  84662. * @param plane defines the plane to project to
  84663. * @returns the projected vector3
  84664. */
  84665. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84666. /**
  84667. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84668. * @param origin defines the origin of the projection ray
  84669. * @param plane defines the plane to project to
  84670. * @param result defines the Vector3 where to store the result
  84671. */
  84672. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84673. /**
  84674. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84675. * @param otherVector defines the second operand
  84676. * @returns true if both vectors are equals
  84677. */
  84678. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84679. /**
  84680. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84681. * @param otherVector defines the second operand
  84682. * @param epsilon defines the minimal distance to define values as equals
  84683. * @returns true if both vectors are distant less than epsilon
  84684. */
  84685. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84686. /**
  84687. * Returns true if the current Vector3 coordinates equals the given floats
  84688. * @param x defines the x coordinate of the operand
  84689. * @param y defines the y coordinate of the operand
  84690. * @param z defines the z coordinate of the operand
  84691. * @returns true if both vectors are equals
  84692. */
  84693. equalsToFloats(x: number, y: number, z: number): boolean;
  84694. /**
  84695. * Multiplies the current Vector3 coordinates by the given ones
  84696. * @param otherVector defines the second operand
  84697. * @returns the current updated Vector3
  84698. */
  84699. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84700. /**
  84701. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84702. * @param otherVector defines the second operand
  84703. * @returns the new Vector3
  84704. */
  84705. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84706. /**
  84707. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84708. * @param otherVector defines the second operand
  84709. * @param result defines the Vector3 object where to store the result
  84710. * @returns the current Vector3
  84711. */
  84712. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84713. /**
  84714. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84715. * @param x defines the x coordinate of the operand
  84716. * @param y defines the y coordinate of the operand
  84717. * @param z defines the z coordinate of the operand
  84718. * @returns the new Vector3
  84719. */
  84720. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84721. /**
  84722. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84723. * @param otherVector defines the second operand
  84724. * @returns the new Vector3
  84725. */
  84726. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84727. /**
  84728. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84729. * @param otherVector defines the second operand
  84730. * @param result defines the Vector3 object where to store the result
  84731. * @returns the current Vector3
  84732. */
  84733. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84734. /**
  84735. * Divides the current Vector3 coordinates by the given ones.
  84736. * @param otherVector defines the second operand
  84737. * @returns the current updated Vector3
  84738. */
  84739. divideInPlace(otherVector: Vector3): Vector3;
  84740. /**
  84741. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84742. * @param other defines the second operand
  84743. * @returns the current updated Vector3
  84744. */
  84745. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84746. /**
  84747. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84748. * @param other defines the second operand
  84749. * @returns the current updated Vector3
  84750. */
  84751. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84752. /**
  84753. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84754. * @param x defines the x coordinate of the operand
  84755. * @param y defines the y coordinate of the operand
  84756. * @param z defines the z coordinate of the operand
  84757. * @returns the current updated Vector3
  84758. */
  84759. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84760. /**
  84761. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84762. * @param x defines the x coordinate of the operand
  84763. * @param y defines the y coordinate of the operand
  84764. * @param z defines the z coordinate of the operand
  84765. * @returns the current updated Vector3
  84766. */
  84767. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84768. /**
  84769. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84770. * Check if is non uniform within a certain amount of decimal places to account for this
  84771. * @param epsilon the amount the values can differ
  84772. * @returns if the the vector is non uniform to a certain number of decimal places
  84773. */
  84774. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84775. /**
  84776. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84777. */
  84778. get isNonUniform(): boolean;
  84779. /**
  84780. * Gets a new Vector3 from current Vector3 floored values
  84781. * @returns a new Vector3
  84782. */
  84783. floor(): Vector3;
  84784. /**
  84785. * Gets a new Vector3 from current Vector3 floored values
  84786. * @returns a new Vector3
  84787. */
  84788. fract(): Vector3;
  84789. /**
  84790. * Gets the length of the Vector3
  84791. * @returns the length of the Vector3
  84792. */
  84793. length(): number;
  84794. /**
  84795. * Gets the squared length of the Vector3
  84796. * @returns squared length of the Vector3
  84797. */
  84798. lengthSquared(): number;
  84799. /**
  84800. * Normalize the current Vector3.
  84801. * Please note that this is an in place operation.
  84802. * @returns the current updated Vector3
  84803. */
  84804. normalize(): Vector3;
  84805. /**
  84806. * Reorders the x y z properties of the vector in place
  84807. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84808. * @returns the current updated vector
  84809. */
  84810. reorderInPlace(order: string): this;
  84811. /**
  84812. * Rotates the vector around 0,0,0 by a quaternion
  84813. * @param quaternion the rotation quaternion
  84814. * @param result vector to store the result
  84815. * @returns the resulting vector
  84816. */
  84817. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84818. /**
  84819. * Rotates a vector around a given point
  84820. * @param quaternion the rotation quaternion
  84821. * @param point the point to rotate around
  84822. * @param result vector to store the result
  84823. * @returns the resulting vector
  84824. */
  84825. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84826. /**
  84827. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84828. * The cross product is then orthogonal to both current and "other"
  84829. * @param other defines the right operand
  84830. * @returns the cross product
  84831. */
  84832. cross(other: Vector3): Vector3;
  84833. /**
  84834. * Normalize the current Vector3 with the given input length.
  84835. * Please note that this is an in place operation.
  84836. * @param len the length of the vector
  84837. * @returns the current updated Vector3
  84838. */
  84839. normalizeFromLength(len: number): Vector3;
  84840. /**
  84841. * Normalize the current Vector3 to a new vector
  84842. * @returns the new Vector3
  84843. */
  84844. normalizeToNew(): Vector3;
  84845. /**
  84846. * Normalize the current Vector3 to the reference
  84847. * @param reference define the Vector3 to update
  84848. * @returns the updated Vector3
  84849. */
  84850. normalizeToRef(reference: Vector3): Vector3;
  84851. /**
  84852. * Creates a new Vector3 copied from the current Vector3
  84853. * @returns the new Vector3
  84854. */
  84855. clone(): Vector3;
  84856. /**
  84857. * Copies the given vector coordinates to the current Vector3 ones
  84858. * @param source defines the source Vector3
  84859. * @returns the current updated Vector3
  84860. */
  84861. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84862. /**
  84863. * Copies the given floats to the current Vector3 coordinates
  84864. * @param x defines the x coordinate of the operand
  84865. * @param y defines the y coordinate of the operand
  84866. * @param z defines the z coordinate of the operand
  84867. * @returns the current updated Vector3
  84868. */
  84869. copyFromFloats(x: number, y: number, z: number): Vector3;
  84870. /**
  84871. * Copies the given floats to the current Vector3 coordinates
  84872. * @param x defines the x coordinate of the operand
  84873. * @param y defines the y coordinate of the operand
  84874. * @param z defines the z coordinate of the operand
  84875. * @returns the current updated Vector3
  84876. */
  84877. set(x: number, y: number, z: number): Vector3;
  84878. /**
  84879. * Copies the given float to the current Vector3 coordinates
  84880. * @param v defines the x, y and z coordinates of the operand
  84881. * @returns the current updated Vector3
  84882. */
  84883. setAll(v: number): Vector3;
  84884. /**
  84885. * Get the clip factor between two vectors
  84886. * @param vector0 defines the first operand
  84887. * @param vector1 defines the second operand
  84888. * @param axis defines the axis to use
  84889. * @param size defines the size along the axis
  84890. * @returns the clip factor
  84891. */
  84892. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84893. /**
  84894. * Get angle between two vectors
  84895. * @param vector0 angle between vector0 and vector1
  84896. * @param vector1 angle between vector0 and vector1
  84897. * @param normal direction of the normal
  84898. * @return the angle between vector0 and vector1
  84899. */
  84900. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84901. /**
  84902. * Returns a new Vector3 set from the index "offset" of the given array
  84903. * @param array defines the source array
  84904. * @param offset defines the offset in the source array
  84905. * @returns the new Vector3
  84906. */
  84907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84908. /**
  84909. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84910. * @param array defines the source array
  84911. * @param offset defines the offset in the source array
  84912. * @returns the new Vector3
  84913. * @deprecated Please use FromArray instead.
  84914. */
  84915. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84916. /**
  84917. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84918. * @param array defines the source array
  84919. * @param offset defines the offset in the source array
  84920. * @param result defines the Vector3 where to store the result
  84921. */
  84922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84923. /**
  84924. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84925. * @param array defines the source array
  84926. * @param offset defines the offset in the source array
  84927. * @param result defines the Vector3 where to store the result
  84928. * @deprecated Please use FromArrayToRef instead.
  84929. */
  84930. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84931. /**
  84932. * Sets the given vector "result" with the given floats.
  84933. * @param x defines the x coordinate of the source
  84934. * @param y defines the y coordinate of the source
  84935. * @param z defines the z coordinate of the source
  84936. * @param result defines the Vector3 where to store the result
  84937. */
  84938. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84939. /**
  84940. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84941. * @returns a new empty Vector3
  84942. */
  84943. static Zero(): Vector3;
  84944. /**
  84945. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84946. * @returns a new unit Vector3
  84947. */
  84948. static One(): Vector3;
  84949. /**
  84950. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84951. * @returns a new up Vector3
  84952. */
  84953. static Up(): Vector3;
  84954. /**
  84955. * Gets a up Vector3 that must not be updated
  84956. */
  84957. static get UpReadOnly(): DeepImmutable<Vector3>;
  84958. /**
  84959. * Gets a zero Vector3 that must not be updated
  84960. */
  84961. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84962. /**
  84963. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84964. * @returns a new down Vector3
  84965. */
  84966. static Down(): Vector3;
  84967. /**
  84968. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84969. * @param rightHandedSystem is the scene right-handed (negative z)
  84970. * @returns a new forward Vector3
  84971. */
  84972. static Forward(rightHandedSystem?: boolean): Vector3;
  84973. /**
  84974. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84975. * @param rightHandedSystem is the scene right-handed (negative-z)
  84976. * @returns a new forward Vector3
  84977. */
  84978. static Backward(rightHandedSystem?: boolean): Vector3;
  84979. /**
  84980. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84981. * @returns a new right Vector3
  84982. */
  84983. static Right(): Vector3;
  84984. /**
  84985. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84986. * @returns a new left Vector3
  84987. */
  84988. static Left(): Vector3;
  84989. /**
  84990. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84992. * @param vector defines the Vector3 to transform
  84993. * @param transformation defines the transformation matrix
  84994. * @returns the transformed Vector3
  84995. */
  84996. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84997. /**
  84998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84999. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  85000. * @param vector defines the Vector3 to transform
  85001. * @param transformation defines the transformation matrix
  85002. * @param result defines the Vector3 where to store the result
  85003. */
  85004. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85005. /**
  85006. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  85007. * This method computes tranformed coordinates only, not transformed direction vectors
  85008. * @param x define the x coordinate of the source vector
  85009. * @param y define the y coordinate of the source vector
  85010. * @param z define the z coordinate of the source vector
  85011. * @param transformation defines the transformation matrix
  85012. * @param result defines the Vector3 where to store the result
  85013. */
  85014. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85015. /**
  85016. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  85017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85018. * @param vector defines the Vector3 to transform
  85019. * @param transformation defines the transformation matrix
  85020. * @returns the new Vector3
  85021. */
  85022. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  85023. /**
  85024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  85025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85026. * @param vector defines the Vector3 to transform
  85027. * @param transformation defines the transformation matrix
  85028. * @param result defines the Vector3 where to store the result
  85029. */
  85030. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85031. /**
  85032. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  85033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85034. * @param x define the x coordinate of the source vector
  85035. * @param y define the y coordinate of the source vector
  85036. * @param z define the z coordinate of the source vector
  85037. * @param transformation defines the transformation matrix
  85038. * @param result defines the Vector3 where to store the result
  85039. */
  85040. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85041. /**
  85042. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  85043. * @param value1 defines the first control point
  85044. * @param value2 defines the second control point
  85045. * @param value3 defines the third control point
  85046. * @param value4 defines the fourth control point
  85047. * @param amount defines the amount on the spline to use
  85048. * @returns the new Vector3
  85049. */
  85050. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  85051. /**
  85052. * 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"
  85053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85055. * @param value defines the current value
  85056. * @param min defines the lower range value
  85057. * @param max defines the upper range value
  85058. * @returns the new Vector3
  85059. */
  85060. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  85061. /**
  85062. * 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"
  85063. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85064. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85065. * @param value defines the current value
  85066. * @param min defines the lower range value
  85067. * @param max defines the upper range value
  85068. * @param result defines the Vector3 where to store the result
  85069. */
  85070. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  85071. /**
  85072. * Checks if a given vector is inside a specific range
  85073. * @param v defines the vector to test
  85074. * @param min defines the minimum range
  85075. * @param max defines the maximum range
  85076. */
  85077. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  85078. /**
  85079. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  85080. * @param value1 defines the first control point
  85081. * @param tangent1 defines the first tangent vector
  85082. * @param value2 defines the second control point
  85083. * @param tangent2 defines the second tangent vector
  85084. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  85085. * @returns the new Vector3
  85086. */
  85087. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  85088. /**
  85089. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  85090. * @param start defines the start value
  85091. * @param end defines the end value
  85092. * @param amount max defines amount between both (between 0 and 1)
  85093. * @returns the new Vector3
  85094. */
  85095. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  85096. /**
  85097. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  85098. * @param start defines the start value
  85099. * @param end defines the end value
  85100. * @param amount max defines amount between both (between 0 and 1)
  85101. * @param result defines the Vector3 where to store the result
  85102. */
  85103. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  85104. /**
  85105. * Returns the dot product (float) between the vectors "left" and "right"
  85106. * @param left defines the left operand
  85107. * @param right defines the right operand
  85108. * @returns the dot product
  85109. */
  85110. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  85111. /**
  85112. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  85113. * The cross product is then orthogonal to both "left" and "right"
  85114. * @param left defines the left operand
  85115. * @param right defines the right operand
  85116. * @returns the cross product
  85117. */
  85118. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85119. /**
  85120. * Sets the given vector "result" with the cross product of "left" and "right"
  85121. * The cross product is then orthogonal to both "left" and "right"
  85122. * @param left defines the left operand
  85123. * @param right defines the right operand
  85124. * @param result defines the Vector3 where to store the result
  85125. */
  85126. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  85127. /**
  85128. * Returns a new Vector3 as the normalization of the given vector
  85129. * @param vector defines the Vector3 to normalize
  85130. * @returns the new Vector3
  85131. */
  85132. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  85133. /**
  85134. * Sets the given vector "result" with the normalization of the given first vector
  85135. * @param vector defines the Vector3 to normalize
  85136. * @param result defines the Vector3 where to store the result
  85137. */
  85138. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  85139. /**
  85140. * Project a Vector3 onto screen space
  85141. * @param vector defines the Vector3 to project
  85142. * @param world defines the world matrix to use
  85143. * @param transform defines the transform (view x projection) matrix to use
  85144. * @param viewport defines the screen viewport to use
  85145. * @returns the new Vector3
  85146. */
  85147. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  85148. /**
  85149. * Project a Vector3 onto screen space to reference
  85150. * @param vector defines the Vector3 to project
  85151. * @param world defines the world matrix to use
  85152. * @param transform defines the transform (view x projection) matrix to use
  85153. * @param viewport defines the screen viewport to use
  85154. * @param result the vector in which the screen space will be stored
  85155. * @returns the new Vector3
  85156. */
  85157. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  85158. /** @hidden */
  85159. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  85160. /**
  85161. * Unproject from screen space to object space
  85162. * @param source defines the screen space Vector3 to use
  85163. * @param viewportWidth defines the current width of the viewport
  85164. * @param viewportHeight defines the current height of the viewport
  85165. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85166. * @param transform defines the transform (view x projection) matrix to use
  85167. * @returns the new Vector3
  85168. */
  85169. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  85170. /**
  85171. * Unproject from screen space to object space
  85172. * @param source defines the screen space Vector3 to use
  85173. * @param viewportWidth defines the current width of the viewport
  85174. * @param viewportHeight defines the current height of the viewport
  85175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85176. * @param view defines the view matrix to use
  85177. * @param projection defines the projection matrix to use
  85178. * @returns the new Vector3
  85179. */
  85180. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  85181. /**
  85182. * Unproject from screen space to object space
  85183. * @param source defines the screen space Vector3 to use
  85184. * @param viewportWidth defines the current width of the viewport
  85185. * @param viewportHeight defines the current height of the viewport
  85186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85187. * @param view defines the view matrix to use
  85188. * @param projection defines the projection matrix to use
  85189. * @param result defines the Vector3 where to store the result
  85190. */
  85191. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85192. /**
  85193. * Unproject from screen space to object space
  85194. * @param sourceX defines the screen space x coordinate to use
  85195. * @param sourceY defines the screen space y coordinate to use
  85196. * @param sourceZ defines the screen space z coordinate to use
  85197. * @param viewportWidth defines the current width of the viewport
  85198. * @param viewportHeight defines the current height of the viewport
  85199. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85200. * @param view defines the view matrix to use
  85201. * @param projection defines the projection matrix to use
  85202. * @param result defines the Vector3 where to store the result
  85203. */
  85204. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85205. /**
  85206. * Gets the minimal coordinate values between two Vector3
  85207. * @param left defines the first operand
  85208. * @param right defines the second operand
  85209. * @returns the new Vector3
  85210. */
  85211. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85212. /**
  85213. * Gets the maximal coordinate values between two Vector3
  85214. * @param left defines the first operand
  85215. * @param right defines the second operand
  85216. * @returns the new Vector3
  85217. */
  85218. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85219. /**
  85220. * Returns the distance between the vectors "value1" and "value2"
  85221. * @param value1 defines the first operand
  85222. * @param value2 defines the second operand
  85223. * @returns the distance
  85224. */
  85225. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85226. /**
  85227. * Returns the squared distance between the vectors "value1" and "value2"
  85228. * @param value1 defines the first operand
  85229. * @param value2 defines the second operand
  85230. * @returns the squared distance
  85231. */
  85232. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85233. /**
  85234. * Returns a new Vector3 located at the center between "value1" and "value2"
  85235. * @param value1 defines the first operand
  85236. * @param value2 defines the second operand
  85237. * @returns the new Vector3
  85238. */
  85239. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85240. /**
  85241. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85242. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85243. * to something in order to rotate it from its local system to the given target system
  85244. * Note: axis1, axis2 and axis3 are normalized during this operation
  85245. * @param axis1 defines the first axis
  85246. * @param axis2 defines the second axis
  85247. * @param axis3 defines the third axis
  85248. * @returns a new Vector3
  85249. */
  85250. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85251. /**
  85252. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85253. * @param axis1 defines the first axis
  85254. * @param axis2 defines the second axis
  85255. * @param axis3 defines the third axis
  85256. * @param ref defines the Vector3 where to store the result
  85257. */
  85258. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85259. }
  85260. /**
  85261. * Vector4 class created for EulerAngle class conversion to Quaternion
  85262. */
  85263. export class Vector4 {
  85264. /** x value of the vector */
  85265. x: number;
  85266. /** y value of the vector */
  85267. y: number;
  85268. /** z value of the vector */
  85269. z: number;
  85270. /** w value of the vector */
  85271. w: number;
  85272. /**
  85273. * Creates a Vector4 object from the given floats.
  85274. * @param x x value of the vector
  85275. * @param y y value of the vector
  85276. * @param z z value of the vector
  85277. * @param w w value of the vector
  85278. */
  85279. constructor(
  85280. /** x value of the vector */
  85281. x: number,
  85282. /** y value of the vector */
  85283. y: number,
  85284. /** z value of the vector */
  85285. z: number,
  85286. /** w value of the vector */
  85287. w: number);
  85288. /**
  85289. * Returns the string with the Vector4 coordinates.
  85290. * @returns a string containing all the vector values
  85291. */
  85292. toString(): string;
  85293. /**
  85294. * Returns the string "Vector4".
  85295. * @returns "Vector4"
  85296. */
  85297. getClassName(): string;
  85298. /**
  85299. * Returns the Vector4 hash code.
  85300. * @returns a unique hash code
  85301. */
  85302. getHashCode(): number;
  85303. /**
  85304. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85305. * @returns the resulting array
  85306. */
  85307. asArray(): number[];
  85308. /**
  85309. * Populates the given array from the given index with the Vector4 coordinates.
  85310. * @param array array to populate
  85311. * @param index index of the array to start at (default: 0)
  85312. * @returns the Vector4.
  85313. */
  85314. toArray(array: FloatArray, index?: number): Vector4;
  85315. /**
  85316. * Update the current vector from an array
  85317. * @param array defines the destination array
  85318. * @param index defines the offset in the destination array
  85319. * @returns the current Vector3
  85320. */
  85321. fromArray(array: FloatArray, index?: number): Vector4;
  85322. /**
  85323. * Adds the given vector to the current Vector4.
  85324. * @param otherVector the vector to add
  85325. * @returns the updated Vector4.
  85326. */
  85327. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85328. /**
  85329. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85330. * @param otherVector the vector to add
  85331. * @returns the resulting vector
  85332. */
  85333. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85334. /**
  85335. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85336. * @param otherVector the vector to add
  85337. * @param result the vector to store the result
  85338. * @returns the current Vector4.
  85339. */
  85340. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85341. /**
  85342. * Subtract in place the given vector from the current Vector4.
  85343. * @param otherVector the vector to subtract
  85344. * @returns the updated Vector4.
  85345. */
  85346. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85347. /**
  85348. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85349. * @param otherVector the vector to add
  85350. * @returns the new vector with the result
  85351. */
  85352. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85353. /**
  85354. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85355. * @param otherVector the vector to subtract
  85356. * @param result the vector to store the result
  85357. * @returns the current Vector4.
  85358. */
  85359. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85360. /**
  85361. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85362. */
  85363. /**
  85364. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85365. * @param x value to subtract
  85366. * @param y value to subtract
  85367. * @param z value to subtract
  85368. * @param w value to subtract
  85369. * @returns new vector containing the result
  85370. */
  85371. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85372. /**
  85373. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85374. * @param x value to subtract
  85375. * @param y value to subtract
  85376. * @param z value to subtract
  85377. * @param w value to subtract
  85378. * @param result the vector to store the result in
  85379. * @returns the current Vector4.
  85380. */
  85381. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85382. /**
  85383. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85384. * @returns a new vector with the negated values
  85385. */
  85386. negate(): Vector4;
  85387. /**
  85388. * Negate this vector in place
  85389. * @returns this
  85390. */
  85391. negateInPlace(): Vector4;
  85392. /**
  85393. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85394. * @param result defines the Vector3 object where to store the result
  85395. * @returns the current Vector4
  85396. */
  85397. negateToRef(result: Vector4): Vector4;
  85398. /**
  85399. * Multiplies the current Vector4 coordinates by scale (float).
  85400. * @param scale the number to scale with
  85401. * @returns the updated Vector4.
  85402. */
  85403. scaleInPlace(scale: number): Vector4;
  85404. /**
  85405. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85406. * @param scale the number to scale with
  85407. * @returns a new vector with the result
  85408. */
  85409. scale(scale: number): Vector4;
  85410. /**
  85411. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85412. * @param scale the number to scale with
  85413. * @param result a vector to store the result in
  85414. * @returns the current Vector4.
  85415. */
  85416. scaleToRef(scale: number, result: Vector4): Vector4;
  85417. /**
  85418. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85419. * @param scale defines the scale factor
  85420. * @param result defines the Vector4 object where to store the result
  85421. * @returns the unmodified current Vector4
  85422. */
  85423. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85424. /**
  85425. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85426. * @param otherVector the vector to compare against
  85427. * @returns true if they are equal
  85428. */
  85429. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85430. /**
  85431. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85432. * @param otherVector vector to compare against
  85433. * @param epsilon (Default: very small number)
  85434. * @returns true if they are equal
  85435. */
  85436. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85437. /**
  85438. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85439. * @param x x value to compare against
  85440. * @param y y value to compare against
  85441. * @param z z value to compare against
  85442. * @param w w value to compare against
  85443. * @returns true if equal
  85444. */
  85445. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85446. /**
  85447. * Multiplies in place the current Vector4 by the given one.
  85448. * @param otherVector vector to multiple with
  85449. * @returns the updated Vector4.
  85450. */
  85451. multiplyInPlace(otherVector: Vector4): Vector4;
  85452. /**
  85453. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85454. * @param otherVector vector to multiple with
  85455. * @returns resulting new vector
  85456. */
  85457. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85458. /**
  85459. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85460. * @param otherVector vector to multiple with
  85461. * @param result vector to store the result
  85462. * @returns the current Vector4.
  85463. */
  85464. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85465. /**
  85466. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85467. * @param x x value multiply with
  85468. * @param y y value multiply with
  85469. * @param z z value multiply with
  85470. * @param w w value multiply with
  85471. * @returns resulting new vector
  85472. */
  85473. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85474. /**
  85475. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85476. * @param otherVector vector to devide with
  85477. * @returns resulting new vector
  85478. */
  85479. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85480. /**
  85481. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85482. * @param otherVector vector to devide with
  85483. * @param result vector to store the result
  85484. * @returns the current Vector4.
  85485. */
  85486. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85487. /**
  85488. * Divides the current Vector3 coordinates by the given ones.
  85489. * @param otherVector vector to devide with
  85490. * @returns the updated Vector3.
  85491. */
  85492. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85493. /**
  85494. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85495. * @param other defines the second operand
  85496. * @returns the current updated Vector4
  85497. */
  85498. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85499. /**
  85500. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85501. * @param other defines the second operand
  85502. * @returns the current updated Vector4
  85503. */
  85504. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85505. /**
  85506. * Gets a new Vector4 from current Vector4 floored values
  85507. * @returns a new Vector4
  85508. */
  85509. floor(): Vector4;
  85510. /**
  85511. * Gets a new Vector4 from current Vector3 floored values
  85512. * @returns a new Vector4
  85513. */
  85514. fract(): Vector4;
  85515. /**
  85516. * Returns the Vector4 length (float).
  85517. * @returns the length
  85518. */
  85519. length(): number;
  85520. /**
  85521. * Returns the Vector4 squared length (float).
  85522. * @returns the length squared
  85523. */
  85524. lengthSquared(): number;
  85525. /**
  85526. * Normalizes in place the Vector4.
  85527. * @returns the updated Vector4.
  85528. */
  85529. normalize(): Vector4;
  85530. /**
  85531. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85532. * @returns this converted to a new vector3
  85533. */
  85534. toVector3(): Vector3;
  85535. /**
  85536. * Returns a new Vector4 copied from the current one.
  85537. * @returns the new cloned vector
  85538. */
  85539. clone(): Vector4;
  85540. /**
  85541. * Updates the current Vector4 with the given one coordinates.
  85542. * @param source the source vector to copy from
  85543. * @returns the updated Vector4.
  85544. */
  85545. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85546. /**
  85547. * Updates the current Vector4 coordinates with the given floats.
  85548. * @param x float to copy from
  85549. * @param y float to copy from
  85550. * @param z float to copy from
  85551. * @param w float to copy from
  85552. * @returns the updated Vector4.
  85553. */
  85554. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85555. /**
  85556. * Updates the current Vector4 coordinates with the given floats.
  85557. * @param x float to set from
  85558. * @param y float to set from
  85559. * @param z float to set from
  85560. * @param w float to set from
  85561. * @returns the updated Vector4.
  85562. */
  85563. set(x: number, y: number, z: number, w: number): Vector4;
  85564. /**
  85565. * Copies the given float to the current Vector3 coordinates
  85566. * @param v defines the x, y, z and w coordinates of the operand
  85567. * @returns the current updated Vector3
  85568. */
  85569. setAll(v: number): Vector4;
  85570. /**
  85571. * Returns a new Vector4 set from the starting index of the given array.
  85572. * @param array the array to pull values from
  85573. * @param offset the offset into the array to start at
  85574. * @returns the new vector
  85575. */
  85576. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85577. /**
  85578. * Updates the given vector "result" from the starting index of the given array.
  85579. * @param array the array to pull values from
  85580. * @param offset the offset into the array to start at
  85581. * @param result the vector to store the result in
  85582. */
  85583. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85584. /**
  85585. * Updates the given vector "result" from the starting index of the given Float32Array.
  85586. * @param array the array to pull values from
  85587. * @param offset the offset into the array to start at
  85588. * @param result the vector to store the result in
  85589. */
  85590. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85591. /**
  85592. * Updates the given vector "result" coordinates from the given floats.
  85593. * @param x float to set from
  85594. * @param y float to set from
  85595. * @param z float to set from
  85596. * @param w float to set from
  85597. * @param result the vector to the floats in
  85598. */
  85599. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85600. /**
  85601. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85602. * @returns the new vector
  85603. */
  85604. static Zero(): Vector4;
  85605. /**
  85606. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85607. * @returns the new vector
  85608. */
  85609. static One(): Vector4;
  85610. /**
  85611. * Returns a new normalized Vector4 from the given one.
  85612. * @param vector the vector to normalize
  85613. * @returns the vector
  85614. */
  85615. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85616. /**
  85617. * Updates the given vector "result" from the normalization of the given one.
  85618. * @param vector the vector to normalize
  85619. * @param result the vector to store the result in
  85620. */
  85621. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85622. /**
  85623. * Returns a vector with the minimum values from the left and right vectors
  85624. * @param left left vector to minimize
  85625. * @param right right vector to minimize
  85626. * @returns a new vector with the minimum of the left and right vector values
  85627. */
  85628. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85629. /**
  85630. * Returns a vector with the maximum values from the left and right vectors
  85631. * @param left left vector to maximize
  85632. * @param right right vector to maximize
  85633. * @returns a new vector with the maximum of the left and right vector values
  85634. */
  85635. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85636. /**
  85637. * Returns the distance (float) between the vectors "value1" and "value2".
  85638. * @param value1 value to calulate the distance between
  85639. * @param value2 value to calulate the distance between
  85640. * @return the distance between the two vectors
  85641. */
  85642. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85643. /**
  85644. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85645. * @param value1 value to calulate the distance between
  85646. * @param value2 value to calulate the distance between
  85647. * @return the distance between the two vectors squared
  85648. */
  85649. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85650. /**
  85651. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85652. * @param value1 value to calulate the center between
  85653. * @param value2 value to calulate the center between
  85654. * @return the center between the two vectors
  85655. */
  85656. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85657. /**
  85658. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85659. * This methods computes transformed normalized direction vectors only.
  85660. * @param vector the vector to transform
  85661. * @param transformation the transformation matrix to apply
  85662. * @returns the new vector
  85663. */
  85664. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85665. /**
  85666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85667. * This methods computes transformed normalized direction vectors only.
  85668. * @param vector the vector to transform
  85669. * @param transformation the transformation matrix to apply
  85670. * @param result the vector to store the result in
  85671. */
  85672. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85673. /**
  85674. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85675. * This methods computes transformed normalized direction vectors only.
  85676. * @param x value to transform
  85677. * @param y value to transform
  85678. * @param z value to transform
  85679. * @param w value to transform
  85680. * @param transformation the transformation matrix to apply
  85681. * @param result the vector to store the results in
  85682. */
  85683. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85684. /**
  85685. * Creates a new Vector4 from a Vector3
  85686. * @param source defines the source data
  85687. * @param w defines the 4th component (default is 0)
  85688. * @returns a new Vector4
  85689. */
  85690. static FromVector3(source: Vector3, w?: number): Vector4;
  85691. }
  85692. /**
  85693. * Class used to store quaternion data
  85694. * @see https://en.wikipedia.org/wiki/Quaternion
  85695. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85696. */
  85697. export class Quaternion {
  85698. /** @hidden */
  85699. _x: number;
  85700. /** @hidden */
  85701. _y: number;
  85702. /** @hidden */
  85703. _z: number;
  85704. /** @hidden */
  85705. _w: number;
  85706. /** @hidden */
  85707. _isDirty: boolean;
  85708. /** Gets or sets the x coordinate */
  85709. get x(): number;
  85710. set x(value: number);
  85711. /** Gets or sets the y coordinate */
  85712. get y(): number;
  85713. set y(value: number);
  85714. /** Gets or sets the z coordinate */
  85715. get z(): number;
  85716. set z(value: number);
  85717. /** Gets or sets the w coordinate */
  85718. get w(): number;
  85719. set w(value: number);
  85720. /**
  85721. * Creates a new Quaternion from the given floats
  85722. * @param x defines the first component (0 by default)
  85723. * @param y defines the second component (0 by default)
  85724. * @param z defines the third component (0 by default)
  85725. * @param w defines the fourth component (1.0 by default)
  85726. */
  85727. constructor(x?: number, y?: number, z?: number, w?: number);
  85728. /**
  85729. * Gets a string representation for the current quaternion
  85730. * @returns a string with the Quaternion coordinates
  85731. */
  85732. toString(): string;
  85733. /**
  85734. * Gets the class name of the quaternion
  85735. * @returns the string "Quaternion"
  85736. */
  85737. getClassName(): string;
  85738. /**
  85739. * Gets a hash code for this quaternion
  85740. * @returns the quaternion hash code
  85741. */
  85742. getHashCode(): number;
  85743. /**
  85744. * Copy the quaternion to an array
  85745. * @returns a new array populated with 4 elements from the quaternion coordinates
  85746. */
  85747. asArray(): number[];
  85748. /**
  85749. * Check if two quaternions are equals
  85750. * @param otherQuaternion defines the second operand
  85751. * @return true if the current quaternion and the given one coordinates are strictly equals
  85752. */
  85753. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85754. /**
  85755. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85756. * @param otherQuaternion defines the other quaternion
  85757. * @param epsilon defines the minimal distance to consider equality
  85758. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85759. */
  85760. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85761. /**
  85762. * Clone the current quaternion
  85763. * @returns a new quaternion copied from the current one
  85764. */
  85765. clone(): Quaternion;
  85766. /**
  85767. * Copy a quaternion to the current one
  85768. * @param other defines the other quaternion
  85769. * @returns the updated current quaternion
  85770. */
  85771. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85772. /**
  85773. * Updates the current quaternion with the given float coordinates
  85774. * @param x defines the x coordinate
  85775. * @param y defines the y coordinate
  85776. * @param z defines the z coordinate
  85777. * @param w defines the w coordinate
  85778. * @returns the updated current quaternion
  85779. */
  85780. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85781. /**
  85782. * Updates the current quaternion from the given float coordinates
  85783. * @param x defines the x coordinate
  85784. * @param y defines the y coordinate
  85785. * @param z defines the z coordinate
  85786. * @param w defines the w coordinate
  85787. * @returns the updated current quaternion
  85788. */
  85789. set(x: number, y: number, z: number, w: number): Quaternion;
  85790. /**
  85791. * Adds two quaternions
  85792. * @param other defines the second operand
  85793. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85794. */
  85795. add(other: DeepImmutable<Quaternion>): Quaternion;
  85796. /**
  85797. * Add a quaternion to the current one
  85798. * @param other defines the quaternion to add
  85799. * @returns the current quaternion
  85800. */
  85801. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85802. /**
  85803. * Subtract two quaternions
  85804. * @param other defines the second operand
  85805. * @returns a new quaternion as the subtraction result of the given one from the current one
  85806. */
  85807. subtract(other: Quaternion): Quaternion;
  85808. /**
  85809. * Multiplies the current quaternion by a scale factor
  85810. * @param value defines the scale factor
  85811. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85812. */
  85813. scale(value: number): Quaternion;
  85814. /**
  85815. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85816. * @param scale defines the scale factor
  85817. * @param result defines the Quaternion object where to store the result
  85818. * @returns the unmodified current quaternion
  85819. */
  85820. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85821. /**
  85822. * Multiplies in place the current quaternion by a scale factor
  85823. * @param value defines the scale factor
  85824. * @returns the current modified quaternion
  85825. */
  85826. scaleInPlace(value: number): Quaternion;
  85827. /**
  85828. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85829. * @param scale defines the scale factor
  85830. * @param result defines the Quaternion object where to store the result
  85831. * @returns the unmodified current quaternion
  85832. */
  85833. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85834. /**
  85835. * Multiplies two quaternions
  85836. * @param q1 defines the second operand
  85837. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85838. */
  85839. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85840. /**
  85841. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85842. * @param q1 defines the second operand
  85843. * @param result defines the target quaternion
  85844. * @returns the current quaternion
  85845. */
  85846. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85847. /**
  85848. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85849. * @param q1 defines the second operand
  85850. * @returns the currentupdated quaternion
  85851. */
  85852. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85853. /**
  85854. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85855. * @param ref defines the target quaternion
  85856. * @returns the current quaternion
  85857. */
  85858. conjugateToRef(ref: Quaternion): Quaternion;
  85859. /**
  85860. * Conjugates in place (1-q) the current quaternion
  85861. * @returns the current updated quaternion
  85862. */
  85863. conjugateInPlace(): Quaternion;
  85864. /**
  85865. * Conjugates in place (1-q) the current quaternion
  85866. * @returns a new quaternion
  85867. */
  85868. conjugate(): Quaternion;
  85869. /**
  85870. * Gets length of current quaternion
  85871. * @returns the quaternion length (float)
  85872. */
  85873. length(): number;
  85874. /**
  85875. * Normalize in place the current quaternion
  85876. * @returns the current updated quaternion
  85877. */
  85878. normalize(): Quaternion;
  85879. /**
  85880. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85881. * @param order is a reserved parameter and is ignored for now
  85882. * @returns a new Vector3 containing the Euler angles
  85883. */
  85884. toEulerAngles(order?: string): Vector3;
  85885. /**
  85886. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85887. * @param result defines the vector which will be filled with the Euler angles
  85888. * @returns the current unchanged quaternion
  85889. */
  85890. toEulerAnglesToRef(result: Vector3): Quaternion;
  85891. /**
  85892. * Updates the given rotation matrix with the current quaternion values
  85893. * @param result defines the target matrix
  85894. * @returns the current unchanged quaternion
  85895. */
  85896. toRotationMatrix(result: Matrix): Quaternion;
  85897. /**
  85898. * Updates the current quaternion from the given rotation matrix values
  85899. * @param matrix defines the source matrix
  85900. * @returns the current updated quaternion
  85901. */
  85902. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85903. /**
  85904. * Creates a new quaternion from a rotation matrix
  85905. * @param matrix defines the source matrix
  85906. * @returns a new quaternion created from the given rotation matrix values
  85907. */
  85908. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85909. /**
  85910. * Updates the given quaternion with the given rotation matrix values
  85911. * @param matrix defines the source matrix
  85912. * @param result defines the target quaternion
  85913. */
  85914. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85915. /**
  85916. * Returns the dot product (float) between the quaternions "left" and "right"
  85917. * @param left defines the left operand
  85918. * @param right defines the right operand
  85919. * @returns the dot product
  85920. */
  85921. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85922. /**
  85923. * Checks if the two quaternions are close to each other
  85924. * @param quat0 defines the first quaternion to check
  85925. * @param quat1 defines the second quaternion to check
  85926. * @returns true if the two quaternions are close to each other
  85927. */
  85928. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85929. /**
  85930. * Creates an empty quaternion
  85931. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85932. */
  85933. static Zero(): Quaternion;
  85934. /**
  85935. * Inverse a given quaternion
  85936. * @param q defines the source quaternion
  85937. * @returns a new quaternion as the inverted current quaternion
  85938. */
  85939. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85940. /**
  85941. * Inverse a given quaternion
  85942. * @param q defines the source quaternion
  85943. * @param result the quaternion the result will be stored in
  85944. * @returns the result quaternion
  85945. */
  85946. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85947. /**
  85948. * Creates an identity quaternion
  85949. * @returns the identity quaternion
  85950. */
  85951. static Identity(): Quaternion;
  85952. /**
  85953. * Gets a boolean indicating if the given quaternion is identity
  85954. * @param quaternion defines the quaternion to check
  85955. * @returns true if the quaternion is identity
  85956. */
  85957. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85958. /**
  85959. * Creates a quaternion from a rotation around an axis
  85960. * @param axis defines the axis to use
  85961. * @param angle defines the angle to use
  85962. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85963. */
  85964. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85965. /**
  85966. * Creates a rotation around an axis and stores it into the given quaternion
  85967. * @param axis defines the axis to use
  85968. * @param angle defines the angle to use
  85969. * @param result defines the target quaternion
  85970. * @returns the target quaternion
  85971. */
  85972. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85973. /**
  85974. * Creates a new quaternion from data stored into an array
  85975. * @param array defines the data source
  85976. * @param offset defines the offset in the source array where the data starts
  85977. * @returns a new quaternion
  85978. */
  85979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85980. /**
  85981. * Updates the given quaternion "result" from the starting index of the given array.
  85982. * @param array the array to pull values from
  85983. * @param offset the offset into the array to start at
  85984. * @param result the quaternion to store the result in
  85985. */
  85986. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85987. /**
  85988. * Create a quaternion from Euler rotation angles
  85989. * @param x Pitch
  85990. * @param y Yaw
  85991. * @param z Roll
  85992. * @returns the new Quaternion
  85993. */
  85994. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85995. /**
  85996. * Updates a quaternion from Euler rotation angles
  85997. * @param x Pitch
  85998. * @param y Yaw
  85999. * @param z Roll
  86000. * @param result the quaternion to store the result
  86001. * @returns the updated quaternion
  86002. */
  86003. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  86004. /**
  86005. * Create a quaternion from Euler rotation vector
  86006. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  86007. * @returns the new Quaternion
  86008. */
  86009. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  86010. /**
  86011. * Updates a quaternion from Euler rotation vector
  86012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  86013. * @param result the quaternion to store the result
  86014. * @returns the updated quaternion
  86015. */
  86016. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  86017. /**
  86018. * Creates a new quaternion from the given Euler float angles (y, x, z)
  86019. * @param yaw defines the rotation around Y axis
  86020. * @param pitch defines the rotation around X axis
  86021. * @param roll defines the rotation around Z axis
  86022. * @returns the new quaternion
  86023. */
  86024. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  86025. /**
  86026. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  86027. * @param yaw defines the rotation around Y axis
  86028. * @param pitch defines the rotation around X axis
  86029. * @param roll defines the rotation around Z axis
  86030. * @param result defines the target quaternion
  86031. */
  86032. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  86033. /**
  86034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  86035. * @param alpha defines the rotation around first axis
  86036. * @param beta defines the rotation around second axis
  86037. * @param gamma defines the rotation around third axis
  86038. * @returns the new quaternion
  86039. */
  86040. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  86041. /**
  86042. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  86043. * @param alpha defines the rotation around first axis
  86044. * @param beta defines the rotation around second axis
  86045. * @param gamma defines the rotation around third axis
  86046. * @param result defines the target quaternion
  86047. */
  86048. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  86049. /**
  86050. * 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)
  86051. * @param axis1 defines the first axis
  86052. * @param axis2 defines the second axis
  86053. * @param axis3 defines the third axis
  86054. * @returns the new quaternion
  86055. */
  86056. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  86057. /**
  86058. * 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
  86059. * @param axis1 defines the first axis
  86060. * @param axis2 defines the second axis
  86061. * @param axis3 defines the third axis
  86062. * @param ref defines the target quaternion
  86063. */
  86064. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  86065. /**
  86066. * Interpolates between two quaternions
  86067. * @param left defines first quaternion
  86068. * @param right defines second quaternion
  86069. * @param amount defines the gradient to use
  86070. * @returns the new interpolated quaternion
  86071. */
  86072. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86073. /**
  86074. * Interpolates between two quaternions and stores it into a target quaternion
  86075. * @param left defines first quaternion
  86076. * @param right defines second quaternion
  86077. * @param amount defines the gradient to use
  86078. * @param result defines the target quaternion
  86079. */
  86080. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  86081. /**
  86082. * Interpolate between two quaternions using Hermite interpolation
  86083. * @param value1 defines first quaternion
  86084. * @param tangent1 defines the incoming tangent
  86085. * @param value2 defines second quaternion
  86086. * @param tangent2 defines the outgoing tangent
  86087. * @param amount defines the target quaternion
  86088. * @returns the new interpolated quaternion
  86089. */
  86090. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86091. }
  86092. /**
  86093. * Class used to store matrix data (4x4)
  86094. */
  86095. export class Matrix {
  86096. /**
  86097. * Gets the precision of matrix computations
  86098. */
  86099. static get Use64Bits(): boolean;
  86100. private static _updateFlagSeed;
  86101. private static _identityReadOnly;
  86102. private _isIdentity;
  86103. private _isIdentityDirty;
  86104. private _isIdentity3x2;
  86105. private _isIdentity3x2Dirty;
  86106. /**
  86107. * Gets the update flag of the matrix which is an unique number for the matrix.
  86108. * It will be incremented every time the matrix data change.
  86109. * You can use it to speed the comparison between two versions of the same matrix.
  86110. */
  86111. updateFlag: number;
  86112. private readonly _m;
  86113. /**
  86114. * Gets the internal data of the matrix
  86115. */
  86116. get m(): DeepImmutable<Float32Array | Array<number>>;
  86117. /** @hidden */
  86118. _markAsUpdated(): void;
  86119. /** @hidden */
  86120. private _updateIdentityStatus;
  86121. /**
  86122. * Creates an empty matrix (filled with zeros)
  86123. */
  86124. constructor();
  86125. /**
  86126. * Check if the current matrix is identity
  86127. * @returns true is the matrix is the identity matrix
  86128. */
  86129. isIdentity(): boolean;
  86130. /**
  86131. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  86132. * @returns true is the matrix is the identity matrix
  86133. */
  86134. isIdentityAs3x2(): boolean;
  86135. /**
  86136. * Gets the determinant of the matrix
  86137. * @returns the matrix determinant
  86138. */
  86139. determinant(): number;
  86140. /**
  86141. * Returns the matrix as a Float32Array or Array<number>
  86142. * @returns the matrix underlying array
  86143. */
  86144. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86145. /**
  86146. * Returns the matrix as a Float32Array or Array<number>
  86147. * @returns the matrix underlying array.
  86148. */
  86149. asArray(): DeepImmutable<Float32Array | Array<number>>;
  86150. /**
  86151. * Inverts the current matrix in place
  86152. * @returns the current inverted matrix
  86153. */
  86154. invert(): Matrix;
  86155. /**
  86156. * Sets all the matrix elements to zero
  86157. * @returns the current matrix
  86158. */
  86159. reset(): Matrix;
  86160. /**
  86161. * Adds the current matrix with a second one
  86162. * @param other defines the matrix to add
  86163. * @returns a new matrix as the addition of the current matrix and the given one
  86164. */
  86165. add(other: DeepImmutable<Matrix>): Matrix;
  86166. /**
  86167. * Sets the given matrix "result" to the addition of the current matrix and the given one
  86168. * @param other defines the matrix to add
  86169. * @param result defines the target matrix
  86170. * @returns the current matrix
  86171. */
  86172. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86173. /**
  86174. * Adds in place the given matrix to the current matrix
  86175. * @param other defines the second operand
  86176. * @returns the current updated matrix
  86177. */
  86178. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  86179. /**
  86180. * Sets the given matrix to the current inverted Matrix
  86181. * @param other defines the target matrix
  86182. * @returns the unmodified current matrix
  86183. */
  86184. invertToRef(other: Matrix): Matrix;
  86185. /**
  86186. * add a value at the specified position in the current Matrix
  86187. * @param index the index of the value within the matrix. between 0 and 15.
  86188. * @param value the value to be added
  86189. * @returns the current updated matrix
  86190. */
  86191. addAtIndex(index: number, value: number): Matrix;
  86192. /**
  86193. * mutiply the specified position in the current Matrix by a value
  86194. * @param index the index of the value within the matrix. between 0 and 15.
  86195. * @param value the value to be added
  86196. * @returns the current updated matrix
  86197. */
  86198. multiplyAtIndex(index: number, value: number): Matrix;
  86199. /**
  86200. * Inserts the translation vector (using 3 floats) in the current matrix
  86201. * @param x defines the 1st component of the translation
  86202. * @param y defines the 2nd component of the translation
  86203. * @param z defines the 3rd component of the translation
  86204. * @returns the current updated matrix
  86205. */
  86206. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86207. /**
  86208. * Adds the translation vector (using 3 floats) in the current matrix
  86209. * @param x defines the 1st component of the translation
  86210. * @param y defines the 2nd component of the translation
  86211. * @param z defines the 3rd component of the translation
  86212. * @returns the current updated matrix
  86213. */
  86214. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86215. /**
  86216. * Inserts the translation vector in the current matrix
  86217. * @param vector3 defines the translation to insert
  86218. * @returns the current updated matrix
  86219. */
  86220. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  86221. /**
  86222. * Gets the translation value of the current matrix
  86223. * @returns a new Vector3 as the extracted translation from the matrix
  86224. */
  86225. getTranslation(): Vector3;
  86226. /**
  86227. * Fill a Vector3 with the extracted translation from the matrix
  86228. * @param result defines the Vector3 where to store the translation
  86229. * @returns the current matrix
  86230. */
  86231. getTranslationToRef(result: Vector3): Matrix;
  86232. /**
  86233. * Remove rotation and scaling part from the matrix
  86234. * @returns the updated matrix
  86235. */
  86236. removeRotationAndScaling(): Matrix;
  86237. /**
  86238. * Multiply two matrices
  86239. * @param other defines the second operand
  86240. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86241. */
  86242. multiply(other: DeepImmutable<Matrix>): Matrix;
  86243. /**
  86244. * Copy the current matrix from the given one
  86245. * @param other defines the source matrix
  86246. * @returns the current updated matrix
  86247. */
  86248. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86249. /**
  86250. * Populates the given array from the starting index with the current matrix values
  86251. * @param array defines the target array
  86252. * @param offset defines the offset in the target array where to start storing values
  86253. * @returns the current matrix
  86254. */
  86255. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86256. /**
  86257. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86258. * @param other defines the second operand
  86259. * @param result defines the matrix where to store the multiplication
  86260. * @returns the current matrix
  86261. */
  86262. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86263. /**
  86264. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86265. * @param other defines the second operand
  86266. * @param result defines the array where to store the multiplication
  86267. * @param offset defines the offset in the target array where to start storing values
  86268. * @returns the current matrix
  86269. */
  86270. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86271. /**
  86272. * Check equality between this matrix and a second one
  86273. * @param value defines the second matrix to compare
  86274. * @returns true is the current matrix and the given one values are strictly equal
  86275. */
  86276. equals(value: DeepImmutable<Matrix>): boolean;
  86277. /**
  86278. * Clone the current matrix
  86279. * @returns a new matrix from the current matrix
  86280. */
  86281. clone(): Matrix;
  86282. /**
  86283. * Returns the name of the current matrix class
  86284. * @returns the string "Matrix"
  86285. */
  86286. getClassName(): string;
  86287. /**
  86288. * Gets the hash code of the current matrix
  86289. * @returns the hash code
  86290. */
  86291. getHashCode(): number;
  86292. /**
  86293. * Decomposes the current Matrix into a translation, rotation and scaling components
  86294. * @param scale defines the scale vector3 given as a reference to update
  86295. * @param rotation defines the rotation quaternion given as a reference to update
  86296. * @param translation defines the translation vector3 given as a reference to update
  86297. * @returns true if operation was successful
  86298. */
  86299. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86300. /**
  86301. * Gets specific row of the matrix
  86302. * @param index defines the number of the row to get
  86303. * @returns the index-th row of the current matrix as a new Vector4
  86304. */
  86305. getRow(index: number): Nullable<Vector4>;
  86306. /**
  86307. * Sets the index-th row of the current matrix to the vector4 values
  86308. * @param index defines the number of the row to set
  86309. * @param row defines the target vector4
  86310. * @returns the updated current matrix
  86311. */
  86312. setRow(index: number, row: Vector4): Matrix;
  86313. /**
  86314. * Compute the transpose of the matrix
  86315. * @returns the new transposed matrix
  86316. */
  86317. transpose(): Matrix;
  86318. /**
  86319. * Compute the transpose of the matrix and store it in a given matrix
  86320. * @param result defines the target matrix
  86321. * @returns the current matrix
  86322. */
  86323. transposeToRef(result: Matrix): Matrix;
  86324. /**
  86325. * Sets the index-th row of the current matrix with the given 4 x float values
  86326. * @param index defines the row index
  86327. * @param x defines the x component to set
  86328. * @param y defines the y component to set
  86329. * @param z defines the z component to set
  86330. * @param w defines the w component to set
  86331. * @returns the updated current matrix
  86332. */
  86333. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86334. /**
  86335. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86336. * @param scale defines the scale factor
  86337. * @returns a new matrix
  86338. */
  86339. scale(scale: number): Matrix;
  86340. /**
  86341. * Scale the current matrix values by a factor to a given result matrix
  86342. * @param scale defines the scale factor
  86343. * @param result defines the matrix to store the result
  86344. * @returns the current matrix
  86345. */
  86346. scaleToRef(scale: number, result: Matrix): Matrix;
  86347. /**
  86348. * Scale the current matrix values by a factor and add the result to a given matrix
  86349. * @param scale defines the scale factor
  86350. * @param result defines the Matrix to store the result
  86351. * @returns the current matrix
  86352. */
  86353. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86354. /**
  86355. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86356. * @param ref matrix to store the result
  86357. */
  86358. toNormalMatrix(ref: Matrix): void;
  86359. /**
  86360. * Gets only rotation part of the current matrix
  86361. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86362. */
  86363. getRotationMatrix(): Matrix;
  86364. /**
  86365. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86366. * @param result defines the target matrix to store data to
  86367. * @returns the current matrix
  86368. */
  86369. getRotationMatrixToRef(result: Matrix): Matrix;
  86370. /**
  86371. * Toggles model matrix from being right handed to left handed in place and vice versa
  86372. */
  86373. toggleModelMatrixHandInPlace(): void;
  86374. /**
  86375. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86376. */
  86377. toggleProjectionMatrixHandInPlace(): void;
  86378. /**
  86379. * Creates a matrix from an array
  86380. * @param array defines the source array
  86381. * @param offset defines an offset in the source array
  86382. * @returns a new Matrix set from the starting index of the given array
  86383. */
  86384. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86385. /**
  86386. * Copy the content of an array into a given matrix
  86387. * @param array defines the source array
  86388. * @param offset defines an offset in the source array
  86389. * @param result defines the target matrix
  86390. */
  86391. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86392. /**
  86393. * Stores an array into a matrix after having multiplied each component by a given factor
  86394. * @param array defines the source array
  86395. * @param offset defines the offset in the source array
  86396. * @param scale defines the scaling factor
  86397. * @param result defines the target matrix
  86398. */
  86399. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86400. /**
  86401. * Gets an identity matrix that must not be updated
  86402. */
  86403. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86404. /**
  86405. * Stores a list of values (16) inside a given matrix
  86406. * @param initialM11 defines 1st value of 1st row
  86407. * @param initialM12 defines 2nd value of 1st row
  86408. * @param initialM13 defines 3rd value of 1st row
  86409. * @param initialM14 defines 4th value of 1st row
  86410. * @param initialM21 defines 1st value of 2nd row
  86411. * @param initialM22 defines 2nd value of 2nd row
  86412. * @param initialM23 defines 3rd value of 2nd row
  86413. * @param initialM24 defines 4th value of 2nd row
  86414. * @param initialM31 defines 1st value of 3rd row
  86415. * @param initialM32 defines 2nd value of 3rd row
  86416. * @param initialM33 defines 3rd value of 3rd row
  86417. * @param initialM34 defines 4th value of 3rd row
  86418. * @param initialM41 defines 1st value of 4th row
  86419. * @param initialM42 defines 2nd value of 4th row
  86420. * @param initialM43 defines 3rd value of 4th row
  86421. * @param initialM44 defines 4th value of 4th row
  86422. * @param result defines the target matrix
  86423. */
  86424. 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;
  86425. /**
  86426. * Creates new matrix from a list of values (16)
  86427. * @param initialM11 defines 1st value of 1st row
  86428. * @param initialM12 defines 2nd value of 1st row
  86429. * @param initialM13 defines 3rd value of 1st row
  86430. * @param initialM14 defines 4th value of 1st row
  86431. * @param initialM21 defines 1st value of 2nd row
  86432. * @param initialM22 defines 2nd value of 2nd row
  86433. * @param initialM23 defines 3rd value of 2nd row
  86434. * @param initialM24 defines 4th value of 2nd row
  86435. * @param initialM31 defines 1st value of 3rd row
  86436. * @param initialM32 defines 2nd value of 3rd row
  86437. * @param initialM33 defines 3rd value of 3rd row
  86438. * @param initialM34 defines 4th value of 3rd row
  86439. * @param initialM41 defines 1st value of 4th row
  86440. * @param initialM42 defines 2nd value of 4th row
  86441. * @param initialM43 defines 3rd value of 4th row
  86442. * @param initialM44 defines 4th value of 4th row
  86443. * @returns the new matrix
  86444. */
  86445. 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;
  86446. /**
  86447. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86448. * @param scale defines the scale vector3
  86449. * @param rotation defines the rotation quaternion
  86450. * @param translation defines the translation vector3
  86451. * @returns a new matrix
  86452. */
  86453. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86454. /**
  86455. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86456. * @param scale defines the scale vector3
  86457. * @param rotation defines the rotation quaternion
  86458. * @param translation defines the translation vector3
  86459. * @param result defines the target matrix
  86460. */
  86461. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86462. /**
  86463. * Creates a new identity matrix
  86464. * @returns a new identity matrix
  86465. */
  86466. static Identity(): Matrix;
  86467. /**
  86468. * Creates a new identity matrix and stores the result in a given matrix
  86469. * @param result defines the target matrix
  86470. */
  86471. static IdentityToRef(result: Matrix): void;
  86472. /**
  86473. * Creates a new zero matrix
  86474. * @returns a new zero matrix
  86475. */
  86476. static Zero(): Matrix;
  86477. /**
  86478. * Creates a new rotation matrix for "angle" radians around the X axis
  86479. * @param angle defines the angle (in radians) to use
  86480. * @return the new matrix
  86481. */
  86482. static RotationX(angle: number): Matrix;
  86483. /**
  86484. * Creates a new matrix as the invert of a given matrix
  86485. * @param source defines the source matrix
  86486. * @returns the new matrix
  86487. */
  86488. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86489. /**
  86490. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86491. * @param angle defines the angle (in radians) to use
  86492. * @param result defines the target matrix
  86493. */
  86494. static RotationXToRef(angle: number, result: Matrix): void;
  86495. /**
  86496. * Creates a new rotation matrix for "angle" radians around the Y axis
  86497. * @param angle defines the angle (in radians) to use
  86498. * @return the new matrix
  86499. */
  86500. static RotationY(angle: number): Matrix;
  86501. /**
  86502. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86503. * @param angle defines the angle (in radians) to use
  86504. * @param result defines the target matrix
  86505. */
  86506. static RotationYToRef(angle: number, result: Matrix): void;
  86507. /**
  86508. * Creates a new rotation matrix for "angle" radians around the Z axis
  86509. * @param angle defines the angle (in radians) to use
  86510. * @return the new matrix
  86511. */
  86512. static RotationZ(angle: number): Matrix;
  86513. /**
  86514. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86515. * @param angle defines the angle (in radians) to use
  86516. * @param result defines the target matrix
  86517. */
  86518. static RotationZToRef(angle: number, result: Matrix): void;
  86519. /**
  86520. * Creates a new rotation matrix for "angle" radians around the given axis
  86521. * @param axis defines the axis to use
  86522. * @param angle defines the angle (in radians) to use
  86523. * @return the new matrix
  86524. */
  86525. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86526. /**
  86527. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86528. * @param axis defines the axis to use
  86529. * @param angle defines the angle (in radians) to use
  86530. * @param result defines the target matrix
  86531. */
  86532. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86533. /**
  86534. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86535. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86536. * @param from defines the vector to align
  86537. * @param to defines the vector to align to
  86538. * @param result defines the target matrix
  86539. */
  86540. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86541. /**
  86542. * Creates a rotation matrix
  86543. * @param yaw defines the yaw angle in radians (Y axis)
  86544. * @param pitch defines the pitch angle in radians (X axis)
  86545. * @param roll defines the roll angle in radians (Z axis)
  86546. * @returns the new rotation matrix
  86547. */
  86548. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86549. /**
  86550. * Creates a rotation matrix and stores it in a given matrix
  86551. * @param yaw defines the yaw angle in radians (Y axis)
  86552. * @param pitch defines the pitch angle in radians (X axis)
  86553. * @param roll defines the roll angle in radians (Z axis)
  86554. * @param result defines the target matrix
  86555. */
  86556. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86557. /**
  86558. * Creates a scaling matrix
  86559. * @param x defines the scale factor on X axis
  86560. * @param y defines the scale factor on Y axis
  86561. * @param z defines the scale factor on Z axis
  86562. * @returns the new matrix
  86563. */
  86564. static Scaling(x: number, y: number, z: number): Matrix;
  86565. /**
  86566. * Creates a scaling matrix and stores it in a given matrix
  86567. * @param x defines the scale factor on X axis
  86568. * @param y defines the scale factor on Y axis
  86569. * @param z defines the scale factor on Z axis
  86570. * @param result defines the target matrix
  86571. */
  86572. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86573. /**
  86574. * Creates a translation matrix
  86575. * @param x defines the translation on X axis
  86576. * @param y defines the translation on Y axis
  86577. * @param z defines the translationon Z axis
  86578. * @returns the new matrix
  86579. */
  86580. static Translation(x: number, y: number, z: number): Matrix;
  86581. /**
  86582. * Creates a translation matrix and stores it in a given matrix
  86583. * @param x defines the translation on X axis
  86584. * @param y defines the translation on Y axis
  86585. * @param z defines the translationon Z axis
  86586. * @param result defines the target matrix
  86587. */
  86588. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86589. /**
  86590. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86591. * @param startValue defines the start value
  86592. * @param endValue defines the end value
  86593. * @param gradient defines the gradient factor
  86594. * @returns the new matrix
  86595. */
  86596. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86597. /**
  86598. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86599. * @param startValue defines the start value
  86600. * @param endValue defines the end value
  86601. * @param gradient defines the gradient factor
  86602. * @param result defines the Matrix object where to store data
  86603. */
  86604. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86605. /**
  86606. * Builds a new matrix whose values are computed by:
  86607. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86608. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86609. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86610. * @param startValue defines the first matrix
  86611. * @param endValue defines the second matrix
  86612. * @param gradient defines the gradient between the two matrices
  86613. * @returns the new matrix
  86614. */
  86615. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86616. /**
  86617. * Update a matrix to values which are computed by:
  86618. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86619. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86620. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86621. * @param startValue defines the first matrix
  86622. * @param endValue defines the second matrix
  86623. * @param gradient defines the gradient between the two matrices
  86624. * @param result defines the target matrix
  86625. */
  86626. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86627. /**
  86628. * 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"
  86629. * This function works in left handed mode
  86630. * @param eye defines the final position of the entity
  86631. * @param target defines where the entity should look at
  86632. * @param up defines the up vector for the entity
  86633. * @returns the new matrix
  86634. */
  86635. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86636. /**
  86637. * 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".
  86638. * This function works in left handed mode
  86639. * @param eye defines the final position of the entity
  86640. * @param target defines where the entity should look at
  86641. * @param up defines the up vector for the entity
  86642. * @param result defines the target matrix
  86643. */
  86644. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86645. /**
  86646. * 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"
  86647. * This function works in right handed mode
  86648. * @param eye defines the final position of the entity
  86649. * @param target defines where the entity should look at
  86650. * @param up defines the up vector for the entity
  86651. * @returns the new matrix
  86652. */
  86653. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86654. /**
  86655. * 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".
  86656. * This function works in right handed mode
  86657. * @param eye defines the final position of the entity
  86658. * @param target defines where the entity should look at
  86659. * @param up defines the up vector for the entity
  86660. * @param result defines the target matrix
  86661. */
  86662. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86663. /**
  86664. * Create a left-handed orthographic projection matrix
  86665. * @param width defines the viewport width
  86666. * @param height defines the viewport height
  86667. * @param znear defines the near clip plane
  86668. * @param zfar defines the far clip plane
  86669. * @returns a new matrix as a left-handed orthographic projection matrix
  86670. */
  86671. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86672. /**
  86673. * Store a left-handed orthographic projection to a given matrix
  86674. * @param width defines the viewport width
  86675. * @param height defines the viewport height
  86676. * @param znear defines the near clip plane
  86677. * @param zfar defines the far clip plane
  86678. * @param result defines the target matrix
  86679. */
  86680. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86681. /**
  86682. * Create a left-handed orthographic projection matrix
  86683. * @param left defines the viewport left coordinate
  86684. * @param right defines the viewport right coordinate
  86685. * @param bottom defines the viewport bottom coordinate
  86686. * @param top defines the viewport top coordinate
  86687. * @param znear defines the near clip plane
  86688. * @param zfar defines the far clip plane
  86689. * @returns a new matrix as a left-handed orthographic projection matrix
  86690. */
  86691. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86692. /**
  86693. * Stores a left-handed orthographic projection into a given matrix
  86694. * @param left defines the viewport left coordinate
  86695. * @param right defines the viewport right coordinate
  86696. * @param bottom defines the viewport bottom coordinate
  86697. * @param top defines the viewport top coordinate
  86698. * @param znear defines the near clip plane
  86699. * @param zfar defines the far clip plane
  86700. * @param result defines the target matrix
  86701. */
  86702. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86703. /**
  86704. * Creates a right-handed orthographic projection matrix
  86705. * @param left defines the viewport left coordinate
  86706. * @param right defines the viewport right coordinate
  86707. * @param bottom defines the viewport bottom coordinate
  86708. * @param top defines the viewport top coordinate
  86709. * @param znear defines the near clip plane
  86710. * @param zfar defines the far clip plane
  86711. * @returns a new matrix as a right-handed orthographic projection matrix
  86712. */
  86713. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86714. /**
  86715. * Stores a right-handed orthographic projection into a given matrix
  86716. * @param left defines the viewport left coordinate
  86717. * @param right defines the viewport right coordinate
  86718. * @param bottom defines the viewport bottom coordinate
  86719. * @param top defines the viewport top coordinate
  86720. * @param znear defines the near clip plane
  86721. * @param zfar defines the far clip plane
  86722. * @param result defines the target matrix
  86723. */
  86724. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86725. /**
  86726. * Creates a left-handed perspective projection matrix
  86727. * @param width defines the viewport width
  86728. * @param height defines the viewport height
  86729. * @param znear defines the near clip plane
  86730. * @param zfar defines the far clip plane
  86731. * @returns a new matrix as a left-handed perspective projection matrix
  86732. */
  86733. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86734. /**
  86735. * Creates a left-handed perspective projection matrix
  86736. * @param fov defines the horizontal field of view
  86737. * @param aspect defines the aspect ratio
  86738. * @param znear defines the near clip plane
  86739. * @param zfar defines the far clip plane
  86740. * @returns a new matrix as a left-handed perspective projection matrix
  86741. */
  86742. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86743. /**
  86744. * Stores a left-handed perspective projection into a given matrix
  86745. * @param fov defines the horizontal field of view
  86746. * @param aspect defines the aspect ratio
  86747. * @param znear defines the near clip plane
  86748. * @param zfar defines the far clip plane
  86749. * @param result defines the target matrix
  86750. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86751. */
  86752. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86753. /**
  86754. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86755. * @param fov defines the horizontal field of view
  86756. * @param aspect defines the aspect ratio
  86757. * @param znear defines the near clip plane
  86758. * @param zfar not used as infinity is used as far clip
  86759. * @param result defines the target matrix
  86760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86761. */
  86762. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86763. /**
  86764. * Creates a right-handed perspective projection matrix
  86765. * @param fov defines the horizontal field of view
  86766. * @param aspect defines the aspect ratio
  86767. * @param znear defines the near clip plane
  86768. * @param zfar defines the far clip plane
  86769. * @returns a new matrix as a right-handed perspective projection matrix
  86770. */
  86771. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86772. /**
  86773. * Stores a right-handed perspective projection into a given matrix
  86774. * @param fov defines the horizontal field of view
  86775. * @param aspect defines the aspect ratio
  86776. * @param znear defines the near clip plane
  86777. * @param zfar defines the far clip plane
  86778. * @param result defines the target matrix
  86779. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86780. */
  86781. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86782. /**
  86783. * Stores a right-handed perspective projection into a given matrix
  86784. * @param fov defines the horizontal field of view
  86785. * @param aspect defines the aspect ratio
  86786. * @param znear defines the near clip plane
  86787. * @param zfar not used as infinity is used as far clip
  86788. * @param result defines the target matrix
  86789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86790. */
  86791. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86792. /**
  86793. * Stores a perspective projection for WebVR info a given matrix
  86794. * @param fov defines the field of view
  86795. * @param znear defines the near clip plane
  86796. * @param zfar defines the far clip plane
  86797. * @param result defines the target matrix
  86798. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86799. */
  86800. static PerspectiveFovWebVRToRef(fov: {
  86801. upDegrees: number;
  86802. downDegrees: number;
  86803. leftDegrees: number;
  86804. rightDegrees: number;
  86805. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86806. /**
  86807. * Computes a complete transformation matrix
  86808. * @param viewport defines the viewport to use
  86809. * @param world defines the world matrix
  86810. * @param view defines the view matrix
  86811. * @param projection defines the projection matrix
  86812. * @param zmin defines the near clip plane
  86813. * @param zmax defines the far clip plane
  86814. * @returns the transformation matrix
  86815. */
  86816. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86817. /**
  86818. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86819. * @param matrix defines the matrix to use
  86820. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86821. */
  86822. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86823. /**
  86824. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86825. * @param matrix defines the matrix to use
  86826. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86827. */
  86828. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86829. /**
  86830. * Compute the transpose of a given matrix
  86831. * @param matrix defines the matrix to transpose
  86832. * @returns the new matrix
  86833. */
  86834. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86835. /**
  86836. * Compute the transpose of a matrix and store it in a target matrix
  86837. * @param matrix defines the matrix to transpose
  86838. * @param result defines the target matrix
  86839. */
  86840. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86841. /**
  86842. * Computes a reflection matrix from a plane
  86843. * @param plane defines the reflection plane
  86844. * @returns a new matrix
  86845. */
  86846. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86847. /**
  86848. * Computes a reflection matrix from a plane
  86849. * @param plane defines the reflection plane
  86850. * @param result defines the target matrix
  86851. */
  86852. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86853. /**
  86854. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86855. * @param xaxis defines the value of the 1st axis
  86856. * @param yaxis defines the value of the 2nd axis
  86857. * @param zaxis defines the value of the 3rd axis
  86858. * @param result defines the target matrix
  86859. */
  86860. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86861. /**
  86862. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86863. * @param quat defines the quaternion to use
  86864. * @param result defines the target matrix
  86865. */
  86866. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86867. }
  86868. /**
  86869. * @hidden
  86870. */
  86871. export class TmpVectors {
  86872. static Vector2: Vector2[];
  86873. static Vector3: Vector3[];
  86874. static Vector4: Vector4[];
  86875. static Quaternion: Quaternion[];
  86876. static Matrix: Matrix[];
  86877. }
  86878. }
  86879. declare module BABYLON {
  86880. /**
  86881. * Defines potential orientation for back face culling
  86882. */
  86883. export enum Orientation {
  86884. /**
  86885. * Clockwise
  86886. */
  86887. CW = 0,
  86888. /** Counter clockwise */
  86889. CCW = 1
  86890. }
  86891. /** Class used to represent a Bezier curve */
  86892. export class BezierCurve {
  86893. /**
  86894. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86895. * @param t defines the time
  86896. * @param x1 defines the left coordinate on X axis
  86897. * @param y1 defines the left coordinate on Y axis
  86898. * @param x2 defines the right coordinate on X axis
  86899. * @param y2 defines the right coordinate on Y axis
  86900. * @returns the interpolated value
  86901. */
  86902. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86903. }
  86904. /**
  86905. * Defines angle representation
  86906. */
  86907. export class Angle {
  86908. private _radians;
  86909. /**
  86910. * Creates an Angle object of "radians" radians (float).
  86911. * @param radians the angle in radians
  86912. */
  86913. constructor(radians: number);
  86914. /**
  86915. * Get value in degrees
  86916. * @returns the Angle value in degrees (float)
  86917. */
  86918. degrees(): number;
  86919. /**
  86920. * Get value in radians
  86921. * @returns the Angle value in radians (float)
  86922. */
  86923. radians(): number;
  86924. /**
  86925. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86926. * @param a defines first point as the origin
  86927. * @param b defines point
  86928. * @returns a new Angle
  86929. */
  86930. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86931. /**
  86932. * Gets a new Angle object from the given float in radians
  86933. * @param radians defines the angle value in radians
  86934. * @returns a new Angle
  86935. */
  86936. static FromRadians(radians: number): Angle;
  86937. /**
  86938. * Gets a new Angle object from the given float in degrees
  86939. * @param degrees defines the angle value in degrees
  86940. * @returns a new Angle
  86941. */
  86942. static FromDegrees(degrees: number): Angle;
  86943. }
  86944. /**
  86945. * This represents an arc in a 2d space.
  86946. */
  86947. export class Arc2 {
  86948. /** Defines the start point of the arc */
  86949. startPoint: Vector2;
  86950. /** Defines the mid point of the arc */
  86951. midPoint: Vector2;
  86952. /** Defines the end point of the arc */
  86953. endPoint: Vector2;
  86954. /**
  86955. * Defines the center point of the arc.
  86956. */
  86957. centerPoint: Vector2;
  86958. /**
  86959. * Defines the radius of the arc.
  86960. */
  86961. radius: number;
  86962. /**
  86963. * Defines the angle of the arc (from mid point to end point).
  86964. */
  86965. angle: Angle;
  86966. /**
  86967. * Defines the start angle of the arc (from start point to middle point).
  86968. */
  86969. startAngle: Angle;
  86970. /**
  86971. * Defines the orientation of the arc (clock wise/counter clock wise).
  86972. */
  86973. orientation: Orientation;
  86974. /**
  86975. * Creates an Arc object from the three given points : start, middle and end.
  86976. * @param startPoint Defines the start point of the arc
  86977. * @param midPoint Defines the midlle point of the arc
  86978. * @param endPoint Defines the end point of the arc
  86979. */
  86980. constructor(
  86981. /** Defines the start point of the arc */
  86982. startPoint: Vector2,
  86983. /** Defines the mid point of the arc */
  86984. midPoint: Vector2,
  86985. /** Defines the end point of the arc */
  86986. endPoint: Vector2);
  86987. }
  86988. /**
  86989. * Represents a 2D path made up of multiple 2D points
  86990. */
  86991. export class Path2 {
  86992. private _points;
  86993. private _length;
  86994. /**
  86995. * If the path start and end point are the same
  86996. */
  86997. closed: boolean;
  86998. /**
  86999. * Creates a Path2 object from the starting 2D coordinates x and y.
  87000. * @param x the starting points x value
  87001. * @param y the starting points y value
  87002. */
  87003. constructor(x: number, y: number);
  87004. /**
  87005. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  87006. * @param x the added points x value
  87007. * @param y the added points y value
  87008. * @returns the updated Path2.
  87009. */
  87010. addLineTo(x: number, y: number): Path2;
  87011. /**
  87012. * 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.
  87013. * @param midX middle point x value
  87014. * @param midY middle point y value
  87015. * @param endX end point x value
  87016. * @param endY end point y value
  87017. * @param numberOfSegments (default: 36)
  87018. * @returns the updated Path2.
  87019. */
  87020. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  87021. /**
  87022. * Closes the Path2.
  87023. * @returns the Path2.
  87024. */
  87025. close(): Path2;
  87026. /**
  87027. * Gets the sum of the distance between each sequential point in the path
  87028. * @returns the Path2 total length (float).
  87029. */
  87030. length(): number;
  87031. /**
  87032. * Gets the points which construct the path
  87033. * @returns the Path2 internal array of points.
  87034. */
  87035. getPoints(): Vector2[];
  87036. /**
  87037. * Retreives the point at the distance aways from the starting point
  87038. * @param normalizedLengthPosition the length along the path to retreive the point from
  87039. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  87040. */
  87041. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  87042. /**
  87043. * Creates a new path starting from an x and y position
  87044. * @param x starting x value
  87045. * @param y starting y value
  87046. * @returns a new Path2 starting at the coordinates (x, y).
  87047. */
  87048. static StartingAt(x: number, y: number): Path2;
  87049. }
  87050. /**
  87051. * Represents a 3D path made up of multiple 3D points
  87052. */
  87053. export class Path3D {
  87054. /**
  87055. * an array of Vector3, the curve axis of the Path3D
  87056. */
  87057. path: Vector3[];
  87058. private _curve;
  87059. private _distances;
  87060. private _tangents;
  87061. private _normals;
  87062. private _binormals;
  87063. private _raw;
  87064. private _alignTangentsWithPath;
  87065. private readonly _pointAtData;
  87066. /**
  87067. * new Path3D(path, normal, raw)
  87068. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  87069. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  87070. * @param path an array of Vector3, the curve axis of the Path3D
  87071. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  87072. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  87073. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  87074. */
  87075. constructor(
  87076. /**
  87077. * an array of Vector3, the curve axis of the Path3D
  87078. */
  87079. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  87080. /**
  87081. * Returns the Path3D array of successive Vector3 designing its curve.
  87082. * @returns the Path3D array of successive Vector3 designing its curve.
  87083. */
  87084. getCurve(): Vector3[];
  87085. /**
  87086. * Returns the Path3D array of successive Vector3 designing its curve.
  87087. * @returns the Path3D array of successive Vector3 designing its curve.
  87088. */
  87089. getPoints(): Vector3[];
  87090. /**
  87091. * @returns the computed length (float) of the path.
  87092. */
  87093. length(): number;
  87094. /**
  87095. * Returns an array populated with tangent vectors on each Path3D curve point.
  87096. * @returns an array populated with tangent vectors on each Path3D curve point.
  87097. */
  87098. getTangents(): Vector3[];
  87099. /**
  87100. * Returns an array populated with normal vectors on each Path3D curve point.
  87101. * @returns an array populated with normal vectors on each Path3D curve point.
  87102. */
  87103. getNormals(): Vector3[];
  87104. /**
  87105. * Returns an array populated with binormal vectors on each Path3D curve point.
  87106. * @returns an array populated with binormal vectors on each Path3D curve point.
  87107. */
  87108. getBinormals(): Vector3[];
  87109. /**
  87110. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  87111. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  87112. */
  87113. getDistances(): number[];
  87114. /**
  87115. * Returns an interpolated point along this path
  87116. * @param position the position of the point along this path, from 0.0 to 1.0
  87117. * @returns a new Vector3 as the point
  87118. */
  87119. getPointAt(position: number): Vector3;
  87120. /**
  87121. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87122. * @param position the position of the point along this path, from 0.0 to 1.0
  87123. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  87124. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  87125. */
  87126. getTangentAt(position: number, interpolated?: boolean): Vector3;
  87127. /**
  87128. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87129. * @param position the position of the point along this path, from 0.0 to 1.0
  87130. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  87131. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  87132. */
  87133. getNormalAt(position: number, interpolated?: boolean): Vector3;
  87134. /**
  87135. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  87136. * @param position the position of the point along this path, from 0.0 to 1.0
  87137. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  87138. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  87139. */
  87140. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  87141. /**
  87142. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  87143. * @param position the position of the point along this path, from 0.0 to 1.0
  87144. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  87145. */
  87146. getDistanceAt(position: number): number;
  87147. /**
  87148. * Returns the array index of the previous point of an interpolated point along this path
  87149. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87150. * @returns the array index
  87151. */
  87152. getPreviousPointIndexAt(position: number): number;
  87153. /**
  87154. * 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)
  87155. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87156. * @returns the sub position
  87157. */
  87158. getSubPositionAt(position: number): number;
  87159. /**
  87160. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  87161. * @param target the vector of which to get the closest position to
  87162. * @returns the position of the closest virtual point on this path to the target vector
  87163. */
  87164. getClosestPositionTo(target: Vector3): number;
  87165. /**
  87166. * Returns a sub path (slice) of this path
  87167. * @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
  87168. * @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
  87169. * @returns a sub path (slice) of this path
  87170. */
  87171. slice(start?: number, end?: number): Path3D;
  87172. /**
  87173. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  87174. * @param path path which all values are copied into the curves points
  87175. * @param firstNormal which should be projected onto the curve
  87176. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  87177. * @returns the same object updated.
  87178. */
  87179. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  87180. private _compute;
  87181. private _getFirstNonNullVector;
  87182. private _getLastNonNullVector;
  87183. private _normalVector;
  87184. /**
  87185. * Updates the point at data for an interpolated point along this curve
  87186. * @param position the position of the point along this curve, from 0.0 to 1.0
  87187. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  87188. * @returns the (updated) point at data
  87189. */
  87190. private _updatePointAtData;
  87191. /**
  87192. * Updates the point at data from the specified parameters
  87193. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  87194. * @param point the interpolated point
  87195. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  87196. */
  87197. private _setPointAtData;
  87198. /**
  87199. * Updates the point at interpolation matrix for the tangents, normals and binormals
  87200. */
  87201. private _updateInterpolationMatrix;
  87202. }
  87203. /**
  87204. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87205. * A Curve3 is designed from a series of successive Vector3.
  87206. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  87207. */
  87208. export class Curve3 {
  87209. private _points;
  87210. private _length;
  87211. /**
  87212. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  87213. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  87214. * @param v1 (Vector3) the control point
  87215. * @param v2 (Vector3) the end point of the Quadratic Bezier
  87216. * @param nbPoints (integer) the wanted number of points in the curve
  87217. * @returns the created Curve3
  87218. */
  87219. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87220. /**
  87221. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  87222. * @param v0 (Vector3) the origin point of the Cubic Bezier
  87223. * @param v1 (Vector3) the first control point
  87224. * @param v2 (Vector3) the second control point
  87225. * @param v3 (Vector3) the end point of the Cubic Bezier
  87226. * @param nbPoints (integer) the wanted number of points in the curve
  87227. * @returns the created Curve3
  87228. */
  87229. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87230. /**
  87231. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  87232. * @param p1 (Vector3) the origin point of the Hermite Spline
  87233. * @param t1 (Vector3) the tangent vector at the origin point
  87234. * @param p2 (Vector3) the end point of the Hermite Spline
  87235. * @param t2 (Vector3) the tangent vector at the end point
  87236. * @param nbPoints (integer) the wanted number of points in the curve
  87237. * @returns the created Curve3
  87238. */
  87239. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87240. /**
  87241. * Returns a Curve3 object along a CatmullRom Spline curve :
  87242. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87243. * @param nbPoints (integer) the wanted number of points between each curve control points
  87244. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87245. * @returns the created Curve3
  87246. */
  87247. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87248. /**
  87249. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87250. * A Curve3 is designed from a series of successive Vector3.
  87251. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87252. * @param points points which make up the curve
  87253. */
  87254. constructor(points: Vector3[]);
  87255. /**
  87256. * @returns the Curve3 stored array of successive Vector3
  87257. */
  87258. getPoints(): Vector3[];
  87259. /**
  87260. * @returns the computed length (float) of the curve.
  87261. */
  87262. length(): number;
  87263. /**
  87264. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87265. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87266. * curveA and curveB keep unchanged.
  87267. * @param curve the curve to continue from this curve
  87268. * @returns the newly constructed curve
  87269. */
  87270. continue(curve: DeepImmutable<Curve3>): Curve3;
  87271. private _computeLength;
  87272. }
  87273. }
  87274. declare module BABYLON {
  87275. /**
  87276. * This represents the main contract an easing function should follow.
  87277. * Easing functions are used throughout the animation system.
  87278. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87279. */
  87280. export interface IEasingFunction {
  87281. /**
  87282. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87283. * of the easing function.
  87284. * The link below provides some of the most common examples of easing functions.
  87285. * @see https://easings.net/
  87286. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87287. * @returns the corresponding value on the curve defined by the easing function
  87288. */
  87289. ease(gradient: number): number;
  87290. }
  87291. /**
  87292. * Base class used for every default easing function.
  87293. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87294. */
  87295. export class EasingFunction implements IEasingFunction {
  87296. /**
  87297. * Interpolation follows the mathematical formula associated with the easing function.
  87298. */
  87299. static readonly EASINGMODE_EASEIN: number;
  87300. /**
  87301. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87302. */
  87303. static readonly EASINGMODE_EASEOUT: number;
  87304. /**
  87305. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87306. */
  87307. static readonly EASINGMODE_EASEINOUT: number;
  87308. private _easingMode;
  87309. /**
  87310. * Sets the easing mode of the current function.
  87311. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87312. */
  87313. setEasingMode(easingMode: number): void;
  87314. /**
  87315. * Gets the current easing mode.
  87316. * @returns the easing mode
  87317. */
  87318. getEasingMode(): number;
  87319. /**
  87320. * @hidden
  87321. */
  87322. easeInCore(gradient: number): number;
  87323. /**
  87324. * Given an input gradient between 0 and 1, this returns the corresponding value
  87325. * of the easing function.
  87326. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87327. * @returns the corresponding value on the curve defined by the easing function
  87328. */
  87329. ease(gradient: number): number;
  87330. }
  87331. /**
  87332. * Easing function with a circle shape (see link below).
  87333. * @see https://easings.net/#easeInCirc
  87334. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87335. */
  87336. export class CircleEase extends EasingFunction implements IEasingFunction {
  87337. /** @hidden */
  87338. easeInCore(gradient: number): number;
  87339. }
  87340. /**
  87341. * Easing function with a ease back shape (see link below).
  87342. * @see https://easings.net/#easeInBack
  87343. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87344. */
  87345. export class BackEase extends EasingFunction implements IEasingFunction {
  87346. /** Defines the amplitude of the function */
  87347. amplitude: number;
  87348. /**
  87349. * Instantiates a back ease easing
  87350. * @see https://easings.net/#easeInBack
  87351. * @param amplitude Defines the amplitude of the function
  87352. */
  87353. constructor(
  87354. /** Defines the amplitude of the function */
  87355. amplitude?: number);
  87356. /** @hidden */
  87357. easeInCore(gradient: number): number;
  87358. }
  87359. /**
  87360. * Easing function with a bouncing shape (see link below).
  87361. * @see https://easings.net/#easeInBounce
  87362. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87363. */
  87364. export class BounceEase extends EasingFunction implements IEasingFunction {
  87365. /** Defines the number of bounces */
  87366. bounces: number;
  87367. /** Defines the amplitude of the bounce */
  87368. bounciness: number;
  87369. /**
  87370. * Instantiates a bounce easing
  87371. * @see https://easings.net/#easeInBounce
  87372. * @param bounces Defines the number of bounces
  87373. * @param bounciness Defines the amplitude of the bounce
  87374. */
  87375. constructor(
  87376. /** Defines the number of bounces */
  87377. bounces?: number,
  87378. /** Defines the amplitude of the bounce */
  87379. bounciness?: number);
  87380. /** @hidden */
  87381. easeInCore(gradient: number): number;
  87382. }
  87383. /**
  87384. * Easing function with a power of 3 shape (see link below).
  87385. * @see https://easings.net/#easeInCubic
  87386. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87387. */
  87388. export class CubicEase extends EasingFunction implements IEasingFunction {
  87389. /** @hidden */
  87390. easeInCore(gradient: number): number;
  87391. }
  87392. /**
  87393. * Easing function with an elastic shape (see link below).
  87394. * @see https://easings.net/#easeInElastic
  87395. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87396. */
  87397. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87398. /** Defines the number of oscillations*/
  87399. oscillations: number;
  87400. /** Defines the amplitude of the oscillations*/
  87401. springiness: number;
  87402. /**
  87403. * Instantiates an elastic easing function
  87404. * @see https://easings.net/#easeInElastic
  87405. * @param oscillations Defines the number of oscillations
  87406. * @param springiness Defines the amplitude of the oscillations
  87407. */
  87408. constructor(
  87409. /** Defines the number of oscillations*/
  87410. oscillations?: number,
  87411. /** Defines the amplitude of the oscillations*/
  87412. springiness?: number);
  87413. /** @hidden */
  87414. easeInCore(gradient: number): number;
  87415. }
  87416. /**
  87417. * Easing function with an exponential shape (see link below).
  87418. * @see https://easings.net/#easeInExpo
  87419. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87420. */
  87421. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87422. /** Defines the exponent of the function */
  87423. exponent: number;
  87424. /**
  87425. * Instantiates an exponential easing function
  87426. * @see https://easings.net/#easeInExpo
  87427. * @param exponent Defines the exponent of the function
  87428. */
  87429. constructor(
  87430. /** Defines the exponent of the function */
  87431. exponent?: number);
  87432. /** @hidden */
  87433. easeInCore(gradient: number): number;
  87434. }
  87435. /**
  87436. * Easing function with a power shape (see link below).
  87437. * @see https://easings.net/#easeInQuad
  87438. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87439. */
  87440. export class PowerEase extends EasingFunction implements IEasingFunction {
  87441. /** Defines the power of the function */
  87442. power: number;
  87443. /**
  87444. * Instantiates an power base easing function
  87445. * @see https://easings.net/#easeInQuad
  87446. * @param power Defines the power of the function
  87447. */
  87448. constructor(
  87449. /** Defines the power of the function */
  87450. power?: number);
  87451. /** @hidden */
  87452. easeInCore(gradient: number): number;
  87453. }
  87454. /**
  87455. * Easing function with a power of 2 shape (see link below).
  87456. * @see https://easings.net/#easeInQuad
  87457. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87458. */
  87459. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87460. /** @hidden */
  87461. easeInCore(gradient: number): number;
  87462. }
  87463. /**
  87464. * Easing function with a power of 4 shape (see link below).
  87465. * @see https://easings.net/#easeInQuart
  87466. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87467. */
  87468. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87469. /** @hidden */
  87470. easeInCore(gradient: number): number;
  87471. }
  87472. /**
  87473. * Easing function with a power of 5 shape (see link below).
  87474. * @see https://easings.net/#easeInQuint
  87475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87476. */
  87477. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87478. /** @hidden */
  87479. easeInCore(gradient: number): number;
  87480. }
  87481. /**
  87482. * Easing function with a sin shape (see link below).
  87483. * @see https://easings.net/#easeInSine
  87484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87485. */
  87486. export class SineEase extends EasingFunction implements IEasingFunction {
  87487. /** @hidden */
  87488. easeInCore(gradient: number): number;
  87489. }
  87490. /**
  87491. * Easing function with a bezier shape (see link below).
  87492. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87494. */
  87495. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87496. /** Defines the x component of the start tangent in the bezier curve */
  87497. x1: number;
  87498. /** Defines the y component of the start tangent in the bezier curve */
  87499. y1: number;
  87500. /** Defines the x component of the end tangent in the bezier curve */
  87501. x2: number;
  87502. /** Defines the y component of the end tangent in the bezier curve */
  87503. y2: number;
  87504. /**
  87505. * Instantiates a bezier function
  87506. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87507. * @param x1 Defines the x component of the start tangent in the bezier curve
  87508. * @param y1 Defines the y component of the start tangent in the bezier curve
  87509. * @param x2 Defines the x component of the end tangent in the bezier curve
  87510. * @param y2 Defines the y component of the end tangent in the bezier curve
  87511. */
  87512. constructor(
  87513. /** Defines the x component of the start tangent in the bezier curve */
  87514. x1?: number,
  87515. /** Defines the y component of the start tangent in the bezier curve */
  87516. y1?: number,
  87517. /** Defines the x component of the end tangent in the bezier curve */
  87518. x2?: number,
  87519. /** Defines the y component of the end tangent in the bezier curve */
  87520. y2?: number);
  87521. /** @hidden */
  87522. easeInCore(gradient: number): number;
  87523. }
  87524. }
  87525. declare module BABYLON {
  87526. /**
  87527. * Class used to hold a RBG color
  87528. */
  87529. export class Color3 {
  87530. /**
  87531. * Defines the red component (between 0 and 1, default is 0)
  87532. */
  87533. r: number;
  87534. /**
  87535. * Defines the green component (between 0 and 1, default is 0)
  87536. */
  87537. g: number;
  87538. /**
  87539. * Defines the blue component (between 0 and 1, default is 0)
  87540. */
  87541. b: number;
  87542. /**
  87543. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87544. * @param r defines the red component (between 0 and 1, default is 0)
  87545. * @param g defines the green component (between 0 and 1, default is 0)
  87546. * @param b defines the blue component (between 0 and 1, default is 0)
  87547. */
  87548. constructor(
  87549. /**
  87550. * Defines the red component (between 0 and 1, default is 0)
  87551. */
  87552. r?: number,
  87553. /**
  87554. * Defines the green component (between 0 and 1, default is 0)
  87555. */
  87556. g?: number,
  87557. /**
  87558. * Defines the blue component (between 0 and 1, default is 0)
  87559. */
  87560. b?: number);
  87561. /**
  87562. * Creates a string with the Color3 current values
  87563. * @returns the string representation of the Color3 object
  87564. */
  87565. toString(): string;
  87566. /**
  87567. * Returns the string "Color3"
  87568. * @returns "Color3"
  87569. */
  87570. getClassName(): string;
  87571. /**
  87572. * Compute the Color3 hash code
  87573. * @returns an unique number that can be used to hash Color3 objects
  87574. */
  87575. getHashCode(): number;
  87576. /**
  87577. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87578. * @param array defines the array where to store the r,g,b components
  87579. * @param index defines an optional index in the target array to define where to start storing values
  87580. * @returns the current Color3 object
  87581. */
  87582. toArray(array: FloatArray, index?: number): Color3;
  87583. /**
  87584. * Update the current color with values stored in an array from the starting index of the given array
  87585. * @param array defines the source array
  87586. * @param offset defines an offset in the source array
  87587. * @returns the current Color3 object
  87588. */
  87589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87590. /**
  87591. * Returns a new Color4 object from the current Color3 and the given alpha
  87592. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87593. * @returns a new Color4 object
  87594. */
  87595. toColor4(alpha?: number): Color4;
  87596. /**
  87597. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87598. * @returns the new array
  87599. */
  87600. asArray(): number[];
  87601. /**
  87602. * Returns the luminance value
  87603. * @returns a float value
  87604. */
  87605. toLuminance(): number;
  87606. /**
  87607. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87608. * @param otherColor defines the second operand
  87609. * @returns the new Color3 object
  87610. */
  87611. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87612. /**
  87613. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87614. * @param otherColor defines the second operand
  87615. * @param result defines the Color3 object where to store the result
  87616. * @returns the current Color3
  87617. */
  87618. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87619. /**
  87620. * Determines equality between Color3 objects
  87621. * @param otherColor defines the second operand
  87622. * @returns true if the rgb values are equal to the given ones
  87623. */
  87624. equals(otherColor: DeepImmutable<Color3>): boolean;
  87625. /**
  87626. * Determines equality between the current Color3 object and a set of r,b,g values
  87627. * @param r defines the red component to check
  87628. * @param g defines the green component to check
  87629. * @param b defines the blue component to check
  87630. * @returns true if the rgb values are equal to the given ones
  87631. */
  87632. equalsFloats(r: number, g: number, b: number): boolean;
  87633. /**
  87634. * Multiplies in place each rgb value by scale
  87635. * @param scale defines the scaling factor
  87636. * @returns the updated Color3
  87637. */
  87638. scale(scale: number): Color3;
  87639. /**
  87640. * Multiplies the rgb values by scale and stores the result into "result"
  87641. * @param scale defines the scaling factor
  87642. * @param result defines the Color3 object where to store the result
  87643. * @returns the unmodified current Color3
  87644. */
  87645. scaleToRef(scale: number, result: Color3): Color3;
  87646. /**
  87647. * Scale the current Color3 values by a factor and add the result to a given Color3
  87648. * @param scale defines the scale factor
  87649. * @param result defines color to store the result into
  87650. * @returns the unmodified current Color3
  87651. */
  87652. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87653. /**
  87654. * Clamps the rgb values by the min and max values and stores the result into "result"
  87655. * @param min defines minimum clamping value (default is 0)
  87656. * @param max defines maximum clamping value (default is 1)
  87657. * @param result defines color to store the result into
  87658. * @returns the original Color3
  87659. */
  87660. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87661. /**
  87662. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87663. * @param otherColor defines the second operand
  87664. * @returns the new Color3
  87665. */
  87666. add(otherColor: DeepImmutable<Color3>): Color3;
  87667. /**
  87668. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87669. * @param otherColor defines the second operand
  87670. * @param result defines Color3 object to store the result into
  87671. * @returns the unmodified current Color3
  87672. */
  87673. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87674. /**
  87675. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87676. * @param otherColor defines the second operand
  87677. * @returns the new Color3
  87678. */
  87679. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87680. /**
  87681. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87682. * @param otherColor defines the second operand
  87683. * @param result defines Color3 object to store the result into
  87684. * @returns the unmodified current Color3
  87685. */
  87686. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87687. /**
  87688. * Copy the current object
  87689. * @returns a new Color3 copied the current one
  87690. */
  87691. clone(): Color3;
  87692. /**
  87693. * Copies the rgb values from the source in the current Color3
  87694. * @param source defines the source Color3 object
  87695. * @returns the updated Color3 object
  87696. */
  87697. copyFrom(source: DeepImmutable<Color3>): Color3;
  87698. /**
  87699. * Updates the Color3 rgb values from the given floats
  87700. * @param r defines the red component to read from
  87701. * @param g defines the green component to read from
  87702. * @param b defines the blue component to read from
  87703. * @returns the current Color3 object
  87704. */
  87705. copyFromFloats(r: number, g: number, b: number): Color3;
  87706. /**
  87707. * Updates the Color3 rgb values from the given floats
  87708. * @param r defines the red component to read from
  87709. * @param g defines the green component to read from
  87710. * @param b defines the blue component to read from
  87711. * @returns the current Color3 object
  87712. */
  87713. set(r: number, g: number, b: number): Color3;
  87714. /**
  87715. * Compute the Color3 hexadecimal code as a string
  87716. * @returns a string containing the hexadecimal representation of the Color3 object
  87717. */
  87718. toHexString(): string;
  87719. /**
  87720. * Computes a new Color3 converted from the current one to linear space
  87721. * @returns a new Color3 object
  87722. */
  87723. toLinearSpace(): Color3;
  87724. /**
  87725. * Converts current color in rgb space to HSV values
  87726. * @returns a new color3 representing the HSV values
  87727. */
  87728. toHSV(): Color3;
  87729. /**
  87730. * Converts current color in rgb space to HSV values
  87731. * @param result defines the Color3 where to store the HSV values
  87732. */
  87733. toHSVToRef(result: Color3): void;
  87734. /**
  87735. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87736. * @param convertedColor defines the Color3 object where to store the linear space version
  87737. * @returns the unmodified Color3
  87738. */
  87739. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87740. /**
  87741. * Computes a new Color3 converted from the current one to gamma space
  87742. * @returns a new Color3 object
  87743. */
  87744. toGammaSpace(): Color3;
  87745. /**
  87746. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87747. * @param convertedColor defines the Color3 object where to store the gamma space version
  87748. * @returns the unmodified Color3
  87749. */
  87750. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87751. private static _BlackReadOnly;
  87752. /**
  87753. * Convert Hue, saturation and value to a Color3 (RGB)
  87754. * @param hue defines the hue
  87755. * @param saturation defines the saturation
  87756. * @param value defines the value
  87757. * @param result defines the Color3 where to store the RGB values
  87758. */
  87759. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87760. /**
  87761. * Creates a new Color3 from the string containing valid hexadecimal values
  87762. * @param hex defines a string containing valid hexadecimal values
  87763. * @returns a new Color3 object
  87764. */
  87765. static FromHexString(hex: string): Color3;
  87766. /**
  87767. * Creates a new Color3 from the starting index of the given array
  87768. * @param array defines the source array
  87769. * @param offset defines an offset in the source array
  87770. * @returns a new Color3 object
  87771. */
  87772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87773. /**
  87774. * Creates a new Color3 from the starting index element of the given array
  87775. * @param array defines the source array to read from
  87776. * @param offset defines the offset in the source array
  87777. * @param result defines the target Color3 object
  87778. */
  87779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87780. /**
  87781. * Creates a new Color3 from integer values (< 256)
  87782. * @param r defines the red component to read from (value between 0 and 255)
  87783. * @param g defines the green component to read from (value between 0 and 255)
  87784. * @param b defines the blue component to read from (value between 0 and 255)
  87785. * @returns a new Color3 object
  87786. */
  87787. static FromInts(r: number, g: number, b: number): Color3;
  87788. /**
  87789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87790. * @param start defines the start Color3 value
  87791. * @param end defines the end Color3 value
  87792. * @param amount defines the gradient value between start and end
  87793. * @returns a new Color3 object
  87794. */
  87795. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87796. /**
  87797. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87798. * @param left defines the start value
  87799. * @param right defines the end value
  87800. * @param amount defines the gradient factor
  87801. * @param result defines the Color3 object where to store the result
  87802. */
  87803. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87804. /**
  87805. * Returns a Color3 value containing a red color
  87806. * @returns a new Color3 object
  87807. */
  87808. static Red(): Color3;
  87809. /**
  87810. * Returns a Color3 value containing a green color
  87811. * @returns a new Color3 object
  87812. */
  87813. static Green(): Color3;
  87814. /**
  87815. * Returns a Color3 value containing a blue color
  87816. * @returns a new Color3 object
  87817. */
  87818. static Blue(): Color3;
  87819. /**
  87820. * Returns a Color3 value containing a black color
  87821. * @returns a new Color3 object
  87822. */
  87823. static Black(): Color3;
  87824. /**
  87825. * Gets a Color3 value containing a black color that must not be updated
  87826. */
  87827. static get BlackReadOnly(): DeepImmutable<Color3>;
  87828. /**
  87829. * Returns a Color3 value containing a white color
  87830. * @returns a new Color3 object
  87831. */
  87832. static White(): Color3;
  87833. /**
  87834. * Returns a Color3 value containing a purple color
  87835. * @returns a new Color3 object
  87836. */
  87837. static Purple(): Color3;
  87838. /**
  87839. * Returns a Color3 value containing a magenta color
  87840. * @returns a new Color3 object
  87841. */
  87842. static Magenta(): Color3;
  87843. /**
  87844. * Returns a Color3 value containing a yellow color
  87845. * @returns a new Color3 object
  87846. */
  87847. static Yellow(): Color3;
  87848. /**
  87849. * Returns a Color3 value containing a gray color
  87850. * @returns a new Color3 object
  87851. */
  87852. static Gray(): Color3;
  87853. /**
  87854. * Returns a Color3 value containing a teal color
  87855. * @returns a new Color3 object
  87856. */
  87857. static Teal(): Color3;
  87858. /**
  87859. * Returns a Color3 value containing a random color
  87860. * @returns a new Color3 object
  87861. */
  87862. static Random(): Color3;
  87863. }
  87864. /**
  87865. * Class used to hold a RBGA color
  87866. */
  87867. export class Color4 {
  87868. /**
  87869. * Defines the red component (between 0 and 1, default is 0)
  87870. */
  87871. r: number;
  87872. /**
  87873. * Defines the green component (between 0 and 1, default is 0)
  87874. */
  87875. g: number;
  87876. /**
  87877. * Defines the blue component (between 0 and 1, default is 0)
  87878. */
  87879. b: number;
  87880. /**
  87881. * Defines the alpha component (between 0 and 1, default is 1)
  87882. */
  87883. a: number;
  87884. /**
  87885. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87886. * @param r defines the red component (between 0 and 1, default is 0)
  87887. * @param g defines the green component (between 0 and 1, default is 0)
  87888. * @param b defines the blue component (between 0 and 1, default is 0)
  87889. * @param a defines the alpha component (between 0 and 1, default is 1)
  87890. */
  87891. constructor(
  87892. /**
  87893. * Defines the red component (between 0 and 1, default is 0)
  87894. */
  87895. r?: number,
  87896. /**
  87897. * Defines the green component (between 0 and 1, default is 0)
  87898. */
  87899. g?: number,
  87900. /**
  87901. * Defines the blue component (between 0 and 1, default is 0)
  87902. */
  87903. b?: number,
  87904. /**
  87905. * Defines the alpha component (between 0 and 1, default is 1)
  87906. */
  87907. a?: number);
  87908. /**
  87909. * Adds in place the given Color4 values to the current Color4 object
  87910. * @param right defines the second operand
  87911. * @returns the current updated Color4 object
  87912. */
  87913. addInPlace(right: DeepImmutable<Color4>): Color4;
  87914. /**
  87915. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87916. * @returns the new array
  87917. */
  87918. asArray(): number[];
  87919. /**
  87920. * Stores from the starting index in the given array the Color4 successive values
  87921. * @param array defines the array where to store the r,g,b components
  87922. * @param index defines an optional index in the target array to define where to start storing values
  87923. * @returns the current Color4 object
  87924. */
  87925. toArray(array: number[], index?: number): Color4;
  87926. /**
  87927. * Update the current color with values stored in an array from the starting index of the given array
  87928. * @param array defines the source array
  87929. * @param offset defines an offset in the source array
  87930. * @returns the current Color4 object
  87931. */
  87932. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87933. /**
  87934. * Determines equality between Color4 objects
  87935. * @param otherColor defines the second operand
  87936. * @returns true if the rgba values are equal to the given ones
  87937. */
  87938. equals(otherColor: DeepImmutable<Color4>): boolean;
  87939. /**
  87940. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87941. * @param right defines the second operand
  87942. * @returns a new Color4 object
  87943. */
  87944. add(right: DeepImmutable<Color4>): Color4;
  87945. /**
  87946. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87947. * @param right defines the second operand
  87948. * @returns a new Color4 object
  87949. */
  87950. subtract(right: DeepImmutable<Color4>): Color4;
  87951. /**
  87952. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87953. * @param right defines the second operand
  87954. * @param result defines the Color4 object where to store the result
  87955. * @returns the current Color4 object
  87956. */
  87957. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87958. /**
  87959. * Creates a new Color4 with the current Color4 values multiplied by scale
  87960. * @param scale defines the scaling factor to apply
  87961. * @returns a new Color4 object
  87962. */
  87963. scale(scale: number): Color4;
  87964. /**
  87965. * Multiplies the current Color4 values by scale and stores the result in "result"
  87966. * @param scale defines the scaling factor to apply
  87967. * @param result defines the Color4 object where to store the result
  87968. * @returns the current unmodified Color4
  87969. */
  87970. scaleToRef(scale: number, result: Color4): Color4;
  87971. /**
  87972. * Scale the current Color4 values by a factor and add the result to a given Color4
  87973. * @param scale defines the scale factor
  87974. * @param result defines the Color4 object where to store the result
  87975. * @returns the unmodified current Color4
  87976. */
  87977. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87978. /**
  87979. * Clamps the rgb values by the min and max values and stores the result into "result"
  87980. * @param min defines minimum clamping value (default is 0)
  87981. * @param max defines maximum clamping value (default is 1)
  87982. * @param result defines color to store the result into.
  87983. * @returns the cuurent Color4
  87984. */
  87985. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87986. /**
  87987. * Multipy an Color4 value by another and return a new Color4 object
  87988. * @param color defines the Color4 value to multiply by
  87989. * @returns a new Color4 object
  87990. */
  87991. multiply(color: Color4): Color4;
  87992. /**
  87993. * Multipy a Color4 value by another and push the result in a reference value
  87994. * @param color defines the Color4 value to multiply by
  87995. * @param result defines the Color4 to fill the result in
  87996. * @returns the result Color4
  87997. */
  87998. multiplyToRef(color: Color4, result: Color4): Color4;
  87999. /**
  88000. * Creates a string with the Color4 current values
  88001. * @returns the string representation of the Color4 object
  88002. */
  88003. toString(): string;
  88004. /**
  88005. * Returns the string "Color4"
  88006. * @returns "Color4"
  88007. */
  88008. getClassName(): string;
  88009. /**
  88010. * Compute the Color4 hash code
  88011. * @returns an unique number that can be used to hash Color4 objects
  88012. */
  88013. getHashCode(): number;
  88014. /**
  88015. * Creates a new Color4 copied from the current one
  88016. * @returns a new Color4 object
  88017. */
  88018. clone(): Color4;
  88019. /**
  88020. * Copies the given Color4 values into the current one
  88021. * @param source defines the source Color4 object
  88022. * @returns the current updated Color4 object
  88023. */
  88024. copyFrom(source: Color4): Color4;
  88025. /**
  88026. * Copies the given float values into the current one
  88027. * @param r defines the red component to read from
  88028. * @param g defines the green component to read from
  88029. * @param b defines the blue component to read from
  88030. * @param a defines the alpha component to read from
  88031. * @returns the current updated Color4 object
  88032. */
  88033. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  88034. /**
  88035. * Copies the given float values into the current one
  88036. * @param r defines the red component to read from
  88037. * @param g defines the green component to read from
  88038. * @param b defines the blue component to read from
  88039. * @param a defines the alpha component to read from
  88040. * @returns the current updated Color4 object
  88041. */
  88042. set(r: number, g: number, b: number, a: number): Color4;
  88043. /**
  88044. * Compute the Color4 hexadecimal code as a string
  88045. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  88046. * @returns a string containing the hexadecimal representation of the Color4 object
  88047. */
  88048. toHexString(returnAsColor3?: boolean): string;
  88049. /**
  88050. * Computes a new Color4 converted from the current one to linear space
  88051. * @returns a new Color4 object
  88052. */
  88053. toLinearSpace(): Color4;
  88054. /**
  88055. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  88056. * @param convertedColor defines the Color4 object where to store the linear space version
  88057. * @returns the unmodified Color4
  88058. */
  88059. toLinearSpaceToRef(convertedColor: Color4): Color4;
  88060. /**
  88061. * Computes a new Color4 converted from the current one to gamma space
  88062. * @returns a new Color4 object
  88063. */
  88064. toGammaSpace(): Color4;
  88065. /**
  88066. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  88067. * @param convertedColor defines the Color4 object where to store the gamma space version
  88068. * @returns the unmodified Color4
  88069. */
  88070. toGammaSpaceToRef(convertedColor: Color4): Color4;
  88071. /**
  88072. * Creates a new Color4 from the string containing valid hexadecimal values
  88073. * @param hex defines a string containing valid hexadecimal values
  88074. * @returns a new Color4 object
  88075. */
  88076. static FromHexString(hex: string): Color4;
  88077. /**
  88078. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88079. * @param left defines the start value
  88080. * @param right defines the end value
  88081. * @param amount defines the gradient factor
  88082. * @returns a new Color4 object
  88083. */
  88084. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  88085. /**
  88086. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88087. * @param left defines the start value
  88088. * @param right defines the end value
  88089. * @param amount defines the gradient factor
  88090. * @param result defines the Color4 object where to store data
  88091. */
  88092. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  88093. /**
  88094. * Creates a new Color4 from a Color3 and an alpha value
  88095. * @param color3 defines the source Color3 to read from
  88096. * @param alpha defines the alpha component (1.0 by default)
  88097. * @returns a new Color4 object
  88098. */
  88099. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  88100. /**
  88101. * Creates a new Color4 from the starting index element of the given array
  88102. * @param array defines the source array to read from
  88103. * @param offset defines the offset in the source array
  88104. * @returns a new Color4 object
  88105. */
  88106. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  88107. /**
  88108. * Creates a new Color4 from the starting index element of the given array
  88109. * @param array defines the source array to read from
  88110. * @param offset defines the offset in the source array
  88111. * @param result defines the target Color4 object
  88112. */
  88113. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  88114. /**
  88115. * Creates a new Color3 from integer values (< 256)
  88116. * @param r defines the red component to read from (value between 0 and 255)
  88117. * @param g defines the green component to read from (value between 0 and 255)
  88118. * @param b defines the blue component to read from (value between 0 and 255)
  88119. * @param a defines the alpha component to read from (value between 0 and 255)
  88120. * @returns a new Color3 object
  88121. */
  88122. static FromInts(r: number, g: number, b: number, a: number): Color4;
  88123. /**
  88124. * Check the content of a given array and convert it to an array containing RGBA data
  88125. * If the original array was already containing count * 4 values then it is returned directly
  88126. * @param colors defines the array to check
  88127. * @param count defines the number of RGBA data to expect
  88128. * @returns an array containing count * 4 values (RGBA)
  88129. */
  88130. static CheckColors4(colors: number[], count: number): number[];
  88131. }
  88132. /**
  88133. * @hidden
  88134. */
  88135. export class TmpColors {
  88136. static Color3: Color3[];
  88137. static Color4: Color4[];
  88138. }
  88139. }
  88140. declare module BABYLON {
  88141. /**
  88142. * Defines an interface which represents an animation key frame
  88143. */
  88144. export interface IAnimationKey {
  88145. /**
  88146. * Frame of the key frame
  88147. */
  88148. frame: number;
  88149. /**
  88150. * Value at the specifies key frame
  88151. */
  88152. value: any;
  88153. /**
  88154. * The input tangent for the cubic hermite spline
  88155. */
  88156. inTangent?: any;
  88157. /**
  88158. * The output tangent for the cubic hermite spline
  88159. */
  88160. outTangent?: any;
  88161. /**
  88162. * The animation interpolation type
  88163. */
  88164. interpolation?: AnimationKeyInterpolation;
  88165. }
  88166. /**
  88167. * Enum for the animation key frame interpolation type
  88168. */
  88169. export enum AnimationKeyInterpolation {
  88170. /**
  88171. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  88172. */
  88173. STEP = 1
  88174. }
  88175. }
  88176. declare module BABYLON {
  88177. /**
  88178. * Represents the range of an animation
  88179. */
  88180. export class AnimationRange {
  88181. /**The name of the animation range**/
  88182. name: string;
  88183. /**The starting frame of the animation */
  88184. from: number;
  88185. /**The ending frame of the animation*/
  88186. to: number;
  88187. /**
  88188. * Initializes the range of an animation
  88189. * @param name The name of the animation range
  88190. * @param from The starting frame of the animation
  88191. * @param to The ending frame of the animation
  88192. */
  88193. constructor(
  88194. /**The name of the animation range**/
  88195. name: string,
  88196. /**The starting frame of the animation */
  88197. from: number,
  88198. /**The ending frame of the animation*/
  88199. to: number);
  88200. /**
  88201. * Makes a copy of the animation range
  88202. * @returns A copy of the animation range
  88203. */
  88204. clone(): AnimationRange;
  88205. }
  88206. }
  88207. declare module BABYLON {
  88208. /**
  88209. * Composed of a frame, and an action function
  88210. */
  88211. export class AnimationEvent {
  88212. /** The frame for which the event is triggered **/
  88213. frame: number;
  88214. /** The event to perform when triggered **/
  88215. action: (currentFrame: number) => void;
  88216. /** Specifies if the event should be triggered only once**/
  88217. onlyOnce?: boolean | undefined;
  88218. /**
  88219. * Specifies if the animation event is done
  88220. */
  88221. isDone: boolean;
  88222. /**
  88223. * Initializes the animation event
  88224. * @param frame The frame for which the event is triggered
  88225. * @param action The event to perform when triggered
  88226. * @param onlyOnce Specifies if the event should be triggered only once
  88227. */
  88228. constructor(
  88229. /** The frame for which the event is triggered **/
  88230. frame: number,
  88231. /** The event to perform when triggered **/
  88232. action: (currentFrame: number) => void,
  88233. /** Specifies if the event should be triggered only once**/
  88234. onlyOnce?: boolean | undefined);
  88235. /** @hidden */
  88236. _clone(): AnimationEvent;
  88237. }
  88238. }
  88239. declare module BABYLON {
  88240. /**
  88241. * Interface used to define a behavior
  88242. */
  88243. export interface Behavior<T> {
  88244. /** gets or sets behavior's name */
  88245. name: string;
  88246. /**
  88247. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88248. */
  88249. init(): void;
  88250. /**
  88251. * Called when the behavior is attached to a target
  88252. * @param target defines the target where the behavior is attached to
  88253. */
  88254. attach(target: T): void;
  88255. /**
  88256. * Called when the behavior is detached from its target
  88257. */
  88258. detach(): void;
  88259. }
  88260. /**
  88261. * Interface implemented by classes supporting behaviors
  88262. */
  88263. export interface IBehaviorAware<T> {
  88264. /**
  88265. * Attach a behavior
  88266. * @param behavior defines the behavior to attach
  88267. * @returns the current host
  88268. */
  88269. addBehavior(behavior: Behavior<T>): T;
  88270. /**
  88271. * Remove a behavior from the current object
  88272. * @param behavior defines the behavior to detach
  88273. * @returns the current host
  88274. */
  88275. removeBehavior(behavior: Behavior<T>): T;
  88276. /**
  88277. * Gets a behavior using its name to search
  88278. * @param name defines the name to search
  88279. * @returns the behavior or null if not found
  88280. */
  88281. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88282. }
  88283. }
  88284. declare module BABYLON {
  88285. /**
  88286. * Class used to store data that will be store in GPU memory
  88287. */
  88288. export class Buffer {
  88289. private _engine;
  88290. private _buffer;
  88291. /** @hidden */
  88292. _data: Nullable<DataArray>;
  88293. private _updatable;
  88294. private _instanced;
  88295. private _divisor;
  88296. private _isAlreadyOwned;
  88297. /**
  88298. * Gets the byte stride.
  88299. */
  88300. readonly byteStride: number;
  88301. /**
  88302. * Constructor
  88303. * @param engine the engine
  88304. * @param data the data to use for this buffer
  88305. * @param updatable whether the data is updatable
  88306. * @param stride the stride (optional)
  88307. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88308. * @param instanced whether the buffer is instanced (optional)
  88309. * @param useBytes set to true if the stride in in bytes (optional)
  88310. * @param divisor sets an optional divisor for instances (1 by default)
  88311. */
  88312. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88313. /**
  88314. * Create a new VertexBuffer based on the current buffer
  88315. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88316. * @param offset defines offset in the buffer (0 by default)
  88317. * @param size defines the size in floats of attributes (position is 3 for instance)
  88318. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88319. * @param instanced defines if the vertex buffer contains indexed data
  88320. * @param useBytes defines if the offset and stride are in bytes *
  88321. * @param divisor sets an optional divisor for instances (1 by default)
  88322. * @returns the new vertex buffer
  88323. */
  88324. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88325. /**
  88326. * Gets a boolean indicating if the Buffer is updatable?
  88327. * @returns true if the buffer is updatable
  88328. */
  88329. isUpdatable(): boolean;
  88330. /**
  88331. * Gets current buffer's data
  88332. * @returns a DataArray or null
  88333. */
  88334. getData(): Nullable<DataArray>;
  88335. /**
  88336. * Gets underlying native buffer
  88337. * @returns underlying native buffer
  88338. */
  88339. getBuffer(): Nullable<DataBuffer>;
  88340. /**
  88341. * Gets the stride in float32 units (i.e. byte stride / 4).
  88342. * May not be an integer if the byte stride is not divisible by 4.
  88343. * @returns the stride in float32 units
  88344. * @deprecated Please use byteStride instead.
  88345. */
  88346. getStrideSize(): number;
  88347. /**
  88348. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88349. * @param data defines the data to store
  88350. */
  88351. create(data?: Nullable<DataArray>): void;
  88352. /** @hidden */
  88353. _rebuild(): void;
  88354. /**
  88355. * Update current buffer data
  88356. * @param data defines the data to store
  88357. */
  88358. update(data: DataArray): void;
  88359. /**
  88360. * Updates the data directly.
  88361. * @param data the new data
  88362. * @param offset the new offset
  88363. * @param vertexCount the vertex count (optional)
  88364. * @param useBytes set to true if the offset is in bytes
  88365. */
  88366. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88367. /** @hidden */
  88368. _increaseReferences(): void;
  88369. /**
  88370. * Release all resources
  88371. */
  88372. dispose(): void;
  88373. }
  88374. /**
  88375. * Specialized buffer used to store vertex data
  88376. */
  88377. export class VertexBuffer {
  88378. /** @hidden */
  88379. _buffer: Buffer;
  88380. private _kind;
  88381. private _size;
  88382. private _ownsBuffer;
  88383. private _instanced;
  88384. private _instanceDivisor;
  88385. /**
  88386. * The byte type.
  88387. */
  88388. static readonly BYTE: number;
  88389. /**
  88390. * The unsigned byte type.
  88391. */
  88392. static readonly UNSIGNED_BYTE: number;
  88393. /**
  88394. * The short type.
  88395. */
  88396. static readonly SHORT: number;
  88397. /**
  88398. * The unsigned short type.
  88399. */
  88400. static readonly UNSIGNED_SHORT: number;
  88401. /**
  88402. * The integer type.
  88403. */
  88404. static readonly INT: number;
  88405. /**
  88406. * The unsigned integer type.
  88407. */
  88408. static readonly UNSIGNED_INT: number;
  88409. /**
  88410. * The float type.
  88411. */
  88412. static readonly FLOAT: number;
  88413. /**
  88414. * Gets or sets the instance divisor when in instanced mode
  88415. */
  88416. get instanceDivisor(): number;
  88417. set instanceDivisor(value: number);
  88418. /**
  88419. * Gets the byte stride.
  88420. */
  88421. readonly byteStride: number;
  88422. /**
  88423. * Gets the byte offset.
  88424. */
  88425. readonly byteOffset: number;
  88426. /**
  88427. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88428. */
  88429. readonly normalized: boolean;
  88430. /**
  88431. * Gets the data type of each component in the array.
  88432. */
  88433. readonly type: number;
  88434. /**
  88435. * Constructor
  88436. * @param engine the engine
  88437. * @param data the data to use for this vertex buffer
  88438. * @param kind the vertex buffer kind
  88439. * @param updatable whether the data is updatable
  88440. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88441. * @param stride the stride (optional)
  88442. * @param instanced whether the buffer is instanced (optional)
  88443. * @param offset the offset of the data (optional)
  88444. * @param size the number of components (optional)
  88445. * @param type the type of the component (optional)
  88446. * @param normalized whether the data contains normalized data (optional)
  88447. * @param useBytes set to true if stride and offset are in bytes (optional)
  88448. * @param divisor defines the instance divisor to use (1 by default)
  88449. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  88450. */
  88451. 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);
  88452. /** @hidden */
  88453. _rebuild(): void;
  88454. /**
  88455. * Returns the kind of the VertexBuffer (string)
  88456. * @returns a string
  88457. */
  88458. getKind(): string;
  88459. /**
  88460. * Gets a boolean indicating if the VertexBuffer is updatable?
  88461. * @returns true if the buffer is updatable
  88462. */
  88463. isUpdatable(): boolean;
  88464. /**
  88465. * Gets current buffer's data
  88466. * @returns a DataArray or null
  88467. */
  88468. getData(): Nullable<DataArray>;
  88469. /**
  88470. * Gets underlying native buffer
  88471. * @returns underlying native buffer
  88472. */
  88473. getBuffer(): Nullable<DataBuffer>;
  88474. /**
  88475. * Gets the stride in float32 units (i.e. byte stride / 4).
  88476. * May not be an integer if the byte stride is not divisible by 4.
  88477. * @returns the stride in float32 units
  88478. * @deprecated Please use byteStride instead.
  88479. */
  88480. getStrideSize(): number;
  88481. /**
  88482. * Returns the offset as a multiple of the type byte length.
  88483. * @returns the offset in bytes
  88484. * @deprecated Please use byteOffset instead.
  88485. */
  88486. getOffset(): number;
  88487. /**
  88488. * Returns the number of components per vertex attribute (integer)
  88489. * @returns the size in float
  88490. */
  88491. getSize(): number;
  88492. /**
  88493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88494. * @returns true if this buffer is instanced
  88495. */
  88496. getIsInstanced(): boolean;
  88497. /**
  88498. * Returns the instancing divisor, zero for non-instanced (integer).
  88499. * @returns a number
  88500. */
  88501. getInstanceDivisor(): number;
  88502. /**
  88503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88504. * @param data defines the data to store
  88505. */
  88506. create(data?: DataArray): void;
  88507. /**
  88508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88509. * This function will create a new buffer if the current one is not updatable
  88510. * @param data defines the data to store
  88511. */
  88512. update(data: DataArray): void;
  88513. /**
  88514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88515. * Returns the directly updated WebGLBuffer.
  88516. * @param data the new data
  88517. * @param offset the new offset
  88518. * @param useBytes set to true if the offset is in bytes
  88519. */
  88520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88521. /**
  88522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88523. */
  88524. dispose(): void;
  88525. /**
  88526. * Enumerates each value of this vertex buffer as numbers.
  88527. * @param count the number of values to enumerate
  88528. * @param callback the callback function called for each value
  88529. */
  88530. forEach(count: number, callback: (value: number, index: number) => void): void;
  88531. /**
  88532. * Positions
  88533. */
  88534. static readonly PositionKind: string;
  88535. /**
  88536. * Normals
  88537. */
  88538. static readonly NormalKind: string;
  88539. /**
  88540. * Tangents
  88541. */
  88542. static readonly TangentKind: string;
  88543. /**
  88544. * Texture coordinates
  88545. */
  88546. static readonly UVKind: string;
  88547. /**
  88548. * Texture coordinates 2
  88549. */
  88550. static readonly UV2Kind: string;
  88551. /**
  88552. * Texture coordinates 3
  88553. */
  88554. static readonly UV3Kind: string;
  88555. /**
  88556. * Texture coordinates 4
  88557. */
  88558. static readonly UV4Kind: string;
  88559. /**
  88560. * Texture coordinates 5
  88561. */
  88562. static readonly UV5Kind: string;
  88563. /**
  88564. * Texture coordinates 6
  88565. */
  88566. static readonly UV6Kind: string;
  88567. /**
  88568. * Colors
  88569. */
  88570. static readonly ColorKind: string;
  88571. /**
  88572. * Matrix indices (for bones)
  88573. */
  88574. static readonly MatricesIndicesKind: string;
  88575. /**
  88576. * Matrix weights (for bones)
  88577. */
  88578. static readonly MatricesWeightsKind: string;
  88579. /**
  88580. * Additional matrix indices (for bones)
  88581. */
  88582. static readonly MatricesIndicesExtraKind: string;
  88583. /**
  88584. * Additional matrix weights (for bones)
  88585. */
  88586. static readonly MatricesWeightsExtraKind: string;
  88587. /**
  88588. * Deduces the stride given a kind.
  88589. * @param kind The kind string to deduce
  88590. * @returns The deduced stride
  88591. */
  88592. static DeduceStride(kind: string): number;
  88593. /**
  88594. * Gets the byte length of the given type.
  88595. * @param type the type
  88596. * @returns the number of bytes
  88597. */
  88598. static GetTypeByteLength(type: number): number;
  88599. /**
  88600. * Enumerates each value of the given parameters as numbers.
  88601. * @param data the data to enumerate
  88602. * @param byteOffset the byte offset of the data
  88603. * @param byteStride the byte stride of the data
  88604. * @param componentCount the number of components per element
  88605. * @param componentType the type of the component
  88606. * @param count the number of values to enumerate
  88607. * @param normalized whether the data is normalized
  88608. * @param callback the callback function called for each value
  88609. */
  88610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88611. private static _GetFloatValue;
  88612. }
  88613. }
  88614. declare module BABYLON {
  88615. /**
  88616. * @hidden
  88617. */
  88618. export class IntersectionInfo {
  88619. bu: Nullable<number>;
  88620. bv: Nullable<number>;
  88621. distance: number;
  88622. faceId: number;
  88623. subMeshId: number;
  88624. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88625. }
  88626. }
  88627. declare module BABYLON {
  88628. /**
  88629. * Class used to store bounding sphere information
  88630. */
  88631. export class BoundingSphere {
  88632. /**
  88633. * Gets the center of the bounding sphere in local space
  88634. */
  88635. readonly center: Vector3;
  88636. /**
  88637. * Radius of the bounding sphere in local space
  88638. */
  88639. radius: number;
  88640. /**
  88641. * Gets the center of the bounding sphere in world space
  88642. */
  88643. readonly centerWorld: Vector3;
  88644. /**
  88645. * Radius of the bounding sphere in world space
  88646. */
  88647. radiusWorld: number;
  88648. /**
  88649. * Gets the minimum vector in local space
  88650. */
  88651. readonly minimum: Vector3;
  88652. /**
  88653. * Gets the maximum vector in local space
  88654. */
  88655. readonly maximum: Vector3;
  88656. private _worldMatrix;
  88657. private static readonly TmpVector3;
  88658. /**
  88659. * Creates a new bounding sphere
  88660. * @param min defines the minimum vector (in local space)
  88661. * @param max defines the maximum vector (in local space)
  88662. * @param worldMatrix defines the new world matrix
  88663. */
  88664. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88665. /**
  88666. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88667. * @param min defines the new minimum vector (in local space)
  88668. * @param max defines the new maximum vector (in local space)
  88669. * @param worldMatrix defines the new world matrix
  88670. */
  88671. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88672. /**
  88673. * Scale the current bounding sphere by applying a scale factor
  88674. * @param factor defines the scale factor to apply
  88675. * @returns the current bounding box
  88676. */
  88677. scale(factor: number): BoundingSphere;
  88678. /**
  88679. * Gets the world matrix of the bounding box
  88680. * @returns a matrix
  88681. */
  88682. getWorldMatrix(): DeepImmutable<Matrix>;
  88683. /** @hidden */
  88684. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88685. /**
  88686. * Tests if the bounding sphere is intersecting the frustum planes
  88687. * @param frustumPlanes defines the frustum planes to test
  88688. * @returns true if there is an intersection
  88689. */
  88690. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88691. /**
  88692. * Tests if the bounding sphere center is in between the frustum planes.
  88693. * Used for optimistic fast inclusion.
  88694. * @param frustumPlanes defines the frustum planes to test
  88695. * @returns true if the sphere center is in between the frustum planes
  88696. */
  88697. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88698. /**
  88699. * Tests if a point is inside the bounding sphere
  88700. * @param point defines the point to test
  88701. * @returns true if the point is inside the bounding sphere
  88702. */
  88703. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88704. /**
  88705. * Checks if two sphere intersct
  88706. * @param sphere0 sphere 0
  88707. * @param sphere1 sphere 1
  88708. * @returns true if the speres intersect
  88709. */
  88710. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88711. }
  88712. }
  88713. declare module BABYLON {
  88714. /**
  88715. * Class used to store bounding box information
  88716. */
  88717. export class BoundingBox implements ICullable {
  88718. /**
  88719. * Gets the 8 vectors representing the bounding box in local space
  88720. */
  88721. readonly vectors: Vector3[];
  88722. /**
  88723. * Gets the center of the bounding box in local space
  88724. */
  88725. readonly center: Vector3;
  88726. /**
  88727. * Gets the center of the bounding box in world space
  88728. */
  88729. readonly centerWorld: Vector3;
  88730. /**
  88731. * Gets the extend size in local space
  88732. */
  88733. readonly extendSize: Vector3;
  88734. /**
  88735. * Gets the extend size in world space
  88736. */
  88737. readonly extendSizeWorld: Vector3;
  88738. /**
  88739. * Gets the OBB (object bounding box) directions
  88740. */
  88741. readonly directions: Vector3[];
  88742. /**
  88743. * Gets the 8 vectors representing the bounding box in world space
  88744. */
  88745. readonly vectorsWorld: Vector3[];
  88746. /**
  88747. * Gets the minimum vector in world space
  88748. */
  88749. readonly minimumWorld: Vector3;
  88750. /**
  88751. * Gets the maximum vector in world space
  88752. */
  88753. readonly maximumWorld: Vector3;
  88754. /**
  88755. * Gets the minimum vector in local space
  88756. */
  88757. readonly minimum: Vector3;
  88758. /**
  88759. * Gets the maximum vector in local space
  88760. */
  88761. readonly maximum: Vector3;
  88762. private _worldMatrix;
  88763. private static readonly TmpVector3;
  88764. /**
  88765. * @hidden
  88766. */
  88767. _tag: number;
  88768. /**
  88769. * Creates a new bounding box
  88770. * @param min defines the minimum vector (in local space)
  88771. * @param max defines the maximum vector (in local space)
  88772. * @param worldMatrix defines the new world matrix
  88773. */
  88774. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88775. /**
  88776. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88777. * @param min defines the new minimum vector (in local space)
  88778. * @param max defines the new maximum vector (in local space)
  88779. * @param worldMatrix defines the new world matrix
  88780. */
  88781. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88782. /**
  88783. * Scale the current bounding box by applying a scale factor
  88784. * @param factor defines the scale factor to apply
  88785. * @returns the current bounding box
  88786. */
  88787. scale(factor: number): BoundingBox;
  88788. /**
  88789. * Gets the world matrix of the bounding box
  88790. * @returns a matrix
  88791. */
  88792. getWorldMatrix(): DeepImmutable<Matrix>;
  88793. /** @hidden */
  88794. _update(world: DeepImmutable<Matrix>): void;
  88795. /**
  88796. * Tests if the bounding box is intersecting the frustum planes
  88797. * @param frustumPlanes defines the frustum planes to test
  88798. * @returns true if there is an intersection
  88799. */
  88800. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88801. /**
  88802. * Tests if the bounding box is entirely inside the frustum planes
  88803. * @param frustumPlanes defines the frustum planes to test
  88804. * @returns true if there is an inclusion
  88805. */
  88806. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88807. /**
  88808. * Tests if a point is inside the bounding box
  88809. * @param point defines the point to test
  88810. * @returns true if the point is inside the bounding box
  88811. */
  88812. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88813. /**
  88814. * Tests if the bounding box intersects with a bounding sphere
  88815. * @param sphere defines the sphere to test
  88816. * @returns true if there is an intersection
  88817. */
  88818. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88819. /**
  88820. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88821. * @param min defines the min vector to use
  88822. * @param max defines the max vector to use
  88823. * @returns true if there is an intersection
  88824. */
  88825. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88826. /**
  88827. * Tests if two bounding boxes are intersections
  88828. * @param box0 defines the first box to test
  88829. * @param box1 defines the second box to test
  88830. * @returns true if there is an intersection
  88831. */
  88832. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88833. /**
  88834. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88835. * @param minPoint defines the minimum vector of the bounding box
  88836. * @param maxPoint defines the maximum vector of the bounding box
  88837. * @param sphereCenter defines the sphere center
  88838. * @param sphereRadius defines the sphere radius
  88839. * @returns true if there is an intersection
  88840. */
  88841. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88842. /**
  88843. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88844. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88845. * @param frustumPlanes defines the frustum planes to test
  88846. * @return true if there is an inclusion
  88847. */
  88848. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88849. /**
  88850. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88851. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88852. * @param frustumPlanes defines the frustum planes to test
  88853. * @return true if there is an intersection
  88854. */
  88855. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88856. }
  88857. }
  88858. declare module BABYLON {
  88859. /** @hidden */
  88860. export class Collider {
  88861. /** Define if a collision was found */
  88862. collisionFound: boolean;
  88863. /**
  88864. * Define last intersection point in local space
  88865. */
  88866. intersectionPoint: Vector3;
  88867. /**
  88868. * Define last collided mesh
  88869. */
  88870. collidedMesh: Nullable<AbstractMesh>;
  88871. private _collisionPoint;
  88872. private _planeIntersectionPoint;
  88873. private _tempVector;
  88874. private _tempVector2;
  88875. private _tempVector3;
  88876. private _tempVector4;
  88877. private _edge;
  88878. private _baseToVertex;
  88879. private _destinationPoint;
  88880. private _slidePlaneNormal;
  88881. private _displacementVector;
  88882. /** @hidden */
  88883. _radius: Vector3;
  88884. /** @hidden */
  88885. _retry: number;
  88886. private _velocity;
  88887. private _basePoint;
  88888. private _epsilon;
  88889. /** @hidden */
  88890. _velocityWorldLength: number;
  88891. /** @hidden */
  88892. _basePointWorld: Vector3;
  88893. private _velocityWorld;
  88894. private _normalizedVelocity;
  88895. /** @hidden */
  88896. _initialVelocity: Vector3;
  88897. /** @hidden */
  88898. _initialPosition: Vector3;
  88899. private _nearestDistance;
  88900. private _collisionMask;
  88901. get collisionMask(): number;
  88902. set collisionMask(mask: number);
  88903. /**
  88904. * Gets the plane normal used to compute the sliding response (in local space)
  88905. */
  88906. get slidePlaneNormal(): Vector3;
  88907. /** @hidden */
  88908. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88909. /** @hidden */
  88910. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88911. /** @hidden */
  88912. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88913. /** @hidden */
  88914. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88915. /** @hidden */
  88916. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88917. /** @hidden */
  88918. _getResponse(pos: Vector3, vel: Vector3): void;
  88919. }
  88920. }
  88921. declare module BABYLON {
  88922. /**
  88923. * Interface for cullable objects
  88924. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88925. */
  88926. export interface ICullable {
  88927. /**
  88928. * Checks if the object or part of the object is in the frustum
  88929. * @param frustumPlanes Camera near/planes
  88930. * @returns true if the object is in frustum otherwise false
  88931. */
  88932. isInFrustum(frustumPlanes: Plane[]): boolean;
  88933. /**
  88934. * Checks if a cullable object (mesh...) is in the camera frustum
  88935. * Unlike isInFrustum this cheks the full bounding box
  88936. * @param frustumPlanes Camera near/planes
  88937. * @returns true if the object is in frustum otherwise false
  88938. */
  88939. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88940. }
  88941. /**
  88942. * Info for a bounding data of a mesh
  88943. */
  88944. export class BoundingInfo implements ICullable {
  88945. /**
  88946. * Bounding box for the mesh
  88947. */
  88948. readonly boundingBox: BoundingBox;
  88949. /**
  88950. * Bounding sphere for the mesh
  88951. */
  88952. readonly boundingSphere: BoundingSphere;
  88953. private _isLocked;
  88954. private static readonly TmpVector3;
  88955. /**
  88956. * Constructs bounding info
  88957. * @param minimum min vector of the bounding box/sphere
  88958. * @param maximum max vector of the bounding box/sphere
  88959. * @param worldMatrix defines the new world matrix
  88960. */
  88961. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88962. /**
  88963. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88964. * @param min defines the new minimum vector (in local space)
  88965. * @param max defines the new maximum vector (in local space)
  88966. * @param worldMatrix defines the new world matrix
  88967. */
  88968. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88969. /**
  88970. * min vector of the bounding box/sphere
  88971. */
  88972. get minimum(): Vector3;
  88973. /**
  88974. * max vector of the bounding box/sphere
  88975. */
  88976. get maximum(): Vector3;
  88977. /**
  88978. * If the info is locked and won't be updated to avoid perf overhead
  88979. */
  88980. get isLocked(): boolean;
  88981. set isLocked(value: boolean);
  88982. /**
  88983. * Updates the bounding sphere and box
  88984. * @param world world matrix to be used to update
  88985. */
  88986. update(world: DeepImmutable<Matrix>): void;
  88987. /**
  88988. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88989. * @param center New center of the bounding info
  88990. * @param extend New extend of the bounding info
  88991. * @returns the current bounding info
  88992. */
  88993. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88994. /**
  88995. * Scale the current bounding info by applying a scale factor
  88996. * @param factor defines the scale factor to apply
  88997. * @returns the current bounding info
  88998. */
  88999. scale(factor: number): BoundingInfo;
  89000. /**
  89001. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  89002. * @param frustumPlanes defines the frustum to test
  89003. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  89004. * @returns true if the bounding info is in the frustum planes
  89005. */
  89006. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  89007. /**
  89008. * Gets the world distance between the min and max points of the bounding box
  89009. */
  89010. get diagonalLength(): number;
  89011. /**
  89012. * Checks if a cullable object (mesh...) is in the camera frustum
  89013. * Unlike isInFrustum this cheks the full bounding box
  89014. * @param frustumPlanes Camera near/planes
  89015. * @returns true if the object is in frustum otherwise false
  89016. */
  89017. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  89018. /** @hidden */
  89019. _checkCollision(collider: Collider): boolean;
  89020. /**
  89021. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  89022. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89023. * @param point the point to check intersection with
  89024. * @returns if the point intersects
  89025. */
  89026. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  89027. /**
  89028. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  89029. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89030. * @param boundingInfo the bounding info to check intersection with
  89031. * @param precise if the intersection should be done using OBB
  89032. * @returns if the bounding info intersects
  89033. */
  89034. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  89035. }
  89036. }
  89037. declare module BABYLON {
  89038. /**
  89039. * Extracts minimum and maximum values from a list of indexed positions
  89040. * @param positions defines the positions to use
  89041. * @param indices defines the indices to the positions
  89042. * @param indexStart defines the start index
  89043. * @param indexCount defines the end index
  89044. * @param bias defines bias value to add to the result
  89045. * @return minimum and maximum values
  89046. */
  89047. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89048. minimum: Vector3;
  89049. maximum: Vector3;
  89050. };
  89051. /**
  89052. * Extracts minimum and maximum values from a list of positions
  89053. * @param positions defines the positions to use
  89054. * @param start defines the start index in the positions array
  89055. * @param count defines the number of positions to handle
  89056. * @param bias defines bias value to add to the result
  89057. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89058. * @return minimum and maximum values
  89059. */
  89060. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89061. minimum: Vector3;
  89062. maximum: Vector3;
  89063. };
  89064. }
  89065. declare module BABYLON {
  89066. /**
  89067. * Class used to manipulate GUIDs
  89068. */
  89069. export class GUID {
  89070. /**
  89071. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89072. * Be aware Math.random() could cause collisions, but:
  89073. * "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"
  89074. * @returns a pseudo random id
  89075. */
  89076. static RandomId(): string;
  89077. }
  89078. }
  89079. declare module BABYLON {
  89080. /**
  89081. * Base class of all the textures in babylon.
  89082. * It groups all the common properties the materials, post process, lights... might need
  89083. * in order to make a correct use of the texture.
  89084. */
  89085. export class BaseTexture extends ThinTexture implements IAnimatable {
  89086. /**
  89087. * Default anisotropic filtering level for the application.
  89088. * It is set to 4 as a good tradeoff between perf and quality.
  89089. */
  89090. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89091. /**
  89092. * Gets or sets the unique id of the texture
  89093. */
  89094. uniqueId: number;
  89095. /**
  89096. * Define the name of the texture.
  89097. */
  89098. name: string;
  89099. /**
  89100. * Gets or sets an object used to store user defined information.
  89101. */
  89102. metadata: any;
  89103. /**
  89104. * For internal use only. Please do not use.
  89105. */
  89106. reservedDataStore: any;
  89107. private _hasAlpha;
  89108. /**
  89109. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89110. */
  89111. set hasAlpha(value: boolean);
  89112. get hasAlpha(): boolean;
  89113. /**
  89114. * Defines if the alpha value should be determined via the rgb values.
  89115. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89116. */
  89117. getAlphaFromRGB: boolean;
  89118. /**
  89119. * Intensity or strength of the texture.
  89120. * It is commonly used by materials to fine tune the intensity of the texture
  89121. */
  89122. level: number;
  89123. /**
  89124. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89125. * This is part of the texture as textures usually maps to one uv set.
  89126. */
  89127. coordinatesIndex: number;
  89128. protected _coordinatesMode: number;
  89129. /**
  89130. * How a texture is mapped.
  89131. *
  89132. * | Value | Type | Description |
  89133. * | ----- | ----------------------------------- | ----------- |
  89134. * | 0 | EXPLICIT_MODE | |
  89135. * | 1 | SPHERICAL_MODE | |
  89136. * | 2 | PLANAR_MODE | |
  89137. * | 3 | CUBIC_MODE | |
  89138. * | 4 | PROJECTION_MODE | |
  89139. * | 5 | SKYBOX_MODE | |
  89140. * | 6 | INVCUBIC_MODE | |
  89141. * | 7 | EQUIRECTANGULAR_MODE | |
  89142. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89143. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89144. */
  89145. set coordinatesMode(value: number);
  89146. get coordinatesMode(): number;
  89147. /**
  89148. * | Value | Type | Description |
  89149. * | ----- | ------------------ | ----------- |
  89150. * | 0 | CLAMP_ADDRESSMODE | |
  89151. * | 1 | WRAP_ADDRESSMODE | |
  89152. * | 2 | MIRROR_ADDRESSMODE | |
  89153. */
  89154. get wrapU(): number;
  89155. set wrapU(value: number);
  89156. /**
  89157. * | Value | Type | Description |
  89158. * | ----- | ------------------ | ----------- |
  89159. * | 0 | CLAMP_ADDRESSMODE | |
  89160. * | 1 | WRAP_ADDRESSMODE | |
  89161. * | 2 | MIRROR_ADDRESSMODE | |
  89162. */
  89163. get wrapV(): number;
  89164. set wrapV(value: number);
  89165. /**
  89166. * | Value | Type | Description |
  89167. * | ----- | ------------------ | ----------- |
  89168. * | 0 | CLAMP_ADDRESSMODE | |
  89169. * | 1 | WRAP_ADDRESSMODE | |
  89170. * | 2 | MIRROR_ADDRESSMODE | |
  89171. */
  89172. wrapR: number;
  89173. /**
  89174. * With compliant hardware and browser (supporting anisotropic filtering)
  89175. * this defines the level of anisotropic filtering in the texture.
  89176. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89177. */
  89178. anisotropicFilteringLevel: number;
  89179. private _isCube;
  89180. /**
  89181. * Define if the texture is a cube texture or if false a 2d texture.
  89182. */
  89183. get isCube(): boolean;
  89184. set isCube(value: boolean);
  89185. /**
  89186. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89187. */
  89188. get is3D(): boolean;
  89189. set is3D(value: boolean);
  89190. /**
  89191. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  89192. */
  89193. get is2DArray(): boolean;
  89194. set is2DArray(value: boolean);
  89195. private _gammaSpace;
  89196. /**
  89197. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89198. * HDR texture are usually stored in linear space.
  89199. * This only impacts the PBR and Background materials
  89200. */
  89201. get gammaSpace(): boolean;
  89202. set gammaSpace(gamma: boolean);
  89203. /**
  89204. * Gets or sets whether or not the texture contains RGBD data.
  89205. */
  89206. get isRGBD(): boolean;
  89207. set isRGBD(value: boolean);
  89208. /**
  89209. * Is Z inverted in the texture (useful in a cube texture).
  89210. */
  89211. invertZ: boolean;
  89212. /**
  89213. * Are mip maps generated for this texture or not.
  89214. */
  89215. get noMipmap(): boolean;
  89216. /**
  89217. * @hidden
  89218. */
  89219. lodLevelInAlpha: boolean;
  89220. /**
  89221. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89222. */
  89223. get lodGenerationOffset(): number;
  89224. set lodGenerationOffset(value: number);
  89225. /**
  89226. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89227. */
  89228. get lodGenerationScale(): number;
  89229. set lodGenerationScale(value: number);
  89230. /**
  89231. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89232. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89233. * average roughness values.
  89234. */
  89235. get linearSpecularLOD(): boolean;
  89236. set linearSpecularLOD(value: boolean);
  89237. /**
  89238. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89239. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89240. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89241. */
  89242. get irradianceTexture(): Nullable<BaseTexture>;
  89243. set irradianceTexture(value: Nullable<BaseTexture>);
  89244. /**
  89245. * Define if the texture is a render target.
  89246. */
  89247. isRenderTarget: boolean;
  89248. /**
  89249. * Define the unique id of the texture in the scene.
  89250. */
  89251. get uid(): string;
  89252. /** @hidden */
  89253. _prefiltered: boolean;
  89254. /**
  89255. * Return a string representation of the texture.
  89256. * @returns the texture as a string
  89257. */
  89258. toString(): string;
  89259. /**
  89260. * Get the class name of the texture.
  89261. * @returns "BaseTexture"
  89262. */
  89263. getClassName(): string;
  89264. /**
  89265. * Define the list of animation attached to the texture.
  89266. */
  89267. animations: Animation[];
  89268. /**
  89269. * An event triggered when the texture is disposed.
  89270. */
  89271. onDisposeObservable: Observable<BaseTexture>;
  89272. private _onDisposeObserver;
  89273. /**
  89274. * Callback triggered when the texture has been disposed.
  89275. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89276. */
  89277. set onDispose(callback: () => void);
  89278. protected _scene: Nullable<Scene>;
  89279. /** @hidden */
  89280. _texture: Nullable<InternalTexture>;
  89281. private _uid;
  89282. /**
  89283. * Define if the texture is preventinga material to render or not.
  89284. * If not and the texture is not ready, the engine will use a default black texture instead.
  89285. */
  89286. get isBlocking(): boolean;
  89287. /**
  89288. * Instantiates a new BaseTexture.
  89289. * Base class of all the textures in babylon.
  89290. * It groups all the common properties the materials, post process, lights... might need
  89291. * in order to make a correct use of the texture.
  89292. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89293. */
  89294. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89295. /**
  89296. * Get the scene the texture belongs to.
  89297. * @returns the scene or null if undefined
  89298. */
  89299. getScene(): Nullable<Scene>;
  89300. /** @hidden */
  89301. protected _getEngine(): Nullable<ThinEngine>;
  89302. /**
  89303. * Checks if the texture has the same transform matrix than another texture
  89304. * @param texture texture to check against
  89305. * @returns true if the transforms are the same, else false
  89306. */
  89307. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89308. /**
  89309. * Get the texture transform matrix used to offset tile the texture for istance.
  89310. * @returns the transformation matrix
  89311. */
  89312. getTextureMatrix(): Matrix;
  89313. /**
  89314. * Get the texture reflection matrix used to rotate/transform the reflection.
  89315. * @returns the reflection matrix
  89316. */
  89317. getReflectionTextureMatrix(): Matrix;
  89318. /**
  89319. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89320. * @returns true if ready or not blocking
  89321. */
  89322. isReadyOrNotBlocking(): boolean;
  89323. /**
  89324. * Scales the texture if is `canRescale()`
  89325. * @param ratio the resize factor we want to use to rescale
  89326. */
  89327. scale(ratio: number): void;
  89328. /**
  89329. * Get if the texture can rescale.
  89330. */
  89331. get canRescale(): boolean;
  89332. /** @hidden */
  89333. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89334. /** @hidden */
  89335. _rebuild(): void;
  89336. /**
  89337. * Clones the texture.
  89338. * @returns the cloned texture
  89339. */
  89340. clone(): Nullable<BaseTexture>;
  89341. /**
  89342. * Get the texture underlying type (INT, FLOAT...)
  89343. */
  89344. get textureType(): number;
  89345. /**
  89346. * Get the texture underlying format (RGB, RGBA...)
  89347. */
  89348. get textureFormat(): number;
  89349. /**
  89350. * Indicates that textures need to be re-calculated for all materials
  89351. */
  89352. protected _markAllSubMeshesAsTexturesDirty(): void;
  89353. /**
  89354. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89355. * This will returns an RGBA array buffer containing either in values (0-255) or
  89356. * float values (0-1) depending of the underlying buffer type.
  89357. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89358. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89359. * @param buffer defines a user defined buffer to fill with data (can be null)
  89360. * @returns The Array buffer containing the pixels data.
  89361. */
  89362. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89363. /** @hidden */
  89364. get _lodTextureHigh(): Nullable<BaseTexture>;
  89365. /** @hidden */
  89366. get _lodTextureMid(): Nullable<BaseTexture>;
  89367. /** @hidden */
  89368. get _lodTextureLow(): Nullable<BaseTexture>;
  89369. /**
  89370. * Dispose the texture and release its associated resources.
  89371. */
  89372. dispose(): void;
  89373. /**
  89374. * Serialize the texture into a JSON representation that can be parsed later on.
  89375. * @returns the JSON representation of the texture
  89376. */
  89377. serialize(): any;
  89378. /**
  89379. * Helper function to be called back once a list of texture contains only ready textures.
  89380. * @param textures Define the list of textures to wait for
  89381. * @param callback Define the callback triggered once the entire list will be ready
  89382. */
  89383. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89384. private static _isScene;
  89385. }
  89386. }
  89387. declare module BABYLON {
  89388. /** @hidden */
  89389. export class WebGLDataBuffer extends DataBuffer {
  89390. private _buffer;
  89391. constructor(resource: WebGLBuffer);
  89392. get underlyingResource(): any;
  89393. }
  89394. }
  89395. declare module BABYLON {
  89396. /** @hidden */
  89397. export class WebGLPipelineContext implements IPipelineContext {
  89398. engine: ThinEngine;
  89399. program: Nullable<WebGLProgram>;
  89400. context?: WebGLRenderingContext;
  89401. vertexShader?: WebGLShader;
  89402. fragmentShader?: WebGLShader;
  89403. isParallelCompiled: boolean;
  89404. onCompiled?: () => void;
  89405. transformFeedback?: WebGLTransformFeedback | null;
  89406. vertexCompilationError: Nullable<string>;
  89407. fragmentCompilationError: Nullable<string>;
  89408. programLinkError: Nullable<string>;
  89409. programValidationError: Nullable<string>;
  89410. get isAsync(): boolean;
  89411. get isReady(): boolean;
  89412. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89413. _getVertexShaderCode(): string | null;
  89414. _getFragmentShaderCode(): string | null;
  89415. }
  89416. }
  89417. declare module BABYLON {
  89418. interface ThinEngine {
  89419. /**
  89420. * Create an uniform buffer
  89421. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89422. * @param elements defines the content of the uniform buffer
  89423. * @returns the webGL uniform buffer
  89424. */
  89425. createUniformBuffer(elements: FloatArray): DataBuffer;
  89426. /**
  89427. * Create a dynamic uniform buffer
  89428. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89429. * @param elements defines the content of the uniform buffer
  89430. * @returns the webGL uniform buffer
  89431. */
  89432. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89433. /**
  89434. * Update an existing uniform buffer
  89435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89436. * @param uniformBuffer defines the target uniform buffer
  89437. * @param elements defines the content to update
  89438. * @param offset defines the offset in the uniform buffer where update should start
  89439. * @param count defines the size of the data to update
  89440. */
  89441. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89442. /**
  89443. * Bind an uniform buffer to the current webGL context
  89444. * @param buffer defines the buffer to bind
  89445. */
  89446. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89447. /**
  89448. * Bind a buffer to the current webGL context at a given location
  89449. * @param buffer defines the buffer to bind
  89450. * @param location defines the index where to bind the buffer
  89451. */
  89452. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89453. /**
  89454. * Bind a specific block at a given index in a specific shader program
  89455. * @param pipelineContext defines the pipeline context to use
  89456. * @param blockName defines the block name
  89457. * @param index defines the index where to bind the block
  89458. */
  89459. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89460. }
  89461. }
  89462. declare module BABYLON {
  89463. /**
  89464. * Uniform buffer objects.
  89465. *
  89466. * Handles blocks of uniform on the GPU.
  89467. *
  89468. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89469. *
  89470. * For more information, please refer to :
  89471. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89472. */
  89473. export class UniformBuffer {
  89474. private _engine;
  89475. private _buffer;
  89476. private _data;
  89477. private _bufferData;
  89478. private _dynamic?;
  89479. private _uniformLocations;
  89480. private _uniformSizes;
  89481. private _uniformLocationPointer;
  89482. private _needSync;
  89483. private _noUBO;
  89484. private _currentEffect;
  89485. /** @hidden */
  89486. _alreadyBound: boolean;
  89487. private static _MAX_UNIFORM_SIZE;
  89488. private static _tempBuffer;
  89489. /**
  89490. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89491. * This is dynamic to allow compat with webgl 1 and 2.
  89492. * You will need to pass the name of the uniform as well as the value.
  89493. */
  89494. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89495. /**
  89496. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89497. * This is dynamic to allow compat with webgl 1 and 2.
  89498. * You will need to pass the name of the uniform as well as the value.
  89499. */
  89500. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89501. /**
  89502. * Lambda to Update a single float in a uniform buffer.
  89503. * This is dynamic to allow compat with webgl 1 and 2.
  89504. * You will need to pass the name of the uniform as well as the value.
  89505. */
  89506. updateFloat: (name: string, x: number) => void;
  89507. /**
  89508. * Lambda to Update a vec2 of float in a uniform buffer.
  89509. * This is dynamic to allow compat with webgl 1 and 2.
  89510. * You will need to pass the name of the uniform as well as the value.
  89511. */
  89512. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89513. /**
  89514. * Lambda to Update a vec3 of float in a uniform buffer.
  89515. * This is dynamic to allow compat with webgl 1 and 2.
  89516. * You will need to pass the name of the uniform as well as the value.
  89517. */
  89518. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89519. /**
  89520. * Lambda to Update a vec4 of float in a uniform buffer.
  89521. * This is dynamic to allow compat with webgl 1 and 2.
  89522. * You will need to pass the name of the uniform as well as the value.
  89523. */
  89524. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89525. /**
  89526. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89527. * This is dynamic to allow compat with webgl 1 and 2.
  89528. * You will need to pass the name of the uniform as well as the value.
  89529. */
  89530. updateMatrix: (name: string, mat: Matrix) => void;
  89531. /**
  89532. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89533. * This is dynamic to allow compat with webgl 1 and 2.
  89534. * You will need to pass the name of the uniform as well as the value.
  89535. */
  89536. updateVector3: (name: string, vector: Vector3) => void;
  89537. /**
  89538. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89539. * This is dynamic to allow compat with webgl 1 and 2.
  89540. * You will need to pass the name of the uniform as well as the value.
  89541. */
  89542. updateVector4: (name: string, vector: Vector4) => void;
  89543. /**
  89544. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89545. * This is dynamic to allow compat with webgl 1 and 2.
  89546. * You will need to pass the name of the uniform as well as the value.
  89547. */
  89548. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89549. /**
  89550. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89551. * This is dynamic to allow compat with webgl 1 and 2.
  89552. * You will need to pass the name of the uniform as well as the value.
  89553. */
  89554. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89555. /**
  89556. * Instantiates a new Uniform buffer objects.
  89557. *
  89558. * Handles blocks of uniform on the GPU.
  89559. *
  89560. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89561. *
  89562. * For more information, please refer to :
  89563. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89564. * @param engine Define the engine the buffer is associated with
  89565. * @param data Define the data contained in the buffer
  89566. * @param dynamic Define if the buffer is updatable
  89567. */
  89568. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89569. /**
  89570. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89571. * or just falling back on setUniformXXX calls.
  89572. */
  89573. get useUbo(): boolean;
  89574. /**
  89575. * Indicates if the WebGL underlying uniform buffer is in sync
  89576. * with the javascript cache data.
  89577. */
  89578. get isSync(): boolean;
  89579. /**
  89580. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89581. * Also, a dynamic UniformBuffer will disable cache verification and always
  89582. * update the underlying WebGL uniform buffer to the GPU.
  89583. * @returns if Dynamic, otherwise false
  89584. */
  89585. isDynamic(): boolean;
  89586. /**
  89587. * The data cache on JS side.
  89588. * @returns the underlying data as a float array
  89589. */
  89590. getData(): Float32Array;
  89591. /**
  89592. * The underlying WebGL Uniform buffer.
  89593. * @returns the webgl buffer
  89594. */
  89595. getBuffer(): Nullable<DataBuffer>;
  89596. /**
  89597. * std140 layout specifies how to align data within an UBO structure.
  89598. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89599. * for specs.
  89600. */
  89601. private _fillAlignment;
  89602. /**
  89603. * Adds an uniform in the buffer.
  89604. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89605. * for the layout to be correct !
  89606. * @param name Name of the uniform, as used in the uniform block in the shader.
  89607. * @param size Data size, or data directly.
  89608. */
  89609. addUniform(name: string, size: number | number[]): void;
  89610. /**
  89611. * Adds a Matrix 4x4 to the uniform buffer.
  89612. * @param name Name of the uniform, as used in the uniform block in the shader.
  89613. * @param mat A 4x4 matrix.
  89614. */
  89615. addMatrix(name: string, mat: Matrix): void;
  89616. /**
  89617. * Adds a vec2 to the uniform buffer.
  89618. * @param name Name of the uniform, as used in the uniform block in the shader.
  89619. * @param x Define the x component value of the vec2
  89620. * @param y Define the y component value of the vec2
  89621. */
  89622. addFloat2(name: string, x: number, y: number): void;
  89623. /**
  89624. * Adds a vec3 to the uniform buffer.
  89625. * @param name Name of the uniform, as used in the uniform block in the shader.
  89626. * @param x Define the x component value of the vec3
  89627. * @param y Define the y component value of the vec3
  89628. * @param z Define the z component value of the vec3
  89629. */
  89630. addFloat3(name: string, x: number, y: number, z: number): void;
  89631. /**
  89632. * Adds a vec3 to the uniform buffer.
  89633. * @param name Name of the uniform, as used in the uniform block in the shader.
  89634. * @param color Define the vec3 from a Color
  89635. */
  89636. addColor3(name: string, color: Color3): void;
  89637. /**
  89638. * Adds a vec4 to the uniform buffer.
  89639. * @param name Name of the uniform, as used in the uniform block in the shader.
  89640. * @param color Define the rgb components from a Color
  89641. * @param alpha Define the a component of the vec4
  89642. */
  89643. addColor4(name: string, color: Color3, alpha: number): void;
  89644. /**
  89645. * Adds a vec3 to the uniform buffer.
  89646. * @param name Name of the uniform, as used in the uniform block in the shader.
  89647. * @param vector Define the vec3 components from a Vector
  89648. */
  89649. addVector3(name: string, vector: Vector3): void;
  89650. /**
  89651. * Adds a Matrix 3x3 to the uniform buffer.
  89652. * @param name Name of the uniform, as used in the uniform block in the shader.
  89653. */
  89654. addMatrix3x3(name: string): void;
  89655. /**
  89656. * Adds a Matrix 2x2 to the uniform buffer.
  89657. * @param name Name of the uniform, as used in the uniform block in the shader.
  89658. */
  89659. addMatrix2x2(name: string): void;
  89660. /**
  89661. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89662. */
  89663. create(): void;
  89664. /** @hidden */
  89665. _rebuild(): void;
  89666. /**
  89667. * Updates the WebGL Uniform Buffer on the GPU.
  89668. * If the `dynamic` flag is set to true, no cache comparison is done.
  89669. * Otherwise, the buffer will be updated only if the cache differs.
  89670. */
  89671. update(): void;
  89672. /**
  89673. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89675. * @param data Define the flattened data
  89676. * @param size Define the size of the data.
  89677. */
  89678. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89679. private _valueCache;
  89680. private _cacheMatrix;
  89681. private _updateMatrix3x3ForUniform;
  89682. private _updateMatrix3x3ForEffect;
  89683. private _updateMatrix2x2ForEffect;
  89684. private _updateMatrix2x2ForUniform;
  89685. private _updateFloatForEffect;
  89686. private _updateFloatForUniform;
  89687. private _updateFloat2ForEffect;
  89688. private _updateFloat2ForUniform;
  89689. private _updateFloat3ForEffect;
  89690. private _updateFloat3ForUniform;
  89691. private _updateFloat4ForEffect;
  89692. private _updateFloat4ForUniform;
  89693. private _updateMatrixForEffect;
  89694. private _updateMatrixForUniform;
  89695. private _updateVector3ForEffect;
  89696. private _updateVector3ForUniform;
  89697. private _updateVector4ForEffect;
  89698. private _updateVector4ForUniform;
  89699. private _updateColor3ForEffect;
  89700. private _updateColor3ForUniform;
  89701. private _updateColor4ForEffect;
  89702. private _updateColor4ForUniform;
  89703. /**
  89704. * Sets a sampler uniform on the effect.
  89705. * @param name Define the name of the sampler.
  89706. * @param texture Define the texture to set in the sampler
  89707. */
  89708. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89709. /**
  89710. * Directly updates the value of the uniform in the cache AND on the GPU.
  89711. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89712. * @param data Define the flattened data
  89713. */
  89714. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89715. /**
  89716. * Binds this uniform buffer to an effect.
  89717. * @param effect Define the effect to bind the buffer to
  89718. * @param name Name of the uniform block in the shader.
  89719. */
  89720. bindToEffect(effect: Effect, name: string): void;
  89721. /**
  89722. * Disposes the uniform buffer.
  89723. */
  89724. dispose(): void;
  89725. }
  89726. }
  89727. declare module BABYLON {
  89728. /**
  89729. * Manages the defines for the Material
  89730. */
  89731. export class MaterialDefines {
  89732. /** @hidden */
  89733. protected _keys: string[];
  89734. private _isDirty;
  89735. /** @hidden */
  89736. _renderId: number;
  89737. /** @hidden */
  89738. _areLightsDirty: boolean;
  89739. /** @hidden */
  89740. _areLightsDisposed: boolean;
  89741. /** @hidden */
  89742. _areAttributesDirty: boolean;
  89743. /** @hidden */
  89744. _areTexturesDirty: boolean;
  89745. /** @hidden */
  89746. _areFresnelDirty: boolean;
  89747. /** @hidden */
  89748. _areMiscDirty: boolean;
  89749. /** @hidden */
  89750. _arePrePassDirty: boolean;
  89751. /** @hidden */
  89752. _areImageProcessingDirty: boolean;
  89753. /** @hidden */
  89754. _normals: boolean;
  89755. /** @hidden */
  89756. _uvs: boolean;
  89757. /** @hidden */
  89758. _needNormals: boolean;
  89759. /** @hidden */
  89760. _needUVs: boolean;
  89761. [id: string]: any;
  89762. /**
  89763. * Specifies if the material needs to be re-calculated
  89764. */
  89765. get isDirty(): boolean;
  89766. /**
  89767. * Marks the material to indicate that it has been re-calculated
  89768. */
  89769. markAsProcessed(): void;
  89770. /**
  89771. * Marks the material to indicate that it needs to be re-calculated
  89772. */
  89773. markAsUnprocessed(): void;
  89774. /**
  89775. * Marks the material to indicate all of its defines need to be re-calculated
  89776. */
  89777. markAllAsDirty(): void;
  89778. /**
  89779. * Marks the material to indicate that image processing needs to be re-calculated
  89780. */
  89781. markAsImageProcessingDirty(): void;
  89782. /**
  89783. * Marks the material to indicate the lights need to be re-calculated
  89784. * @param disposed Defines whether the light is dirty due to dispose or not
  89785. */
  89786. markAsLightDirty(disposed?: boolean): void;
  89787. /**
  89788. * Marks the attribute state as changed
  89789. */
  89790. markAsAttributesDirty(): void;
  89791. /**
  89792. * Marks the texture state as changed
  89793. */
  89794. markAsTexturesDirty(): void;
  89795. /**
  89796. * Marks the fresnel state as changed
  89797. */
  89798. markAsFresnelDirty(): void;
  89799. /**
  89800. * Marks the misc state as changed
  89801. */
  89802. markAsMiscDirty(): void;
  89803. /**
  89804. * Marks the prepass state as changed
  89805. */
  89806. markAsPrePassDirty(): void;
  89807. /**
  89808. * Rebuilds the material defines
  89809. */
  89810. rebuild(): void;
  89811. /**
  89812. * Specifies if two material defines are equal
  89813. * @param other - A material define instance to compare to
  89814. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89815. */
  89816. isEqual(other: MaterialDefines): boolean;
  89817. /**
  89818. * Clones this instance's defines to another instance
  89819. * @param other - material defines to clone values to
  89820. */
  89821. cloneTo(other: MaterialDefines): void;
  89822. /**
  89823. * Resets the material define values
  89824. */
  89825. reset(): void;
  89826. /**
  89827. * Converts the material define values to a string
  89828. * @returns - String of material define information
  89829. */
  89830. toString(): string;
  89831. }
  89832. }
  89833. declare module BABYLON {
  89834. /**
  89835. * Enum that determines the text-wrapping mode to use.
  89836. */
  89837. export enum InspectableType {
  89838. /**
  89839. * Checkbox for booleans
  89840. */
  89841. Checkbox = 0,
  89842. /**
  89843. * Sliders for numbers
  89844. */
  89845. Slider = 1,
  89846. /**
  89847. * Vector3
  89848. */
  89849. Vector3 = 2,
  89850. /**
  89851. * Quaternions
  89852. */
  89853. Quaternion = 3,
  89854. /**
  89855. * Color3
  89856. */
  89857. Color3 = 4,
  89858. /**
  89859. * String
  89860. */
  89861. String = 5
  89862. }
  89863. /**
  89864. * Interface used to define custom inspectable properties.
  89865. * This interface is used by the inspector to display custom property grids
  89866. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89867. */
  89868. export interface IInspectable {
  89869. /**
  89870. * Gets the label to display
  89871. */
  89872. label: string;
  89873. /**
  89874. * Gets the name of the property to edit
  89875. */
  89876. propertyName: string;
  89877. /**
  89878. * Gets the type of the editor to use
  89879. */
  89880. type: InspectableType;
  89881. /**
  89882. * Gets the minimum value of the property when using in "slider" mode
  89883. */
  89884. min?: number;
  89885. /**
  89886. * Gets the maximum value of the property when using in "slider" mode
  89887. */
  89888. max?: number;
  89889. /**
  89890. * Gets the setp to use when using in "slider" mode
  89891. */
  89892. step?: number;
  89893. }
  89894. }
  89895. declare module BABYLON {
  89896. /**
  89897. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89898. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89899. * 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.
  89900. */
  89901. export abstract class Light extends Node {
  89902. /**
  89903. * Falloff Default: light is falling off following the material specification:
  89904. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89905. */
  89906. static readonly FALLOFF_DEFAULT: number;
  89907. /**
  89908. * Falloff Physical: light is falling off following the inverse squared distance law.
  89909. */
  89910. static readonly FALLOFF_PHYSICAL: number;
  89911. /**
  89912. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89913. * to enhance interoperability with other engines.
  89914. */
  89915. static readonly FALLOFF_GLTF: number;
  89916. /**
  89917. * Falloff Standard: light is falling off like in the standard material
  89918. * to enhance interoperability with other materials.
  89919. */
  89920. static readonly FALLOFF_STANDARD: number;
  89921. /**
  89922. * If every light affecting the material is in this lightmapMode,
  89923. * material.lightmapTexture adds or multiplies
  89924. * (depends on material.useLightmapAsShadowmap)
  89925. * after every other light calculations.
  89926. */
  89927. static readonly LIGHTMAP_DEFAULT: number;
  89928. /**
  89929. * material.lightmapTexture as only diffuse lighting from this light
  89930. * adds only specular lighting from this light
  89931. * adds dynamic shadows
  89932. */
  89933. static readonly LIGHTMAP_SPECULAR: number;
  89934. /**
  89935. * material.lightmapTexture as only lighting
  89936. * no light calculation from this light
  89937. * only adds dynamic shadows from this light
  89938. */
  89939. static readonly LIGHTMAP_SHADOWSONLY: number;
  89940. /**
  89941. * Each light type uses the default quantity according to its type:
  89942. * point/spot lights use luminous intensity
  89943. * directional lights use illuminance
  89944. */
  89945. static readonly INTENSITYMODE_AUTOMATIC: number;
  89946. /**
  89947. * lumen (lm)
  89948. */
  89949. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89950. /**
  89951. * candela (lm/sr)
  89952. */
  89953. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89954. /**
  89955. * lux (lm/m^2)
  89956. */
  89957. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89958. /**
  89959. * nit (cd/m^2)
  89960. */
  89961. static readonly INTENSITYMODE_LUMINANCE: number;
  89962. /**
  89963. * Light type const id of the point light.
  89964. */
  89965. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89966. /**
  89967. * Light type const id of the directional light.
  89968. */
  89969. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89970. /**
  89971. * Light type const id of the spot light.
  89972. */
  89973. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89974. /**
  89975. * Light type const id of the hemispheric light.
  89976. */
  89977. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89978. /**
  89979. * Diffuse gives the basic color to an object.
  89980. */
  89981. diffuse: Color3;
  89982. /**
  89983. * Specular produces a highlight color on an object.
  89984. * Note: This is note affecting PBR materials.
  89985. */
  89986. specular: Color3;
  89987. /**
  89988. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89989. * falling off base on range or angle.
  89990. * This can be set to any values in Light.FALLOFF_x.
  89991. *
  89992. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89993. * other types of materials.
  89994. */
  89995. falloffType: number;
  89996. /**
  89997. * Strength of the light.
  89998. * Note: By default it is define in the framework own unit.
  89999. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90000. */
  90001. intensity: number;
  90002. private _range;
  90003. protected _inverseSquaredRange: number;
  90004. /**
  90005. * Defines how far from the source the light is impacting in scene units.
  90006. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90007. */
  90008. get range(): number;
  90009. /**
  90010. * Defines how far from the source the light is impacting in scene units.
  90011. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90012. */
  90013. set range(value: number);
  90014. /**
  90015. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90016. * of light.
  90017. */
  90018. private _photometricScale;
  90019. private _intensityMode;
  90020. /**
  90021. * Gets the photometric scale used to interpret the intensity.
  90022. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90023. */
  90024. get intensityMode(): number;
  90025. /**
  90026. * Sets the photometric scale used to interpret the intensity.
  90027. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90028. */
  90029. set intensityMode(value: number);
  90030. private _radius;
  90031. /**
  90032. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90033. */
  90034. get radius(): number;
  90035. /**
  90036. * sets the light radius used by PBR Materials to simulate soft area lights.
  90037. */
  90038. set radius(value: number);
  90039. private _renderPriority;
  90040. /**
  90041. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90042. * exceeding the number allowed of the materials.
  90043. */
  90044. renderPriority: number;
  90045. private _shadowEnabled;
  90046. /**
  90047. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90048. * the current shadow generator.
  90049. */
  90050. get shadowEnabled(): boolean;
  90051. /**
  90052. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90053. * the current shadow generator.
  90054. */
  90055. set shadowEnabled(value: boolean);
  90056. private _includedOnlyMeshes;
  90057. /**
  90058. * Gets the only meshes impacted by this light.
  90059. */
  90060. get includedOnlyMeshes(): AbstractMesh[];
  90061. /**
  90062. * Sets the only meshes impacted by this light.
  90063. */
  90064. set includedOnlyMeshes(value: AbstractMesh[]);
  90065. private _excludedMeshes;
  90066. /**
  90067. * Gets the meshes not impacted by this light.
  90068. */
  90069. get excludedMeshes(): AbstractMesh[];
  90070. /**
  90071. * Sets the meshes not impacted by this light.
  90072. */
  90073. set excludedMeshes(value: AbstractMesh[]);
  90074. private _excludeWithLayerMask;
  90075. /**
  90076. * Gets the layer id use to find what meshes are not impacted by the light.
  90077. * Inactive if 0
  90078. */
  90079. get excludeWithLayerMask(): number;
  90080. /**
  90081. * Sets the layer id use to find what meshes are not impacted by the light.
  90082. * Inactive if 0
  90083. */
  90084. set excludeWithLayerMask(value: number);
  90085. private _includeOnlyWithLayerMask;
  90086. /**
  90087. * Gets the layer id use to find what meshes are impacted by the light.
  90088. * Inactive if 0
  90089. */
  90090. get includeOnlyWithLayerMask(): number;
  90091. /**
  90092. * Sets the layer id use to find what meshes are impacted by the light.
  90093. * Inactive if 0
  90094. */
  90095. set includeOnlyWithLayerMask(value: number);
  90096. private _lightmapMode;
  90097. /**
  90098. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90099. */
  90100. get lightmapMode(): number;
  90101. /**
  90102. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90103. */
  90104. set lightmapMode(value: number);
  90105. /**
  90106. * Shadow generator associted to the light.
  90107. * @hidden Internal use only.
  90108. */
  90109. _shadowGenerator: Nullable<IShadowGenerator>;
  90110. /**
  90111. * @hidden Internal use only.
  90112. */
  90113. _excludedMeshesIds: string[];
  90114. /**
  90115. * @hidden Internal use only.
  90116. */
  90117. _includedOnlyMeshesIds: string[];
  90118. /**
  90119. * The current light unifom buffer.
  90120. * @hidden Internal use only.
  90121. */
  90122. _uniformBuffer: UniformBuffer;
  90123. /** @hidden */
  90124. _renderId: number;
  90125. /**
  90126. * Creates a Light object in the scene.
  90127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90128. * @param name The firendly name of the light
  90129. * @param scene The scene the light belongs too
  90130. */
  90131. constructor(name: string, scene: Scene);
  90132. protected abstract _buildUniformLayout(): void;
  90133. /**
  90134. * Sets the passed Effect "effect" with the Light information.
  90135. * @param effect The effect to update
  90136. * @param lightIndex The index of the light in the effect to update
  90137. * @returns The light
  90138. */
  90139. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90140. /**
  90141. * Sets the passed Effect "effect" with the Light textures.
  90142. * @param effect The effect to update
  90143. * @param lightIndex The index of the light in the effect to update
  90144. * @returns The light
  90145. */
  90146. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90147. /**
  90148. * Binds the lights information from the scene to the effect for the given mesh.
  90149. * @param lightIndex Light index
  90150. * @param scene The scene where the light belongs to
  90151. * @param effect The effect we are binding the data to
  90152. * @param useSpecular Defines if specular is supported
  90153. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90154. */
  90155. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90156. /**
  90157. * Sets the passed Effect "effect" with the Light information.
  90158. * @param effect The effect to update
  90159. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90160. * @returns The light
  90161. */
  90162. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90163. /**
  90164. * Returns the string "Light".
  90165. * @returns the class name
  90166. */
  90167. getClassName(): string;
  90168. /** @hidden */
  90169. readonly _isLight: boolean;
  90170. /**
  90171. * Converts the light information to a readable string for debug purpose.
  90172. * @param fullDetails Supports for multiple levels of logging within scene loading
  90173. * @returns the human readable light info
  90174. */
  90175. toString(fullDetails?: boolean): string;
  90176. /** @hidden */
  90177. protected _syncParentEnabledState(): void;
  90178. /**
  90179. * Set the enabled state of this node.
  90180. * @param value - the new enabled state
  90181. */
  90182. setEnabled(value: boolean): void;
  90183. /**
  90184. * Returns the Light associated shadow generator if any.
  90185. * @return the associated shadow generator.
  90186. */
  90187. getShadowGenerator(): Nullable<IShadowGenerator>;
  90188. /**
  90189. * Returns a Vector3, the absolute light position in the World.
  90190. * @returns the world space position of the light
  90191. */
  90192. getAbsolutePosition(): Vector3;
  90193. /**
  90194. * Specifies if the light will affect the passed mesh.
  90195. * @param mesh The mesh to test against the light
  90196. * @return true the mesh is affected otherwise, false.
  90197. */
  90198. canAffectMesh(mesh: AbstractMesh): boolean;
  90199. /**
  90200. * Sort function to order lights for rendering.
  90201. * @param a First Light object to compare to second.
  90202. * @param b Second Light object to compare first.
  90203. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90204. */
  90205. static CompareLightsPriority(a: Light, b: Light): number;
  90206. /**
  90207. * Releases resources associated with this node.
  90208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90210. */
  90211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90212. /**
  90213. * Returns the light type ID (integer).
  90214. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90215. */
  90216. getTypeID(): number;
  90217. /**
  90218. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90219. * @returns the scaled intensity in intensity mode unit
  90220. */
  90221. getScaledIntensity(): number;
  90222. /**
  90223. * Returns a new Light object, named "name", from the current one.
  90224. * @param name The name of the cloned light
  90225. * @param newParent The parent of this light, if it has one
  90226. * @returns the new created light
  90227. */
  90228. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  90229. /**
  90230. * Serializes the current light into a Serialization object.
  90231. * @returns the serialized object.
  90232. */
  90233. serialize(): any;
  90234. /**
  90235. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90236. * This new light is named "name" and added to the passed scene.
  90237. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90238. * @param name The friendly name of the light
  90239. * @param scene The scene the new light will belong to
  90240. * @returns the constructor function
  90241. */
  90242. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90243. /**
  90244. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90245. * @param parsedLight The JSON representation of the light
  90246. * @param scene The scene to create the parsed light in
  90247. * @returns the created light after parsing
  90248. */
  90249. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90250. private _hookArrayForExcluded;
  90251. private _hookArrayForIncludedOnly;
  90252. private _resyncMeshes;
  90253. /**
  90254. * Forces the meshes to update their light related information in their rendering used effects
  90255. * @hidden Internal Use Only
  90256. */
  90257. _markMeshesAsLightDirty(): void;
  90258. /**
  90259. * Recomputes the cached photometric scale if needed.
  90260. */
  90261. private _computePhotometricScale;
  90262. /**
  90263. * Returns the Photometric Scale according to the light type and intensity mode.
  90264. */
  90265. private _getPhotometricScale;
  90266. /**
  90267. * Reorder the light in the scene according to their defined priority.
  90268. * @hidden Internal Use Only
  90269. */
  90270. _reorderLightsInScene(): void;
  90271. /**
  90272. * Prepares the list of defines specific to the light type.
  90273. * @param defines the list of defines
  90274. * @param lightIndex defines the index of the light for the effect
  90275. */
  90276. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90277. }
  90278. }
  90279. declare module BABYLON {
  90280. /** Defines supported spaces */
  90281. export enum Space {
  90282. /** Local (object) space */
  90283. LOCAL = 0,
  90284. /** World space */
  90285. WORLD = 1,
  90286. /** Bone space */
  90287. BONE = 2
  90288. }
  90289. /** Defines the 3 main axes */
  90290. export class Axis {
  90291. /** X axis */
  90292. static X: Vector3;
  90293. /** Y axis */
  90294. static Y: Vector3;
  90295. /** Z axis */
  90296. static Z: Vector3;
  90297. }
  90298. /**
  90299. * Defines cartesian components.
  90300. */
  90301. export enum Coordinate {
  90302. /** X axis */
  90303. X = 0,
  90304. /** Y axis */
  90305. Y = 1,
  90306. /** Z axis */
  90307. Z = 2
  90308. }
  90309. }
  90310. declare module BABYLON {
  90311. /**
  90312. * Interface describing all the common properties and methods a shadow light needs to implement.
  90313. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90314. * as well as binding the different shadow properties to the effects.
  90315. */
  90316. export interface IShadowLight extends Light {
  90317. /**
  90318. * The light id in the scene (used in scene.findLighById for instance)
  90319. */
  90320. id: string;
  90321. /**
  90322. * The position the shdow will be casted from.
  90323. */
  90324. position: Vector3;
  90325. /**
  90326. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90327. */
  90328. direction: Vector3;
  90329. /**
  90330. * The transformed position. Position of the light in world space taking parenting in account.
  90331. */
  90332. transformedPosition: Vector3;
  90333. /**
  90334. * The transformed direction. Direction of the light in world space taking parenting in account.
  90335. */
  90336. transformedDirection: Vector3;
  90337. /**
  90338. * The friendly name of the light in the scene.
  90339. */
  90340. name: string;
  90341. /**
  90342. * Defines the shadow projection clipping minimum z value.
  90343. */
  90344. shadowMinZ: number;
  90345. /**
  90346. * Defines the shadow projection clipping maximum z value.
  90347. */
  90348. shadowMaxZ: number;
  90349. /**
  90350. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90351. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90352. */
  90353. computeTransformedInformation(): boolean;
  90354. /**
  90355. * Gets the scene the light belongs to.
  90356. * @returns The scene
  90357. */
  90358. getScene(): Scene;
  90359. /**
  90360. * Callback defining a custom Projection Matrix Builder.
  90361. * This can be used to override the default projection matrix computation.
  90362. */
  90363. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90364. /**
  90365. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90366. * @param matrix The materix to updated with the projection information
  90367. * @param viewMatrix The transform matrix of the light
  90368. * @param renderList The list of mesh to render in the map
  90369. * @returns The current light
  90370. */
  90371. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90372. /**
  90373. * Gets the current depth scale used in ESM.
  90374. * @returns The scale
  90375. */
  90376. getDepthScale(): number;
  90377. /**
  90378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90379. * @returns true if a cube texture needs to be use
  90380. */
  90381. needCube(): boolean;
  90382. /**
  90383. * Detects if the projection matrix requires to be recomputed this frame.
  90384. * @returns true if it requires to be recomputed otherwise, false.
  90385. */
  90386. needProjectionMatrixCompute(): boolean;
  90387. /**
  90388. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90389. */
  90390. forceProjectionMatrixCompute(): void;
  90391. /**
  90392. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90393. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90394. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90395. */
  90396. getShadowDirection(faceIndex?: number): Vector3;
  90397. /**
  90398. * Gets the minZ used for shadow according to both the scene and the light.
  90399. * @param activeCamera The camera we are returning the min for
  90400. * @returns the depth min z
  90401. */
  90402. getDepthMinZ(activeCamera: Camera): number;
  90403. /**
  90404. * Gets the maxZ used for shadow according to both the scene and the light.
  90405. * @param activeCamera The camera we are returning the max for
  90406. * @returns the depth max z
  90407. */
  90408. getDepthMaxZ(activeCamera: Camera): number;
  90409. }
  90410. /**
  90411. * Base implementation IShadowLight
  90412. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90413. */
  90414. export abstract class ShadowLight extends Light implements IShadowLight {
  90415. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90416. protected _position: Vector3;
  90417. protected _setPosition(value: Vector3): void;
  90418. /**
  90419. * Sets the position the shadow will be casted from. Also use as the light position for both
  90420. * point and spot lights.
  90421. */
  90422. get position(): Vector3;
  90423. /**
  90424. * Sets the position the shadow will be casted from. Also use as the light position for both
  90425. * point and spot lights.
  90426. */
  90427. set position(value: Vector3);
  90428. protected _direction: Vector3;
  90429. protected _setDirection(value: Vector3): void;
  90430. /**
  90431. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90432. * Also use as the light direction on spot and directional lights.
  90433. */
  90434. get direction(): Vector3;
  90435. /**
  90436. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90437. * Also use as the light direction on spot and directional lights.
  90438. */
  90439. set direction(value: Vector3);
  90440. protected _shadowMinZ: number;
  90441. /**
  90442. * Gets the shadow projection clipping minimum z value.
  90443. */
  90444. get shadowMinZ(): number;
  90445. /**
  90446. * Sets the shadow projection clipping minimum z value.
  90447. */
  90448. set shadowMinZ(value: number);
  90449. protected _shadowMaxZ: number;
  90450. /**
  90451. * Sets the shadow projection clipping maximum z value.
  90452. */
  90453. get shadowMaxZ(): number;
  90454. /**
  90455. * Gets the shadow projection clipping maximum z value.
  90456. */
  90457. set shadowMaxZ(value: number);
  90458. /**
  90459. * Callback defining a custom Projection Matrix Builder.
  90460. * This can be used to override the default projection matrix computation.
  90461. */
  90462. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90463. /**
  90464. * The transformed position. Position of the light in world space taking parenting in account.
  90465. */
  90466. transformedPosition: Vector3;
  90467. /**
  90468. * The transformed direction. Direction of the light in world space taking parenting in account.
  90469. */
  90470. transformedDirection: Vector3;
  90471. private _needProjectionMatrixCompute;
  90472. /**
  90473. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90474. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90475. */
  90476. computeTransformedInformation(): boolean;
  90477. /**
  90478. * Return the depth scale used for the shadow map.
  90479. * @returns the depth scale.
  90480. */
  90481. getDepthScale(): number;
  90482. /**
  90483. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90484. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90485. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90486. */
  90487. getShadowDirection(faceIndex?: number): Vector3;
  90488. /**
  90489. * Returns the ShadowLight absolute position in the World.
  90490. * @returns the position vector in world space
  90491. */
  90492. getAbsolutePosition(): Vector3;
  90493. /**
  90494. * Sets the ShadowLight direction toward the passed target.
  90495. * @param target The point to target in local space
  90496. * @returns the updated ShadowLight direction
  90497. */
  90498. setDirectionToTarget(target: Vector3): Vector3;
  90499. /**
  90500. * Returns the light rotation in euler definition.
  90501. * @returns the x y z rotation in local space.
  90502. */
  90503. getRotation(): Vector3;
  90504. /**
  90505. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90506. * @returns true if a cube texture needs to be use
  90507. */
  90508. needCube(): boolean;
  90509. /**
  90510. * Detects if the projection matrix requires to be recomputed this frame.
  90511. * @returns true if it requires to be recomputed otherwise, false.
  90512. */
  90513. needProjectionMatrixCompute(): boolean;
  90514. /**
  90515. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90516. */
  90517. forceProjectionMatrixCompute(): void;
  90518. /** @hidden */
  90519. _initCache(): void;
  90520. /** @hidden */
  90521. _isSynchronized(): boolean;
  90522. /**
  90523. * Computes the world matrix of the node
  90524. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90525. * @returns the world matrix
  90526. */
  90527. computeWorldMatrix(force?: boolean): Matrix;
  90528. /**
  90529. * Gets the minZ used for shadow according to both the scene and the light.
  90530. * @param activeCamera The camera we are returning the min for
  90531. * @returns the depth min z
  90532. */
  90533. getDepthMinZ(activeCamera: Camera): number;
  90534. /**
  90535. * Gets the maxZ used for shadow according to both the scene and the light.
  90536. * @param activeCamera The camera we are returning the max for
  90537. * @returns the depth max z
  90538. */
  90539. getDepthMaxZ(activeCamera: Camera): number;
  90540. /**
  90541. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90542. * @param matrix The materix to updated with the projection information
  90543. * @param viewMatrix The transform matrix of the light
  90544. * @param renderList The list of mesh to render in the map
  90545. * @returns The current light
  90546. */
  90547. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90548. }
  90549. }
  90550. declare module BABYLON {
  90551. /**
  90552. * Configuration needed for prepass-capable materials
  90553. */
  90554. export class PrePassConfiguration {
  90555. /**
  90556. * Previous world matrices of meshes carrying this material
  90557. * Used for computing velocity
  90558. */
  90559. previousWorldMatrices: {
  90560. [index: number]: Matrix;
  90561. };
  90562. /**
  90563. * Previous view project matrix
  90564. * Used for computing velocity
  90565. */
  90566. previousViewProjection: Matrix;
  90567. /**
  90568. * Previous bones of meshes carrying this material
  90569. * Used for computing velocity
  90570. */
  90571. previousBones: {
  90572. [index: number]: Float32Array;
  90573. };
  90574. /**
  90575. * Add the required uniforms to the current list.
  90576. * @param uniforms defines the current uniform list.
  90577. */
  90578. static AddUniforms(uniforms: string[]): void;
  90579. /**
  90580. * Add the required samplers to the current list.
  90581. * @param samplers defines the current sampler list.
  90582. */
  90583. static AddSamplers(samplers: string[]): void;
  90584. /**
  90585. * Binds the material data.
  90586. * @param effect defines the effect to update
  90587. * @param scene defines the scene the material belongs to.
  90588. * @param mesh The mesh
  90589. * @param world World matrix of this mesh
  90590. * @param isFrozen Is the material frozen
  90591. */
  90592. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90593. }
  90594. }
  90595. declare module BABYLON {
  90596. /**
  90597. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90598. * This is the base of the follow, arc rotate cameras and Free camera
  90599. * @see https://doc.babylonjs.com/features/cameras
  90600. */
  90601. export class TargetCamera extends Camera {
  90602. private static _RigCamTransformMatrix;
  90603. private static _TargetTransformMatrix;
  90604. private static _TargetFocalPoint;
  90605. private _tmpUpVector;
  90606. private _tmpTargetVector;
  90607. /**
  90608. * Define the current direction the camera is moving to
  90609. */
  90610. cameraDirection: Vector3;
  90611. /**
  90612. * Define the current rotation the camera is rotating to
  90613. */
  90614. cameraRotation: Vector2;
  90615. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90616. ignoreParentScaling: boolean;
  90617. /**
  90618. * When set, the up vector of the camera will be updated by the rotation of the camera
  90619. */
  90620. updateUpVectorFromRotation: boolean;
  90621. private _tmpQuaternion;
  90622. /**
  90623. * Define the current rotation of the camera
  90624. */
  90625. rotation: Vector3;
  90626. /**
  90627. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90628. */
  90629. rotationQuaternion: Quaternion;
  90630. /**
  90631. * Define the current speed of the camera
  90632. */
  90633. speed: number;
  90634. /**
  90635. * Add constraint to the camera to prevent it to move freely in all directions and
  90636. * around all axis.
  90637. */
  90638. noRotationConstraint: boolean;
  90639. /**
  90640. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90641. * panning
  90642. */
  90643. invertRotation: boolean;
  90644. /**
  90645. * Speed multiplier for inverse camera panning
  90646. */
  90647. inverseRotationSpeed: number;
  90648. /**
  90649. * Define the current target of the camera as an object or a position.
  90650. */
  90651. lockedTarget: any;
  90652. /** @hidden */
  90653. _currentTarget: Vector3;
  90654. /** @hidden */
  90655. _initialFocalDistance: number;
  90656. /** @hidden */
  90657. _viewMatrix: Matrix;
  90658. /** @hidden */
  90659. _camMatrix: Matrix;
  90660. /** @hidden */
  90661. _cameraTransformMatrix: Matrix;
  90662. /** @hidden */
  90663. _cameraRotationMatrix: Matrix;
  90664. /** @hidden */
  90665. _referencePoint: Vector3;
  90666. /** @hidden */
  90667. _transformedReferencePoint: Vector3;
  90668. /** @hidden */
  90669. _reset: () => void;
  90670. private _defaultUp;
  90671. /**
  90672. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90673. * This is the base of the follow, arc rotate cameras and Free camera
  90674. * @see https://doc.babylonjs.com/features/cameras
  90675. * @param name Defines the name of the camera in the scene
  90676. * @param position Defines the start position of the camera in the scene
  90677. * @param scene Defines the scene the camera belongs to
  90678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90679. */
  90680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90681. /**
  90682. * Gets the position in front of the camera at a given distance.
  90683. * @param distance The distance from the camera we want the position to be
  90684. * @returns the position
  90685. */
  90686. getFrontPosition(distance: number): Vector3;
  90687. /** @hidden */
  90688. _getLockedTargetPosition(): Nullable<Vector3>;
  90689. private _storedPosition;
  90690. private _storedRotation;
  90691. private _storedRotationQuaternion;
  90692. /**
  90693. * Store current camera state of the camera (fov, position, rotation, etc..)
  90694. * @returns the camera
  90695. */
  90696. storeState(): Camera;
  90697. /**
  90698. * Restored camera state. You must call storeState() first
  90699. * @returns whether it was successful or not
  90700. * @hidden
  90701. */
  90702. _restoreStateValues(): boolean;
  90703. /** @hidden */
  90704. _initCache(): void;
  90705. /** @hidden */
  90706. _updateCache(ignoreParentClass?: boolean): void;
  90707. /** @hidden */
  90708. _isSynchronizedViewMatrix(): boolean;
  90709. /** @hidden */
  90710. _computeLocalCameraSpeed(): number;
  90711. /**
  90712. * Defines the target the camera should look at.
  90713. * @param target Defines the new target as a Vector or a mesh
  90714. */
  90715. setTarget(target: Vector3): void;
  90716. /**
  90717. * Defines the target point of the camera.
  90718. * The camera looks towards it form the radius distance.
  90719. */
  90720. get target(): Vector3;
  90721. set target(value: Vector3);
  90722. /**
  90723. * Return the current target position of the camera. This value is expressed in local space.
  90724. * @returns the target position
  90725. */
  90726. getTarget(): Vector3;
  90727. /** @hidden */
  90728. _decideIfNeedsToMove(): boolean;
  90729. /** @hidden */
  90730. _updatePosition(): void;
  90731. /** @hidden */
  90732. _checkInputs(): void;
  90733. protected _updateCameraRotationMatrix(): void;
  90734. /**
  90735. * 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)
  90736. * @returns the current camera
  90737. */
  90738. private _rotateUpVectorWithCameraRotationMatrix;
  90739. private _cachedRotationZ;
  90740. private _cachedQuaternionRotationZ;
  90741. /** @hidden */
  90742. _getViewMatrix(): Matrix;
  90743. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90744. /**
  90745. * @hidden
  90746. */
  90747. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90748. /**
  90749. * @hidden
  90750. */
  90751. _updateRigCameras(): void;
  90752. private _getRigCamPositionAndTarget;
  90753. /**
  90754. * Gets the current object class name.
  90755. * @return the class name
  90756. */
  90757. getClassName(): string;
  90758. }
  90759. }
  90760. declare module BABYLON {
  90761. /**
  90762. * @ignore
  90763. * This is a list of all the different input types that are available in the application.
  90764. * Fo instance: ArcRotateCameraGamepadInput...
  90765. */
  90766. export var CameraInputTypes: {};
  90767. /**
  90768. * This is the contract to implement in order to create a new input class.
  90769. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90770. */
  90771. export interface ICameraInput<TCamera extends Camera> {
  90772. /**
  90773. * Defines the camera the input is attached to.
  90774. */
  90775. camera: Nullable<TCamera>;
  90776. /**
  90777. * Gets the class name of the current intput.
  90778. * @returns the class name
  90779. */
  90780. getClassName(): string;
  90781. /**
  90782. * Get the friendly name associated with the input class.
  90783. * @returns the input friendly name
  90784. */
  90785. getSimpleName(): string;
  90786. /**
  90787. * Attach the input controls to a specific dom element to get the input from.
  90788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90789. */
  90790. attachControl(noPreventDefault?: boolean): void;
  90791. /**
  90792. * Detach the current controls from the specified dom element.
  90793. */
  90794. detachControl(): void;
  90795. /**
  90796. * Update the current camera state depending on the inputs that have been used this frame.
  90797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90798. */
  90799. checkInputs?: () => void;
  90800. }
  90801. /**
  90802. * Represents a map of input types to input instance or input index to input instance.
  90803. */
  90804. export interface CameraInputsMap<TCamera extends Camera> {
  90805. /**
  90806. * Accessor to the input by input type.
  90807. */
  90808. [name: string]: ICameraInput<TCamera>;
  90809. /**
  90810. * Accessor to the input by input index.
  90811. */
  90812. [idx: number]: ICameraInput<TCamera>;
  90813. }
  90814. /**
  90815. * This represents the input manager used within a camera.
  90816. * It helps dealing with all the different kind of input attached to a camera.
  90817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90818. */
  90819. export class CameraInputsManager<TCamera extends Camera> {
  90820. /**
  90821. * Defines the list of inputs attahed to the camera.
  90822. */
  90823. attached: CameraInputsMap<TCamera>;
  90824. /**
  90825. * Defines the dom element the camera is collecting inputs from.
  90826. * This is null if the controls have not been attached.
  90827. */
  90828. attachedToElement: boolean;
  90829. /**
  90830. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90831. */
  90832. noPreventDefault: boolean;
  90833. /**
  90834. * Defined the camera the input manager belongs to.
  90835. */
  90836. camera: TCamera;
  90837. /**
  90838. * Update the current camera state depending on the inputs that have been used this frame.
  90839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90840. */
  90841. checkInputs: () => void;
  90842. /**
  90843. * Instantiate a new Camera Input Manager.
  90844. * @param camera Defines the camera the input manager blongs to
  90845. */
  90846. constructor(camera: TCamera);
  90847. /**
  90848. * Add an input method to a camera
  90849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90850. * @param input camera input method
  90851. */
  90852. add(input: ICameraInput<TCamera>): void;
  90853. /**
  90854. * Remove a specific input method from a camera
  90855. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90856. * @param inputToRemove camera input method
  90857. */
  90858. remove(inputToRemove: ICameraInput<TCamera>): void;
  90859. /**
  90860. * Remove a specific input type from a camera
  90861. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90862. * @param inputType the type of the input to remove
  90863. */
  90864. removeByType(inputType: string): void;
  90865. private _addCheckInputs;
  90866. /**
  90867. * Attach the input controls to the currently attached dom element to listen the events from.
  90868. * @param input Defines the input to attach
  90869. */
  90870. attachInput(input: ICameraInput<TCamera>): void;
  90871. /**
  90872. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90873. * @param element Defines the dom element to collect the events from
  90874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90875. */
  90876. attachElement(noPreventDefault?: boolean): void;
  90877. /**
  90878. * Detach the current manager inputs controls from a specific dom element.
  90879. * @param element Defines the dom element to collect the events from
  90880. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90881. */
  90882. detachElement(disconnect?: boolean): void;
  90883. /**
  90884. * Rebuild the dynamic inputCheck function from the current list of
  90885. * defined inputs in the manager.
  90886. */
  90887. rebuildInputCheck(): void;
  90888. /**
  90889. * Remove all attached input methods from a camera
  90890. */
  90891. clear(): void;
  90892. /**
  90893. * Serialize the current input manager attached to a camera.
  90894. * This ensures than once parsed,
  90895. * the input associated to the camera will be identical to the current ones
  90896. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90897. */
  90898. serialize(serializedCamera: any): void;
  90899. /**
  90900. * Parses an input manager serialized JSON to restore the previous list of inputs
  90901. * and states associated to a camera.
  90902. * @param parsedCamera Defines the JSON to parse
  90903. */
  90904. parse(parsedCamera: any): void;
  90905. }
  90906. }
  90907. declare module BABYLON {
  90908. /**
  90909. * Gather the list of keyboard event types as constants.
  90910. */
  90911. export class KeyboardEventTypes {
  90912. /**
  90913. * The keydown event is fired when a key becomes active (pressed).
  90914. */
  90915. static readonly KEYDOWN: number;
  90916. /**
  90917. * The keyup event is fired when a key has been released.
  90918. */
  90919. static readonly KEYUP: number;
  90920. }
  90921. /**
  90922. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90923. */
  90924. export class KeyboardInfo {
  90925. /**
  90926. * Defines the type of event (KeyboardEventTypes)
  90927. */
  90928. type: number;
  90929. /**
  90930. * Defines the related dom event
  90931. */
  90932. event: KeyboardEvent;
  90933. /**
  90934. * Instantiates a new keyboard info.
  90935. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90936. * @param type Defines the type of event (KeyboardEventTypes)
  90937. * @param event Defines the related dom event
  90938. */
  90939. constructor(
  90940. /**
  90941. * Defines the type of event (KeyboardEventTypes)
  90942. */
  90943. type: number,
  90944. /**
  90945. * Defines the related dom event
  90946. */
  90947. event: KeyboardEvent);
  90948. }
  90949. /**
  90950. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90951. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  90952. */
  90953. export class KeyboardInfoPre extends KeyboardInfo {
  90954. /**
  90955. * Defines the type of event (KeyboardEventTypes)
  90956. */
  90957. type: number;
  90958. /**
  90959. * Defines the related dom event
  90960. */
  90961. event: KeyboardEvent;
  90962. /**
  90963. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  90964. */
  90965. skipOnPointerObservable: boolean;
  90966. /**
  90967. * Instantiates a new keyboard pre info.
  90968. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90969. * @param type Defines the type of event (KeyboardEventTypes)
  90970. * @param event Defines the related dom event
  90971. */
  90972. constructor(
  90973. /**
  90974. * Defines the type of event (KeyboardEventTypes)
  90975. */
  90976. type: number,
  90977. /**
  90978. * Defines the related dom event
  90979. */
  90980. event: KeyboardEvent);
  90981. }
  90982. }
  90983. declare module BABYLON {
  90984. /**
  90985. * Manage the keyboard inputs to control the movement of a free camera.
  90986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90987. */
  90988. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  90989. /**
  90990. * Defines the camera the input is attached to.
  90991. */
  90992. camera: FreeCamera;
  90993. /**
  90994. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  90995. */
  90996. keysUp: number[];
  90997. /**
  90998. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  90999. */
  91000. keysUpward: number[];
  91001. /**
  91002. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91003. */
  91004. keysDown: number[];
  91005. /**
  91006. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  91007. */
  91008. keysDownward: number[];
  91009. /**
  91010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91011. */
  91012. keysLeft: number[];
  91013. /**
  91014. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91015. */
  91016. keysRight: number[];
  91017. private _keys;
  91018. private _onCanvasBlurObserver;
  91019. private _onKeyboardObserver;
  91020. private _engine;
  91021. private _scene;
  91022. /**
  91023. * Attach the input controls to a specific dom element to get the input from.
  91024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91025. */
  91026. attachControl(noPreventDefault?: boolean): void;
  91027. /**
  91028. * Detach the current controls from the specified dom element.
  91029. */
  91030. detachControl(): void;
  91031. /**
  91032. * Update the current camera state depending on the inputs that have been used this frame.
  91033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91034. */
  91035. checkInputs(): void;
  91036. /**
  91037. * Gets the class name of the current intput.
  91038. * @returns the class name
  91039. */
  91040. getClassName(): string;
  91041. /** @hidden */
  91042. _onLostFocus(): void;
  91043. /**
  91044. * Get the friendly name associated with the input class.
  91045. * @returns the input friendly name
  91046. */
  91047. getSimpleName(): string;
  91048. }
  91049. }
  91050. declare module BABYLON {
  91051. /**
  91052. * Interface used to define Action
  91053. */
  91054. export interface IAction {
  91055. /**
  91056. * Trigger for the action
  91057. */
  91058. trigger: number;
  91059. /** Options of the trigger */
  91060. triggerOptions: any;
  91061. /**
  91062. * Gets the trigger parameters
  91063. * @returns the trigger parameters
  91064. */
  91065. getTriggerParameter(): any;
  91066. /**
  91067. * Internal only - executes current action event
  91068. * @hidden
  91069. */
  91070. _executeCurrent(evt?: ActionEvent): void;
  91071. /**
  91072. * Serialize placeholder for child classes
  91073. * @param parent of child
  91074. * @returns the serialized object
  91075. */
  91076. serialize(parent: any): any;
  91077. /**
  91078. * Internal only
  91079. * @hidden
  91080. */
  91081. _prepare(): void;
  91082. /**
  91083. * Internal only - manager for action
  91084. * @hidden
  91085. */
  91086. _actionManager: Nullable<AbstractActionManager>;
  91087. /**
  91088. * Adds action to chain of actions, may be a DoNothingAction
  91089. * @param action defines the next action to execute
  91090. * @returns The action passed in
  91091. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91092. */
  91093. then(action: IAction): IAction;
  91094. }
  91095. /**
  91096. * The action to be carried out following a trigger
  91097. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91098. */
  91099. export class Action implements IAction {
  91100. /** the trigger, with or without parameters, for the action */
  91101. triggerOptions: any;
  91102. /**
  91103. * Trigger for the action
  91104. */
  91105. trigger: number;
  91106. /**
  91107. * Internal only - manager for action
  91108. * @hidden
  91109. */
  91110. _actionManager: ActionManager;
  91111. private _nextActiveAction;
  91112. private _child;
  91113. private _condition?;
  91114. private _triggerParameter;
  91115. /**
  91116. * An event triggered prior to action being executed.
  91117. */
  91118. onBeforeExecuteObservable: Observable<Action>;
  91119. /**
  91120. * Creates a new Action
  91121. * @param triggerOptions the trigger, with or without parameters, for the action
  91122. * @param condition an optional determinant of action
  91123. */
  91124. constructor(
  91125. /** the trigger, with or without parameters, for the action */
  91126. triggerOptions: any, condition?: Condition);
  91127. /**
  91128. * Internal only
  91129. * @hidden
  91130. */
  91131. _prepare(): void;
  91132. /**
  91133. * Gets the trigger parameters
  91134. * @returns the trigger parameters
  91135. */
  91136. getTriggerParameter(): any;
  91137. /**
  91138. * Internal only - executes current action event
  91139. * @hidden
  91140. */
  91141. _executeCurrent(evt?: ActionEvent): void;
  91142. /**
  91143. * Execute placeholder for child classes
  91144. * @param evt optional action event
  91145. */
  91146. execute(evt?: ActionEvent): void;
  91147. /**
  91148. * Skips to next active action
  91149. */
  91150. skipToNextActiveAction(): void;
  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: Action): Action;
  91158. /**
  91159. * Internal only
  91160. * @hidden
  91161. */
  91162. _getProperty(propertyPath: string): string;
  91163. /**
  91164. * Internal only
  91165. * @hidden
  91166. */
  91167. _getEffectiveTarget(target: any, propertyPath: string): any;
  91168. /**
  91169. * Serialize placeholder for child classes
  91170. * @param parent of child
  91171. * @returns the serialized object
  91172. */
  91173. serialize(parent: any): any;
  91174. /**
  91175. * Internal only called by serialize
  91176. * @hidden
  91177. */
  91178. protected _serialize(serializedAction: any, parent?: any): any;
  91179. /**
  91180. * Internal only
  91181. * @hidden
  91182. */
  91183. static _SerializeValueAsString: (value: any) => string;
  91184. /**
  91185. * Internal only
  91186. * @hidden
  91187. */
  91188. static _GetTargetProperty: (target: Scene | Node) => {
  91189. name: string;
  91190. targetType: string;
  91191. value: string;
  91192. };
  91193. }
  91194. }
  91195. declare module BABYLON {
  91196. /**
  91197. * A Condition applied to an Action
  91198. */
  91199. export class Condition {
  91200. /**
  91201. * Internal only - manager for action
  91202. * @hidden
  91203. */
  91204. _actionManager: ActionManager;
  91205. /**
  91206. * Internal only
  91207. * @hidden
  91208. */
  91209. _evaluationId: number;
  91210. /**
  91211. * Internal only
  91212. * @hidden
  91213. */
  91214. _currentResult: boolean;
  91215. /**
  91216. * Creates a new Condition
  91217. * @param actionManager the manager of the action the condition is applied to
  91218. */
  91219. constructor(actionManager: ActionManager);
  91220. /**
  91221. * Check if the current condition is valid
  91222. * @returns a boolean
  91223. */
  91224. isValid(): boolean;
  91225. /**
  91226. * Internal only
  91227. * @hidden
  91228. */
  91229. _getProperty(propertyPath: string): string;
  91230. /**
  91231. * Internal only
  91232. * @hidden
  91233. */
  91234. _getEffectiveTarget(target: any, propertyPath: string): any;
  91235. /**
  91236. * Serialize placeholder for child classes
  91237. * @returns the serialized object
  91238. */
  91239. serialize(): any;
  91240. /**
  91241. * Internal only
  91242. * @hidden
  91243. */
  91244. protected _serialize(serializedCondition: any): any;
  91245. }
  91246. /**
  91247. * Defines specific conditional operators as extensions of Condition
  91248. */
  91249. export class ValueCondition extends Condition {
  91250. /** path to specify the property of the target the conditional operator uses */
  91251. propertyPath: string;
  91252. /** the value compared by the conditional operator against the current value of the property */
  91253. value: any;
  91254. /** the conditional operator, default ValueCondition.IsEqual */
  91255. operator: number;
  91256. /**
  91257. * Internal only
  91258. * @hidden
  91259. */
  91260. private static _IsEqual;
  91261. /**
  91262. * Internal only
  91263. * @hidden
  91264. */
  91265. private static _IsDifferent;
  91266. /**
  91267. * Internal only
  91268. * @hidden
  91269. */
  91270. private static _IsGreater;
  91271. /**
  91272. * Internal only
  91273. * @hidden
  91274. */
  91275. private static _IsLesser;
  91276. /**
  91277. * returns the number for IsEqual
  91278. */
  91279. static get IsEqual(): number;
  91280. /**
  91281. * Returns the number for IsDifferent
  91282. */
  91283. static get IsDifferent(): number;
  91284. /**
  91285. * Returns the number for IsGreater
  91286. */
  91287. static get IsGreater(): number;
  91288. /**
  91289. * Returns the number for IsLesser
  91290. */
  91291. static get IsLesser(): number;
  91292. /**
  91293. * Internal only The action manager for the condition
  91294. * @hidden
  91295. */
  91296. _actionManager: ActionManager;
  91297. /**
  91298. * Internal only
  91299. * @hidden
  91300. */
  91301. private _target;
  91302. /**
  91303. * Internal only
  91304. * @hidden
  91305. */
  91306. private _effectiveTarget;
  91307. /**
  91308. * Internal only
  91309. * @hidden
  91310. */
  91311. private _property;
  91312. /**
  91313. * Creates a new ValueCondition
  91314. * @param actionManager manager for the action the condition applies to
  91315. * @param target for the action
  91316. * @param propertyPath path to specify the property of the target the conditional operator uses
  91317. * @param value the value compared by the conditional operator against the current value of the property
  91318. * @param operator the conditional operator, default ValueCondition.IsEqual
  91319. */
  91320. constructor(actionManager: ActionManager, target: any,
  91321. /** path to specify the property of the target the conditional operator uses */
  91322. propertyPath: string,
  91323. /** the value compared by the conditional operator against the current value of the property */
  91324. value: any,
  91325. /** the conditional operator, default ValueCondition.IsEqual */
  91326. operator?: number);
  91327. /**
  91328. * Compares the given value with the property value for the specified conditional operator
  91329. * @returns the result of the comparison
  91330. */
  91331. isValid(): boolean;
  91332. /**
  91333. * Serialize the ValueCondition into a JSON compatible object
  91334. * @returns serialization object
  91335. */
  91336. serialize(): any;
  91337. /**
  91338. * Gets the name of the conditional operator for the ValueCondition
  91339. * @param operator the conditional operator
  91340. * @returns the name
  91341. */
  91342. static GetOperatorName(operator: number): string;
  91343. }
  91344. /**
  91345. * Defines a predicate condition as an extension of Condition
  91346. */
  91347. export class PredicateCondition extends Condition {
  91348. /** defines the predicate function used to validate the condition */
  91349. predicate: () => boolean;
  91350. /**
  91351. * Internal only - manager for action
  91352. * @hidden
  91353. */
  91354. _actionManager: ActionManager;
  91355. /**
  91356. * Creates a new PredicateCondition
  91357. * @param actionManager manager for the action the condition applies to
  91358. * @param predicate defines the predicate function used to validate the condition
  91359. */
  91360. constructor(actionManager: ActionManager,
  91361. /** defines the predicate function used to validate the condition */
  91362. predicate: () => boolean);
  91363. /**
  91364. * @returns the validity of the predicate condition
  91365. */
  91366. isValid(): boolean;
  91367. }
  91368. /**
  91369. * Defines a state condition as an extension of Condition
  91370. */
  91371. export class StateCondition extends Condition {
  91372. /** Value to compare with target state */
  91373. value: string;
  91374. /**
  91375. * Internal only - manager for action
  91376. * @hidden
  91377. */
  91378. _actionManager: ActionManager;
  91379. /**
  91380. * Internal only
  91381. * @hidden
  91382. */
  91383. private _target;
  91384. /**
  91385. * Creates a new StateCondition
  91386. * @param actionManager manager for the action the condition applies to
  91387. * @param target of the condition
  91388. * @param value to compare with target state
  91389. */
  91390. constructor(actionManager: ActionManager, target: any,
  91391. /** Value to compare with target state */
  91392. value: string);
  91393. /**
  91394. * Gets a boolean indicating if the current condition is met
  91395. * @returns the validity of the state
  91396. */
  91397. isValid(): boolean;
  91398. /**
  91399. * Serialize the StateCondition into a JSON compatible object
  91400. * @returns serialization object
  91401. */
  91402. serialize(): any;
  91403. }
  91404. }
  91405. declare module BABYLON {
  91406. /**
  91407. * This defines an action responsible to toggle a boolean once triggered.
  91408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91409. */
  91410. export class SwitchBooleanAction extends Action {
  91411. /**
  91412. * The path to the boolean property in the target object
  91413. */
  91414. propertyPath: string;
  91415. private _target;
  91416. private _effectiveTarget;
  91417. private _property;
  91418. /**
  91419. * Instantiate the action
  91420. * @param triggerOptions defines the trigger options
  91421. * @param target defines the object containing the boolean
  91422. * @param propertyPath defines the path to the boolean property in the target object
  91423. * @param condition defines the trigger related conditions
  91424. */
  91425. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91426. /** @hidden */
  91427. _prepare(): void;
  91428. /**
  91429. * Execute the action toggle the boolean value.
  91430. */
  91431. execute(): void;
  91432. /**
  91433. * Serializes the actions and its related information.
  91434. * @param parent defines the object to serialize in
  91435. * @returns the serialized object
  91436. */
  91437. serialize(parent: any): any;
  91438. }
  91439. /**
  91440. * This defines an action responsible to set a the state field of the target
  91441. * to a desired value once triggered.
  91442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91443. */
  91444. export class SetStateAction extends Action {
  91445. /**
  91446. * The value to store in the state field.
  91447. */
  91448. value: string;
  91449. private _target;
  91450. /**
  91451. * Instantiate the action
  91452. * @param triggerOptions defines the trigger options
  91453. * @param target defines the object containing the state property
  91454. * @param value defines the value to store in the state field
  91455. * @param condition defines the trigger related conditions
  91456. */
  91457. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91458. /**
  91459. * Execute the action and store the value on the target state property.
  91460. */
  91461. execute(): void;
  91462. /**
  91463. * Serializes the actions and its related information.
  91464. * @param parent defines the object to serialize in
  91465. * @returns the serialized object
  91466. */
  91467. serialize(parent: any): any;
  91468. }
  91469. /**
  91470. * This defines an action responsible to set a property of the target
  91471. * to a desired value once triggered.
  91472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91473. */
  91474. export class SetValueAction extends Action {
  91475. /**
  91476. * The path of the property to set in the target.
  91477. */
  91478. propertyPath: string;
  91479. /**
  91480. * The value to set in the property
  91481. */
  91482. value: any;
  91483. private _target;
  91484. private _effectiveTarget;
  91485. private _property;
  91486. /**
  91487. * Instantiate the action
  91488. * @param triggerOptions defines the trigger options
  91489. * @param target defines the object containing the property
  91490. * @param propertyPath defines the path of the property to set in the target
  91491. * @param value defines the value to set in the property
  91492. * @param condition defines the trigger related conditions
  91493. */
  91494. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91495. /** @hidden */
  91496. _prepare(): void;
  91497. /**
  91498. * Execute the action and set the targetted property to the desired value.
  91499. */
  91500. execute(): void;
  91501. /**
  91502. * Serializes the actions and its related information.
  91503. * @param parent defines the object to serialize in
  91504. * @returns the serialized object
  91505. */
  91506. serialize(parent: any): any;
  91507. }
  91508. /**
  91509. * This defines an action responsible to increment the target value
  91510. * to a desired value once triggered.
  91511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91512. */
  91513. export class IncrementValueAction extends Action {
  91514. /**
  91515. * The path of the property to increment in the target.
  91516. */
  91517. propertyPath: string;
  91518. /**
  91519. * The value we should increment the property by.
  91520. */
  91521. value: any;
  91522. private _target;
  91523. private _effectiveTarget;
  91524. private _property;
  91525. /**
  91526. * Instantiate the action
  91527. * @param triggerOptions defines the trigger options
  91528. * @param target defines the object containing the property
  91529. * @param propertyPath defines the path of the property to increment in the target
  91530. * @param value defines the value value we should increment the property by
  91531. * @param condition defines the trigger related conditions
  91532. */
  91533. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91534. /** @hidden */
  91535. _prepare(): void;
  91536. /**
  91537. * Execute the action and increment the target of the value amount.
  91538. */
  91539. execute(): void;
  91540. /**
  91541. * Serializes the actions and its related information.
  91542. * @param parent defines the object to serialize in
  91543. * @returns the serialized object
  91544. */
  91545. serialize(parent: any): any;
  91546. }
  91547. /**
  91548. * This defines an action responsible to start an animation once triggered.
  91549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91550. */
  91551. export class PlayAnimationAction extends Action {
  91552. /**
  91553. * Where the animation should start (animation frame)
  91554. */
  91555. from: number;
  91556. /**
  91557. * Where the animation should stop (animation frame)
  91558. */
  91559. to: number;
  91560. /**
  91561. * Define if the animation should loop or stop after the first play.
  91562. */
  91563. loop?: boolean;
  91564. private _target;
  91565. /**
  91566. * Instantiate the action
  91567. * @param triggerOptions defines the trigger options
  91568. * @param target defines the target animation or animation name
  91569. * @param from defines from where the animation should start (animation frame)
  91570. * @param end defines where the animation should stop (animation frame)
  91571. * @param loop defines if the animation should loop or stop after the first play
  91572. * @param condition defines the trigger related conditions
  91573. */
  91574. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91575. /** @hidden */
  91576. _prepare(): void;
  91577. /**
  91578. * Execute the action and play the animation.
  91579. */
  91580. execute(): void;
  91581. /**
  91582. * Serializes the actions and its related information.
  91583. * @param parent defines the object to serialize in
  91584. * @returns the serialized object
  91585. */
  91586. serialize(parent: any): any;
  91587. }
  91588. /**
  91589. * This defines an action responsible to stop an animation once triggered.
  91590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91591. */
  91592. export class StopAnimationAction extends Action {
  91593. private _target;
  91594. /**
  91595. * Instantiate the action
  91596. * @param triggerOptions defines the trigger options
  91597. * @param target defines the target animation or animation name
  91598. * @param condition defines the trigger related conditions
  91599. */
  91600. constructor(triggerOptions: any, target: any, condition?: Condition);
  91601. /** @hidden */
  91602. _prepare(): void;
  91603. /**
  91604. * Execute the action and stop the animation.
  91605. */
  91606. execute(): void;
  91607. /**
  91608. * Serializes the actions and its related information.
  91609. * @param parent defines the object to serialize in
  91610. * @returns the serialized object
  91611. */
  91612. serialize(parent: any): any;
  91613. }
  91614. /**
  91615. * This defines an action responsible that does nothing once triggered.
  91616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91617. */
  91618. export class DoNothingAction extends Action {
  91619. /**
  91620. * Instantiate the action
  91621. * @param triggerOptions defines the trigger options
  91622. * @param condition defines the trigger related conditions
  91623. */
  91624. constructor(triggerOptions?: any, condition?: Condition);
  91625. /**
  91626. * Execute the action and do nothing.
  91627. */
  91628. execute(): void;
  91629. /**
  91630. * Serializes the actions and its related information.
  91631. * @param parent defines the object to serialize in
  91632. * @returns the serialized object
  91633. */
  91634. serialize(parent: any): any;
  91635. }
  91636. /**
  91637. * This defines an action responsible to trigger several actions once triggered.
  91638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91639. */
  91640. export class CombineAction extends Action {
  91641. /**
  91642. * The list of aggregated animations to run.
  91643. */
  91644. children: Action[];
  91645. /**
  91646. * Instantiate the action
  91647. * @param triggerOptions defines the trigger options
  91648. * @param children defines the list of aggregated animations to run
  91649. * @param condition defines the trigger related conditions
  91650. */
  91651. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91652. /** @hidden */
  91653. _prepare(): void;
  91654. /**
  91655. * Execute the action and executes all the aggregated actions.
  91656. */
  91657. execute(evt: ActionEvent): void;
  91658. /**
  91659. * Serializes the actions and its related information.
  91660. * @param parent defines the object to serialize in
  91661. * @returns the serialized object
  91662. */
  91663. serialize(parent: any): any;
  91664. }
  91665. /**
  91666. * This defines an action responsible to run code (external event) once triggered.
  91667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91668. */
  91669. export class ExecuteCodeAction extends Action {
  91670. /**
  91671. * The callback function to run.
  91672. */
  91673. func: (evt: ActionEvent) => void;
  91674. /**
  91675. * Instantiate the action
  91676. * @param triggerOptions defines the trigger options
  91677. * @param func defines the callback function to run
  91678. * @param condition defines the trigger related conditions
  91679. */
  91680. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91681. /**
  91682. * Execute the action and run the attached code.
  91683. */
  91684. execute(evt: ActionEvent): void;
  91685. }
  91686. /**
  91687. * This defines an action responsible to set the parent property of the target once triggered.
  91688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91689. */
  91690. export class SetParentAction extends Action {
  91691. private _parent;
  91692. private _target;
  91693. /**
  91694. * Instantiate the action
  91695. * @param triggerOptions defines the trigger options
  91696. * @param target defines the target containing the parent property
  91697. * @param parent defines from where the animation should start (animation frame)
  91698. * @param condition defines the trigger related conditions
  91699. */
  91700. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91701. /** @hidden */
  91702. _prepare(): void;
  91703. /**
  91704. * Execute the action and set the parent property.
  91705. */
  91706. execute(): void;
  91707. /**
  91708. * Serializes the actions and its related information.
  91709. * @param parent defines the object to serialize in
  91710. * @returns the serialized object
  91711. */
  91712. serialize(parent: any): any;
  91713. }
  91714. }
  91715. declare module BABYLON {
  91716. /**
  91717. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91718. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91720. */
  91721. export class ActionManager extends AbstractActionManager {
  91722. /**
  91723. * Nothing
  91724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91725. */
  91726. static readonly NothingTrigger: number;
  91727. /**
  91728. * On pick
  91729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91730. */
  91731. static readonly OnPickTrigger: number;
  91732. /**
  91733. * On left pick
  91734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91735. */
  91736. static readonly OnLeftPickTrigger: number;
  91737. /**
  91738. * On right pick
  91739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91740. */
  91741. static readonly OnRightPickTrigger: number;
  91742. /**
  91743. * On center pick
  91744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91745. */
  91746. static readonly OnCenterPickTrigger: number;
  91747. /**
  91748. * On pick down
  91749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91750. */
  91751. static readonly OnPickDownTrigger: number;
  91752. /**
  91753. * On double pick
  91754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91755. */
  91756. static readonly OnDoublePickTrigger: number;
  91757. /**
  91758. * On pick up
  91759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91760. */
  91761. static readonly OnPickUpTrigger: number;
  91762. /**
  91763. * On pick out.
  91764. * This trigger will only be raised if you also declared a OnPickDown
  91765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91766. */
  91767. static readonly OnPickOutTrigger: number;
  91768. /**
  91769. * On long press
  91770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91771. */
  91772. static readonly OnLongPressTrigger: number;
  91773. /**
  91774. * On pointer over
  91775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91776. */
  91777. static readonly OnPointerOverTrigger: number;
  91778. /**
  91779. * On pointer out
  91780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91781. */
  91782. static readonly OnPointerOutTrigger: number;
  91783. /**
  91784. * On every frame
  91785. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91786. */
  91787. static readonly OnEveryFrameTrigger: number;
  91788. /**
  91789. * On intersection enter
  91790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91791. */
  91792. static readonly OnIntersectionEnterTrigger: number;
  91793. /**
  91794. * On intersection exit
  91795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91796. */
  91797. static readonly OnIntersectionExitTrigger: number;
  91798. /**
  91799. * On key down
  91800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91801. */
  91802. static readonly OnKeyDownTrigger: number;
  91803. /**
  91804. * On key up
  91805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91806. */
  91807. static readonly OnKeyUpTrigger: number;
  91808. private _scene;
  91809. /**
  91810. * Creates a new action manager
  91811. * @param scene defines the hosting scene
  91812. */
  91813. constructor(scene: Scene);
  91814. /**
  91815. * Releases all associated resources
  91816. */
  91817. dispose(): void;
  91818. /**
  91819. * Gets hosting scene
  91820. * @returns the hosting scene
  91821. */
  91822. getScene(): Scene;
  91823. /**
  91824. * Does this action manager handles actions of any of the given triggers
  91825. * @param triggers defines the triggers to be tested
  91826. * @return a boolean indicating whether one (or more) of the triggers is handled
  91827. */
  91828. hasSpecificTriggers(triggers: number[]): boolean;
  91829. /**
  91830. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91831. * speed.
  91832. * @param triggerA defines the trigger to be tested
  91833. * @param triggerB defines the trigger to be tested
  91834. * @return a boolean indicating whether one (or more) of the triggers is handled
  91835. */
  91836. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91837. /**
  91838. * Does this action manager handles actions of a given trigger
  91839. * @param trigger defines the trigger to be tested
  91840. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91841. * @return whether the trigger is handled
  91842. */
  91843. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91844. /**
  91845. * Does this action manager has pointer triggers
  91846. */
  91847. get hasPointerTriggers(): boolean;
  91848. /**
  91849. * Does this action manager has pick triggers
  91850. */
  91851. get hasPickTriggers(): boolean;
  91852. /**
  91853. * Registers an action to this action manager
  91854. * @param action defines the action to be registered
  91855. * @return the action amended (prepared) after registration
  91856. */
  91857. registerAction(action: IAction): Nullable<IAction>;
  91858. /**
  91859. * Unregisters an action to this action manager
  91860. * @param action defines the action to be unregistered
  91861. * @return a boolean indicating whether the action has been unregistered
  91862. */
  91863. unregisterAction(action: IAction): Boolean;
  91864. /**
  91865. * Process a specific trigger
  91866. * @param trigger defines the trigger to process
  91867. * @param evt defines the event details to be processed
  91868. */
  91869. processTrigger(trigger: number, evt?: IActionEvent): void;
  91870. /** @hidden */
  91871. _getEffectiveTarget(target: any, propertyPath: string): any;
  91872. /** @hidden */
  91873. _getProperty(propertyPath: string): string;
  91874. /**
  91875. * Serialize this manager to a JSON object
  91876. * @param name defines the property name to store this manager
  91877. * @returns a JSON representation of this manager
  91878. */
  91879. serialize(name: string): any;
  91880. /**
  91881. * Creates a new ActionManager from a JSON data
  91882. * @param parsedActions defines the JSON data to read from
  91883. * @param object defines the hosting mesh
  91884. * @param scene defines the hosting scene
  91885. */
  91886. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91887. /**
  91888. * Get a trigger name by index
  91889. * @param trigger defines the trigger index
  91890. * @returns a trigger name
  91891. */
  91892. static GetTriggerName(trigger: number): string;
  91893. }
  91894. }
  91895. declare module BABYLON {
  91896. /**
  91897. * Class representing a ray with position and direction
  91898. */
  91899. export class Ray {
  91900. /** origin point */
  91901. origin: Vector3;
  91902. /** direction */
  91903. direction: Vector3;
  91904. /** length of the ray */
  91905. length: number;
  91906. private static readonly _TmpVector3;
  91907. private _tmpRay;
  91908. /**
  91909. * Creates a new ray
  91910. * @param origin origin point
  91911. * @param direction direction
  91912. * @param length length of the ray
  91913. */
  91914. constructor(
  91915. /** origin point */
  91916. origin: Vector3,
  91917. /** direction */
  91918. direction: Vector3,
  91919. /** length of the ray */
  91920. length?: number);
  91921. /**
  91922. * Checks if the ray intersects a box
  91923. * This does not account for the ray lenght by design to improve perfs.
  91924. * @param minimum bound of the box
  91925. * @param maximum bound of the box
  91926. * @param intersectionTreshold extra extend to be added to the box in all direction
  91927. * @returns if the box was hit
  91928. */
  91929. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91930. /**
  91931. * Checks if the ray intersects a box
  91932. * This does not account for the ray lenght by design to improve perfs.
  91933. * @param box the bounding box to check
  91934. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91935. * @returns if the box was hit
  91936. */
  91937. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91938. /**
  91939. * If the ray hits a sphere
  91940. * @param sphere the bounding sphere to check
  91941. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91942. * @returns true if it hits the sphere
  91943. */
  91944. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91945. /**
  91946. * If the ray hits a triange
  91947. * @param vertex0 triangle vertex
  91948. * @param vertex1 triangle vertex
  91949. * @param vertex2 triangle vertex
  91950. * @returns intersection information if hit
  91951. */
  91952. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91953. /**
  91954. * Checks if ray intersects a plane
  91955. * @param plane the plane to check
  91956. * @returns the distance away it was hit
  91957. */
  91958. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91959. /**
  91960. * Calculate the intercept of a ray on a given axis
  91961. * @param axis to check 'x' | 'y' | 'z'
  91962. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91963. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91964. */
  91965. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91966. /**
  91967. * Checks if ray intersects a mesh
  91968. * @param mesh the mesh to check
  91969. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91970. * @returns picking info of the intersecton
  91971. */
  91972. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91973. /**
  91974. * Checks if ray intersects a mesh
  91975. * @param meshes the meshes to check
  91976. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91977. * @param results array to store result in
  91978. * @returns Array of picking infos
  91979. */
  91980. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91981. private _comparePickingInfo;
  91982. private static smallnum;
  91983. private static rayl;
  91984. /**
  91985. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91986. * @param sega the first point of the segment to test the intersection against
  91987. * @param segb the second point of the segment to test the intersection against
  91988. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91989. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91990. */
  91991. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91992. /**
  91993. * Update the ray from viewport position
  91994. * @param x position
  91995. * @param y y position
  91996. * @param viewportWidth viewport width
  91997. * @param viewportHeight viewport height
  91998. * @param world world matrix
  91999. * @param view view matrix
  92000. * @param projection projection matrix
  92001. * @returns this ray updated
  92002. */
  92003. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  92004. /**
  92005. * Creates a ray with origin and direction of 0,0,0
  92006. * @returns the new ray
  92007. */
  92008. static Zero(): Ray;
  92009. /**
  92010. * Creates a new ray from screen space and viewport
  92011. * @param x position
  92012. * @param y y position
  92013. * @param viewportWidth viewport width
  92014. * @param viewportHeight viewport height
  92015. * @param world world matrix
  92016. * @param view view matrix
  92017. * @param projection projection matrix
  92018. * @returns new ray
  92019. */
  92020. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  92021. /**
  92022. * 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
  92023. * transformed to the given world matrix.
  92024. * @param origin The origin point
  92025. * @param end The end point
  92026. * @param world a matrix to transform the ray to. Default is the identity matrix.
  92027. * @returns the new ray
  92028. */
  92029. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  92030. /**
  92031. * Transforms a ray by a matrix
  92032. * @param ray ray to transform
  92033. * @param matrix matrix to apply
  92034. * @returns the resulting new ray
  92035. */
  92036. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  92037. /**
  92038. * Transforms a ray by a matrix
  92039. * @param ray ray to transform
  92040. * @param matrix matrix to apply
  92041. * @param result ray to store result in
  92042. */
  92043. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  92044. /**
  92045. * Unproject a ray from screen space to object space
  92046. * @param sourceX defines the screen space x coordinate to use
  92047. * @param sourceY defines the screen space y coordinate to use
  92048. * @param viewportWidth defines the current width of the viewport
  92049. * @param viewportHeight defines the current height of the viewport
  92050. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  92051. * @param view defines the view matrix to use
  92052. * @param projection defines the projection matrix to use
  92053. */
  92054. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  92055. }
  92056. /**
  92057. * Type used to define predicate used to select faces when a mesh intersection is detected
  92058. */
  92059. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  92060. interface Scene {
  92061. /** @hidden */
  92062. _tempPickingRay: Nullable<Ray>;
  92063. /** @hidden */
  92064. _cachedRayForTransform: Ray;
  92065. /** @hidden */
  92066. _pickWithRayInverseMatrix: Matrix;
  92067. /** @hidden */
  92068. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92069. /** @hidden */
  92070. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92071. /** @hidden */
  92072. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  92073. }
  92074. }
  92075. declare module BABYLON {
  92076. /**
  92077. * Groups all the scene component constants in one place to ease maintenance.
  92078. * @hidden
  92079. */
  92080. export class SceneComponentConstants {
  92081. static readonly NAME_EFFECTLAYER: string;
  92082. static readonly NAME_LAYER: string;
  92083. static readonly NAME_LENSFLARESYSTEM: string;
  92084. static readonly NAME_BOUNDINGBOXRENDERER: string;
  92085. static readonly NAME_PARTICLESYSTEM: string;
  92086. static readonly NAME_GAMEPAD: string;
  92087. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  92088. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  92089. static readonly NAME_PREPASSRENDERER: string;
  92090. static readonly NAME_DEPTHRENDERER: string;
  92091. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  92092. static readonly NAME_SPRITE: string;
  92093. static readonly NAME_SUBSURFACE: string;
  92094. static readonly NAME_OUTLINERENDERER: string;
  92095. static readonly NAME_PROCEDURALTEXTURE: string;
  92096. static readonly NAME_SHADOWGENERATOR: string;
  92097. static readonly NAME_OCTREE: string;
  92098. static readonly NAME_PHYSICSENGINE: string;
  92099. static readonly NAME_AUDIO: string;
  92100. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  92101. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92102. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  92103. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92104. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  92105. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  92106. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  92107. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  92108. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  92109. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  92110. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  92111. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  92112. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  92113. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  92114. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  92115. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  92116. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  92117. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  92118. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  92119. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  92120. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  92121. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  92122. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  92123. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  92124. static readonly STEP_AFTERRENDER_AUDIO: number;
  92125. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  92126. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  92127. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  92128. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  92129. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  92130. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  92131. static readonly STEP_POINTERMOVE_SPRITE: number;
  92132. static readonly STEP_POINTERDOWN_SPRITE: number;
  92133. static readonly STEP_POINTERUP_SPRITE: number;
  92134. }
  92135. /**
  92136. * This represents a scene component.
  92137. *
  92138. * This is used to decouple the dependency the scene is having on the different workloads like
  92139. * layers, post processes...
  92140. */
  92141. export interface ISceneComponent {
  92142. /**
  92143. * The name of the component. Each component must have a unique name.
  92144. */
  92145. name: string;
  92146. /**
  92147. * The scene the component belongs to.
  92148. */
  92149. scene: Scene;
  92150. /**
  92151. * Register the component to one instance of a scene.
  92152. */
  92153. register(): void;
  92154. /**
  92155. * Rebuilds the elements related to this component in case of
  92156. * context lost for instance.
  92157. */
  92158. rebuild(): void;
  92159. /**
  92160. * Disposes the component and the associated ressources.
  92161. */
  92162. dispose(): void;
  92163. }
  92164. /**
  92165. * This represents a SERIALIZABLE scene component.
  92166. *
  92167. * This extends Scene Component to add Serialization methods on top.
  92168. */
  92169. export interface ISceneSerializableComponent extends ISceneComponent {
  92170. /**
  92171. * Adds all the elements from the container to the scene
  92172. * @param container the container holding the elements
  92173. */
  92174. addFromContainer(container: AbstractScene): void;
  92175. /**
  92176. * Removes all the elements in the container from the scene
  92177. * @param container contains the elements to remove
  92178. * @param dispose if the removed element should be disposed (default: false)
  92179. */
  92180. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92181. /**
  92182. * Serializes the component data to the specified json object
  92183. * @param serializationObject The object to serialize to
  92184. */
  92185. serialize(serializationObject: any): void;
  92186. }
  92187. /**
  92188. * Strong typing of a Mesh related stage step action
  92189. */
  92190. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92191. /**
  92192. * Strong typing of a Evaluate Sub Mesh related stage step action
  92193. */
  92194. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92195. /**
  92196. * Strong typing of a pre active Mesh related stage step action
  92197. */
  92198. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92199. /**
  92200. * Strong typing of a Camera related stage step action
  92201. */
  92202. export type CameraStageAction = (camera: Camera) => void;
  92203. /**
  92204. * Strong typing of a Camera Frame buffer related stage step action
  92205. */
  92206. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92207. /**
  92208. * Strong typing of a Render Target related stage step action
  92209. */
  92210. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92211. /**
  92212. * Strong typing of a RenderingGroup related stage step action
  92213. */
  92214. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92215. /**
  92216. * Strong typing of a Mesh Render related stage step action
  92217. */
  92218. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  92219. /**
  92220. * Strong typing of a simple stage step action
  92221. */
  92222. export type SimpleStageAction = () => void;
  92223. /**
  92224. * Strong typing of a render target action.
  92225. */
  92226. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92227. /**
  92228. * Strong typing of a pointer move action.
  92229. */
  92230. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92231. /**
  92232. * Strong typing of a pointer up/down action.
  92233. */
  92234. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92235. /**
  92236. * Representation of a stage in the scene (Basically a list of ordered steps)
  92237. * @hidden
  92238. */
  92239. export class Stage<T extends Function> extends Array<{
  92240. index: number;
  92241. component: ISceneComponent;
  92242. action: T;
  92243. }> {
  92244. /**
  92245. * Hide ctor from the rest of the world.
  92246. * @param items The items to add.
  92247. */
  92248. private constructor();
  92249. /**
  92250. * Creates a new Stage.
  92251. * @returns A new instance of a Stage
  92252. */
  92253. static Create<T extends Function>(): Stage<T>;
  92254. /**
  92255. * Registers a step in an ordered way in the targeted stage.
  92256. * @param index Defines the position to register the step in
  92257. * @param component Defines the component attached to the step
  92258. * @param action Defines the action to launch during the step
  92259. */
  92260. registerStep(index: number, component: ISceneComponent, action: T): void;
  92261. /**
  92262. * Clears all the steps from the stage.
  92263. */
  92264. clear(): void;
  92265. }
  92266. }
  92267. declare module BABYLON {
  92268. interface Scene {
  92269. /** @hidden */
  92270. _pointerOverSprite: Nullable<Sprite>;
  92271. /** @hidden */
  92272. _pickedDownSprite: Nullable<Sprite>;
  92273. /** @hidden */
  92274. _tempSpritePickingRay: Nullable<Ray>;
  92275. /**
  92276. * All of the sprite managers added to this scene
  92277. * @see https://doc.babylonjs.com/babylon101/sprites
  92278. */
  92279. spriteManagers: Array<ISpriteManager>;
  92280. /**
  92281. * An event triggered when sprites rendering is about to start
  92282. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92283. */
  92284. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92285. /**
  92286. * An event triggered when sprites rendering is done
  92287. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92288. */
  92289. onAfterSpritesRenderingObservable: Observable<Scene>;
  92290. /** @hidden */
  92291. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92292. /** Launch a ray to try to pick a sprite in the scene
  92293. * @param x position on screen
  92294. * @param y position on screen
  92295. * @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
  92296. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92297. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92298. * @returns a PickingInfo
  92299. */
  92300. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92301. /** Use the given ray to pick a sprite in the scene
  92302. * @param ray The ray (in world space) to use to pick meshes
  92303. * @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
  92304. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92305. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92306. * @returns a PickingInfo
  92307. */
  92308. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92309. /** @hidden */
  92310. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92311. /** Launch a ray to try to pick sprites in the scene
  92312. * @param x position on screen
  92313. * @param y position on screen
  92314. * @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
  92315. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92316. * @returns a PickingInfo array
  92317. */
  92318. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92319. /** Use the given ray to pick sprites in the scene
  92320. * @param ray The ray (in world space) to use to pick meshes
  92321. * @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
  92322. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92323. * @returns a PickingInfo array
  92324. */
  92325. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92326. /**
  92327. * Force the sprite under the pointer
  92328. * @param sprite defines the sprite to use
  92329. */
  92330. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92331. /**
  92332. * Gets the sprite under the pointer
  92333. * @returns a Sprite or null if no sprite is under the pointer
  92334. */
  92335. getPointerOverSprite(): Nullable<Sprite>;
  92336. }
  92337. /**
  92338. * Defines the sprite scene component responsible to manage sprites
  92339. * in a given scene.
  92340. */
  92341. export class SpriteSceneComponent implements ISceneComponent {
  92342. /**
  92343. * The component name helpfull to identify the component in the list of scene components.
  92344. */
  92345. readonly name: string;
  92346. /**
  92347. * The scene the component belongs to.
  92348. */
  92349. scene: Scene;
  92350. /** @hidden */
  92351. private _spritePredicate;
  92352. /**
  92353. * Creates a new instance of the component for the given scene
  92354. * @param scene Defines the scene to register the component in
  92355. */
  92356. constructor(scene: Scene);
  92357. /**
  92358. * Registers the component in a given scene
  92359. */
  92360. register(): void;
  92361. /**
  92362. * Rebuilds the elements related to this component in case of
  92363. * context lost for instance.
  92364. */
  92365. rebuild(): void;
  92366. /**
  92367. * Disposes the component and the associated ressources.
  92368. */
  92369. dispose(): void;
  92370. private _pickSpriteButKeepRay;
  92371. private _pointerMove;
  92372. private _pointerDown;
  92373. private _pointerUp;
  92374. }
  92375. }
  92376. declare module BABYLON {
  92377. /**
  92378. * Class used to provide helper for timing
  92379. */
  92380. export class TimingTools {
  92381. /**
  92382. * Polyfill for setImmediate
  92383. * @param action defines the action to execute after the current execution block
  92384. */
  92385. static SetImmediate(action: () => void): void;
  92386. }
  92387. }
  92388. declare module BABYLON {
  92389. /**
  92390. * Class used to enable instatition of objects by class name
  92391. */
  92392. export class InstantiationTools {
  92393. /**
  92394. * Use this object to register external classes like custom textures or material
  92395. * to allow the laoders to instantiate them
  92396. */
  92397. static RegisteredExternalClasses: {
  92398. [key: string]: Object;
  92399. };
  92400. /**
  92401. * Tries to instantiate a new object from a given class name
  92402. * @param className defines the class name to instantiate
  92403. * @returns the new object or null if the system was not able to do the instantiation
  92404. */
  92405. static Instantiate(className: string): any;
  92406. }
  92407. }
  92408. declare module BABYLON {
  92409. /**
  92410. * Class used to host copy specific utilities
  92411. */
  92412. export class CopyTools {
  92413. /**
  92414. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92415. * @param texture defines the texture to read pixels from
  92416. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92417. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92418. * @returns The base64 encoded string or null
  92419. */
  92420. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. /**
  92425. * Define options used to create a depth texture
  92426. */
  92427. export class DepthTextureCreationOptions {
  92428. /** Specifies whether or not a stencil should be allocated in the texture */
  92429. generateStencil?: boolean;
  92430. /** Specifies whether or not bilinear filtering is enable on the texture */
  92431. bilinearFiltering?: boolean;
  92432. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92433. comparisonFunction?: number;
  92434. /** Specifies if the created texture is a cube texture */
  92435. isCube?: boolean;
  92436. }
  92437. }
  92438. declare module BABYLON {
  92439. interface ThinEngine {
  92440. /**
  92441. * Creates a depth stencil cube texture.
  92442. * This is only available in WebGL 2.
  92443. * @param size The size of face edge in the cube texture.
  92444. * @param options The options defining the cube texture.
  92445. * @returns The cube texture
  92446. */
  92447. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92448. /**
  92449. * Creates a cube texture
  92450. * @param rootUrl defines the url where the files to load is located
  92451. * @param scene defines the current scene
  92452. * @param files defines the list of files to load (1 per face)
  92453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92454. * @param onLoad defines an optional callback raised when the texture is loaded
  92455. * @param onError defines an optional callback raised if there is an issue to load the texture
  92456. * @param format defines the format of the data
  92457. * @param forcedExtension defines the extension to use to pick the right loader
  92458. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92459. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92460. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92461. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92462. * @param loaderOptions options to be passed to the loader
  92463. * @returns the cube texture as an InternalTexture
  92464. */
  92465. 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;
  92466. /**
  92467. * Creates a cube texture
  92468. * @param rootUrl defines the url where the files to load is located
  92469. * @param scene defines the current scene
  92470. * @param files defines the list of files to load (1 per face)
  92471. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92472. * @param onLoad defines an optional callback raised when the texture is loaded
  92473. * @param onError defines an optional callback raised if there is an issue to load the texture
  92474. * @param format defines the format of the data
  92475. * @param forcedExtension defines the extension to use to pick the right loader
  92476. * @returns the cube texture as an InternalTexture
  92477. */
  92478. 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;
  92479. /**
  92480. * Creates a cube texture
  92481. * @param rootUrl defines the url where the files to load is located
  92482. * @param scene defines the current scene
  92483. * @param files defines the list of files to load (1 per face)
  92484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92485. * @param onLoad defines an optional callback raised when the texture is loaded
  92486. * @param onError defines an optional callback raised if there is an issue to load the texture
  92487. * @param format defines the format of the data
  92488. * @param forcedExtension defines the extension to use to pick the right loader
  92489. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92490. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92491. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92492. * @returns the cube texture as an InternalTexture
  92493. */
  92494. 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;
  92495. /** @hidden */
  92496. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92497. /** @hidden */
  92498. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92499. /** @hidden */
  92500. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92501. /** @hidden */
  92502. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92503. /**
  92504. * @hidden
  92505. */
  92506. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92507. }
  92508. }
  92509. declare module BABYLON {
  92510. /**
  92511. * Class for creating a cube texture
  92512. */
  92513. export class CubeTexture extends BaseTexture {
  92514. private _delayedOnLoad;
  92515. /**
  92516. * Observable triggered once the texture has been loaded.
  92517. */
  92518. onLoadObservable: Observable<CubeTexture>;
  92519. /**
  92520. * The url of the texture
  92521. */
  92522. url: string;
  92523. /**
  92524. * Gets or sets the center of the bounding box associated with the cube texture.
  92525. * It must define where the camera used to render the texture was set
  92526. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92527. */
  92528. boundingBoxPosition: Vector3;
  92529. private _boundingBoxSize;
  92530. /**
  92531. * Gets or sets the size of the bounding box associated with the cube texture
  92532. * When defined, the cubemap will switch to local mode
  92533. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92534. * @example https://www.babylonjs-playground.com/#RNASML
  92535. */
  92536. set boundingBoxSize(value: Vector3);
  92537. /**
  92538. * Returns the bounding box size
  92539. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92540. */
  92541. get boundingBoxSize(): Vector3;
  92542. protected _rotationY: number;
  92543. /**
  92544. * Sets texture matrix rotation angle around Y axis in radians.
  92545. */
  92546. set rotationY(value: number);
  92547. /**
  92548. * Gets texture matrix rotation angle around Y axis radians.
  92549. */
  92550. get rotationY(): number;
  92551. /**
  92552. * Are mip maps generated for this texture or not.
  92553. */
  92554. get noMipmap(): boolean;
  92555. private _noMipmap;
  92556. private _files;
  92557. protected _forcedExtension: Nullable<string>;
  92558. private _extensions;
  92559. private _textureMatrix;
  92560. private _format;
  92561. private _createPolynomials;
  92562. private _loaderOptions;
  92563. /**
  92564. * Creates a cube texture from an array of image urls
  92565. * @param files defines an array of image urls
  92566. * @param scene defines the hosting scene
  92567. * @param noMipmap specifies if mip maps are not used
  92568. * @returns a cube texture
  92569. */
  92570. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92571. /**
  92572. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92573. * @param url defines the url of the prefiltered texture
  92574. * @param scene defines the scene the texture is attached to
  92575. * @param forcedExtension defines the extension of the file if different from the url
  92576. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92577. * @return the prefiltered texture
  92578. */
  92579. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92580. /**
  92581. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92582. * as prefiltered data.
  92583. * @param rootUrl defines the url of the texture or the root name of the six images
  92584. * @param null defines the scene or engine the texture is attached to
  92585. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92586. * @param noMipmap defines if mipmaps should be created or not
  92587. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92588. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92589. * @param onError defines a callback triggered in case of error during load
  92590. * @param format defines the internal format to use for the texture once loaded
  92591. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92592. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92593. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92594. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92595. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92596. * @param loaderOptions options to be passed to the loader
  92597. * @return the cube texture
  92598. */
  92599. 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);
  92600. /**
  92601. * Get the current class name of the texture useful for serialization or dynamic coding.
  92602. * @returns "CubeTexture"
  92603. */
  92604. getClassName(): string;
  92605. /**
  92606. * Update the url (and optional buffer) of this texture if url was null during construction.
  92607. * @param url the url of the texture
  92608. * @param forcedExtension defines the extension to use
  92609. * @param onLoad callback called when the texture is loaded (defaults to null)
  92610. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92611. */
  92612. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92613. /**
  92614. * Delays loading of the cube texture
  92615. * @param forcedExtension defines the extension to use
  92616. */
  92617. delayLoad(forcedExtension?: string): void;
  92618. /**
  92619. * Returns the reflection texture matrix
  92620. * @returns the reflection texture matrix
  92621. */
  92622. getReflectionTextureMatrix(): Matrix;
  92623. /**
  92624. * Sets the reflection texture matrix
  92625. * @param value Reflection texture matrix
  92626. */
  92627. setReflectionTextureMatrix(value: Matrix): void;
  92628. /**
  92629. * Parses text to create a cube texture
  92630. * @param parsedTexture define the serialized text to read from
  92631. * @param scene defines the hosting scene
  92632. * @param rootUrl defines the root url of the cube texture
  92633. * @returns a cube texture
  92634. */
  92635. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92636. /**
  92637. * Makes a clone, or deep copy, of the cube texture
  92638. * @returns a new cube texture
  92639. */
  92640. clone(): CubeTexture;
  92641. }
  92642. }
  92643. declare module BABYLON {
  92644. /**
  92645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92647. * 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;
  92648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92649. */
  92650. export class ColorCurves {
  92651. private _dirty;
  92652. private _tempColor;
  92653. private _globalCurve;
  92654. private _highlightsCurve;
  92655. private _midtonesCurve;
  92656. private _shadowsCurve;
  92657. private _positiveCurve;
  92658. private _negativeCurve;
  92659. private _globalHue;
  92660. private _globalDensity;
  92661. private _globalSaturation;
  92662. private _globalExposure;
  92663. /**
  92664. * Gets the global Hue value.
  92665. * 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).
  92666. */
  92667. get globalHue(): number;
  92668. /**
  92669. * Sets the global Hue value.
  92670. * 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).
  92671. */
  92672. set globalHue(value: number);
  92673. /**
  92674. * Gets the global Density value.
  92675. * 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.
  92676. * Values less than zero provide a filter of opposite hue.
  92677. */
  92678. get globalDensity(): number;
  92679. /**
  92680. * Sets the global Density value.
  92681. * 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.
  92682. * Values less than zero provide a filter of opposite hue.
  92683. */
  92684. set globalDensity(value: number);
  92685. /**
  92686. * Gets the global Saturation value.
  92687. * 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.
  92688. */
  92689. get globalSaturation(): number;
  92690. /**
  92691. * Sets the global Saturation value.
  92692. * 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.
  92693. */
  92694. set globalSaturation(value: number);
  92695. /**
  92696. * Gets the global Exposure value.
  92697. * 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.
  92698. */
  92699. get globalExposure(): number;
  92700. /**
  92701. * Sets the global Exposure value.
  92702. * 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.
  92703. */
  92704. set globalExposure(value: number);
  92705. private _highlightsHue;
  92706. private _highlightsDensity;
  92707. private _highlightsSaturation;
  92708. private _highlightsExposure;
  92709. /**
  92710. * Gets the highlights Hue value.
  92711. * 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).
  92712. */
  92713. get highlightsHue(): number;
  92714. /**
  92715. * Sets the highlights Hue value.
  92716. * 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).
  92717. */
  92718. set highlightsHue(value: number);
  92719. /**
  92720. * Gets the highlights Density value.
  92721. * 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.
  92722. * Values less than zero provide a filter of opposite hue.
  92723. */
  92724. get highlightsDensity(): number;
  92725. /**
  92726. * Sets the highlights Density value.
  92727. * 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.
  92728. * Values less than zero provide a filter of opposite hue.
  92729. */
  92730. set highlightsDensity(value: number);
  92731. /**
  92732. * Gets the highlights Saturation value.
  92733. * 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.
  92734. */
  92735. get highlightsSaturation(): number;
  92736. /**
  92737. * Sets the highlights Saturation value.
  92738. * 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.
  92739. */
  92740. set highlightsSaturation(value: number);
  92741. /**
  92742. * Gets the highlights Exposure value.
  92743. * 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.
  92744. */
  92745. get highlightsExposure(): number;
  92746. /**
  92747. * Sets the highlights Exposure value.
  92748. * 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.
  92749. */
  92750. set highlightsExposure(value: number);
  92751. private _midtonesHue;
  92752. private _midtonesDensity;
  92753. private _midtonesSaturation;
  92754. private _midtonesExposure;
  92755. /**
  92756. * Gets the midtones Hue value.
  92757. * 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).
  92758. */
  92759. get midtonesHue(): number;
  92760. /**
  92761. * Sets the midtones Hue value.
  92762. * 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).
  92763. */
  92764. set midtonesHue(value: number);
  92765. /**
  92766. * Gets the midtones Density value.
  92767. * 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.
  92768. * Values less than zero provide a filter of opposite hue.
  92769. */
  92770. get midtonesDensity(): number;
  92771. /**
  92772. * Sets the midtones Density value.
  92773. * 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.
  92774. * Values less than zero provide a filter of opposite hue.
  92775. */
  92776. set midtonesDensity(value: number);
  92777. /**
  92778. * Gets the midtones Saturation value.
  92779. * 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.
  92780. */
  92781. get midtonesSaturation(): number;
  92782. /**
  92783. * Sets the midtones Saturation value.
  92784. * 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.
  92785. */
  92786. set midtonesSaturation(value: number);
  92787. /**
  92788. * Gets the midtones Exposure value.
  92789. * 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.
  92790. */
  92791. get midtonesExposure(): number;
  92792. /**
  92793. * Sets the midtones Exposure value.
  92794. * 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.
  92795. */
  92796. set midtonesExposure(value: number);
  92797. private _shadowsHue;
  92798. private _shadowsDensity;
  92799. private _shadowsSaturation;
  92800. private _shadowsExposure;
  92801. /**
  92802. * Gets the shadows Hue value.
  92803. * 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).
  92804. */
  92805. get shadowsHue(): number;
  92806. /**
  92807. * Sets the shadows Hue value.
  92808. * 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).
  92809. */
  92810. set shadowsHue(value: number);
  92811. /**
  92812. * Gets the shadows Density value.
  92813. * 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.
  92814. * Values less than zero provide a filter of opposite hue.
  92815. */
  92816. get shadowsDensity(): number;
  92817. /**
  92818. * Sets the shadows Density value.
  92819. * 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.
  92820. * Values less than zero provide a filter of opposite hue.
  92821. */
  92822. set shadowsDensity(value: number);
  92823. /**
  92824. * Gets the shadows Saturation value.
  92825. * 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.
  92826. */
  92827. get shadowsSaturation(): number;
  92828. /**
  92829. * Sets the shadows Saturation value.
  92830. * 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.
  92831. */
  92832. set shadowsSaturation(value: number);
  92833. /**
  92834. * Gets the shadows Exposure value.
  92835. * 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.
  92836. */
  92837. get shadowsExposure(): number;
  92838. /**
  92839. * Sets the shadows Exposure value.
  92840. * 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.
  92841. */
  92842. set shadowsExposure(value: number);
  92843. /**
  92844. * Returns the class name
  92845. * @returns The class name
  92846. */
  92847. getClassName(): string;
  92848. /**
  92849. * Binds the color curves to the shader.
  92850. * @param colorCurves The color curve to bind
  92851. * @param effect The effect to bind to
  92852. * @param positiveUniform The positive uniform shader parameter
  92853. * @param neutralUniform The neutral uniform shader parameter
  92854. * @param negativeUniform The negative uniform shader parameter
  92855. */
  92856. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92857. /**
  92858. * Prepare the list of uniforms associated with the ColorCurves effects.
  92859. * @param uniformsList The list of uniforms used in the effect
  92860. */
  92861. static PrepareUniforms(uniformsList: string[]): void;
  92862. /**
  92863. * Returns color grading data based on a hue, density, saturation and exposure value.
  92864. * @param filterHue The hue of the color filter.
  92865. * @param filterDensity The density of the color filter.
  92866. * @param saturation The saturation.
  92867. * @param exposure The exposure.
  92868. * @param result The result data container.
  92869. */
  92870. private getColorGradingDataToRef;
  92871. /**
  92872. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92873. * @param value The input slider value in range [-100,100].
  92874. * @returns Adjusted value.
  92875. */
  92876. private static applyColorGradingSliderNonlinear;
  92877. /**
  92878. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92879. * @param hue The hue (H) input.
  92880. * @param saturation The saturation (S) input.
  92881. * @param brightness The brightness (B) input.
  92882. * @result An RGBA color represented as Vector4.
  92883. */
  92884. private static fromHSBToRef;
  92885. /**
  92886. * Returns a value clamped between min and max
  92887. * @param value The value to clamp
  92888. * @param min The minimum of value
  92889. * @param max The maximum of value
  92890. * @returns The clamped value.
  92891. */
  92892. private static clamp;
  92893. /**
  92894. * Clones the current color curve instance.
  92895. * @return The cloned curves
  92896. */
  92897. clone(): ColorCurves;
  92898. /**
  92899. * Serializes the current color curve instance to a json representation.
  92900. * @return a JSON representation
  92901. */
  92902. serialize(): any;
  92903. /**
  92904. * Parses the color curve from a json representation.
  92905. * @param source the JSON source to parse
  92906. * @return The parsed curves
  92907. */
  92908. static Parse(source: any): ColorCurves;
  92909. }
  92910. }
  92911. declare module BABYLON {
  92912. /**
  92913. * Interface to follow in your material defines to integrate easily the
  92914. * Image proccessing functions.
  92915. * @hidden
  92916. */
  92917. export interface IImageProcessingConfigurationDefines {
  92918. IMAGEPROCESSING: boolean;
  92919. VIGNETTE: boolean;
  92920. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92921. VIGNETTEBLENDMODEOPAQUE: boolean;
  92922. TONEMAPPING: boolean;
  92923. TONEMAPPING_ACES: boolean;
  92924. CONTRAST: boolean;
  92925. EXPOSURE: boolean;
  92926. COLORCURVES: boolean;
  92927. COLORGRADING: boolean;
  92928. COLORGRADING3D: boolean;
  92929. SAMPLER3DGREENDEPTH: boolean;
  92930. SAMPLER3DBGRMAP: boolean;
  92931. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92932. }
  92933. /**
  92934. * @hidden
  92935. */
  92936. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92937. IMAGEPROCESSING: boolean;
  92938. VIGNETTE: boolean;
  92939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92940. VIGNETTEBLENDMODEOPAQUE: boolean;
  92941. TONEMAPPING: boolean;
  92942. TONEMAPPING_ACES: boolean;
  92943. CONTRAST: boolean;
  92944. COLORCURVES: boolean;
  92945. COLORGRADING: boolean;
  92946. COLORGRADING3D: boolean;
  92947. SAMPLER3DGREENDEPTH: boolean;
  92948. SAMPLER3DBGRMAP: boolean;
  92949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92950. EXPOSURE: boolean;
  92951. constructor();
  92952. }
  92953. /**
  92954. * This groups together the common properties used for image processing either in direct forward pass
  92955. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92956. * or not.
  92957. */
  92958. export class ImageProcessingConfiguration {
  92959. /**
  92960. * Default tone mapping applied in BabylonJS.
  92961. */
  92962. static readonly TONEMAPPING_STANDARD: number;
  92963. /**
  92964. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92965. * to other engines rendering to increase portability.
  92966. */
  92967. static readonly TONEMAPPING_ACES: number;
  92968. /**
  92969. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92970. */
  92971. colorCurves: Nullable<ColorCurves>;
  92972. private _colorCurvesEnabled;
  92973. /**
  92974. * Gets wether the color curves effect is enabled.
  92975. */
  92976. get colorCurvesEnabled(): boolean;
  92977. /**
  92978. * Sets wether the color curves effect is enabled.
  92979. */
  92980. set colorCurvesEnabled(value: boolean);
  92981. private _colorGradingTexture;
  92982. /**
  92983. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92984. */
  92985. get colorGradingTexture(): Nullable<BaseTexture>;
  92986. /**
  92987. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92988. */
  92989. set colorGradingTexture(value: Nullable<BaseTexture>);
  92990. private _colorGradingEnabled;
  92991. /**
  92992. * Gets wether the color grading effect is enabled.
  92993. */
  92994. get colorGradingEnabled(): boolean;
  92995. /**
  92996. * Sets wether the color grading effect is enabled.
  92997. */
  92998. set colorGradingEnabled(value: boolean);
  92999. private _colorGradingWithGreenDepth;
  93000. /**
  93001. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93002. */
  93003. get colorGradingWithGreenDepth(): boolean;
  93004. /**
  93005. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93006. */
  93007. set colorGradingWithGreenDepth(value: boolean);
  93008. private _colorGradingBGR;
  93009. /**
  93010. * Gets wether the color grading texture contains BGR values.
  93011. */
  93012. get colorGradingBGR(): boolean;
  93013. /**
  93014. * Sets wether the color grading texture contains BGR values.
  93015. */
  93016. set colorGradingBGR(value: boolean);
  93017. /** @hidden */
  93018. _exposure: number;
  93019. /**
  93020. * Gets the Exposure used in the effect.
  93021. */
  93022. get exposure(): number;
  93023. /**
  93024. * Sets the Exposure used in the effect.
  93025. */
  93026. set exposure(value: number);
  93027. private _toneMappingEnabled;
  93028. /**
  93029. * Gets wether the tone mapping effect is enabled.
  93030. */
  93031. get toneMappingEnabled(): boolean;
  93032. /**
  93033. * Sets wether the tone mapping effect is enabled.
  93034. */
  93035. set toneMappingEnabled(value: boolean);
  93036. private _toneMappingType;
  93037. /**
  93038. * Gets the type of tone mapping effect.
  93039. */
  93040. get toneMappingType(): number;
  93041. /**
  93042. * Sets the type of tone mapping effect used in BabylonJS.
  93043. */
  93044. set toneMappingType(value: number);
  93045. protected _contrast: number;
  93046. /**
  93047. * Gets the contrast used in the effect.
  93048. */
  93049. get contrast(): number;
  93050. /**
  93051. * Sets the contrast used in the effect.
  93052. */
  93053. set contrast(value: number);
  93054. /**
  93055. * Vignette stretch size.
  93056. */
  93057. vignetteStretch: number;
  93058. /**
  93059. * Vignette centre X Offset.
  93060. */
  93061. vignetteCentreX: number;
  93062. /**
  93063. * Vignette centre Y Offset.
  93064. */
  93065. vignetteCentreY: number;
  93066. /**
  93067. * Vignette weight or intensity of the vignette effect.
  93068. */
  93069. vignetteWeight: number;
  93070. /**
  93071. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93072. * if vignetteEnabled is set to true.
  93073. */
  93074. vignetteColor: Color4;
  93075. /**
  93076. * Camera field of view used by the Vignette effect.
  93077. */
  93078. vignetteCameraFov: number;
  93079. private _vignetteBlendMode;
  93080. /**
  93081. * Gets the vignette blend mode allowing different kind of effect.
  93082. */
  93083. get vignetteBlendMode(): number;
  93084. /**
  93085. * Sets the vignette blend mode allowing different kind of effect.
  93086. */
  93087. set vignetteBlendMode(value: number);
  93088. private _vignetteEnabled;
  93089. /**
  93090. * Gets wether the vignette effect is enabled.
  93091. */
  93092. get vignetteEnabled(): boolean;
  93093. /**
  93094. * Sets wether the vignette effect is enabled.
  93095. */
  93096. set vignetteEnabled(value: boolean);
  93097. private _applyByPostProcess;
  93098. /**
  93099. * Gets wether the image processing is applied through a post process or not.
  93100. */
  93101. get applyByPostProcess(): boolean;
  93102. /**
  93103. * Sets wether the image processing is applied through a post process or not.
  93104. */
  93105. set applyByPostProcess(value: boolean);
  93106. private _isEnabled;
  93107. /**
  93108. * Gets wether the image processing is enabled or not.
  93109. */
  93110. get isEnabled(): boolean;
  93111. /**
  93112. * Sets wether the image processing is enabled or not.
  93113. */
  93114. set isEnabled(value: boolean);
  93115. /**
  93116. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93117. */
  93118. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93119. /**
  93120. * Method called each time the image processing information changes requires to recompile the effect.
  93121. */
  93122. protected _updateParameters(): void;
  93123. /**
  93124. * Gets the current class name.
  93125. * @return "ImageProcessingConfiguration"
  93126. */
  93127. getClassName(): string;
  93128. /**
  93129. * Prepare the list of uniforms associated with the Image Processing effects.
  93130. * @param uniforms The list of uniforms used in the effect
  93131. * @param defines the list of defines currently in use
  93132. */
  93133. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93134. /**
  93135. * Prepare the list of samplers associated with the Image Processing effects.
  93136. * @param samplersList The list of uniforms used in the effect
  93137. * @param defines the list of defines currently in use
  93138. */
  93139. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93140. /**
  93141. * Prepare the list of defines associated to the shader.
  93142. * @param defines the list of defines to complete
  93143. * @param forPostProcess Define if we are currently in post process mode or not
  93144. */
  93145. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93146. /**
  93147. * Returns true if all the image processing information are ready.
  93148. * @returns True if ready, otherwise, false
  93149. */
  93150. isReady(): boolean;
  93151. /**
  93152. * Binds the image processing to the shader.
  93153. * @param effect The effect to bind to
  93154. * @param overrideAspectRatio Override the aspect ratio of the effect
  93155. */
  93156. bind(effect: Effect, overrideAspectRatio?: number): void;
  93157. /**
  93158. * Clones the current image processing instance.
  93159. * @return The cloned image processing
  93160. */
  93161. clone(): ImageProcessingConfiguration;
  93162. /**
  93163. * Serializes the current image processing instance to a json representation.
  93164. * @return a JSON representation
  93165. */
  93166. serialize(): any;
  93167. /**
  93168. * Parses the image processing from a json representation.
  93169. * @param source the JSON source to parse
  93170. * @return The parsed image processing
  93171. */
  93172. static Parse(source: any): ImageProcessingConfiguration;
  93173. private static _VIGNETTEMODE_MULTIPLY;
  93174. private static _VIGNETTEMODE_OPAQUE;
  93175. /**
  93176. * Used to apply the vignette as a mix with the pixel color.
  93177. */
  93178. static get VIGNETTEMODE_MULTIPLY(): number;
  93179. /**
  93180. * Used to apply the vignette as a replacement of the pixel color.
  93181. */
  93182. static get VIGNETTEMODE_OPAQUE(): number;
  93183. }
  93184. }
  93185. declare module BABYLON {
  93186. /** @hidden */
  93187. export var postprocessVertexShader: {
  93188. name: string;
  93189. shader: string;
  93190. };
  93191. }
  93192. declare module BABYLON {
  93193. /**
  93194. * Type used to define a render target texture size (either with a number or with a rect width and height)
  93195. */
  93196. export type RenderTargetTextureSize = number | {
  93197. width: number;
  93198. height: number;
  93199. layers?: number;
  93200. };
  93201. interface ThinEngine {
  93202. /**
  93203. * Creates a new render target texture
  93204. * @param size defines the size of the texture
  93205. * @param options defines the options used to create the texture
  93206. * @returns a new render target texture stored in an InternalTexture
  93207. */
  93208. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  93209. /**
  93210. * Creates a depth stencil texture.
  93211. * This is only available in WebGL 2 or with the depth texture extension available.
  93212. * @param size The size of face edge in the texture.
  93213. * @param options The options defining the texture.
  93214. * @returns The texture
  93215. */
  93216. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93217. /** @hidden */
  93218. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93219. }
  93220. }
  93221. declare module BABYLON {
  93222. /**
  93223. * Defines the kind of connection point for node based material
  93224. */
  93225. export enum NodeMaterialBlockConnectionPointTypes {
  93226. /** Float */
  93227. Float = 1,
  93228. /** Int */
  93229. Int = 2,
  93230. /** Vector2 */
  93231. Vector2 = 4,
  93232. /** Vector3 */
  93233. Vector3 = 8,
  93234. /** Vector4 */
  93235. Vector4 = 16,
  93236. /** Color3 */
  93237. Color3 = 32,
  93238. /** Color4 */
  93239. Color4 = 64,
  93240. /** Matrix */
  93241. Matrix = 128,
  93242. /** Custom object */
  93243. Object = 256,
  93244. /** Detect type based on connection */
  93245. AutoDetect = 1024,
  93246. /** Output type that will be defined by input type */
  93247. BasedOnInput = 2048
  93248. }
  93249. }
  93250. declare module BABYLON {
  93251. /**
  93252. * Enum used to define the target of a block
  93253. */
  93254. export enum NodeMaterialBlockTargets {
  93255. /** Vertex shader */
  93256. Vertex = 1,
  93257. /** Fragment shader */
  93258. Fragment = 2,
  93259. /** Neutral */
  93260. Neutral = 4,
  93261. /** Vertex and Fragment */
  93262. VertexAndFragment = 3
  93263. }
  93264. }
  93265. declare module BABYLON {
  93266. /**
  93267. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93268. */
  93269. export enum NodeMaterialBlockConnectionPointMode {
  93270. /** Value is an uniform */
  93271. Uniform = 0,
  93272. /** Value is a mesh attribute */
  93273. Attribute = 1,
  93274. /** Value is a varying between vertex and fragment shaders */
  93275. Varying = 2,
  93276. /** Mode is undefined */
  93277. Undefined = 3
  93278. }
  93279. }
  93280. declare module BABYLON {
  93281. /**
  93282. * Enum used to define system values e.g. values automatically provided by the system
  93283. */
  93284. export enum NodeMaterialSystemValues {
  93285. /** World */
  93286. World = 1,
  93287. /** View */
  93288. View = 2,
  93289. /** Projection */
  93290. Projection = 3,
  93291. /** ViewProjection */
  93292. ViewProjection = 4,
  93293. /** WorldView */
  93294. WorldView = 5,
  93295. /** WorldViewProjection */
  93296. WorldViewProjection = 6,
  93297. /** CameraPosition */
  93298. CameraPosition = 7,
  93299. /** Fog Color */
  93300. FogColor = 8,
  93301. /** Delta time */
  93302. DeltaTime = 9
  93303. }
  93304. }
  93305. declare module BABYLON {
  93306. /**
  93307. * Represents a camera frustum
  93308. */
  93309. export class Frustum {
  93310. /**
  93311. * Gets the planes representing the frustum
  93312. * @param transform matrix to be applied to the returned planes
  93313. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93314. */
  93315. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93316. /**
  93317. * Gets the near frustum plane transformed by the transform matrix
  93318. * @param transform transformation matrix to be applied to the resulting frustum plane
  93319. * @param frustumPlane the resuling frustum plane
  93320. */
  93321. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93322. /**
  93323. * Gets the far frustum plane transformed by the transform matrix
  93324. * @param transform transformation matrix to be applied to the resulting frustum plane
  93325. * @param frustumPlane the resuling frustum plane
  93326. */
  93327. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93328. /**
  93329. * Gets the left frustum plane transformed by the transform matrix
  93330. * @param transform transformation matrix to be applied to the resulting frustum plane
  93331. * @param frustumPlane the resuling frustum plane
  93332. */
  93333. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93334. /**
  93335. * Gets the right frustum plane transformed by the transform matrix
  93336. * @param transform transformation matrix to be applied to the resulting frustum plane
  93337. * @param frustumPlane the resuling frustum plane
  93338. */
  93339. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93340. /**
  93341. * Gets the top frustum plane transformed by the transform matrix
  93342. * @param transform transformation matrix to be applied to the resulting frustum plane
  93343. * @param frustumPlane the resuling frustum plane
  93344. */
  93345. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93346. /**
  93347. * Gets the bottom frustum plane transformed by the transform matrix
  93348. * @param transform transformation matrix to be applied to the resulting frustum plane
  93349. * @param frustumPlane the resuling frustum plane
  93350. */
  93351. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93352. /**
  93353. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93354. * @param transform transformation matrix to be applied to the resulting frustum planes
  93355. * @param frustumPlanes the resuling frustum planes
  93356. */
  93357. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93358. }
  93359. }
  93360. declare module BABYLON {
  93361. /**
  93362. * Contains position and normal vectors for a vertex
  93363. */
  93364. export class PositionNormalVertex {
  93365. /** the position of the vertex (defaut: 0,0,0) */
  93366. position: Vector3;
  93367. /** the normal of the vertex (defaut: 0,1,0) */
  93368. normal: Vector3;
  93369. /**
  93370. * Creates a PositionNormalVertex
  93371. * @param position the position of the vertex (defaut: 0,0,0)
  93372. * @param normal the normal of the vertex (defaut: 0,1,0)
  93373. */
  93374. constructor(
  93375. /** the position of the vertex (defaut: 0,0,0) */
  93376. position?: Vector3,
  93377. /** the normal of the vertex (defaut: 0,1,0) */
  93378. normal?: Vector3);
  93379. /**
  93380. * Clones the PositionNormalVertex
  93381. * @returns the cloned PositionNormalVertex
  93382. */
  93383. clone(): PositionNormalVertex;
  93384. }
  93385. /**
  93386. * Contains position, normal and uv vectors for a vertex
  93387. */
  93388. export class PositionNormalTextureVertex {
  93389. /** the position of the vertex (defaut: 0,0,0) */
  93390. position: Vector3;
  93391. /** the normal of the vertex (defaut: 0,1,0) */
  93392. normal: Vector3;
  93393. /** the uv of the vertex (default: 0,0) */
  93394. uv: Vector2;
  93395. /**
  93396. * Creates a PositionNormalTextureVertex
  93397. * @param position the position of the vertex (defaut: 0,0,0)
  93398. * @param normal the normal of the vertex (defaut: 0,1,0)
  93399. * @param uv the uv of the vertex (default: 0,0)
  93400. */
  93401. constructor(
  93402. /** the position of the vertex (defaut: 0,0,0) */
  93403. position?: Vector3,
  93404. /** the normal of the vertex (defaut: 0,1,0) */
  93405. normal?: Vector3,
  93406. /** the uv of the vertex (default: 0,0) */
  93407. uv?: Vector2);
  93408. /**
  93409. * Clones the PositionNormalTextureVertex
  93410. * @returns the cloned PositionNormalTextureVertex
  93411. */
  93412. clone(): PositionNormalTextureVertex;
  93413. }
  93414. }
  93415. declare module BABYLON {
  93416. /**
  93417. * Enum defining the type of animations supported by InputBlock
  93418. */
  93419. export enum AnimatedInputBlockTypes {
  93420. /** No animation */
  93421. None = 0,
  93422. /** Time based animation. Will only work for floats */
  93423. Time = 1
  93424. }
  93425. }
  93426. declare module BABYLON {
  93427. /**
  93428. * Block used to expose an input value
  93429. */
  93430. export class InputBlock extends NodeMaterialBlock {
  93431. private _mode;
  93432. private _associatedVariableName;
  93433. private _storedValue;
  93434. private _valueCallback;
  93435. private _type;
  93436. private _animationType;
  93437. /** Gets or set a value used to limit the range of float values */
  93438. min: number;
  93439. /** Gets or set a value used to limit the range of float values */
  93440. max: number;
  93441. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93442. isBoolean: boolean;
  93443. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93444. matrixMode: number;
  93445. /** @hidden */
  93446. _systemValue: Nullable<NodeMaterialSystemValues>;
  93447. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93448. isConstant: boolean;
  93449. /** Gets or sets the group to use to display this block in the Inspector */
  93450. groupInInspector: string;
  93451. /** Gets an observable raised when the value is changed */
  93452. onValueChangedObservable: Observable<InputBlock>;
  93453. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  93454. convertToGammaSpace: boolean;
  93455. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  93456. convertToLinearSpace: boolean;
  93457. /**
  93458. * Gets or sets the connection point type (default is float)
  93459. */
  93460. get type(): NodeMaterialBlockConnectionPointTypes;
  93461. /**
  93462. * Creates a new InputBlock
  93463. * @param name defines the block name
  93464. * @param target defines the target of that block (Vertex by default)
  93465. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93466. */
  93467. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93468. /**
  93469. * Validates if a name is a reserve word.
  93470. * @param newName the new name to be given to the node.
  93471. * @returns false if the name is a reserve word, else true.
  93472. */
  93473. validateBlockName(newName: string): boolean;
  93474. /**
  93475. * Gets the output component
  93476. */
  93477. get output(): NodeMaterialConnectionPoint;
  93478. /**
  93479. * Set the source of this connection point to a vertex attribute
  93480. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93481. * @returns the current connection point
  93482. */
  93483. setAsAttribute(attributeName?: string): InputBlock;
  93484. /**
  93485. * Set the source of this connection point to a system value
  93486. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93487. * @returns the current connection point
  93488. */
  93489. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93490. /**
  93491. * Gets or sets the value of that point.
  93492. * Please note that this value will be ignored if valueCallback is defined
  93493. */
  93494. get value(): any;
  93495. set value(value: any);
  93496. /**
  93497. * Gets or sets a callback used to get the value of that point.
  93498. * Please note that setting this value will force the connection point to ignore the value property
  93499. */
  93500. get valueCallback(): () => any;
  93501. set valueCallback(value: () => any);
  93502. /**
  93503. * Gets or sets the associated variable name in the shader
  93504. */
  93505. get associatedVariableName(): string;
  93506. set associatedVariableName(value: string);
  93507. /** Gets or sets the type of animation applied to the input */
  93508. get animationType(): AnimatedInputBlockTypes;
  93509. set animationType(value: AnimatedInputBlockTypes);
  93510. /**
  93511. * Gets a boolean indicating that this connection point not defined yet
  93512. */
  93513. get isUndefined(): boolean;
  93514. /**
  93515. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93516. * In this case the connection point name must be the name of the uniform to use.
  93517. * Can only be set on inputs
  93518. */
  93519. get isUniform(): boolean;
  93520. set isUniform(value: boolean);
  93521. /**
  93522. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93523. * In this case the connection point name must be the name of the attribute to use
  93524. * Can only be set on inputs
  93525. */
  93526. get isAttribute(): boolean;
  93527. set isAttribute(value: boolean);
  93528. /**
  93529. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93530. * Can only be set on exit points
  93531. */
  93532. get isVarying(): boolean;
  93533. set isVarying(value: boolean);
  93534. /**
  93535. * Gets a boolean indicating that the current connection point is a system value
  93536. */
  93537. get isSystemValue(): boolean;
  93538. /**
  93539. * Gets or sets the current well known value or null if not defined as a system value
  93540. */
  93541. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93542. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93543. /**
  93544. * Gets the current class name
  93545. * @returns the class name
  93546. */
  93547. getClassName(): string;
  93548. /**
  93549. * Animate the input if animationType !== None
  93550. * @param scene defines the rendering scene
  93551. */
  93552. animate(scene: Scene): void;
  93553. private _emitDefine;
  93554. initialize(state: NodeMaterialBuildState): void;
  93555. /**
  93556. * Set the input block to its default value (based on its type)
  93557. */
  93558. setDefaultValue(): void;
  93559. private _emitConstant;
  93560. /** @hidden */
  93561. get _noContextSwitch(): boolean;
  93562. private _emit;
  93563. /** @hidden */
  93564. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93565. /** @hidden */
  93566. _transmit(effect: Effect, scene: Scene): void;
  93567. protected _buildBlock(state: NodeMaterialBuildState): void;
  93568. protected _dumpPropertiesCode(): string;
  93569. dispose(): void;
  93570. serialize(): any;
  93571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93572. }
  93573. }
  93574. declare module BABYLON {
  93575. /**
  93576. * Enum used to define the compatibility state between two connection points
  93577. */
  93578. export enum NodeMaterialConnectionPointCompatibilityStates {
  93579. /** Points are compatibles */
  93580. Compatible = 0,
  93581. /** Points are incompatible because of their types */
  93582. TypeIncompatible = 1,
  93583. /** Points are incompatible because of their targets (vertex vs fragment) */
  93584. TargetIncompatible = 2
  93585. }
  93586. /**
  93587. * Defines the direction of a connection point
  93588. */
  93589. export enum NodeMaterialConnectionPointDirection {
  93590. /** Input */
  93591. Input = 0,
  93592. /** Output */
  93593. Output = 1
  93594. }
  93595. /**
  93596. * Defines a connection point for a block
  93597. */
  93598. export class NodeMaterialConnectionPoint {
  93599. /**
  93600. * Checks if two types are equivalent
  93601. * @param type1 type 1 to check
  93602. * @param type2 type 2 to check
  93603. * @returns true if both types are equivalent, else false
  93604. */
  93605. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93606. /** @hidden */
  93607. _ownerBlock: NodeMaterialBlock;
  93608. /** @hidden */
  93609. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93610. private _endpoints;
  93611. private _associatedVariableName;
  93612. private _direction;
  93613. /** @hidden */
  93614. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93615. /** @hidden */
  93616. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93617. /** @hidden */
  93618. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93619. private _type;
  93620. /** @hidden */
  93621. _enforceAssociatedVariableName: boolean;
  93622. /** Gets the direction of the point */
  93623. get direction(): NodeMaterialConnectionPointDirection;
  93624. /** Indicates that this connection point needs dual validation before being connected to another point */
  93625. needDualDirectionValidation: boolean;
  93626. /**
  93627. * Gets or sets the additional types supported by this connection point
  93628. */
  93629. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93630. /**
  93631. * Gets or sets the additional types excluded by this connection point
  93632. */
  93633. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93634. /**
  93635. * Observable triggered when this point is connected
  93636. */
  93637. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93638. /**
  93639. * Gets or sets the associated variable name in the shader
  93640. */
  93641. get associatedVariableName(): string;
  93642. set associatedVariableName(value: string);
  93643. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93644. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93645. /**
  93646. * Gets or sets the connection point type (default is float)
  93647. */
  93648. get type(): NodeMaterialBlockConnectionPointTypes;
  93649. set type(value: NodeMaterialBlockConnectionPointTypes);
  93650. /**
  93651. * Gets or sets the connection point name
  93652. */
  93653. name: string;
  93654. /**
  93655. * Gets or sets the connection point name
  93656. */
  93657. displayName: string;
  93658. /**
  93659. * Gets or sets a boolean indicating that this connection point can be omitted
  93660. */
  93661. isOptional: boolean;
  93662. /**
  93663. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93664. */
  93665. isExposedOnFrame: boolean;
  93666. /**
  93667. * Gets or sets number indicating the position that the port is exposed to on a frame
  93668. */
  93669. exposedPortPosition: number;
  93670. /**
  93671. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93672. */
  93673. define: string;
  93674. /** @hidden */
  93675. _prioritizeVertex: boolean;
  93676. private _target;
  93677. /** Gets or sets the target of that connection point */
  93678. get target(): NodeMaterialBlockTargets;
  93679. set target(value: NodeMaterialBlockTargets);
  93680. /**
  93681. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93682. */
  93683. get isConnected(): boolean;
  93684. /**
  93685. * Gets a boolean indicating that the current point is connected to an input block
  93686. */
  93687. get isConnectedToInputBlock(): boolean;
  93688. /**
  93689. * Gets a the connected input block (if any)
  93690. */
  93691. get connectInputBlock(): Nullable<InputBlock>;
  93692. /** Get the other side of the connection (if any) */
  93693. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93694. /** Get the block that owns this connection point */
  93695. get ownerBlock(): NodeMaterialBlock;
  93696. /** Get the block connected on the other side of this connection (if any) */
  93697. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93698. /** Get the block connected on the endpoints of this connection (if any) */
  93699. get connectedBlocks(): Array<NodeMaterialBlock>;
  93700. /** Gets the list of connected endpoints */
  93701. get endpoints(): NodeMaterialConnectionPoint[];
  93702. /** Gets a boolean indicating if that output point is connected to at least one input */
  93703. get hasEndpoints(): boolean;
  93704. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93705. get isConnectedInVertexShader(): boolean;
  93706. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93707. get isConnectedInFragmentShader(): boolean;
  93708. /**
  93709. * Creates a block suitable to be used as an input for this input point.
  93710. * If null is returned, a block based on the point type will be created.
  93711. * @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
  93712. */
  93713. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93714. /**
  93715. * Creates a new connection point
  93716. * @param name defines the connection point name
  93717. * @param ownerBlock defines the block hosting this connection point
  93718. * @param direction defines the direction of the connection point
  93719. */
  93720. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93721. /**
  93722. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93723. * @returns the class name
  93724. */
  93725. getClassName(): string;
  93726. /**
  93727. * Gets a boolean indicating if the current point can be connected to another point
  93728. * @param connectionPoint defines the other connection point
  93729. * @returns a boolean
  93730. */
  93731. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93732. /**
  93733. * Gets a number indicating if the current point can be connected to another point
  93734. * @param connectionPoint defines the other connection point
  93735. * @returns a number defining the compatibility state
  93736. */
  93737. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93738. /**
  93739. * Connect this point to another connection point
  93740. * @param connectionPoint defines the other connection point
  93741. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93742. * @returns the current connection point
  93743. */
  93744. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93745. /**
  93746. * Disconnect this point from one of his endpoint
  93747. * @param endpoint defines the other connection point
  93748. * @returns the current connection point
  93749. */
  93750. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93751. /**
  93752. * Serializes this point in a JSON representation
  93753. * @param isInput defines if the connection point is an input (default is true)
  93754. * @returns the serialized point object
  93755. */
  93756. serialize(isInput?: boolean): any;
  93757. /**
  93758. * Release resources
  93759. */
  93760. dispose(): void;
  93761. }
  93762. }
  93763. declare module BABYLON {
  93764. /**
  93765. * Enum used to define the material modes
  93766. */
  93767. export enum NodeMaterialModes {
  93768. /** Regular material */
  93769. Material = 0,
  93770. /** For post process */
  93771. PostProcess = 1,
  93772. /** For particle system */
  93773. Particle = 2,
  93774. /** For procedural texture */
  93775. ProceduralTexture = 3
  93776. }
  93777. }
  93778. declare module BABYLON {
  93779. /** @hidden */
  93780. export var helperFunctions: {
  93781. name: string;
  93782. shader: string;
  93783. };
  93784. }
  93785. declare module BABYLON {
  93786. /**
  93787. * Block used to read a texture from a sampler
  93788. */
  93789. export class TextureBlock extends NodeMaterialBlock {
  93790. private _defineName;
  93791. private _linearDefineName;
  93792. private _gammaDefineName;
  93793. private _tempTextureRead;
  93794. private _samplerName;
  93795. private _transformedUVName;
  93796. private _textureTransformName;
  93797. private _textureInfoName;
  93798. private _mainUVName;
  93799. private _mainUVDefineName;
  93800. private _fragmentOnly;
  93801. /**
  93802. * Gets or sets the texture associated with the node
  93803. */
  93804. texture: Nullable<Texture>;
  93805. /**
  93806. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93807. */
  93808. convertToGammaSpace: boolean;
  93809. /**
  93810. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93811. */
  93812. convertToLinearSpace: boolean;
  93813. /**
  93814. * Create a new TextureBlock
  93815. * @param name defines the block name
  93816. */
  93817. constructor(name: string, fragmentOnly?: boolean);
  93818. /**
  93819. * Gets the current class name
  93820. * @returns the class name
  93821. */
  93822. getClassName(): string;
  93823. /**
  93824. * Gets the uv input component
  93825. */
  93826. get uv(): NodeMaterialConnectionPoint;
  93827. /**
  93828. * Gets the rgba output component
  93829. */
  93830. get rgba(): NodeMaterialConnectionPoint;
  93831. /**
  93832. * Gets the rgb output component
  93833. */
  93834. get rgb(): NodeMaterialConnectionPoint;
  93835. /**
  93836. * Gets the r output component
  93837. */
  93838. get r(): NodeMaterialConnectionPoint;
  93839. /**
  93840. * Gets the g output component
  93841. */
  93842. get g(): NodeMaterialConnectionPoint;
  93843. /**
  93844. * Gets the b output component
  93845. */
  93846. get b(): NodeMaterialConnectionPoint;
  93847. /**
  93848. * Gets the a output component
  93849. */
  93850. get a(): NodeMaterialConnectionPoint;
  93851. get target(): NodeMaterialBlockTargets;
  93852. autoConfigure(material: NodeMaterial): void;
  93853. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93855. isReady(): boolean;
  93856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93857. private get _isMixed();
  93858. private _injectVertexCode;
  93859. private _writeTextureRead;
  93860. private _writeOutput;
  93861. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93862. protected _dumpPropertiesCode(): string;
  93863. serialize(): any;
  93864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93865. }
  93866. }
  93867. declare module BABYLON {
  93868. /** @hidden */
  93869. export var reflectionFunction: {
  93870. name: string;
  93871. shader: string;
  93872. };
  93873. }
  93874. declare module BABYLON {
  93875. /**
  93876. * Base block used to read a reflection texture from a sampler
  93877. */
  93878. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93879. /** @hidden */
  93880. _define3DName: string;
  93881. /** @hidden */
  93882. _defineCubicName: string;
  93883. /** @hidden */
  93884. _defineExplicitName: string;
  93885. /** @hidden */
  93886. _defineProjectionName: string;
  93887. /** @hidden */
  93888. _defineLocalCubicName: string;
  93889. /** @hidden */
  93890. _defineSphericalName: string;
  93891. /** @hidden */
  93892. _definePlanarName: string;
  93893. /** @hidden */
  93894. _defineEquirectangularName: string;
  93895. /** @hidden */
  93896. _defineMirroredEquirectangularFixedName: string;
  93897. /** @hidden */
  93898. _defineEquirectangularFixedName: string;
  93899. /** @hidden */
  93900. _defineSkyboxName: string;
  93901. /** @hidden */
  93902. _defineOppositeZ: string;
  93903. /** @hidden */
  93904. _cubeSamplerName: string;
  93905. /** @hidden */
  93906. _2DSamplerName: string;
  93907. protected _positionUVWName: string;
  93908. protected _directionWName: string;
  93909. protected _reflectionVectorName: string;
  93910. /** @hidden */
  93911. _reflectionCoordsName: string;
  93912. /** @hidden */
  93913. _reflectionMatrixName: string;
  93914. protected _reflectionColorName: string;
  93915. /**
  93916. * Gets or sets the texture associated with the node
  93917. */
  93918. texture: Nullable<BaseTexture>;
  93919. /**
  93920. * Create a new ReflectionTextureBaseBlock
  93921. * @param name defines the block name
  93922. */
  93923. constructor(name: string);
  93924. /**
  93925. * Gets the current class name
  93926. * @returns the class name
  93927. */
  93928. getClassName(): string;
  93929. /**
  93930. * Gets the world position input component
  93931. */
  93932. abstract get position(): NodeMaterialConnectionPoint;
  93933. /**
  93934. * Gets the world position input component
  93935. */
  93936. abstract get worldPosition(): NodeMaterialConnectionPoint;
  93937. /**
  93938. * Gets the world normal input component
  93939. */
  93940. abstract get worldNormal(): NodeMaterialConnectionPoint;
  93941. /**
  93942. * Gets the world input component
  93943. */
  93944. abstract get world(): NodeMaterialConnectionPoint;
  93945. /**
  93946. * Gets the camera (or eye) position component
  93947. */
  93948. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  93949. /**
  93950. * Gets the view input component
  93951. */
  93952. abstract get view(): NodeMaterialConnectionPoint;
  93953. protected _getTexture(): Nullable<BaseTexture>;
  93954. autoConfigure(material: NodeMaterial): void;
  93955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93956. isReady(): boolean;
  93957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93958. /**
  93959. * Gets the code to inject in the vertex shader
  93960. * @param state current state of the node material building
  93961. * @returns the shader code
  93962. */
  93963. handleVertexSide(state: NodeMaterialBuildState): string;
  93964. /**
  93965. * Handles the inits for the fragment code path
  93966. * @param state node material build state
  93967. */
  93968. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  93969. /**
  93970. * Generates the reflection coords code for the fragment code path
  93971. * @param worldNormalVarName name of the world normal variable
  93972. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  93973. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  93974. * @returns the shader code
  93975. */
  93976. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  93977. /**
  93978. * Generates the reflection color code for the fragment code path
  93979. * @param lodVarName name of the lod variable
  93980. * @param swizzleLookupTexture swizzle to use for the final color variable
  93981. * @returns the shader code
  93982. */
  93983. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  93984. /**
  93985. * Generates the code corresponding to the connected output points
  93986. * @param state node material build state
  93987. * @param varName name of the variable to output
  93988. * @returns the shader code
  93989. */
  93990. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  93991. protected _buildBlock(state: NodeMaterialBuildState): this;
  93992. protected _dumpPropertiesCode(): string;
  93993. serialize(): any;
  93994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93995. }
  93996. }
  93997. declare module BABYLON {
  93998. /**
  93999. * Defines a connection point to be used for points with a custom object type
  94000. */
  94001. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  94002. private _blockType;
  94003. private _blockName;
  94004. private _nameForCheking?;
  94005. /**
  94006. * Creates a new connection point
  94007. * @param name defines the connection point name
  94008. * @param ownerBlock defines the block hosting this connection point
  94009. * @param direction defines the direction of the connection point
  94010. */
  94011. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  94012. /**
  94013. * Gets a number indicating if the current point can be connected to another point
  94014. * @param connectionPoint defines the other connection point
  94015. * @returns a number defining the compatibility state
  94016. */
  94017. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  94018. /**
  94019. * Creates a block suitable to be used as an input for this input point.
  94020. * If null is returned, a block based on the point type will be created.
  94021. * @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
  94022. */
  94023. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  94024. }
  94025. }
  94026. declare module BABYLON {
  94027. /**
  94028. * Enum defining the type of properties that can be edited in the property pages in the NME
  94029. */
  94030. export enum PropertyTypeForEdition {
  94031. /** property is a boolean */
  94032. Boolean = 0,
  94033. /** property is a float */
  94034. Float = 1,
  94035. /** property is a Vector2 */
  94036. Vector2 = 2,
  94037. /** property is a list of values */
  94038. List = 3
  94039. }
  94040. /**
  94041. * Interface that defines an option in a variable of type list
  94042. */
  94043. export interface IEditablePropertyListOption {
  94044. /** label of the option */
  94045. "label": string;
  94046. /** value of the option */
  94047. "value": number;
  94048. }
  94049. /**
  94050. * Interface that defines the options available for an editable property
  94051. */
  94052. export interface IEditablePropertyOption {
  94053. /** min value */
  94054. "min"?: number;
  94055. /** max value */
  94056. "max"?: number;
  94057. /** notifiers: indicates which actions to take when the property is changed */
  94058. "notifiers"?: {
  94059. /** the material should be rebuilt */
  94060. "rebuild"?: boolean;
  94061. /** the preview should be updated */
  94062. "update"?: boolean;
  94063. };
  94064. /** list of the options for a variable of type list */
  94065. "options"?: IEditablePropertyListOption[];
  94066. }
  94067. /**
  94068. * Interface that describes an editable property
  94069. */
  94070. export interface IPropertyDescriptionForEdition {
  94071. /** name of the property */
  94072. "propertyName": string;
  94073. /** display name of the property */
  94074. "displayName": string;
  94075. /** type of the property */
  94076. "type": PropertyTypeForEdition;
  94077. /** group of the property - all properties with the same group value will be displayed in a specific section */
  94078. "groupName": string;
  94079. /** options for the property */
  94080. "options": IEditablePropertyOption;
  94081. }
  94082. /**
  94083. * Decorator that flags a property in a node material block as being editable
  94084. */
  94085. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  94086. }
  94087. declare module BABYLON {
  94088. /**
  94089. * Block used to implement the refraction part of the sub surface module of the PBR material
  94090. */
  94091. export class RefractionBlock extends NodeMaterialBlock {
  94092. /** @hidden */
  94093. _define3DName: string;
  94094. /** @hidden */
  94095. _refractionMatrixName: string;
  94096. /** @hidden */
  94097. _defineLODRefractionAlpha: string;
  94098. /** @hidden */
  94099. _defineLinearSpecularRefraction: string;
  94100. /** @hidden */
  94101. _defineOppositeZ: string;
  94102. /** @hidden */
  94103. _cubeSamplerName: string;
  94104. /** @hidden */
  94105. _2DSamplerName: string;
  94106. /** @hidden */
  94107. _vRefractionMicrosurfaceInfosName: string;
  94108. /** @hidden */
  94109. _vRefractionInfosName: string;
  94110. /** @hidden */
  94111. _vRefractionFilteringInfoName: string;
  94112. private _scene;
  94113. /**
  94114. * The properties below are set by the main PBR block prior to calling methods of this class.
  94115. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  94116. * It's less burden on the user side in the editor part.
  94117. */
  94118. /** @hidden */
  94119. viewConnectionPoint: NodeMaterialConnectionPoint;
  94120. /** @hidden */
  94121. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  94122. /**
  94123. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  94124. * Materials half opaque for instance using refraction could benefit from this control.
  94125. */
  94126. linkRefractionWithTransparency: boolean;
  94127. /**
  94128. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  94129. */
  94130. invertRefractionY: boolean;
  94131. /**
  94132. * Gets or sets the texture associated with the node
  94133. */
  94134. texture: Nullable<BaseTexture>;
  94135. /**
  94136. * Create a new RefractionBlock
  94137. * @param name defines the block name
  94138. */
  94139. constructor(name: string);
  94140. /**
  94141. * Gets the current class name
  94142. * @returns the class name
  94143. */
  94144. getClassName(): string;
  94145. /**
  94146. * Gets the intensity input component
  94147. */
  94148. get intensity(): NodeMaterialConnectionPoint;
  94149. /**
  94150. * Gets the tint at distance input component
  94151. */
  94152. get tintAtDistance(): NodeMaterialConnectionPoint;
  94153. /**
  94154. * Gets the view input component
  94155. */
  94156. get view(): NodeMaterialConnectionPoint;
  94157. /**
  94158. * Gets the refraction object output component
  94159. */
  94160. get refraction(): NodeMaterialConnectionPoint;
  94161. /**
  94162. * Returns true if the block has a texture
  94163. */
  94164. get hasTexture(): boolean;
  94165. protected _getTexture(): Nullable<BaseTexture>;
  94166. autoConfigure(material: NodeMaterial): void;
  94167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94168. isReady(): boolean;
  94169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94170. /**
  94171. * Gets the main code of the block (fragment side)
  94172. * @param state current state of the node material building
  94173. * @returns the shader code
  94174. */
  94175. getCode(state: NodeMaterialBuildState): string;
  94176. protected _buildBlock(state: NodeMaterialBuildState): this;
  94177. protected _dumpPropertiesCode(): string;
  94178. serialize(): any;
  94179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94180. }
  94181. }
  94182. declare module BABYLON {
  94183. /**
  94184. * Base block used as input for post process
  94185. */
  94186. export class CurrentScreenBlock extends NodeMaterialBlock {
  94187. private _samplerName;
  94188. private _linearDefineName;
  94189. private _gammaDefineName;
  94190. private _mainUVName;
  94191. private _tempTextureRead;
  94192. /**
  94193. * Gets or sets the texture associated with the node
  94194. */
  94195. texture: Nullable<BaseTexture>;
  94196. /**
  94197. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94198. */
  94199. convertToGammaSpace: boolean;
  94200. /**
  94201. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94202. */
  94203. convertToLinearSpace: boolean;
  94204. /**
  94205. * Create a new CurrentScreenBlock
  94206. * @param name defines the block name
  94207. */
  94208. constructor(name: string);
  94209. /**
  94210. * Gets the current class name
  94211. * @returns the class name
  94212. */
  94213. getClassName(): string;
  94214. /**
  94215. * Gets the uv input component
  94216. */
  94217. get uv(): NodeMaterialConnectionPoint;
  94218. /**
  94219. * Gets the rgba output component
  94220. */
  94221. get rgba(): NodeMaterialConnectionPoint;
  94222. /**
  94223. * Gets the rgb output component
  94224. */
  94225. get rgb(): NodeMaterialConnectionPoint;
  94226. /**
  94227. * Gets the r output component
  94228. */
  94229. get r(): NodeMaterialConnectionPoint;
  94230. /**
  94231. * Gets the g output component
  94232. */
  94233. get g(): NodeMaterialConnectionPoint;
  94234. /**
  94235. * Gets the b output component
  94236. */
  94237. get b(): NodeMaterialConnectionPoint;
  94238. /**
  94239. * Gets the a output component
  94240. */
  94241. get a(): NodeMaterialConnectionPoint;
  94242. /**
  94243. * Initialize the block and prepare the context for build
  94244. * @param state defines the state that will be used for the build
  94245. */
  94246. initialize(state: NodeMaterialBuildState): void;
  94247. get target(): NodeMaterialBlockTargets;
  94248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94249. isReady(): boolean;
  94250. private _injectVertexCode;
  94251. private _writeTextureRead;
  94252. private _writeOutput;
  94253. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94254. serialize(): any;
  94255. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94256. }
  94257. }
  94258. declare module BABYLON {
  94259. /**
  94260. * Base block used for the particle texture
  94261. */
  94262. export class ParticleTextureBlock extends NodeMaterialBlock {
  94263. private _samplerName;
  94264. private _linearDefineName;
  94265. private _gammaDefineName;
  94266. private _tempTextureRead;
  94267. /**
  94268. * Gets or sets the texture associated with the node
  94269. */
  94270. texture: Nullable<BaseTexture>;
  94271. /**
  94272. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94273. */
  94274. convertToGammaSpace: boolean;
  94275. /**
  94276. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94277. */
  94278. convertToLinearSpace: boolean;
  94279. /**
  94280. * Create a new ParticleTextureBlock
  94281. * @param name defines the block name
  94282. */
  94283. constructor(name: string);
  94284. /**
  94285. * Gets the current class name
  94286. * @returns the class name
  94287. */
  94288. getClassName(): string;
  94289. /**
  94290. * Gets the uv input component
  94291. */
  94292. get uv(): NodeMaterialConnectionPoint;
  94293. /**
  94294. * Gets the rgba output component
  94295. */
  94296. get rgba(): NodeMaterialConnectionPoint;
  94297. /**
  94298. * Gets the rgb output component
  94299. */
  94300. get rgb(): NodeMaterialConnectionPoint;
  94301. /**
  94302. * Gets the r output component
  94303. */
  94304. get r(): NodeMaterialConnectionPoint;
  94305. /**
  94306. * Gets the g output component
  94307. */
  94308. get g(): NodeMaterialConnectionPoint;
  94309. /**
  94310. * Gets the b output component
  94311. */
  94312. get b(): NodeMaterialConnectionPoint;
  94313. /**
  94314. * Gets the a output component
  94315. */
  94316. get a(): NodeMaterialConnectionPoint;
  94317. /**
  94318. * Initialize the block and prepare the context for build
  94319. * @param state defines the state that will be used for the build
  94320. */
  94321. initialize(state: NodeMaterialBuildState): void;
  94322. autoConfigure(material: NodeMaterial): void;
  94323. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94324. isReady(): boolean;
  94325. private _writeOutput;
  94326. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94327. serialize(): any;
  94328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94329. }
  94330. }
  94331. declare module BABYLON {
  94332. /**
  94333. * Class used to store shared data between 2 NodeMaterialBuildState
  94334. */
  94335. export class NodeMaterialBuildStateSharedData {
  94336. /**
  94337. * Gets the list of emitted varyings
  94338. */
  94339. temps: string[];
  94340. /**
  94341. * Gets the list of emitted varyings
  94342. */
  94343. varyings: string[];
  94344. /**
  94345. * Gets the varying declaration string
  94346. */
  94347. varyingDeclaration: string;
  94348. /**
  94349. * Input blocks
  94350. */
  94351. inputBlocks: InputBlock[];
  94352. /**
  94353. * Input blocks
  94354. */
  94355. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94356. /**
  94357. * Bindable blocks (Blocks that need to set data to the effect)
  94358. */
  94359. bindableBlocks: NodeMaterialBlock[];
  94360. /**
  94361. * List of blocks that can provide a compilation fallback
  94362. */
  94363. blocksWithFallbacks: NodeMaterialBlock[];
  94364. /**
  94365. * List of blocks that can provide a define update
  94366. */
  94367. blocksWithDefines: NodeMaterialBlock[];
  94368. /**
  94369. * List of blocks that can provide a repeatable content
  94370. */
  94371. repeatableContentBlocks: NodeMaterialBlock[];
  94372. /**
  94373. * List of blocks that can provide a dynamic list of uniforms
  94374. */
  94375. dynamicUniformBlocks: NodeMaterialBlock[];
  94376. /**
  94377. * List of blocks that can block the isReady function for the material
  94378. */
  94379. blockingBlocks: NodeMaterialBlock[];
  94380. /**
  94381. * Gets the list of animated inputs
  94382. */
  94383. animatedInputs: InputBlock[];
  94384. /**
  94385. * Build Id used to avoid multiple recompilations
  94386. */
  94387. buildId: number;
  94388. /** List of emitted variables */
  94389. variableNames: {
  94390. [key: string]: number;
  94391. };
  94392. /** List of emitted defines */
  94393. defineNames: {
  94394. [key: string]: number;
  94395. };
  94396. /** Should emit comments? */
  94397. emitComments: boolean;
  94398. /** Emit build activity */
  94399. verbose: boolean;
  94400. /** Gets or sets the hosting scene */
  94401. scene: Scene;
  94402. /**
  94403. * Gets the compilation hints emitted at compilation time
  94404. */
  94405. hints: {
  94406. needWorldViewMatrix: boolean;
  94407. needWorldViewProjectionMatrix: boolean;
  94408. needAlphaBlending: boolean;
  94409. needAlphaTesting: boolean;
  94410. };
  94411. /**
  94412. * List of compilation checks
  94413. */
  94414. checks: {
  94415. emitVertex: boolean;
  94416. emitFragment: boolean;
  94417. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94418. };
  94419. /**
  94420. * Is vertex program allowed to be empty?
  94421. */
  94422. allowEmptyVertexProgram: boolean;
  94423. /** Creates a new shared data */
  94424. constructor();
  94425. /**
  94426. * Emits console errors and exceptions if there is a failing check
  94427. */
  94428. emitErrors(): void;
  94429. }
  94430. }
  94431. declare module BABYLON {
  94432. /**
  94433. * Class used to store node based material build state
  94434. */
  94435. export class NodeMaterialBuildState {
  94436. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94437. supportUniformBuffers: boolean;
  94438. /**
  94439. * Gets the list of emitted attributes
  94440. */
  94441. attributes: string[];
  94442. /**
  94443. * Gets the list of emitted uniforms
  94444. */
  94445. uniforms: string[];
  94446. /**
  94447. * Gets the list of emitted constants
  94448. */
  94449. constants: string[];
  94450. /**
  94451. * Gets the list of emitted samplers
  94452. */
  94453. samplers: string[];
  94454. /**
  94455. * Gets the list of emitted functions
  94456. */
  94457. functions: {
  94458. [key: string]: string;
  94459. };
  94460. /**
  94461. * Gets the list of emitted extensions
  94462. */
  94463. extensions: {
  94464. [key: string]: string;
  94465. };
  94466. /**
  94467. * Gets the target of the compilation state
  94468. */
  94469. target: NodeMaterialBlockTargets;
  94470. /**
  94471. * Gets the list of emitted counters
  94472. */
  94473. counters: {
  94474. [key: string]: number;
  94475. };
  94476. /**
  94477. * Shared data between multiple NodeMaterialBuildState instances
  94478. */
  94479. sharedData: NodeMaterialBuildStateSharedData;
  94480. /** @hidden */
  94481. _vertexState: NodeMaterialBuildState;
  94482. /** @hidden */
  94483. _attributeDeclaration: string;
  94484. /** @hidden */
  94485. _uniformDeclaration: string;
  94486. /** @hidden */
  94487. _constantDeclaration: string;
  94488. /** @hidden */
  94489. _samplerDeclaration: string;
  94490. /** @hidden */
  94491. _varyingTransfer: string;
  94492. /** @hidden */
  94493. _injectAtEnd: string;
  94494. private _repeatableContentAnchorIndex;
  94495. /** @hidden */
  94496. _builtCompilationString: string;
  94497. /**
  94498. * Gets the emitted compilation strings
  94499. */
  94500. compilationString: string;
  94501. /**
  94502. * Finalize the compilation strings
  94503. * @param state defines the current compilation state
  94504. */
  94505. finalize(state: NodeMaterialBuildState): void;
  94506. /** @hidden */
  94507. get _repeatableContentAnchor(): string;
  94508. /** @hidden */
  94509. _getFreeVariableName(prefix: string): string;
  94510. /** @hidden */
  94511. _getFreeDefineName(prefix: string): string;
  94512. /** @hidden */
  94513. _excludeVariableName(name: string): void;
  94514. /** @hidden */
  94515. _emit2DSampler(name: string): void;
  94516. /** @hidden */
  94517. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94518. /** @hidden */
  94519. _emitExtension(name: string, extension: string, define?: string): void;
  94520. /** @hidden */
  94521. _emitFunction(name: string, code: string, comments: string): void;
  94522. /** @hidden */
  94523. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94524. replaceStrings?: {
  94525. search: RegExp;
  94526. replace: string;
  94527. }[];
  94528. repeatKey?: string;
  94529. }): string;
  94530. /** @hidden */
  94531. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94532. repeatKey?: string;
  94533. removeAttributes?: boolean;
  94534. removeUniforms?: boolean;
  94535. removeVaryings?: boolean;
  94536. removeIfDef?: boolean;
  94537. replaceStrings?: {
  94538. search: RegExp;
  94539. replace: string;
  94540. }[];
  94541. }, storeKey?: string): void;
  94542. /** @hidden */
  94543. _registerTempVariable(name: string): boolean;
  94544. /** @hidden */
  94545. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94546. /** @hidden */
  94547. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94548. /** @hidden */
  94549. _emitFloat(value: number): string;
  94550. }
  94551. }
  94552. declare module BABYLON {
  94553. /**
  94554. * Helper class used to generate session unique ID
  94555. */
  94556. export class UniqueIdGenerator {
  94557. private static _UniqueIdCounter;
  94558. /**
  94559. * Gets an unique (relatively to the current scene) Id
  94560. */
  94561. static get UniqueId(): number;
  94562. }
  94563. }
  94564. declare module BABYLON {
  94565. /**
  94566. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94567. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94568. */
  94569. export class EffectFallbacks implements IEffectFallbacks {
  94570. private _defines;
  94571. private _currentRank;
  94572. private _maxRank;
  94573. private _mesh;
  94574. /**
  94575. * Removes the fallback from the bound mesh.
  94576. */
  94577. unBindMesh(): void;
  94578. /**
  94579. * Adds a fallback on the specified property.
  94580. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94581. * @param define The name of the define in the shader
  94582. */
  94583. addFallback(rank: number, define: string): void;
  94584. /**
  94585. * Sets the mesh to use CPU skinning when needing to fallback.
  94586. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94587. * @param mesh The mesh to use the fallbacks.
  94588. */
  94589. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94590. /**
  94591. * Checks to see if more fallbacks are still availible.
  94592. */
  94593. get hasMoreFallbacks(): boolean;
  94594. /**
  94595. * Removes the defines that should be removed when falling back.
  94596. * @param currentDefines defines the current define statements for the shader.
  94597. * @param effect defines the current effect we try to compile
  94598. * @returns The resulting defines with defines of the current rank removed.
  94599. */
  94600. reduce(currentDefines: string, effect: Effect): string;
  94601. }
  94602. }
  94603. declare module BABYLON {
  94604. /**
  94605. * Defines a block that can be used inside a node based material
  94606. */
  94607. export class NodeMaterialBlock {
  94608. private _buildId;
  94609. private _buildTarget;
  94610. private _target;
  94611. private _isFinalMerger;
  94612. private _isInput;
  94613. private _name;
  94614. protected _isUnique: boolean;
  94615. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94616. inputsAreExclusive: boolean;
  94617. /** @hidden */
  94618. _codeVariableName: string;
  94619. /** @hidden */
  94620. _inputs: NodeMaterialConnectionPoint[];
  94621. /** @hidden */
  94622. _outputs: NodeMaterialConnectionPoint[];
  94623. /** @hidden */
  94624. _preparationId: number;
  94625. /**
  94626. * Gets the name of the block
  94627. */
  94628. get name(): string;
  94629. /**
  94630. * Sets the name of the block. Will check if the name is valid.
  94631. */
  94632. set name(newName: string);
  94633. /**
  94634. * Gets or sets the unique id of the node
  94635. */
  94636. uniqueId: number;
  94637. /**
  94638. * Gets or sets the comments associated with this block
  94639. */
  94640. comments: string;
  94641. /**
  94642. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94643. */
  94644. get isUnique(): boolean;
  94645. /**
  94646. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94647. */
  94648. get isFinalMerger(): boolean;
  94649. /**
  94650. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94651. */
  94652. get isInput(): boolean;
  94653. /**
  94654. * Gets or sets the build Id
  94655. */
  94656. get buildId(): number;
  94657. set buildId(value: number);
  94658. /**
  94659. * Gets or sets the target of the block
  94660. */
  94661. get target(): NodeMaterialBlockTargets;
  94662. set target(value: NodeMaterialBlockTargets);
  94663. /**
  94664. * Gets the list of input points
  94665. */
  94666. get inputs(): NodeMaterialConnectionPoint[];
  94667. /** Gets the list of output points */
  94668. get outputs(): NodeMaterialConnectionPoint[];
  94669. /**
  94670. * Find an input by its name
  94671. * @param name defines the name of the input to look for
  94672. * @returns the input or null if not found
  94673. */
  94674. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94675. /**
  94676. * Find an output by its name
  94677. * @param name defines the name of the outputto look for
  94678. * @returns the output or null if not found
  94679. */
  94680. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94681. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94682. visibleInInspector: boolean;
  94683. /**
  94684. * Creates a new NodeMaterialBlock
  94685. * @param name defines the block name
  94686. * @param target defines the target of that block (Vertex by default)
  94687. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94688. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94689. */
  94690. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94691. /**
  94692. * Initialize the block and prepare the context for build
  94693. * @param state defines the state that will be used for the build
  94694. */
  94695. initialize(state: NodeMaterialBuildState): void;
  94696. /**
  94697. * Bind data to effect. Will only be called for blocks with isBindable === true
  94698. * @param effect defines the effect to bind data to
  94699. * @param nodeMaterial defines the hosting NodeMaterial
  94700. * @param mesh defines the mesh that will be rendered
  94701. * @param subMesh defines the submesh that will be rendered
  94702. */
  94703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94704. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94705. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94706. protected _writeFloat(value: number): string;
  94707. /**
  94708. * Gets the current class name e.g. "NodeMaterialBlock"
  94709. * @returns the class name
  94710. */
  94711. getClassName(): string;
  94712. /**
  94713. * Register a new input. Must be called inside a block constructor
  94714. * @param name defines the connection point name
  94715. * @param type defines the connection point type
  94716. * @param isOptional defines a boolean indicating that this input can be omitted
  94717. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94718. * @param point an already created connection point. If not provided, create a new one
  94719. * @returns the current block
  94720. */
  94721. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94722. /**
  94723. * Register a new output. Must be called inside a block constructor
  94724. * @param name defines the connection point name
  94725. * @param type defines the connection point type
  94726. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94727. * @param point an already created connection point. If not provided, create a new one
  94728. * @returns the current block
  94729. */
  94730. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94731. /**
  94732. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94733. * @param forOutput defines an optional connection point to check compatibility with
  94734. * @returns the first available input or null
  94735. */
  94736. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94737. /**
  94738. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94739. * @param forBlock defines an optional block to check compatibility with
  94740. * @returns the first available input or null
  94741. */
  94742. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94743. /**
  94744. * Gets the sibling of the given output
  94745. * @param current defines the current output
  94746. * @returns the next output in the list or null
  94747. */
  94748. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94749. /**
  94750. * Connect current block with another block
  94751. * @param other defines the block to connect with
  94752. * @param options define the various options to help pick the right connections
  94753. * @returns the current block
  94754. */
  94755. connectTo(other: NodeMaterialBlock, options?: {
  94756. input?: string;
  94757. output?: string;
  94758. outputSwizzle?: string;
  94759. }): this | undefined;
  94760. protected _buildBlock(state: NodeMaterialBuildState): void;
  94761. /**
  94762. * Add uniforms, samplers and uniform buffers at compilation time
  94763. * @param state defines the state to update
  94764. * @param nodeMaterial defines the node material requesting the update
  94765. * @param defines defines the material defines to update
  94766. * @param uniformBuffers defines the list of uniform buffer names
  94767. */
  94768. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94769. /**
  94770. * Add potential fallbacks if shader compilation fails
  94771. * @param mesh defines the mesh to be rendered
  94772. * @param fallbacks defines the current prioritized list of fallbacks
  94773. */
  94774. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94775. /**
  94776. * Initialize defines for shader compilation
  94777. * @param mesh defines the mesh to be rendered
  94778. * @param nodeMaterial defines the node material requesting the update
  94779. * @param defines defines the material defines to update
  94780. * @param useInstances specifies that instances should be used
  94781. */
  94782. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94783. /**
  94784. * Update defines for shader compilation
  94785. * @param mesh defines the mesh to be rendered
  94786. * @param nodeMaterial defines the node material requesting the update
  94787. * @param defines defines the material defines to update
  94788. * @param useInstances specifies that instances should be used
  94789. * @param subMesh defines which submesh to render
  94790. */
  94791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94792. /**
  94793. * Lets the block try to connect some inputs automatically
  94794. * @param material defines the hosting NodeMaterial
  94795. */
  94796. autoConfigure(material: NodeMaterial): void;
  94797. /**
  94798. * Function called when a block is declared as repeatable content generator
  94799. * @param vertexShaderState defines the current compilation state for the vertex shader
  94800. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94801. * @param mesh defines the mesh to be rendered
  94802. * @param defines defines the material defines to update
  94803. */
  94804. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94805. /**
  94806. * Checks if the block is ready
  94807. * @param mesh defines the mesh to be rendered
  94808. * @param nodeMaterial defines the node material requesting the update
  94809. * @param defines defines the material defines to update
  94810. * @param useInstances specifies that instances should be used
  94811. * @returns true if the block is ready
  94812. */
  94813. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94814. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94815. private _processBuild;
  94816. /**
  94817. * Validates the new name for the block node.
  94818. * @param newName the new name to be given to the node.
  94819. * @returns false if the name is a reserve word, else true.
  94820. */
  94821. validateBlockName(newName: string): boolean;
  94822. /**
  94823. * Compile the current node and generate the shader code
  94824. * @param state defines the current compilation state (uniforms, samplers, current string)
  94825. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94826. * @returns true if already built
  94827. */
  94828. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94829. protected _inputRename(name: string): string;
  94830. protected _outputRename(name: string): string;
  94831. protected _dumpPropertiesCode(): string;
  94832. /** @hidden */
  94833. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94834. /** @hidden */
  94835. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94836. /**
  94837. * Clone the current block to a new identical block
  94838. * @param scene defines the hosting scene
  94839. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94840. * @returns a copy of the current block
  94841. */
  94842. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94843. /**
  94844. * Serializes this block in a JSON representation
  94845. * @returns the serialized block object
  94846. */
  94847. serialize(): any;
  94848. /** @hidden */
  94849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94850. private _deserializePortDisplayNamesAndExposedOnFrame;
  94851. /**
  94852. * Release resources
  94853. */
  94854. dispose(): void;
  94855. }
  94856. }
  94857. declare module BABYLON {
  94858. /**
  94859. * Base class of materials working in push mode in babylon JS
  94860. * @hidden
  94861. */
  94862. export class PushMaterial extends Material {
  94863. protected _activeEffect: Effect;
  94864. protected _normalMatrix: Matrix;
  94865. constructor(name: string, scene: Scene);
  94866. getEffect(): Effect;
  94867. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94868. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94869. /**
  94870. * Binds the given world matrix to the active effect
  94871. *
  94872. * @param world the matrix to bind
  94873. */
  94874. bindOnlyWorldMatrix(world: Matrix): void;
  94875. /**
  94876. * Binds the given normal matrix to the active effect
  94877. *
  94878. * @param normalMatrix the matrix to bind
  94879. */
  94880. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94881. bind(world: Matrix, mesh?: Mesh): void;
  94882. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94883. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94884. }
  94885. }
  94886. declare module BABYLON {
  94887. /**
  94888. * Root class for all node material optimizers
  94889. */
  94890. export class NodeMaterialOptimizer {
  94891. /**
  94892. * Function used to optimize a NodeMaterial graph
  94893. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94894. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94895. */
  94896. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94897. }
  94898. }
  94899. declare module BABYLON {
  94900. /**
  94901. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94902. */
  94903. export class TransformBlock extends NodeMaterialBlock {
  94904. /**
  94905. * Defines the value to use to complement W value to transform it to a Vector4
  94906. */
  94907. complementW: number;
  94908. /**
  94909. * Defines the value to use to complement z value to transform it to a Vector4
  94910. */
  94911. complementZ: number;
  94912. /**
  94913. * Creates a new TransformBlock
  94914. * @param name defines the block name
  94915. */
  94916. constructor(name: string);
  94917. /**
  94918. * Gets the current class name
  94919. * @returns the class name
  94920. */
  94921. getClassName(): string;
  94922. /**
  94923. * Gets the vector input
  94924. */
  94925. get vector(): NodeMaterialConnectionPoint;
  94926. /**
  94927. * Gets the output component
  94928. */
  94929. get output(): NodeMaterialConnectionPoint;
  94930. /**
  94931. * Gets the xyz output component
  94932. */
  94933. get xyz(): NodeMaterialConnectionPoint;
  94934. /**
  94935. * Gets the matrix transform input
  94936. */
  94937. get transform(): NodeMaterialConnectionPoint;
  94938. protected _buildBlock(state: NodeMaterialBuildState): this;
  94939. /**
  94940. * Update defines for shader compilation
  94941. * @param mesh defines the mesh to be rendered
  94942. * @param nodeMaterial defines the node material requesting the update
  94943. * @param defines defines the material defines to update
  94944. * @param useInstances specifies that instances should be used
  94945. * @param subMesh defines which submesh to render
  94946. */
  94947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94948. serialize(): any;
  94949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94950. protected _dumpPropertiesCode(): string;
  94951. }
  94952. }
  94953. declare module BABYLON {
  94954. /**
  94955. * Block used to output the vertex position
  94956. */
  94957. export class VertexOutputBlock extends NodeMaterialBlock {
  94958. /**
  94959. * Creates a new VertexOutputBlock
  94960. * @param name defines the block name
  94961. */
  94962. constructor(name: string);
  94963. /**
  94964. * Gets the current class name
  94965. * @returns the class name
  94966. */
  94967. getClassName(): string;
  94968. /**
  94969. * Gets the vector input component
  94970. */
  94971. get vector(): NodeMaterialConnectionPoint;
  94972. protected _buildBlock(state: NodeMaterialBuildState): this;
  94973. }
  94974. }
  94975. declare module BABYLON {
  94976. /**
  94977. * Block used to output the final color
  94978. */
  94979. export class FragmentOutputBlock extends NodeMaterialBlock {
  94980. /**
  94981. * Create a new FragmentOutputBlock
  94982. * @param name defines the block name
  94983. */
  94984. constructor(name: string);
  94985. /**
  94986. * Gets the current class name
  94987. * @returns the class name
  94988. */
  94989. getClassName(): string;
  94990. /**
  94991. * Gets the rgba input component
  94992. */
  94993. get rgba(): NodeMaterialConnectionPoint;
  94994. /**
  94995. * Gets the rgb input component
  94996. */
  94997. get rgb(): NodeMaterialConnectionPoint;
  94998. /**
  94999. * Gets the a input component
  95000. */
  95001. get a(): NodeMaterialConnectionPoint;
  95002. protected _buildBlock(state: NodeMaterialBuildState): this;
  95003. }
  95004. }
  95005. declare module BABYLON {
  95006. /**
  95007. * Block used for the particle ramp gradient section
  95008. */
  95009. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  95010. /**
  95011. * Create a new ParticleRampGradientBlock
  95012. * @param name defines the block name
  95013. */
  95014. constructor(name: string);
  95015. /**
  95016. * Gets the current class name
  95017. * @returns the class name
  95018. */
  95019. getClassName(): string;
  95020. /**
  95021. * Gets the color input component
  95022. */
  95023. get color(): NodeMaterialConnectionPoint;
  95024. /**
  95025. * Gets the rampColor output component
  95026. */
  95027. get rampColor(): NodeMaterialConnectionPoint;
  95028. /**
  95029. * Initialize the block and prepare the context for build
  95030. * @param state defines the state that will be used for the build
  95031. */
  95032. initialize(state: NodeMaterialBuildState): void;
  95033. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95034. }
  95035. }
  95036. declare module BABYLON {
  95037. /**
  95038. * Block used for the particle blend multiply section
  95039. */
  95040. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  95041. /**
  95042. * Create a new ParticleBlendMultiplyBlock
  95043. * @param name defines the block name
  95044. */
  95045. constructor(name: string);
  95046. /**
  95047. * Gets the current class name
  95048. * @returns the class name
  95049. */
  95050. getClassName(): string;
  95051. /**
  95052. * Gets the color input component
  95053. */
  95054. get color(): NodeMaterialConnectionPoint;
  95055. /**
  95056. * Gets the alphaTexture input component
  95057. */
  95058. get alphaTexture(): NodeMaterialConnectionPoint;
  95059. /**
  95060. * Gets the alphaColor input component
  95061. */
  95062. get alphaColor(): NodeMaterialConnectionPoint;
  95063. /**
  95064. * Gets the blendColor output component
  95065. */
  95066. get blendColor(): NodeMaterialConnectionPoint;
  95067. /**
  95068. * Initialize the block and prepare the context for build
  95069. * @param state defines the state that will be used for the build
  95070. */
  95071. initialize(state: NodeMaterialBuildState): void;
  95072. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95073. }
  95074. }
  95075. declare module BABYLON {
  95076. /**
  95077. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  95078. */
  95079. export class VectorMergerBlock extends NodeMaterialBlock {
  95080. /**
  95081. * Create a new VectorMergerBlock
  95082. * @param name defines the block name
  95083. */
  95084. constructor(name: string);
  95085. /**
  95086. * Gets the current class name
  95087. * @returns the class name
  95088. */
  95089. getClassName(): string;
  95090. /**
  95091. * Gets the xyz component (input)
  95092. */
  95093. get xyzIn(): NodeMaterialConnectionPoint;
  95094. /**
  95095. * Gets the xy component (input)
  95096. */
  95097. get xyIn(): NodeMaterialConnectionPoint;
  95098. /**
  95099. * Gets the x component (input)
  95100. */
  95101. get x(): NodeMaterialConnectionPoint;
  95102. /**
  95103. * Gets the y component (input)
  95104. */
  95105. get y(): NodeMaterialConnectionPoint;
  95106. /**
  95107. * Gets the z component (input)
  95108. */
  95109. get z(): NodeMaterialConnectionPoint;
  95110. /**
  95111. * Gets the w component (input)
  95112. */
  95113. get w(): NodeMaterialConnectionPoint;
  95114. /**
  95115. * Gets the xyzw component (output)
  95116. */
  95117. get xyzw(): NodeMaterialConnectionPoint;
  95118. /**
  95119. * Gets the xyz component (output)
  95120. */
  95121. get xyzOut(): NodeMaterialConnectionPoint;
  95122. /**
  95123. * Gets the xy component (output)
  95124. */
  95125. get xyOut(): NodeMaterialConnectionPoint;
  95126. /**
  95127. * Gets the xy component (output)
  95128. * @deprecated Please use xyOut instead.
  95129. */
  95130. get xy(): NodeMaterialConnectionPoint;
  95131. /**
  95132. * Gets the xyz component (output)
  95133. * @deprecated Please use xyzOut instead.
  95134. */
  95135. get xyz(): NodeMaterialConnectionPoint;
  95136. protected _buildBlock(state: NodeMaterialBuildState): this;
  95137. }
  95138. }
  95139. declare module BABYLON {
  95140. /**
  95141. * Block used to remap a float from a range to a new one
  95142. */
  95143. export class RemapBlock extends NodeMaterialBlock {
  95144. /**
  95145. * Gets or sets the source range
  95146. */
  95147. sourceRange: Vector2;
  95148. /**
  95149. * Gets or sets the target range
  95150. */
  95151. targetRange: Vector2;
  95152. /**
  95153. * Creates a new RemapBlock
  95154. * @param name defines the block name
  95155. */
  95156. constructor(name: string);
  95157. /**
  95158. * Gets the current class name
  95159. * @returns the class name
  95160. */
  95161. getClassName(): string;
  95162. /**
  95163. * Gets the input component
  95164. */
  95165. get input(): NodeMaterialConnectionPoint;
  95166. /**
  95167. * Gets the source min input component
  95168. */
  95169. get sourceMin(): NodeMaterialConnectionPoint;
  95170. /**
  95171. * Gets the source max input component
  95172. */
  95173. get sourceMax(): NodeMaterialConnectionPoint;
  95174. /**
  95175. * Gets the target min input component
  95176. */
  95177. get targetMin(): NodeMaterialConnectionPoint;
  95178. /**
  95179. * Gets the target max input component
  95180. */
  95181. get targetMax(): NodeMaterialConnectionPoint;
  95182. /**
  95183. * Gets the output component
  95184. */
  95185. get output(): NodeMaterialConnectionPoint;
  95186. protected _buildBlock(state: NodeMaterialBuildState): this;
  95187. protected _dumpPropertiesCode(): string;
  95188. serialize(): any;
  95189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95190. }
  95191. }
  95192. declare module BABYLON {
  95193. /**
  95194. * Block used to multiply 2 values
  95195. */
  95196. export class MultiplyBlock extends NodeMaterialBlock {
  95197. /**
  95198. * Creates a new MultiplyBlock
  95199. * @param name defines the block name
  95200. */
  95201. constructor(name: string);
  95202. /**
  95203. * Gets the current class name
  95204. * @returns the class name
  95205. */
  95206. getClassName(): string;
  95207. /**
  95208. * Gets the left operand input component
  95209. */
  95210. get left(): NodeMaterialConnectionPoint;
  95211. /**
  95212. * Gets the right operand input component
  95213. */
  95214. get right(): NodeMaterialConnectionPoint;
  95215. /**
  95216. * Gets the output component
  95217. */
  95218. get output(): NodeMaterialConnectionPoint;
  95219. protected _buildBlock(state: NodeMaterialBuildState): this;
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /** Interface used by value gradients (color, factor, ...) */
  95224. export interface IValueGradient {
  95225. /**
  95226. * Gets or sets the gradient value (between 0 and 1)
  95227. */
  95228. gradient: number;
  95229. }
  95230. /** Class used to store color4 gradient */
  95231. export class ColorGradient implements IValueGradient {
  95232. /**
  95233. * Gets or sets the gradient value (between 0 and 1)
  95234. */
  95235. gradient: number;
  95236. /**
  95237. * Gets or sets first associated color
  95238. */
  95239. color1: Color4;
  95240. /**
  95241. * Gets or sets second associated color
  95242. */
  95243. color2?: Color4 | undefined;
  95244. /**
  95245. * Creates a new color4 gradient
  95246. * @param gradient gets or sets the gradient value (between 0 and 1)
  95247. * @param color1 gets or sets first associated color
  95248. * @param color2 gets or sets first second color
  95249. */
  95250. constructor(
  95251. /**
  95252. * Gets or sets the gradient value (between 0 and 1)
  95253. */
  95254. gradient: number,
  95255. /**
  95256. * Gets or sets first associated color
  95257. */
  95258. color1: Color4,
  95259. /**
  95260. * Gets or sets second associated color
  95261. */
  95262. color2?: Color4 | undefined);
  95263. /**
  95264. * Will get a color picked randomly between color1 and color2.
  95265. * If color2 is undefined then color1 will be used
  95266. * @param result defines the target Color4 to store the result in
  95267. */
  95268. getColorToRef(result: Color4): void;
  95269. }
  95270. /** Class used to store color 3 gradient */
  95271. export class Color3Gradient implements IValueGradient {
  95272. /**
  95273. * Gets or sets the gradient value (between 0 and 1)
  95274. */
  95275. gradient: number;
  95276. /**
  95277. * Gets or sets the associated color
  95278. */
  95279. color: Color3;
  95280. /**
  95281. * Creates a new color3 gradient
  95282. * @param gradient gets or sets the gradient value (between 0 and 1)
  95283. * @param color gets or sets associated color
  95284. */
  95285. constructor(
  95286. /**
  95287. * Gets or sets the gradient value (between 0 and 1)
  95288. */
  95289. gradient: number,
  95290. /**
  95291. * Gets or sets the associated color
  95292. */
  95293. color: Color3);
  95294. }
  95295. /** Class used to store factor gradient */
  95296. export class FactorGradient implements IValueGradient {
  95297. /**
  95298. * Gets or sets the gradient value (between 0 and 1)
  95299. */
  95300. gradient: number;
  95301. /**
  95302. * Gets or sets first associated factor
  95303. */
  95304. factor1: number;
  95305. /**
  95306. * Gets or sets second associated factor
  95307. */
  95308. factor2?: number | undefined;
  95309. /**
  95310. * Creates a new factor gradient
  95311. * @param gradient gets or sets the gradient value (between 0 and 1)
  95312. * @param factor1 gets or sets first associated factor
  95313. * @param factor2 gets or sets second associated factor
  95314. */
  95315. constructor(
  95316. /**
  95317. * Gets or sets the gradient value (between 0 and 1)
  95318. */
  95319. gradient: number,
  95320. /**
  95321. * Gets or sets first associated factor
  95322. */
  95323. factor1: number,
  95324. /**
  95325. * Gets or sets second associated factor
  95326. */
  95327. factor2?: number | undefined);
  95328. /**
  95329. * Will get a number picked randomly between factor1 and factor2.
  95330. * If factor2 is undefined then factor1 will be used
  95331. * @returns the picked number
  95332. */
  95333. getFactor(): number;
  95334. }
  95335. /**
  95336. * Helper used to simplify some generic gradient tasks
  95337. */
  95338. export class GradientHelper {
  95339. /**
  95340. * Gets the current gradient from an array of IValueGradient
  95341. * @param ratio defines the current ratio to get
  95342. * @param gradients defines the array of IValueGradient
  95343. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95344. */
  95345. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95346. }
  95347. }
  95348. declare module BABYLON {
  95349. interface ThinEngine {
  95350. /**
  95351. * Creates a raw texture
  95352. * @param data defines the data to store in the texture
  95353. * @param width defines the width of the texture
  95354. * @param height defines the height of the texture
  95355. * @param format defines the format of the data
  95356. * @param generateMipMaps defines if the engine should generate the mip levels
  95357. * @param invertY defines if data must be stored with Y axis inverted
  95358. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95359. * @param compression defines the compression used (null by default)
  95360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95361. * @returns the raw texture inside an InternalTexture
  95362. */
  95363. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95364. /**
  95365. * Update a raw texture
  95366. * @param texture defines the texture to update
  95367. * @param data defines the data to store in the texture
  95368. * @param format defines the format of the data
  95369. * @param invertY defines if data must be stored with Y axis inverted
  95370. */
  95371. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95372. /**
  95373. * Update a raw texture
  95374. * @param texture defines the texture to update
  95375. * @param data defines the data to store in the texture
  95376. * @param format defines the format of the data
  95377. * @param invertY defines if data must be stored with Y axis inverted
  95378. * @param compression defines the compression used (null by default)
  95379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95380. */
  95381. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95382. /**
  95383. * Creates a new raw cube texture
  95384. * @param data defines the array of data to use to create each face
  95385. * @param size defines the size of the textures
  95386. * @param format defines the format of the data
  95387. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95388. * @param generateMipMaps defines if the engine should generate the mip levels
  95389. * @param invertY defines if data must be stored with Y axis inverted
  95390. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95391. * @param compression defines the compression used (null by default)
  95392. * @returns the cube texture as an InternalTexture
  95393. */
  95394. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95395. /**
  95396. * Update a raw cube texture
  95397. * @param texture defines the texture to udpdate
  95398. * @param data defines the data to store
  95399. * @param format defines the data format
  95400. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95401. * @param invertY defines if data must be stored with Y axis inverted
  95402. */
  95403. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95404. /**
  95405. * Update a raw cube texture
  95406. * @param texture defines the texture to udpdate
  95407. * @param data defines the data to store
  95408. * @param format defines the data format
  95409. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95410. * @param invertY defines if data must be stored with Y axis inverted
  95411. * @param compression defines the compression used (null by default)
  95412. */
  95413. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95414. /**
  95415. * Update a raw cube texture
  95416. * @param texture defines the texture to udpdate
  95417. * @param data defines the data to store
  95418. * @param format defines the data format
  95419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95420. * @param invertY defines if data must be stored with Y axis inverted
  95421. * @param compression defines the compression used (null by default)
  95422. * @param level defines which level of the texture to update
  95423. */
  95424. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95425. /**
  95426. * Creates a new raw cube texture from a specified url
  95427. * @param url defines the url where the data is located
  95428. * @param scene defines the current scene
  95429. * @param size defines the size of the textures
  95430. * @param format defines the format of the data
  95431. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95432. * @param noMipmap defines if the engine should avoid generating the mip levels
  95433. * @param callback defines a callback used to extract texture data from loaded data
  95434. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95435. * @param onLoad defines a callback called when texture is loaded
  95436. * @param onError defines a callback called if there is an error
  95437. * @returns the cube texture as an InternalTexture
  95438. */
  95439. 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;
  95440. /**
  95441. * Creates a new raw cube texture from a specified url
  95442. * @param url defines the url where the data is located
  95443. * @param scene defines the current scene
  95444. * @param size defines the size of the textures
  95445. * @param format defines the format of the data
  95446. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95447. * @param noMipmap defines if the engine should avoid generating the mip levels
  95448. * @param callback defines a callback used to extract texture data from loaded data
  95449. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95450. * @param onLoad defines a callback called when texture is loaded
  95451. * @param onError defines a callback called if there is an error
  95452. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95453. * @param invertY defines if data must be stored with Y axis inverted
  95454. * @returns the cube texture as an InternalTexture
  95455. */
  95456. 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;
  95457. /**
  95458. * Creates a new raw 3D texture
  95459. * @param data defines the data used to create the texture
  95460. * @param width defines the width of the texture
  95461. * @param height defines the height of the texture
  95462. * @param depth defines the depth of the texture
  95463. * @param format defines the format of the texture
  95464. * @param generateMipMaps defines if the engine must generate mip levels
  95465. * @param invertY defines if data must be stored with Y axis inverted
  95466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95467. * @param compression defines the compressed used (can be null)
  95468. * @param textureType defines the compressed used (can be null)
  95469. * @returns a new raw 3D texture (stored in an InternalTexture)
  95470. */
  95471. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95472. /**
  95473. * Update a raw 3D texture
  95474. * @param texture defines the texture to update
  95475. * @param data defines the data to store
  95476. * @param format defines the data format
  95477. * @param invertY defines if data must be stored with Y axis inverted
  95478. */
  95479. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95480. /**
  95481. * Update a raw 3D texture
  95482. * @param texture defines the texture to update
  95483. * @param data defines the data to store
  95484. * @param format defines the data format
  95485. * @param invertY defines if data must be stored with Y axis inverted
  95486. * @param compression defines the used compression (can be null)
  95487. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95488. */
  95489. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95490. /**
  95491. * Creates a new raw 2D array texture
  95492. * @param data defines the data used to create the texture
  95493. * @param width defines the width of the texture
  95494. * @param height defines the height of the texture
  95495. * @param depth defines the number of layers of the texture
  95496. * @param format defines the format of the texture
  95497. * @param generateMipMaps defines if the engine must generate mip levels
  95498. * @param invertY defines if data must be stored with Y axis inverted
  95499. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95500. * @param compression defines the compressed used (can be null)
  95501. * @param textureType defines the compressed used (can be null)
  95502. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95503. */
  95504. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95505. /**
  95506. * Update a raw 2D array texture
  95507. * @param texture defines the texture to update
  95508. * @param data defines the data to store
  95509. * @param format defines the data format
  95510. * @param invertY defines if data must be stored with Y axis inverted
  95511. */
  95512. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95513. /**
  95514. * Update a raw 2D array texture
  95515. * @param texture defines the texture to update
  95516. * @param data defines the data to store
  95517. * @param format defines the data format
  95518. * @param invertY defines if data must be stored with Y axis inverted
  95519. * @param compression defines the used compression (can be null)
  95520. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95521. */
  95522. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95523. }
  95524. }
  95525. declare module BABYLON {
  95526. /**
  95527. * Raw texture can help creating a texture directly from an array of data.
  95528. * This can be super useful if you either get the data from an uncompressed source or
  95529. * if you wish to create your texture pixel by pixel.
  95530. */
  95531. export class RawTexture extends Texture {
  95532. /**
  95533. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95534. */
  95535. format: number;
  95536. /**
  95537. * Instantiates a new RawTexture.
  95538. * Raw texture can help creating a texture directly from an array of data.
  95539. * This can be super useful if you either get the data from an uncompressed source or
  95540. * if you wish to create your texture pixel by pixel.
  95541. * @param data define the array of data to use to create the texture
  95542. * @param width define the width of the texture
  95543. * @param height define the height of the texture
  95544. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95545. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95546. * @param generateMipMaps define whether mip maps should be generated or not
  95547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95550. */
  95551. constructor(data: ArrayBufferView, width: number, height: number,
  95552. /**
  95553. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95554. */
  95555. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95556. /**
  95557. * Updates the texture underlying data.
  95558. * @param data Define the new data of the texture
  95559. */
  95560. update(data: ArrayBufferView): void;
  95561. /**
  95562. * Creates a luminance texture from some data.
  95563. * @param data Define the texture data
  95564. * @param width Define the width of the texture
  95565. * @param height Define the height of the texture
  95566. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95570. * @returns the luminance texture
  95571. */
  95572. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95573. /**
  95574. * Creates a luminance alpha texture from some data.
  95575. * @param data Define the texture data
  95576. * @param width Define the width of the texture
  95577. * @param height Define the height of the texture
  95578. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95582. * @returns the luminance alpha texture
  95583. */
  95584. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95585. /**
  95586. * Creates an alpha texture from some data.
  95587. * @param data Define the texture data
  95588. * @param width Define the width of the texture
  95589. * @param height Define the height of the texture
  95590. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95594. * @returns the alpha texture
  95595. */
  95596. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95597. /**
  95598. * Creates a RGB texture from some data.
  95599. * @param data Define the texture data
  95600. * @param width Define the width of the texture
  95601. * @param height Define the height of the texture
  95602. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95603. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95604. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95605. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95606. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95607. * @returns the RGB alpha texture
  95608. */
  95609. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95610. /**
  95611. * Creates a RGBA texture from some data.
  95612. * @param data Define the texture data
  95613. * @param width Define the width of the texture
  95614. * @param height Define the height of the texture
  95615. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95619. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95620. * @returns the RGBA texture
  95621. */
  95622. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95623. /**
  95624. * Creates a R texture from some data.
  95625. * @param data Define the texture data
  95626. * @param width Define the width of the texture
  95627. * @param height Define the height of the texture
  95628. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95632. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95633. * @returns the R texture
  95634. */
  95635. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95636. }
  95637. }
  95638. declare module BABYLON {
  95639. interface ThinEngine {
  95640. /**
  95641. * Update a dynamic index buffer
  95642. * @param indexBuffer defines the target index buffer
  95643. * @param indices defines the data to update
  95644. * @param offset defines the offset in the target index buffer where update should start
  95645. */
  95646. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95647. /**
  95648. * Updates a dynamic vertex buffer.
  95649. * @param vertexBuffer the vertex buffer to update
  95650. * @param data the data used to update the vertex buffer
  95651. * @param byteOffset the byte offset of the data
  95652. * @param byteLength the byte length of the data
  95653. */
  95654. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95655. }
  95656. }
  95657. declare module BABYLON {
  95658. interface AbstractScene {
  95659. /**
  95660. * The list of procedural textures added to the scene
  95661. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95662. */
  95663. proceduralTextures: Array<ProceduralTexture>;
  95664. }
  95665. /**
  95666. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95667. * in a given scene.
  95668. */
  95669. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95670. /**
  95671. * The component name helpfull to identify the component in the list of scene components.
  95672. */
  95673. readonly name: string;
  95674. /**
  95675. * The scene the component belongs to.
  95676. */
  95677. scene: Scene;
  95678. /**
  95679. * Creates a new instance of the component for the given scene
  95680. * @param scene Defines the scene to register the component in
  95681. */
  95682. constructor(scene: Scene);
  95683. /**
  95684. * Registers the component in a given scene
  95685. */
  95686. register(): void;
  95687. /**
  95688. * Rebuilds the elements related to this component in case of
  95689. * context lost for instance.
  95690. */
  95691. rebuild(): void;
  95692. /**
  95693. * Disposes the component and the associated ressources.
  95694. */
  95695. dispose(): void;
  95696. private _beforeClear;
  95697. }
  95698. }
  95699. declare module BABYLON {
  95700. interface ThinEngine {
  95701. /**
  95702. * Creates a new render target cube texture
  95703. * @param size defines the size of the texture
  95704. * @param options defines the options used to create the texture
  95705. * @returns a new render target cube texture stored in an InternalTexture
  95706. */
  95707. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95708. }
  95709. }
  95710. declare module BABYLON {
  95711. /** @hidden */
  95712. export var proceduralVertexShader: {
  95713. name: string;
  95714. shader: string;
  95715. };
  95716. }
  95717. declare module BABYLON {
  95718. /**
  95719. * 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.
  95720. * This is the base class of any Procedural texture and contains most of the shareable code.
  95721. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95722. */
  95723. export class ProceduralTexture extends Texture {
  95724. /**
  95725. * Define if the texture is enabled or not (disabled texture will not render)
  95726. */
  95727. isEnabled: boolean;
  95728. /**
  95729. * Define if the texture must be cleared before rendering (default is true)
  95730. */
  95731. autoClear: boolean;
  95732. /**
  95733. * Callback called when the texture is generated
  95734. */
  95735. onGenerated: () => void;
  95736. /**
  95737. * Event raised when the texture is generated
  95738. */
  95739. onGeneratedObservable: Observable<ProceduralTexture>;
  95740. /**
  95741. * Event raised before the texture is generated
  95742. */
  95743. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95744. /**
  95745. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95746. */
  95747. nodeMaterialSource: Nullable<NodeMaterial>;
  95748. /** @hidden */
  95749. _generateMipMaps: boolean;
  95750. /** @hidden **/
  95751. _effect: Effect;
  95752. /** @hidden */
  95753. _textures: {
  95754. [key: string]: Texture;
  95755. };
  95756. /** @hidden */
  95757. protected _fallbackTexture: Nullable<Texture>;
  95758. private _size;
  95759. private _currentRefreshId;
  95760. private _frameId;
  95761. private _refreshRate;
  95762. private _vertexBuffers;
  95763. private _indexBuffer;
  95764. private _uniforms;
  95765. private _samplers;
  95766. private _fragment;
  95767. private _floats;
  95768. private _ints;
  95769. private _floatsArrays;
  95770. private _colors3;
  95771. private _colors4;
  95772. private _vectors2;
  95773. private _vectors3;
  95774. private _matrices;
  95775. private _fallbackTextureUsed;
  95776. private _fullEngine;
  95777. private _cachedDefines;
  95778. private _contentUpdateId;
  95779. private _contentData;
  95780. /**
  95781. * Instantiates a new procedural texture.
  95782. * 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.
  95783. * This is the base class of any Procedural texture and contains most of the shareable code.
  95784. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95785. * @param name Define the name of the texture
  95786. * @param size Define the size of the texture to create
  95787. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95788. * @param scene Define the scene the texture belongs to
  95789. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95790. * @param generateMipMaps Define if the texture should creates mip maps or not
  95791. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95792. * @param textureType The FBO internal texture type
  95793. */
  95794. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95795. /**
  95796. * The effect that is created when initializing the post process.
  95797. * @returns The created effect corresponding the the postprocess.
  95798. */
  95799. getEffect(): Effect;
  95800. /**
  95801. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95802. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95803. */
  95804. getContent(): Nullable<ArrayBufferView>;
  95805. private _createIndexBuffer;
  95806. /** @hidden */
  95807. _rebuild(): void;
  95808. /**
  95809. * Resets the texture in order to recreate its associated resources.
  95810. * This can be called in case of context loss
  95811. */
  95812. reset(): void;
  95813. protected _getDefines(): string;
  95814. /**
  95815. * Is the texture ready to be used ? (rendered at least once)
  95816. * @returns true if ready, otherwise, false.
  95817. */
  95818. isReady(): boolean;
  95819. /**
  95820. * Resets the refresh counter of the texture and start bak from scratch.
  95821. * Could be useful to regenerate the texture if it is setup to render only once.
  95822. */
  95823. resetRefreshCounter(): void;
  95824. /**
  95825. * Set the fragment shader to use in order to render the texture.
  95826. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95827. */
  95828. setFragment(fragment: any): void;
  95829. /**
  95830. * Define the refresh rate of the texture or the rendering frequency.
  95831. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95832. */
  95833. get refreshRate(): number;
  95834. set refreshRate(value: number);
  95835. /** @hidden */
  95836. _shouldRender(): boolean;
  95837. /**
  95838. * Get the size the texture is rendering at.
  95839. * @returns the size (on cube texture it is always squared)
  95840. */
  95841. getRenderSize(): RenderTargetTextureSize;
  95842. /**
  95843. * Resize the texture to new value.
  95844. * @param size Define the new size the texture should have
  95845. * @param generateMipMaps Define whether the new texture should create mip maps
  95846. */
  95847. resize(size: number, generateMipMaps: boolean): void;
  95848. private _checkUniform;
  95849. /**
  95850. * Set a texture in the shader program used to render.
  95851. * @param name Define the name of the uniform samplers as defined in the shader
  95852. * @param texture Define the texture to bind to this sampler
  95853. * @return the texture itself allowing "fluent" like uniform updates
  95854. */
  95855. setTexture(name: string, texture: Texture): ProceduralTexture;
  95856. /**
  95857. * Set a float in the shader.
  95858. * @param name Define the name of the uniform as defined in the shader
  95859. * @param value Define the value to give to the uniform
  95860. * @return the texture itself allowing "fluent" like uniform updates
  95861. */
  95862. setFloat(name: string, value: number): ProceduralTexture;
  95863. /**
  95864. * Set a int in the shader.
  95865. * @param name Define the name of the uniform as defined in the shader
  95866. * @param value Define the value to give to the uniform
  95867. * @return the texture itself allowing "fluent" like uniform updates
  95868. */
  95869. setInt(name: string, value: number): ProceduralTexture;
  95870. /**
  95871. * Set an array of floats in the shader.
  95872. * @param name Define the name of the uniform as defined in the shader
  95873. * @param value Define the value to give to the uniform
  95874. * @return the texture itself allowing "fluent" like uniform updates
  95875. */
  95876. setFloats(name: string, value: number[]): ProceduralTexture;
  95877. /**
  95878. * Set a vec3 in the shader from a Color3.
  95879. * @param name Define the name of the uniform as defined in the shader
  95880. * @param value Define the value to give to the uniform
  95881. * @return the texture itself allowing "fluent" like uniform updates
  95882. */
  95883. setColor3(name: string, value: Color3): ProceduralTexture;
  95884. /**
  95885. * Set a vec4 in the shader from a Color4.
  95886. * @param name Define the name of the uniform as defined in the shader
  95887. * @param value Define the value to give to the uniform
  95888. * @return the texture itself allowing "fluent" like uniform updates
  95889. */
  95890. setColor4(name: string, value: Color4): ProceduralTexture;
  95891. /**
  95892. * Set a vec2 in the shader from a Vector2.
  95893. * @param name Define the name of the uniform as defined in the shader
  95894. * @param value Define the value to give to the uniform
  95895. * @return the texture itself allowing "fluent" like uniform updates
  95896. */
  95897. setVector2(name: string, value: Vector2): ProceduralTexture;
  95898. /**
  95899. * Set a vec3 in the shader from a Vector3.
  95900. * @param name Define the name of the uniform as defined in the shader
  95901. * @param value Define the value to give to the uniform
  95902. * @return the texture itself allowing "fluent" like uniform updates
  95903. */
  95904. setVector3(name: string, value: Vector3): ProceduralTexture;
  95905. /**
  95906. * Set a mat4 in the shader from a MAtrix.
  95907. * @param name Define the name of the uniform as defined in the shader
  95908. * @param value Define the value to give to the uniform
  95909. * @return the texture itself allowing "fluent" like uniform updates
  95910. */
  95911. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95912. /**
  95913. * Render the texture to its associated render target.
  95914. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95915. */
  95916. render(useCameraPostProcess?: boolean): void;
  95917. /**
  95918. * Clone the texture.
  95919. * @returns the cloned texture
  95920. */
  95921. clone(): ProceduralTexture;
  95922. /**
  95923. * Dispose the texture and release its asoociated resources.
  95924. */
  95925. dispose(): void;
  95926. }
  95927. }
  95928. declare module BABYLON {
  95929. /**
  95930. * This represents the base class for particle system in Babylon.
  95931. * 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.
  95932. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95933. * @example https://doc.babylonjs.com/babylon101/particles
  95934. */
  95935. export class BaseParticleSystem {
  95936. /**
  95937. * Source color is added to the destination color without alpha affecting the result
  95938. */
  95939. static BLENDMODE_ONEONE: number;
  95940. /**
  95941. * Blend current color and particle color using particle’s alpha
  95942. */
  95943. static BLENDMODE_STANDARD: number;
  95944. /**
  95945. * Add current color and particle color multiplied by particle’s alpha
  95946. */
  95947. static BLENDMODE_ADD: number;
  95948. /**
  95949. * Multiply current color with particle color
  95950. */
  95951. static BLENDMODE_MULTIPLY: number;
  95952. /**
  95953. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  95954. */
  95955. static BLENDMODE_MULTIPLYADD: number;
  95956. /**
  95957. * List of animations used by the particle system.
  95958. */
  95959. animations: Animation[];
  95960. /**
  95961. * Gets or sets the unique id of the particle system
  95962. */
  95963. uniqueId: number;
  95964. /**
  95965. * The id of the Particle system.
  95966. */
  95967. id: string;
  95968. /**
  95969. * The friendly name of the Particle system.
  95970. */
  95971. name: string;
  95972. /**
  95973. * Snippet ID if the particle system was created from the snippet server
  95974. */
  95975. snippetId: string;
  95976. /**
  95977. * The rendering group used by the Particle system to chose when to render.
  95978. */
  95979. renderingGroupId: number;
  95980. /**
  95981. * The emitter represents the Mesh or position we are attaching the particle system to.
  95982. */
  95983. emitter: Nullable<AbstractMesh | Vector3>;
  95984. /**
  95985. * The maximum number of particles to emit per frame
  95986. */
  95987. emitRate: number;
  95988. /**
  95989. * If you want to launch only a few particles at once, that can be done, as well.
  95990. */
  95991. manualEmitCount: number;
  95992. /**
  95993. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95994. */
  95995. updateSpeed: number;
  95996. /**
  95997. * The amount of time the particle system is running (depends of the overall update speed).
  95998. */
  95999. targetStopDuration: number;
  96000. /**
  96001. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  96002. */
  96003. disposeOnStop: boolean;
  96004. /**
  96005. * Minimum power of emitting particles.
  96006. */
  96007. minEmitPower: number;
  96008. /**
  96009. * Maximum power of emitting particles.
  96010. */
  96011. maxEmitPower: number;
  96012. /**
  96013. * Minimum life time of emitting particles.
  96014. */
  96015. minLifeTime: number;
  96016. /**
  96017. * Maximum life time of emitting particles.
  96018. */
  96019. maxLifeTime: number;
  96020. /**
  96021. * Minimum Size of emitting particles.
  96022. */
  96023. minSize: number;
  96024. /**
  96025. * Maximum Size of emitting particles.
  96026. */
  96027. maxSize: number;
  96028. /**
  96029. * Minimum scale of emitting particles on X axis.
  96030. */
  96031. minScaleX: number;
  96032. /**
  96033. * Maximum scale of emitting particles on X axis.
  96034. */
  96035. maxScaleX: number;
  96036. /**
  96037. * Minimum scale of emitting particles on Y axis.
  96038. */
  96039. minScaleY: number;
  96040. /**
  96041. * Maximum scale of emitting particles on Y axis.
  96042. */
  96043. maxScaleY: number;
  96044. /**
  96045. * Gets or sets the minimal initial rotation in radians.
  96046. */
  96047. minInitialRotation: number;
  96048. /**
  96049. * Gets or sets the maximal initial rotation in radians.
  96050. */
  96051. maxInitialRotation: number;
  96052. /**
  96053. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  96054. */
  96055. minAngularSpeed: number;
  96056. /**
  96057. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  96058. */
  96059. maxAngularSpeed: number;
  96060. /**
  96061. * The texture used to render each particle. (this can be a spritesheet)
  96062. */
  96063. particleTexture: Nullable<BaseTexture>;
  96064. /**
  96065. * The layer mask we are rendering the particles through.
  96066. */
  96067. layerMask: number;
  96068. /**
  96069. * This can help using your own shader to render the particle system.
  96070. * The according effect will be created
  96071. */
  96072. customShader: any;
  96073. /**
  96074. * By default particle system starts as soon as they are created. This prevents the
  96075. * automatic start to happen and let you decide when to start emitting particles.
  96076. */
  96077. preventAutoStart: boolean;
  96078. private _noiseTexture;
  96079. /**
  96080. * Gets or sets a texture used to add random noise to particle positions
  96081. */
  96082. get noiseTexture(): Nullable<ProceduralTexture>;
  96083. set noiseTexture(value: Nullable<ProceduralTexture>);
  96084. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  96085. noiseStrength: Vector3;
  96086. /**
  96087. * Callback triggered when the particle animation is ending.
  96088. */
  96089. onAnimationEnd: Nullable<() => void>;
  96090. /**
  96091. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  96092. */
  96093. blendMode: number;
  96094. /**
  96095. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  96096. * to override the particles.
  96097. */
  96098. forceDepthWrite: boolean;
  96099. /** 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 */
  96100. preWarmCycles: number;
  96101. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  96102. preWarmStepOffset: number;
  96103. /**
  96104. * 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)
  96105. */
  96106. spriteCellChangeSpeed: number;
  96107. /**
  96108. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  96109. */
  96110. startSpriteCellID: number;
  96111. /**
  96112. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  96113. */
  96114. endSpriteCellID: number;
  96115. /**
  96116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  96117. */
  96118. spriteCellWidth: number;
  96119. /**
  96120. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  96121. */
  96122. spriteCellHeight: number;
  96123. /**
  96124. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  96125. */
  96126. spriteRandomStartCell: boolean;
  96127. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  96128. translationPivot: Vector2;
  96129. /** @hidden */
  96130. protected _isAnimationSheetEnabled: boolean;
  96131. /**
  96132. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  96133. */
  96134. beginAnimationOnStart: boolean;
  96135. /**
  96136. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  96137. */
  96138. beginAnimationFrom: number;
  96139. /**
  96140. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  96141. */
  96142. beginAnimationTo: number;
  96143. /**
  96144. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  96145. */
  96146. beginAnimationLoop: boolean;
  96147. /**
  96148. * Gets or sets a world offset applied to all particles
  96149. */
  96150. worldOffset: Vector3;
  96151. /**
  96152. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  96153. */
  96154. get isAnimationSheetEnabled(): boolean;
  96155. set isAnimationSheetEnabled(value: boolean);
  96156. /**
  96157. * Get hosting scene
  96158. * @returns the scene
  96159. */
  96160. getScene(): Nullable<Scene>;
  96161. /**
  96162. * You can use gravity if you want to give an orientation to your particles.
  96163. */
  96164. gravity: Vector3;
  96165. protected _colorGradients: Nullable<Array<ColorGradient>>;
  96166. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  96167. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  96168. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  96169. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  96170. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  96171. protected _dragGradients: Nullable<Array<FactorGradient>>;
  96172. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  96173. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  96174. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  96175. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  96176. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  96177. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  96178. /**
  96179. * Defines the delay in milliseconds before starting the system (0 by default)
  96180. */
  96181. startDelay: number;
  96182. /**
  96183. * Gets the current list of drag gradients.
  96184. * You must use addDragGradient and removeDragGradient to udpate this list
  96185. * @returns the list of drag gradients
  96186. */
  96187. getDragGradients(): Nullable<Array<FactorGradient>>;
  96188. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  96189. limitVelocityDamping: number;
  96190. /**
  96191. * Gets the current list of limit velocity gradients.
  96192. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  96193. * @returns the list of limit velocity gradients
  96194. */
  96195. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  96196. /**
  96197. * Gets the current list of color gradients.
  96198. * You must use addColorGradient and removeColorGradient to udpate this list
  96199. * @returns the list of color gradients
  96200. */
  96201. getColorGradients(): Nullable<Array<ColorGradient>>;
  96202. /**
  96203. * Gets the current list of size gradients.
  96204. * You must use addSizeGradient and removeSizeGradient to udpate this list
  96205. * @returns the list of size gradients
  96206. */
  96207. getSizeGradients(): Nullable<Array<FactorGradient>>;
  96208. /**
  96209. * Gets the current list of color remap gradients.
  96210. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  96211. * @returns the list of color remap gradients
  96212. */
  96213. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  96214. /**
  96215. * Gets the current list of alpha remap gradients.
  96216. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  96217. * @returns the list of alpha remap gradients
  96218. */
  96219. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  96220. /**
  96221. * Gets the current list of life time gradients.
  96222. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  96223. * @returns the list of life time gradients
  96224. */
  96225. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  96226. /**
  96227. * Gets the current list of angular speed gradients.
  96228. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  96229. * @returns the list of angular speed gradients
  96230. */
  96231. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  96232. /**
  96233. * Gets the current list of velocity gradients.
  96234. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  96235. * @returns the list of velocity gradients
  96236. */
  96237. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  96238. /**
  96239. * Gets the current list of start size gradients.
  96240. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  96241. * @returns the list of start size gradients
  96242. */
  96243. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  96244. /**
  96245. * Gets the current list of emit rate gradients.
  96246. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96247. * @returns the list of emit rate gradients
  96248. */
  96249. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96250. /**
  96251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96253. */
  96254. get direction1(): Vector3;
  96255. set direction1(value: Vector3);
  96256. /**
  96257. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96258. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96259. */
  96260. get direction2(): Vector3;
  96261. set direction2(value: Vector3);
  96262. /**
  96263. * 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.
  96264. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96265. */
  96266. get minEmitBox(): Vector3;
  96267. set minEmitBox(value: Vector3);
  96268. /**
  96269. * 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.
  96270. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96271. */
  96272. get maxEmitBox(): Vector3;
  96273. set maxEmitBox(value: Vector3);
  96274. /**
  96275. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96276. */
  96277. color1: Color4;
  96278. /**
  96279. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96280. */
  96281. color2: Color4;
  96282. /**
  96283. * Color the particle will have at the end of its lifetime
  96284. */
  96285. colorDead: Color4;
  96286. /**
  96287. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96288. */
  96289. textureMask: Color4;
  96290. /**
  96291. * The particle emitter type defines the emitter used by the particle system.
  96292. * It can be for example box, sphere, or cone...
  96293. */
  96294. particleEmitterType: IParticleEmitterType;
  96295. /** @hidden */
  96296. _isSubEmitter: boolean;
  96297. /**
  96298. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96299. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96300. */
  96301. billboardMode: number;
  96302. protected _isBillboardBased: boolean;
  96303. /**
  96304. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96305. */
  96306. get isBillboardBased(): boolean;
  96307. set isBillboardBased(value: boolean);
  96308. /**
  96309. * The scene the particle system belongs to.
  96310. */
  96311. protected _scene: Nullable<Scene>;
  96312. /**
  96313. * The engine the particle system belongs to.
  96314. */
  96315. protected _engine: ThinEngine;
  96316. /**
  96317. * Local cache of defines for image processing.
  96318. */
  96319. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96320. /**
  96321. * Default configuration related to image processing available in the standard Material.
  96322. */
  96323. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96324. /**
  96325. * Gets the image processing configuration used either in this material.
  96326. */
  96327. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96328. /**
  96329. * Sets the Default image processing configuration used either in the this material.
  96330. *
  96331. * If sets to null, the scene one is in use.
  96332. */
  96333. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96334. /**
  96335. * Attaches a new image processing configuration to the Standard Material.
  96336. * @param configuration
  96337. */
  96338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96339. /** @hidden */
  96340. protected _reset(): void;
  96341. /** @hidden */
  96342. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96343. /**
  96344. * Instantiates a particle system.
  96345. * 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.
  96346. * @param name The name of the particle system
  96347. */
  96348. constructor(name: string);
  96349. /**
  96350. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96353. * @returns the emitter
  96354. */
  96355. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96356. /**
  96357. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96358. * @param radius The radius of the hemisphere to emit from
  96359. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96360. * @returns the emitter
  96361. */
  96362. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96363. /**
  96364. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96365. * @param radius The radius of the sphere to emit from
  96366. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96367. * @returns the emitter
  96368. */
  96369. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96370. /**
  96371. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96372. * @param radius The radius of the sphere to emit from
  96373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96375. * @returns the emitter
  96376. */
  96377. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96378. /**
  96379. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96380. * @param radius The radius of the emission cylinder
  96381. * @param height The height of the emission cylinder
  96382. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96383. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96384. * @returns the emitter
  96385. */
  96386. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96387. /**
  96388. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96389. * @param radius The radius of the cylinder to emit from
  96390. * @param height The height of the emission cylinder
  96391. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96392. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96393. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96394. * @returns the emitter
  96395. */
  96396. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96397. /**
  96398. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96399. * @param radius The radius of the cone to emit from
  96400. * @param angle The base angle of the cone
  96401. * @returns the emitter
  96402. */
  96403. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96404. /**
  96405. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96408. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96409. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96410. * @returns the emitter
  96411. */
  96412. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96413. }
  96414. }
  96415. declare module BABYLON {
  96416. /**
  96417. * Type of sub emitter
  96418. */
  96419. export enum SubEmitterType {
  96420. /**
  96421. * Attached to the particle over it's lifetime
  96422. */
  96423. ATTACHED = 0,
  96424. /**
  96425. * Created when the particle dies
  96426. */
  96427. END = 1
  96428. }
  96429. /**
  96430. * Sub emitter class used to emit particles from an existing particle
  96431. */
  96432. export class SubEmitter {
  96433. /**
  96434. * the particle system to be used by the sub emitter
  96435. */
  96436. particleSystem: ParticleSystem;
  96437. /**
  96438. * Type of the submitter (Default: END)
  96439. */
  96440. type: SubEmitterType;
  96441. /**
  96442. * 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)
  96443. * Note: This only is supported when using an emitter of type Mesh
  96444. */
  96445. inheritDirection: boolean;
  96446. /**
  96447. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96448. */
  96449. inheritedVelocityAmount: number;
  96450. /**
  96451. * Creates a sub emitter
  96452. * @param particleSystem the particle system to be used by the sub emitter
  96453. */
  96454. constructor(
  96455. /**
  96456. * the particle system to be used by the sub emitter
  96457. */
  96458. particleSystem: ParticleSystem);
  96459. /**
  96460. * Clones the sub emitter
  96461. * @returns the cloned sub emitter
  96462. */
  96463. clone(): SubEmitter;
  96464. /**
  96465. * Serialize current object to a JSON object
  96466. * @returns the serialized object
  96467. */
  96468. serialize(): any;
  96469. /** @hidden */
  96470. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96471. /**
  96472. * Creates a new SubEmitter from a serialized JSON version
  96473. * @param serializationObject defines the JSON object to read from
  96474. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96475. * @param rootUrl defines the rootUrl for data loading
  96476. * @returns a new SubEmitter
  96477. */
  96478. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96479. /** Release associated resources */
  96480. dispose(): void;
  96481. }
  96482. }
  96483. declare module BABYLON {
  96484. /** @hidden */
  96485. export var clipPlaneFragmentDeclaration: {
  96486. name: string;
  96487. shader: string;
  96488. };
  96489. }
  96490. declare module BABYLON {
  96491. /** @hidden */
  96492. export var imageProcessingDeclaration: {
  96493. name: string;
  96494. shader: string;
  96495. };
  96496. }
  96497. declare module BABYLON {
  96498. /** @hidden */
  96499. export var imageProcessingFunctions: {
  96500. name: string;
  96501. shader: string;
  96502. };
  96503. }
  96504. declare module BABYLON {
  96505. /** @hidden */
  96506. export var clipPlaneFragment: {
  96507. name: string;
  96508. shader: string;
  96509. };
  96510. }
  96511. declare module BABYLON {
  96512. /** @hidden */
  96513. export var particlesPixelShader: {
  96514. name: string;
  96515. shader: string;
  96516. };
  96517. }
  96518. declare module BABYLON {
  96519. /** @hidden */
  96520. export var clipPlaneVertexDeclaration: {
  96521. name: string;
  96522. shader: string;
  96523. };
  96524. }
  96525. declare module BABYLON {
  96526. /** @hidden */
  96527. export var clipPlaneVertex: {
  96528. name: string;
  96529. shader: string;
  96530. };
  96531. }
  96532. declare module BABYLON {
  96533. /** @hidden */
  96534. export var particlesVertexShader: {
  96535. name: string;
  96536. shader: string;
  96537. };
  96538. }
  96539. declare module BABYLON {
  96540. /**
  96541. * Interface used to define entities containing multiple clip planes
  96542. */
  96543. export interface IClipPlanesHolder {
  96544. /**
  96545. * Gets or sets the active clipplane 1
  96546. */
  96547. clipPlane: Nullable<Plane>;
  96548. /**
  96549. * Gets or sets the active clipplane 2
  96550. */
  96551. clipPlane2: Nullable<Plane>;
  96552. /**
  96553. * Gets or sets the active clipplane 3
  96554. */
  96555. clipPlane3: Nullable<Plane>;
  96556. /**
  96557. * Gets or sets the active clipplane 4
  96558. */
  96559. clipPlane4: Nullable<Plane>;
  96560. /**
  96561. * Gets or sets the active clipplane 5
  96562. */
  96563. clipPlane5: Nullable<Plane>;
  96564. /**
  96565. * Gets or sets the active clipplane 6
  96566. */
  96567. clipPlane6: Nullable<Plane>;
  96568. }
  96569. }
  96570. declare module BABYLON {
  96571. /**
  96572. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96573. *
  96574. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96575. *
  96576. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96577. */
  96578. export class ThinMaterialHelper {
  96579. /**
  96580. * Binds the clip plane information from the holder to the effect.
  96581. * @param effect The effect we are binding the data to
  96582. * @param holder The entity containing the clip plane information
  96583. */
  96584. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96585. }
  96586. }
  96587. declare module BABYLON {
  96588. interface ThinEngine {
  96589. /**
  96590. * Sets alpha constants used by some alpha blending modes
  96591. * @param r defines the red component
  96592. * @param g defines the green component
  96593. * @param b defines the blue component
  96594. * @param a defines the alpha component
  96595. */
  96596. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96597. /**
  96598. * Sets the current alpha mode
  96599. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96600. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96601. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96602. */
  96603. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96604. /**
  96605. * Gets the current alpha mode
  96606. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96607. * @returns the current alpha mode
  96608. */
  96609. getAlphaMode(): number;
  96610. /**
  96611. * Sets the current alpha equation
  96612. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96613. */
  96614. setAlphaEquation(equation: number): void;
  96615. /**
  96616. * Gets the current alpha equation.
  96617. * @returns the current alpha equation
  96618. */
  96619. getAlphaEquation(): number;
  96620. }
  96621. }
  96622. declare module BABYLON {
  96623. /**
  96624. * This represents a particle system in Babylon.
  96625. * 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.
  96626. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96627. * @example https://doc.babylonjs.com/babylon101/particles
  96628. */
  96629. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96630. /**
  96631. * Billboard mode will only apply to Y axis
  96632. */
  96633. static readonly BILLBOARDMODE_Y: number;
  96634. /**
  96635. * Billboard mode will apply to all axes
  96636. */
  96637. static readonly BILLBOARDMODE_ALL: number;
  96638. /**
  96639. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96640. */
  96641. static readonly BILLBOARDMODE_STRETCHED: number;
  96642. /**
  96643. * This function can be defined to provide custom update for active particles.
  96644. * This function will be called instead of regular update (age, position, color, etc.).
  96645. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96646. */
  96647. updateFunction: (particles: Particle[]) => void;
  96648. private _emitterWorldMatrix;
  96649. /**
  96650. * This function can be defined to specify initial direction for every new particle.
  96651. * It by default use the emitterType defined function
  96652. */
  96653. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96654. /**
  96655. * This function can be defined to specify initial position for every new particle.
  96656. * It by default use the emitterType defined function
  96657. */
  96658. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96659. /**
  96660. * @hidden
  96661. */
  96662. _inheritedVelocityOffset: Vector3;
  96663. /**
  96664. * An event triggered when the system is disposed
  96665. */
  96666. onDisposeObservable: Observable<IParticleSystem>;
  96667. /**
  96668. * An event triggered when the system is stopped
  96669. */
  96670. onStoppedObservable: Observable<IParticleSystem>;
  96671. private _onDisposeObserver;
  96672. /**
  96673. * Sets a callback that will be triggered when the system is disposed
  96674. */
  96675. set onDispose(callback: () => void);
  96676. private _particles;
  96677. private _epsilon;
  96678. private _capacity;
  96679. private _stockParticles;
  96680. private _newPartsExcess;
  96681. private _vertexData;
  96682. private _vertexBuffer;
  96683. private _vertexBuffers;
  96684. private _spriteBuffer;
  96685. private _indexBuffer;
  96686. private _effect;
  96687. private _customEffect;
  96688. private _cachedDefines;
  96689. private _scaledColorStep;
  96690. private _colorDiff;
  96691. private _scaledDirection;
  96692. private _scaledGravity;
  96693. private _currentRenderId;
  96694. private _alive;
  96695. private _useInstancing;
  96696. private _vertexArrayObject;
  96697. private _started;
  96698. private _stopped;
  96699. private _actualFrame;
  96700. private _scaledUpdateSpeed;
  96701. private _vertexBufferSize;
  96702. /** @hidden */
  96703. _currentEmitRateGradient: Nullable<FactorGradient>;
  96704. /** @hidden */
  96705. _currentEmitRate1: number;
  96706. /** @hidden */
  96707. _currentEmitRate2: number;
  96708. /** @hidden */
  96709. _currentStartSizeGradient: Nullable<FactorGradient>;
  96710. /** @hidden */
  96711. _currentStartSize1: number;
  96712. /** @hidden */
  96713. _currentStartSize2: number;
  96714. private readonly _rawTextureWidth;
  96715. private _rampGradientsTexture;
  96716. private _useRampGradients;
  96717. /** Gets or sets a matrix to use to compute projection */
  96718. defaultProjectionMatrix: Matrix;
  96719. /** Gets or sets a matrix to use to compute view */
  96720. defaultViewMatrix: Matrix;
  96721. /** Gets or sets a boolean indicating that ramp gradients must be used
  96722. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96723. */
  96724. get useRampGradients(): boolean;
  96725. set useRampGradients(value: boolean);
  96726. /**
  96727. * 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.
  96728. * 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: [])
  96729. */
  96730. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96731. private _subEmitters;
  96732. /**
  96733. * @hidden
  96734. * If the particle systems emitter should be disposed when the particle system is disposed
  96735. */
  96736. _disposeEmitterOnDispose: boolean;
  96737. /**
  96738. * The current active Sub-systems, this property is used by the root particle system only.
  96739. */
  96740. activeSubSystems: Array<ParticleSystem>;
  96741. /**
  96742. * Specifies if the particles are updated in emitter local space or world space
  96743. */
  96744. isLocal: boolean;
  96745. private _rootParticleSystem;
  96746. /**
  96747. * Gets the current list of active particles
  96748. */
  96749. get particles(): Particle[];
  96750. /**
  96751. * Gets the number of particles active at the same time.
  96752. * @returns The number of active particles.
  96753. */
  96754. getActiveCount(): number;
  96755. /**
  96756. * Returns the string "ParticleSystem"
  96757. * @returns a string containing the class name
  96758. */
  96759. getClassName(): string;
  96760. /**
  96761. * Gets a boolean indicating that the system is stopping
  96762. * @returns true if the system is currently stopping
  96763. */
  96764. isStopping(): boolean;
  96765. /**
  96766. * Gets the custom effect used to render the particles
  96767. * @param blendMode Blend mode for which the effect should be retrieved
  96768. * @returns The effect
  96769. */
  96770. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96771. /**
  96772. * Sets the custom effect used to render the particles
  96773. * @param effect The effect to set
  96774. * @param blendMode Blend mode for which the effect should be set
  96775. */
  96776. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96777. /** @hidden */
  96778. private _onBeforeDrawParticlesObservable;
  96779. /**
  96780. * Observable that will be called just before the particles are drawn
  96781. */
  96782. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96783. /**
  96784. * Gets the name of the particle vertex shader
  96785. */
  96786. get vertexShaderName(): string;
  96787. /**
  96788. * Instantiates a particle system.
  96789. * 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.
  96790. * @param name The name of the particle system
  96791. * @param capacity The max number of particles alive at the same time
  96792. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96793. * @param customEffect a custom effect used to change the way particles are rendered by default
  96794. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96795. * @param epsilon Offset used to render the particles
  96796. */
  96797. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96798. private _addFactorGradient;
  96799. private _removeFactorGradient;
  96800. /**
  96801. * Adds a new life time gradient
  96802. * @param gradient defines the gradient to use (between 0 and 1)
  96803. * @param factor defines the life time factor to affect to the specified gradient
  96804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96805. * @returns the current particle system
  96806. */
  96807. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96808. /**
  96809. * Remove a specific life time gradient
  96810. * @param gradient defines the gradient to remove
  96811. * @returns the current particle system
  96812. */
  96813. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96814. /**
  96815. * Adds a new size gradient
  96816. * @param gradient defines the gradient to use (between 0 and 1)
  96817. * @param factor defines the size factor to affect to the specified gradient
  96818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96819. * @returns the current particle system
  96820. */
  96821. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96822. /**
  96823. * Remove a specific size gradient
  96824. * @param gradient defines the gradient to remove
  96825. * @returns the current particle system
  96826. */
  96827. removeSizeGradient(gradient: number): IParticleSystem;
  96828. /**
  96829. * Adds a new color remap gradient
  96830. * @param gradient defines the gradient to use (between 0 and 1)
  96831. * @param min defines the color remap minimal range
  96832. * @param max defines the color remap maximal range
  96833. * @returns the current particle system
  96834. */
  96835. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96836. /**
  96837. * Remove a specific color remap gradient
  96838. * @param gradient defines the gradient to remove
  96839. * @returns the current particle system
  96840. */
  96841. removeColorRemapGradient(gradient: number): IParticleSystem;
  96842. /**
  96843. * Adds a new alpha remap gradient
  96844. * @param gradient defines the gradient to use (between 0 and 1)
  96845. * @param min defines the alpha remap minimal range
  96846. * @param max defines the alpha remap maximal range
  96847. * @returns the current particle system
  96848. */
  96849. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96850. /**
  96851. * Remove a specific alpha remap gradient
  96852. * @param gradient defines the gradient to remove
  96853. * @returns the current particle system
  96854. */
  96855. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96856. /**
  96857. * Adds a new angular speed gradient
  96858. * @param gradient defines the gradient to use (between 0 and 1)
  96859. * @param factor defines the angular speed to affect to the specified gradient
  96860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96861. * @returns the current particle system
  96862. */
  96863. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96864. /**
  96865. * Remove a specific angular speed gradient
  96866. * @param gradient defines the gradient to remove
  96867. * @returns the current particle system
  96868. */
  96869. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96870. /**
  96871. * Adds a new velocity gradient
  96872. * @param gradient defines the gradient to use (between 0 and 1)
  96873. * @param factor defines the velocity to affect to the specified gradient
  96874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96875. * @returns the current particle system
  96876. */
  96877. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96878. /**
  96879. * Remove a specific velocity gradient
  96880. * @param gradient defines the gradient to remove
  96881. * @returns the current particle system
  96882. */
  96883. removeVelocityGradient(gradient: number): IParticleSystem;
  96884. /**
  96885. * Adds a new limit velocity gradient
  96886. * @param gradient defines the gradient to use (between 0 and 1)
  96887. * @param factor defines the limit velocity value to affect to the specified gradient
  96888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96889. * @returns the current particle system
  96890. */
  96891. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96892. /**
  96893. * Remove a specific limit velocity gradient
  96894. * @param gradient defines the gradient to remove
  96895. * @returns the current particle system
  96896. */
  96897. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96898. /**
  96899. * Adds a new drag gradient
  96900. * @param gradient defines the gradient to use (between 0 and 1)
  96901. * @param factor defines the drag value to affect to the specified gradient
  96902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96903. * @returns the current particle system
  96904. */
  96905. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96906. /**
  96907. * Remove a specific drag gradient
  96908. * @param gradient defines the gradient to remove
  96909. * @returns the current particle system
  96910. */
  96911. removeDragGradient(gradient: number): IParticleSystem;
  96912. /**
  96913. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96914. * @param gradient defines the gradient to use (between 0 and 1)
  96915. * @param factor defines the emit rate value to affect to the specified gradient
  96916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96917. * @returns the current particle system
  96918. */
  96919. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96920. /**
  96921. * Remove a specific emit rate gradient
  96922. * @param gradient defines the gradient to remove
  96923. * @returns the current particle system
  96924. */
  96925. removeEmitRateGradient(gradient: number): IParticleSystem;
  96926. /**
  96927. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96928. * @param gradient defines the gradient to use (between 0 and 1)
  96929. * @param factor defines the start size value to affect to the specified gradient
  96930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96931. * @returns the current particle system
  96932. */
  96933. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96934. /**
  96935. * Remove a specific start size gradient
  96936. * @param gradient defines the gradient to remove
  96937. * @returns the current particle system
  96938. */
  96939. removeStartSizeGradient(gradient: number): IParticleSystem;
  96940. private _createRampGradientTexture;
  96941. /**
  96942. * Gets the current list of ramp gradients.
  96943. * You must use addRampGradient and removeRampGradient to udpate this list
  96944. * @returns the list of ramp gradients
  96945. */
  96946. getRampGradients(): Nullable<Array<Color3Gradient>>;
  96947. /** Force the system to rebuild all gradients that need to be resync */
  96948. forceRefreshGradients(): void;
  96949. private _syncRampGradientTexture;
  96950. /**
  96951. * Adds a new ramp gradient used to remap particle colors
  96952. * @param gradient defines the gradient to use (between 0 and 1)
  96953. * @param color defines the color to affect to the specified gradient
  96954. * @returns the current particle system
  96955. */
  96956. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  96957. /**
  96958. * Remove a specific ramp gradient
  96959. * @param gradient defines the gradient to remove
  96960. * @returns the current particle system
  96961. */
  96962. removeRampGradient(gradient: number): ParticleSystem;
  96963. /**
  96964. * Adds a new color gradient
  96965. * @param gradient defines the gradient to use (between 0 and 1)
  96966. * @param color1 defines the color to affect to the specified gradient
  96967. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  96968. * @returns this particle system
  96969. */
  96970. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  96971. /**
  96972. * Remove a specific color gradient
  96973. * @param gradient defines the gradient to remove
  96974. * @returns this particle system
  96975. */
  96976. removeColorGradient(gradient: number): IParticleSystem;
  96977. private _fetchR;
  96978. protected _reset(): void;
  96979. private _resetEffect;
  96980. private _createVertexBuffers;
  96981. private _createIndexBuffer;
  96982. /**
  96983. * Gets the maximum number of particles active at the same time.
  96984. * @returns The max number of active particles.
  96985. */
  96986. getCapacity(): number;
  96987. /**
  96988. * Gets whether there are still active particles in the system.
  96989. * @returns True if it is alive, otherwise false.
  96990. */
  96991. isAlive(): boolean;
  96992. /**
  96993. * Gets if the system has been started. (Note: this will still be true after stop is called)
  96994. * @returns True if it has been started, otherwise false.
  96995. */
  96996. isStarted(): boolean;
  96997. private _prepareSubEmitterInternalArray;
  96998. /**
  96999. * Starts the particle system and begins to emit
  97000. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  97001. */
  97002. start(delay?: number): void;
  97003. /**
  97004. * Stops the particle system.
  97005. * @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.
  97006. */
  97007. stop(stopSubEmitters?: boolean): void;
  97008. /**
  97009. * Remove all active particles
  97010. */
  97011. reset(): void;
  97012. /**
  97013. * @hidden (for internal use only)
  97014. */
  97015. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  97016. /**
  97017. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  97018. * Its lifetime will start back at 0.
  97019. */
  97020. recycleParticle: (particle: Particle) => void;
  97021. private _stopSubEmitters;
  97022. private _createParticle;
  97023. private _removeFromRoot;
  97024. private _emitFromParticle;
  97025. private _update;
  97026. /** @hidden */
  97027. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  97028. /** @hidden */
  97029. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  97030. /**
  97031. * Fill the defines array according to the current settings of the particle system
  97032. * @param defines Array to be updated
  97033. * @param blendMode blend mode to take into account when updating the array
  97034. */
  97035. fillDefines(defines: Array<string>, blendMode: number): void;
  97036. /**
  97037. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  97038. * @param uniforms Uniforms array to fill
  97039. * @param attributes Attributes array to fill
  97040. * @param samplers Samplers array to fill
  97041. */
  97042. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  97043. /** @hidden */
  97044. private _getEffect;
  97045. /**
  97046. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  97047. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  97048. */
  97049. animate(preWarmOnly?: boolean): void;
  97050. private _appendParticleVertices;
  97051. /**
  97052. * Rebuilds the particle system.
  97053. */
  97054. rebuild(): void;
  97055. /**
  97056. * Is this system ready to be used/rendered
  97057. * @return true if the system is ready
  97058. */
  97059. isReady(): boolean;
  97060. private _render;
  97061. /**
  97062. * Renders the particle system in its current state.
  97063. * @returns the current number of particles
  97064. */
  97065. render(): number;
  97066. /**
  97067. * Disposes the particle system and free the associated resources
  97068. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  97069. */
  97070. dispose(disposeTexture?: boolean): void;
  97071. /**
  97072. * Clones the particle system.
  97073. * @param name The name of the cloned object
  97074. * @param newEmitter The new emitter to use
  97075. * @returns the cloned particle system
  97076. */
  97077. clone(name: string, newEmitter: any): ParticleSystem;
  97078. /**
  97079. * Serializes the particle system to a JSON object
  97080. * @param serializeTexture defines if the texture must be serialized as well
  97081. * @returns the JSON object
  97082. */
  97083. serialize(serializeTexture?: boolean): any;
  97084. /** @hidden */
  97085. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  97086. /** @hidden */
  97087. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  97088. /**
  97089. * Parses a JSON object to create a particle system.
  97090. * @param parsedParticleSystem The JSON object to parse
  97091. * @param sceneOrEngine The scene or the engine to create the particle system in
  97092. * @param rootUrl The root url to use to load external dependencies like texture
  97093. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  97094. * @returns the Parsed particle system
  97095. */
  97096. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  97097. }
  97098. }
  97099. declare module BABYLON {
  97100. /**
  97101. * A particle represents one of the element emitted by a particle system.
  97102. * This is mainly define by its coordinates, direction, velocity and age.
  97103. */
  97104. export class Particle {
  97105. /**
  97106. * The particle system the particle belongs to.
  97107. */
  97108. particleSystem: ParticleSystem;
  97109. private static _Count;
  97110. /**
  97111. * Unique ID of the particle
  97112. */
  97113. id: number;
  97114. /**
  97115. * The world position of the particle in the scene.
  97116. */
  97117. position: Vector3;
  97118. /**
  97119. * The world direction of the particle in the scene.
  97120. */
  97121. direction: Vector3;
  97122. /**
  97123. * The color of the particle.
  97124. */
  97125. color: Color4;
  97126. /**
  97127. * The color change of the particle per step.
  97128. */
  97129. colorStep: Color4;
  97130. /**
  97131. * Defines how long will the life of the particle be.
  97132. */
  97133. lifeTime: number;
  97134. /**
  97135. * The current age of the particle.
  97136. */
  97137. age: number;
  97138. /**
  97139. * The current size of the particle.
  97140. */
  97141. size: number;
  97142. /**
  97143. * The current scale of the particle.
  97144. */
  97145. scale: Vector2;
  97146. /**
  97147. * The current angle of the particle.
  97148. */
  97149. angle: number;
  97150. /**
  97151. * Defines how fast is the angle changing.
  97152. */
  97153. angularSpeed: number;
  97154. /**
  97155. * Defines the cell index used by the particle to be rendered from a sprite.
  97156. */
  97157. cellIndex: number;
  97158. /**
  97159. * The information required to support color remapping
  97160. */
  97161. remapData: Vector4;
  97162. /** @hidden */
  97163. _randomCellOffset?: number;
  97164. /** @hidden */
  97165. _initialDirection: Nullable<Vector3>;
  97166. /** @hidden */
  97167. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  97168. /** @hidden */
  97169. _initialStartSpriteCellID: number;
  97170. /** @hidden */
  97171. _initialEndSpriteCellID: number;
  97172. /** @hidden */
  97173. _currentColorGradient: Nullable<ColorGradient>;
  97174. /** @hidden */
  97175. _currentColor1: Color4;
  97176. /** @hidden */
  97177. _currentColor2: Color4;
  97178. /** @hidden */
  97179. _currentSizeGradient: Nullable<FactorGradient>;
  97180. /** @hidden */
  97181. _currentSize1: number;
  97182. /** @hidden */
  97183. _currentSize2: number;
  97184. /** @hidden */
  97185. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  97186. /** @hidden */
  97187. _currentAngularSpeed1: number;
  97188. /** @hidden */
  97189. _currentAngularSpeed2: number;
  97190. /** @hidden */
  97191. _currentVelocityGradient: Nullable<FactorGradient>;
  97192. /** @hidden */
  97193. _currentVelocity1: number;
  97194. /** @hidden */
  97195. _currentVelocity2: number;
  97196. /** @hidden */
  97197. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  97198. /** @hidden */
  97199. _currentLimitVelocity1: number;
  97200. /** @hidden */
  97201. _currentLimitVelocity2: number;
  97202. /** @hidden */
  97203. _currentDragGradient: Nullable<FactorGradient>;
  97204. /** @hidden */
  97205. _currentDrag1: number;
  97206. /** @hidden */
  97207. _currentDrag2: number;
  97208. /** @hidden */
  97209. _randomNoiseCoordinates1: Vector3;
  97210. /** @hidden */
  97211. _randomNoiseCoordinates2: Vector3;
  97212. /** @hidden */
  97213. _localPosition?: Vector3;
  97214. /**
  97215. * Creates a new instance Particle
  97216. * @param particleSystem the particle system the particle belongs to
  97217. */
  97218. constructor(
  97219. /**
  97220. * The particle system the particle belongs to.
  97221. */
  97222. particleSystem: ParticleSystem);
  97223. private updateCellInfoFromSystem;
  97224. /**
  97225. * Defines how the sprite cell index is updated for the particle
  97226. */
  97227. updateCellIndex(): void;
  97228. /** @hidden */
  97229. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  97230. /** @hidden */
  97231. _inheritParticleInfoToSubEmitters(): void;
  97232. /** @hidden */
  97233. _reset(): void;
  97234. /**
  97235. * Copy the properties of particle to another one.
  97236. * @param other the particle to copy the information to.
  97237. */
  97238. copyTo(other: Particle): void;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Particle emitter represents a volume emitting particles.
  97244. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97245. */
  97246. export interface IParticleEmitterType {
  97247. /**
  97248. * Called by the particle System when the direction is computed for the created particle.
  97249. * @param worldMatrix is the world matrix of the particle system
  97250. * @param directionToUpdate is the direction vector to update with the result
  97251. * @param particle is the particle we are computed the direction for
  97252. * @param isLocal defines if the direction should be set in local space
  97253. */
  97254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97255. /**
  97256. * Called by the particle System when the position is computed for the created particle.
  97257. * @param worldMatrix is the world matrix of the particle system
  97258. * @param positionToUpdate is the position vector to update with the result
  97259. * @param particle is the particle we are computed the position for
  97260. * @param isLocal defines if the position should be set in local space
  97261. */
  97262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97263. /**
  97264. * Clones the current emitter and returns a copy of it
  97265. * @returns the new emitter
  97266. */
  97267. clone(): IParticleEmitterType;
  97268. /**
  97269. * Called by the GPUParticleSystem to setup the update shader
  97270. * @param effect defines the update shader
  97271. */
  97272. applyToShader(effect: Effect): void;
  97273. /**
  97274. * Returns a string to use to update the GPU particles update shader
  97275. * @returns the effect defines string
  97276. */
  97277. getEffectDefines(): string;
  97278. /**
  97279. * Returns a string representing the class name
  97280. * @returns a string containing the class name
  97281. */
  97282. getClassName(): string;
  97283. /**
  97284. * Serializes the particle system to a JSON object.
  97285. * @returns the JSON object
  97286. */
  97287. serialize(): any;
  97288. /**
  97289. * Parse properties from a JSON object
  97290. * @param serializationObject defines the JSON object
  97291. * @param scene defines the hosting scene
  97292. */
  97293. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97294. }
  97295. }
  97296. declare module BABYLON {
  97297. /**
  97298. * Particle emitter emitting particles from the inside of a box.
  97299. * It emits the particles randomly between 2 given directions.
  97300. */
  97301. export class BoxParticleEmitter implements IParticleEmitterType {
  97302. /**
  97303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97304. */
  97305. direction1: Vector3;
  97306. /**
  97307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97308. */
  97309. direction2: Vector3;
  97310. /**
  97311. * 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.
  97312. */
  97313. minEmitBox: Vector3;
  97314. /**
  97315. * 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.
  97316. */
  97317. maxEmitBox: Vector3;
  97318. /**
  97319. * Creates a new instance BoxParticleEmitter
  97320. */
  97321. constructor();
  97322. /**
  97323. * Called by the particle System when the direction is computed for the created particle.
  97324. * @param worldMatrix is the world matrix of the particle system
  97325. * @param directionToUpdate is the direction vector to update with the result
  97326. * @param particle is the particle we are computed the direction for
  97327. * @param isLocal defines if the direction should be set in local space
  97328. */
  97329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97330. /**
  97331. * Called by the particle System when the position is computed for the created particle.
  97332. * @param worldMatrix is the world matrix of the particle system
  97333. * @param positionToUpdate is the position vector to update with the result
  97334. * @param particle is the particle we are computed the position for
  97335. * @param isLocal defines if the position should be set in local space
  97336. */
  97337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97338. /**
  97339. * Clones the current emitter and returns a copy of it
  97340. * @returns the new emitter
  97341. */
  97342. clone(): BoxParticleEmitter;
  97343. /**
  97344. * Called by the GPUParticleSystem to setup the update shader
  97345. * @param effect defines the update shader
  97346. */
  97347. applyToShader(effect: Effect): void;
  97348. /**
  97349. * Returns a string to use to update the GPU particles update shader
  97350. * @returns a string containng the defines string
  97351. */
  97352. getEffectDefines(): string;
  97353. /**
  97354. * Returns the string "BoxParticleEmitter"
  97355. * @returns a string containing the class name
  97356. */
  97357. getClassName(): string;
  97358. /**
  97359. * Serializes the particle system to a JSON object.
  97360. * @returns the JSON object
  97361. */
  97362. serialize(): any;
  97363. /**
  97364. * Parse properties from a JSON object
  97365. * @param serializationObject defines the JSON object
  97366. */
  97367. parse(serializationObject: any): void;
  97368. }
  97369. }
  97370. declare module BABYLON {
  97371. /**
  97372. * Particle emitter emitting particles from the inside of a cone.
  97373. * It emits the particles alongside the cone volume from the base to the particle.
  97374. * The emission direction might be randomized.
  97375. */
  97376. export class ConeParticleEmitter implements IParticleEmitterType {
  97377. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97378. directionRandomizer: number;
  97379. private _radius;
  97380. private _angle;
  97381. private _height;
  97382. /**
  97383. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97384. */
  97385. radiusRange: number;
  97386. /**
  97387. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97388. */
  97389. heightRange: number;
  97390. /**
  97391. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97392. */
  97393. emitFromSpawnPointOnly: boolean;
  97394. /**
  97395. * Gets or sets the radius of the emission cone
  97396. */
  97397. get radius(): number;
  97398. set radius(value: number);
  97399. /**
  97400. * Gets or sets the angle of the emission cone
  97401. */
  97402. get angle(): number;
  97403. set angle(value: number);
  97404. private _buildHeight;
  97405. /**
  97406. * Creates a new instance ConeParticleEmitter
  97407. * @param radius the radius of the emission cone (1 by default)
  97408. * @param angle the cone base angle (PI by default)
  97409. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97410. */
  97411. constructor(radius?: number, angle?: number,
  97412. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97413. directionRandomizer?: number);
  97414. /**
  97415. * Called by the particle System when the direction is computed for the created particle.
  97416. * @param worldMatrix is the world matrix of the particle system
  97417. * @param directionToUpdate is the direction vector to update with the result
  97418. * @param particle is the particle we are computed the direction for
  97419. * @param isLocal defines if the direction should be set in local space
  97420. */
  97421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97422. /**
  97423. * Called by the particle System when the position is computed for the created particle.
  97424. * @param worldMatrix is the world matrix of the particle system
  97425. * @param positionToUpdate is the position vector to update with the result
  97426. * @param particle is the particle we are computed the position for
  97427. * @param isLocal defines if the position should be set in local space
  97428. */
  97429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97430. /**
  97431. * Clones the current emitter and returns a copy of it
  97432. * @returns the new emitter
  97433. */
  97434. clone(): ConeParticleEmitter;
  97435. /**
  97436. * Called by the GPUParticleSystem to setup the update shader
  97437. * @param effect defines the update shader
  97438. */
  97439. applyToShader(effect: Effect): void;
  97440. /**
  97441. * Returns a string to use to update the GPU particles update shader
  97442. * @returns a string containng the defines string
  97443. */
  97444. getEffectDefines(): string;
  97445. /**
  97446. * Returns the string "ConeParticleEmitter"
  97447. * @returns a string containing the class name
  97448. */
  97449. getClassName(): string;
  97450. /**
  97451. * Serializes the particle system to a JSON object.
  97452. * @returns the JSON object
  97453. */
  97454. serialize(): any;
  97455. /**
  97456. * Parse properties from a JSON object
  97457. * @param serializationObject defines the JSON object
  97458. */
  97459. parse(serializationObject: any): void;
  97460. }
  97461. }
  97462. declare module BABYLON {
  97463. /**
  97464. * Particle emitter emitting particles from the inside of a cylinder.
  97465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97466. */
  97467. export class CylinderParticleEmitter implements IParticleEmitterType {
  97468. /**
  97469. * The radius of the emission cylinder.
  97470. */
  97471. radius: number;
  97472. /**
  97473. * The height of the emission cylinder.
  97474. */
  97475. height: number;
  97476. /**
  97477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97478. */
  97479. radiusRange: number;
  97480. /**
  97481. * How much to randomize the particle direction [0-1].
  97482. */
  97483. directionRandomizer: number;
  97484. /**
  97485. * Creates a new instance CylinderParticleEmitter
  97486. * @param radius the radius of the emission cylinder (1 by default)
  97487. * @param height the height of the emission cylinder (1 by default)
  97488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97490. */
  97491. constructor(
  97492. /**
  97493. * The radius of the emission cylinder.
  97494. */
  97495. radius?: number,
  97496. /**
  97497. * The height of the emission cylinder.
  97498. */
  97499. height?: number,
  97500. /**
  97501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97502. */
  97503. radiusRange?: number,
  97504. /**
  97505. * How much to randomize the particle direction [0-1].
  97506. */
  97507. directionRandomizer?: number);
  97508. /**
  97509. * Called by the particle System when the direction is computed for the created particle.
  97510. * @param worldMatrix is the world matrix of the particle system
  97511. * @param directionToUpdate is the direction vector to update with the result
  97512. * @param particle is the particle we are computed the direction for
  97513. * @param isLocal defines if the direction should be set in local space
  97514. */
  97515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97516. /**
  97517. * Called by the particle System when the position is computed for the created particle.
  97518. * @param worldMatrix is the world matrix of the particle system
  97519. * @param positionToUpdate is the position vector to update with the result
  97520. * @param particle is the particle we are computed the position for
  97521. * @param isLocal defines if the position should be set in local space
  97522. */
  97523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97524. /**
  97525. * Clones the current emitter and returns a copy of it
  97526. * @returns the new emitter
  97527. */
  97528. clone(): CylinderParticleEmitter;
  97529. /**
  97530. * Called by the GPUParticleSystem to setup the update shader
  97531. * @param effect defines the update shader
  97532. */
  97533. applyToShader(effect: Effect): void;
  97534. /**
  97535. * Returns a string to use to update the GPU particles update shader
  97536. * @returns a string containng the defines string
  97537. */
  97538. getEffectDefines(): string;
  97539. /**
  97540. * Returns the string "CylinderParticleEmitter"
  97541. * @returns a string containing the class name
  97542. */
  97543. getClassName(): string;
  97544. /**
  97545. * Serializes the particle system to a JSON object.
  97546. * @returns the JSON object
  97547. */
  97548. serialize(): any;
  97549. /**
  97550. * Parse properties from a JSON object
  97551. * @param serializationObject defines the JSON object
  97552. */
  97553. parse(serializationObject: any): void;
  97554. }
  97555. /**
  97556. * Particle emitter emitting particles from the inside of a cylinder.
  97557. * It emits the particles randomly between two vectors.
  97558. */
  97559. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97560. /**
  97561. * The min limit of the emission direction.
  97562. */
  97563. direction1: Vector3;
  97564. /**
  97565. * The max limit of the emission direction.
  97566. */
  97567. direction2: Vector3;
  97568. /**
  97569. * Creates a new instance CylinderDirectedParticleEmitter
  97570. * @param radius the radius of the emission cylinder (1 by default)
  97571. * @param height the height of the emission cylinder (1 by default)
  97572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97573. * @param direction1 the min limit of the emission direction (up vector by default)
  97574. * @param direction2 the max limit of the emission direction (up vector by default)
  97575. */
  97576. constructor(radius?: number, height?: number, radiusRange?: number,
  97577. /**
  97578. * The min limit of the emission direction.
  97579. */
  97580. direction1?: Vector3,
  97581. /**
  97582. * The max limit of the emission direction.
  97583. */
  97584. direction2?: Vector3);
  97585. /**
  97586. * Called by the particle System when the direction is computed for the created particle.
  97587. * @param worldMatrix is the world matrix of the particle system
  97588. * @param directionToUpdate is the direction vector to update with the result
  97589. * @param particle is the particle we are computed the direction for
  97590. */
  97591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97592. /**
  97593. * Clones the current emitter and returns a copy of it
  97594. * @returns the new emitter
  97595. */
  97596. clone(): CylinderDirectedParticleEmitter;
  97597. /**
  97598. * Called by the GPUParticleSystem to setup the update shader
  97599. * @param effect defines the update shader
  97600. */
  97601. applyToShader(effect: Effect): void;
  97602. /**
  97603. * Returns a string to use to update the GPU particles update shader
  97604. * @returns a string containng the defines string
  97605. */
  97606. getEffectDefines(): string;
  97607. /**
  97608. * Returns the string "CylinderDirectedParticleEmitter"
  97609. * @returns a string containing the class name
  97610. */
  97611. getClassName(): string;
  97612. /**
  97613. * Serializes the particle system to a JSON object.
  97614. * @returns the JSON object
  97615. */
  97616. serialize(): any;
  97617. /**
  97618. * Parse properties from a JSON object
  97619. * @param serializationObject defines the JSON object
  97620. */
  97621. parse(serializationObject: any): void;
  97622. }
  97623. }
  97624. declare module BABYLON {
  97625. /**
  97626. * Particle emitter emitting particles from the inside of a hemisphere.
  97627. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97628. */
  97629. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97630. /**
  97631. * The radius of the emission hemisphere.
  97632. */
  97633. radius: number;
  97634. /**
  97635. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97636. */
  97637. radiusRange: number;
  97638. /**
  97639. * How much to randomize the particle direction [0-1].
  97640. */
  97641. directionRandomizer: number;
  97642. /**
  97643. * Creates a new instance HemisphericParticleEmitter
  97644. * @param radius the radius of the emission hemisphere (1 by default)
  97645. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97646. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97647. */
  97648. constructor(
  97649. /**
  97650. * The radius of the emission hemisphere.
  97651. */
  97652. radius?: number,
  97653. /**
  97654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97655. */
  97656. radiusRange?: number,
  97657. /**
  97658. * How much to randomize the particle direction [0-1].
  97659. */
  97660. directionRandomizer?: number);
  97661. /**
  97662. * Called by the particle System when the direction is computed for the created particle.
  97663. * @param worldMatrix is the world matrix of the particle system
  97664. * @param directionToUpdate is the direction vector to update with the result
  97665. * @param particle is the particle we are computed the direction for
  97666. * @param isLocal defines if the direction should be set in local space
  97667. */
  97668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97669. /**
  97670. * Called by the particle System when the position is computed for the created particle.
  97671. * @param worldMatrix is the world matrix of the particle system
  97672. * @param positionToUpdate is the position vector to update with the result
  97673. * @param particle is the particle we are computed the position for
  97674. * @param isLocal defines if the position should be set in local space
  97675. */
  97676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97677. /**
  97678. * Clones the current emitter and returns a copy of it
  97679. * @returns the new emitter
  97680. */
  97681. clone(): HemisphericParticleEmitter;
  97682. /**
  97683. * Called by the GPUParticleSystem to setup the update shader
  97684. * @param effect defines the update shader
  97685. */
  97686. applyToShader(effect: Effect): void;
  97687. /**
  97688. * Returns a string to use to update the GPU particles update shader
  97689. * @returns a string containng the defines string
  97690. */
  97691. getEffectDefines(): string;
  97692. /**
  97693. * Returns the string "HemisphericParticleEmitter"
  97694. * @returns a string containing the class name
  97695. */
  97696. getClassName(): string;
  97697. /**
  97698. * Serializes the particle system to a JSON object.
  97699. * @returns the JSON object
  97700. */
  97701. serialize(): any;
  97702. /**
  97703. * Parse properties from a JSON object
  97704. * @param serializationObject defines the JSON object
  97705. */
  97706. parse(serializationObject: any): void;
  97707. }
  97708. }
  97709. declare module BABYLON {
  97710. /**
  97711. * Particle emitter emitting particles from a point.
  97712. * It emits the particles randomly between 2 given directions.
  97713. */
  97714. export class PointParticleEmitter implements IParticleEmitterType {
  97715. /**
  97716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97717. */
  97718. direction1: Vector3;
  97719. /**
  97720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97721. */
  97722. direction2: Vector3;
  97723. /**
  97724. * Creates a new instance PointParticleEmitter
  97725. */
  97726. constructor();
  97727. /**
  97728. * Called by the particle System when the direction is computed for the created particle.
  97729. * @param worldMatrix is the world matrix of the particle system
  97730. * @param directionToUpdate is the direction vector to update with the result
  97731. * @param particle is the particle we are computed the direction for
  97732. * @param isLocal defines if the direction should be set in local space
  97733. */
  97734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97735. /**
  97736. * Called by the particle System when the position is computed for the created particle.
  97737. * @param worldMatrix is the world matrix of the particle system
  97738. * @param positionToUpdate is the position vector to update with the result
  97739. * @param particle is the particle we are computed the position for
  97740. * @param isLocal defines if the position should be set in local space
  97741. */
  97742. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97743. /**
  97744. * Clones the current emitter and returns a copy of it
  97745. * @returns the new emitter
  97746. */
  97747. clone(): PointParticleEmitter;
  97748. /**
  97749. * Called by the GPUParticleSystem to setup the update shader
  97750. * @param effect defines the update shader
  97751. */
  97752. applyToShader(effect: Effect): void;
  97753. /**
  97754. * Returns a string to use to update the GPU particles update shader
  97755. * @returns a string containng the defines string
  97756. */
  97757. getEffectDefines(): string;
  97758. /**
  97759. * Returns the string "PointParticleEmitter"
  97760. * @returns a string containing the class name
  97761. */
  97762. getClassName(): string;
  97763. /**
  97764. * Serializes the particle system to a JSON object.
  97765. * @returns the JSON object
  97766. */
  97767. serialize(): any;
  97768. /**
  97769. * Parse properties from a JSON object
  97770. * @param serializationObject defines the JSON object
  97771. */
  97772. parse(serializationObject: any): void;
  97773. }
  97774. }
  97775. declare module BABYLON {
  97776. /**
  97777. * Particle emitter emitting particles from the inside of a sphere.
  97778. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97779. */
  97780. export class SphereParticleEmitter implements IParticleEmitterType {
  97781. /**
  97782. * The radius of the emission sphere.
  97783. */
  97784. radius: number;
  97785. /**
  97786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97787. */
  97788. radiusRange: number;
  97789. /**
  97790. * How much to randomize the particle direction [0-1].
  97791. */
  97792. directionRandomizer: number;
  97793. /**
  97794. * Creates a new instance SphereParticleEmitter
  97795. * @param radius the radius of the emission sphere (1 by default)
  97796. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97797. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97798. */
  97799. constructor(
  97800. /**
  97801. * The radius of the emission sphere.
  97802. */
  97803. radius?: number,
  97804. /**
  97805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97806. */
  97807. radiusRange?: number,
  97808. /**
  97809. * How much to randomize the particle direction [0-1].
  97810. */
  97811. directionRandomizer?: number);
  97812. /**
  97813. * Called by the particle System when the direction is computed for the created particle.
  97814. * @param worldMatrix is the world matrix of the particle system
  97815. * @param directionToUpdate is the direction vector to update with the result
  97816. * @param particle is the particle we are computed the direction for
  97817. * @param isLocal defines if the direction should be set in local space
  97818. */
  97819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97820. /**
  97821. * Called by the particle System when the position is computed for the created particle.
  97822. * @param worldMatrix is the world matrix of the particle system
  97823. * @param positionToUpdate is the position vector to update with the result
  97824. * @param particle is the particle we are computed the position for
  97825. * @param isLocal defines if the position should be set in local space
  97826. */
  97827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97828. /**
  97829. * Clones the current emitter and returns a copy of it
  97830. * @returns the new emitter
  97831. */
  97832. clone(): SphereParticleEmitter;
  97833. /**
  97834. * Called by the GPUParticleSystem to setup the update shader
  97835. * @param effect defines the update shader
  97836. */
  97837. applyToShader(effect: Effect): void;
  97838. /**
  97839. * Returns a string to use to update the GPU particles update shader
  97840. * @returns a string containng the defines string
  97841. */
  97842. getEffectDefines(): string;
  97843. /**
  97844. * Returns the string "SphereParticleEmitter"
  97845. * @returns a string containing the class name
  97846. */
  97847. getClassName(): string;
  97848. /**
  97849. * Serializes the particle system to a JSON object.
  97850. * @returns the JSON object
  97851. */
  97852. serialize(): any;
  97853. /**
  97854. * Parse properties from a JSON object
  97855. * @param serializationObject defines the JSON object
  97856. */
  97857. parse(serializationObject: any): void;
  97858. }
  97859. /**
  97860. * Particle emitter emitting particles from the inside of a sphere.
  97861. * It emits the particles randomly between two vectors.
  97862. */
  97863. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97864. /**
  97865. * The min limit of the emission direction.
  97866. */
  97867. direction1: Vector3;
  97868. /**
  97869. * The max limit of the emission direction.
  97870. */
  97871. direction2: Vector3;
  97872. /**
  97873. * Creates a new instance SphereDirectedParticleEmitter
  97874. * @param radius the radius of the emission sphere (1 by default)
  97875. * @param direction1 the min limit of the emission direction (up vector by default)
  97876. * @param direction2 the max limit of the emission direction (up vector by default)
  97877. */
  97878. constructor(radius?: number,
  97879. /**
  97880. * The min limit of the emission direction.
  97881. */
  97882. direction1?: Vector3,
  97883. /**
  97884. * The max limit of the emission direction.
  97885. */
  97886. direction2?: Vector3);
  97887. /**
  97888. * Called by the particle System when the direction is computed for the created particle.
  97889. * @param worldMatrix is the world matrix of the particle system
  97890. * @param directionToUpdate is the direction vector to update with the result
  97891. * @param particle is the particle we are computed the direction for
  97892. */
  97893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97894. /**
  97895. * Clones the current emitter and returns a copy of it
  97896. * @returns the new emitter
  97897. */
  97898. clone(): SphereDirectedParticleEmitter;
  97899. /**
  97900. * Called by the GPUParticleSystem to setup the update shader
  97901. * @param effect defines the update shader
  97902. */
  97903. applyToShader(effect: Effect): void;
  97904. /**
  97905. * Returns a string to use to update the GPU particles update shader
  97906. * @returns a string containng the defines string
  97907. */
  97908. getEffectDefines(): string;
  97909. /**
  97910. * Returns the string "SphereDirectedParticleEmitter"
  97911. * @returns a string containing the class name
  97912. */
  97913. getClassName(): string;
  97914. /**
  97915. * Serializes the particle system to a JSON object.
  97916. * @returns the JSON object
  97917. */
  97918. serialize(): any;
  97919. /**
  97920. * Parse properties from a JSON object
  97921. * @param serializationObject defines the JSON object
  97922. */
  97923. parse(serializationObject: any): void;
  97924. }
  97925. }
  97926. declare module BABYLON {
  97927. /**
  97928. * Particle emitter emitting particles from a custom list of positions.
  97929. */
  97930. export class CustomParticleEmitter implements IParticleEmitterType {
  97931. /**
  97932. * Gets or sets the position generator that will create the inital position of each particle.
  97933. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97934. */
  97935. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  97936. /**
  97937. * Gets or sets the destination generator that will create the final destination of each particle.
  97938. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97939. */
  97940. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  97941. /**
  97942. * Creates a new instance CustomParticleEmitter
  97943. */
  97944. constructor();
  97945. /**
  97946. * Called by the particle System when the direction is computed for the created particle.
  97947. * @param worldMatrix is the world matrix of the particle system
  97948. * @param directionToUpdate is the direction vector to update with the result
  97949. * @param particle is the particle we are computed the direction for
  97950. * @param isLocal defines if the direction should be set in local space
  97951. */
  97952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97953. /**
  97954. * Called by the particle System when the position is computed for the created particle.
  97955. * @param worldMatrix is the world matrix of the particle system
  97956. * @param positionToUpdate is the position vector to update with the result
  97957. * @param particle is the particle we are computed the position for
  97958. * @param isLocal defines if the position should be set in local space
  97959. */
  97960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97961. /**
  97962. * Clones the current emitter and returns a copy of it
  97963. * @returns the new emitter
  97964. */
  97965. clone(): CustomParticleEmitter;
  97966. /**
  97967. * Called by the GPUParticleSystem to setup the update shader
  97968. * @param effect defines the update shader
  97969. */
  97970. applyToShader(effect: Effect): void;
  97971. /**
  97972. * Returns a string to use to update the GPU particles update shader
  97973. * @returns a string containng the defines string
  97974. */
  97975. getEffectDefines(): string;
  97976. /**
  97977. * Returns the string "PointParticleEmitter"
  97978. * @returns a string containing the class name
  97979. */
  97980. getClassName(): string;
  97981. /**
  97982. * Serializes the particle system to a JSON object.
  97983. * @returns the JSON object
  97984. */
  97985. serialize(): any;
  97986. /**
  97987. * Parse properties from a JSON object
  97988. * @param serializationObject defines the JSON object
  97989. */
  97990. parse(serializationObject: any): void;
  97991. }
  97992. }
  97993. declare module BABYLON {
  97994. /**
  97995. * Particle emitter emitting particles from the inside of a box.
  97996. * It emits the particles randomly between 2 given directions.
  97997. */
  97998. export class MeshParticleEmitter implements IParticleEmitterType {
  97999. private _indices;
  98000. private _positions;
  98001. private _normals;
  98002. private _storedNormal;
  98003. private _mesh;
  98004. /**
  98005. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  98006. */
  98007. direction1: Vector3;
  98008. /**
  98009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  98010. */
  98011. direction2: Vector3;
  98012. /**
  98013. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  98014. */
  98015. useMeshNormalsForDirection: boolean;
  98016. /** Defines the mesh to use as source */
  98017. get mesh(): Nullable<AbstractMesh>;
  98018. set mesh(value: Nullable<AbstractMesh>);
  98019. /**
  98020. * Creates a new instance MeshParticleEmitter
  98021. * @param mesh defines the mesh to use as source
  98022. */
  98023. constructor(mesh?: Nullable<AbstractMesh>);
  98024. /**
  98025. * Called by the particle System when the direction is computed for the created particle.
  98026. * @param worldMatrix is the world matrix of the particle system
  98027. * @param directionToUpdate is the direction vector to update with the result
  98028. * @param particle is the particle we are computed the direction for
  98029. * @param isLocal defines if the direction should be set in local space
  98030. */
  98031. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98032. /**
  98033. * Called by the particle System when the position is computed for the created particle.
  98034. * @param worldMatrix is the world matrix of the particle system
  98035. * @param positionToUpdate is the position vector to update with the result
  98036. * @param particle is the particle we are computed the position for
  98037. * @param isLocal defines if the position should be set in local space
  98038. */
  98039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98040. /**
  98041. * Clones the current emitter and returns a copy of it
  98042. * @returns the new emitter
  98043. */
  98044. clone(): MeshParticleEmitter;
  98045. /**
  98046. * Called by the GPUParticleSystem to setup the update shader
  98047. * @param effect defines the update shader
  98048. */
  98049. applyToShader(effect: Effect): void;
  98050. /**
  98051. * Returns a string to use to update the GPU particles update shader
  98052. * @returns a string containng the defines string
  98053. */
  98054. getEffectDefines(): string;
  98055. /**
  98056. * Returns the string "BoxParticleEmitter"
  98057. * @returns a string containing the class name
  98058. */
  98059. getClassName(): string;
  98060. /**
  98061. * Serializes the particle system to a JSON object.
  98062. * @returns the JSON object
  98063. */
  98064. serialize(): any;
  98065. /**
  98066. * Parse properties from a JSON object
  98067. * @param serializationObject defines the JSON object
  98068. * @param scene defines the hosting scene
  98069. */
  98070. parse(serializationObject: any, scene: Nullable<Scene>): void;
  98071. }
  98072. }
  98073. declare module BABYLON {
  98074. /**
  98075. * Interface representing a particle system in Babylon.js.
  98076. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  98077. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  98078. */
  98079. export interface IParticleSystem {
  98080. /**
  98081. * List of animations used by the particle system.
  98082. */
  98083. animations: Animation[];
  98084. /**
  98085. * The id of the Particle system.
  98086. */
  98087. id: string;
  98088. /**
  98089. * The name of the Particle system.
  98090. */
  98091. name: string;
  98092. /**
  98093. * The emitter represents the Mesh or position we are attaching the particle system to.
  98094. */
  98095. emitter: Nullable<AbstractMesh | Vector3>;
  98096. /**
  98097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  98098. */
  98099. isBillboardBased: boolean;
  98100. /**
  98101. * The rendering group used by the Particle system to chose when to render.
  98102. */
  98103. renderingGroupId: number;
  98104. /**
  98105. * The layer mask we are rendering the particles through.
  98106. */
  98107. layerMask: number;
  98108. /**
  98109. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  98110. */
  98111. updateSpeed: number;
  98112. /**
  98113. * The amount of time the particle system is running (depends of the overall update speed).
  98114. */
  98115. targetStopDuration: number;
  98116. /**
  98117. * The texture used to render each particle. (this can be a spritesheet)
  98118. */
  98119. particleTexture: Nullable<BaseTexture>;
  98120. /**
  98121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  98122. */
  98123. blendMode: number;
  98124. /**
  98125. * Minimum life time of emitting particles.
  98126. */
  98127. minLifeTime: number;
  98128. /**
  98129. * Maximum life time of emitting particles.
  98130. */
  98131. maxLifeTime: number;
  98132. /**
  98133. * Minimum Size of emitting particles.
  98134. */
  98135. minSize: number;
  98136. /**
  98137. * Maximum Size of emitting particles.
  98138. */
  98139. maxSize: number;
  98140. /**
  98141. * Minimum scale of emitting particles on X axis.
  98142. */
  98143. minScaleX: number;
  98144. /**
  98145. * Maximum scale of emitting particles on X axis.
  98146. */
  98147. maxScaleX: number;
  98148. /**
  98149. * Minimum scale of emitting particles on Y axis.
  98150. */
  98151. minScaleY: number;
  98152. /**
  98153. * Maximum scale of emitting particles on Y axis.
  98154. */
  98155. maxScaleY: number;
  98156. /**
  98157. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98158. */
  98159. color1: Color4;
  98160. /**
  98161. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98162. */
  98163. color2: Color4;
  98164. /**
  98165. * Color the particle will have at the end of its lifetime.
  98166. */
  98167. colorDead: Color4;
  98168. /**
  98169. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  98170. */
  98171. emitRate: number;
  98172. /**
  98173. * You can use gravity if you want to give an orientation to your particles.
  98174. */
  98175. gravity: Vector3;
  98176. /**
  98177. * Minimum power of emitting particles.
  98178. */
  98179. minEmitPower: number;
  98180. /**
  98181. * Maximum power of emitting particles.
  98182. */
  98183. maxEmitPower: number;
  98184. /**
  98185. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  98186. */
  98187. minAngularSpeed: number;
  98188. /**
  98189. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  98190. */
  98191. maxAngularSpeed: number;
  98192. /**
  98193. * Gets or sets the minimal initial rotation in radians.
  98194. */
  98195. minInitialRotation: number;
  98196. /**
  98197. * Gets or sets the maximal initial rotation in radians.
  98198. */
  98199. maxInitialRotation: number;
  98200. /**
  98201. * The particle emitter type defines the emitter used by the particle system.
  98202. * It can be for example box, sphere, or cone...
  98203. */
  98204. particleEmitterType: Nullable<IParticleEmitterType>;
  98205. /**
  98206. * Defines the delay in milliseconds before starting the system (0 by default)
  98207. */
  98208. startDelay: number;
  98209. /**
  98210. * 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
  98211. */
  98212. preWarmCycles: number;
  98213. /**
  98214. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  98215. */
  98216. preWarmStepOffset: number;
  98217. /**
  98218. * 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)
  98219. */
  98220. spriteCellChangeSpeed: number;
  98221. /**
  98222. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  98223. */
  98224. startSpriteCellID: number;
  98225. /**
  98226. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  98227. */
  98228. endSpriteCellID: number;
  98229. /**
  98230. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  98231. */
  98232. spriteCellWidth: number;
  98233. /**
  98234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  98235. */
  98236. spriteCellHeight: number;
  98237. /**
  98238. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  98239. */
  98240. spriteRandomStartCell: boolean;
  98241. /**
  98242. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  98243. */
  98244. isAnimationSheetEnabled: boolean;
  98245. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98246. translationPivot: Vector2;
  98247. /**
  98248. * Gets or sets a texture used to add random noise to particle positions
  98249. */
  98250. noiseTexture: Nullable<BaseTexture>;
  98251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98252. noiseStrength: Vector3;
  98253. /**
  98254. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98255. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98256. */
  98257. billboardMode: number;
  98258. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98259. limitVelocityDamping: number;
  98260. /**
  98261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98262. */
  98263. beginAnimationOnStart: boolean;
  98264. /**
  98265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98266. */
  98267. beginAnimationFrom: number;
  98268. /**
  98269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98270. */
  98271. beginAnimationTo: number;
  98272. /**
  98273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98274. */
  98275. beginAnimationLoop: boolean;
  98276. /**
  98277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98278. */
  98279. disposeOnStop: boolean;
  98280. /**
  98281. * Specifies if the particles are updated in emitter local space or world space
  98282. */
  98283. isLocal: boolean;
  98284. /** Snippet ID if the particle system was created from the snippet server */
  98285. snippetId: string;
  98286. /** Gets or sets a matrix to use to compute projection */
  98287. defaultProjectionMatrix: Matrix;
  98288. /**
  98289. * Gets the maximum number of particles active at the same time.
  98290. * @returns The max number of active particles.
  98291. */
  98292. getCapacity(): number;
  98293. /**
  98294. * Gets the number of particles active at the same time.
  98295. * @returns The number of active particles.
  98296. */
  98297. getActiveCount(): number;
  98298. /**
  98299. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98300. * @returns True if it has been started, otherwise false.
  98301. */
  98302. isStarted(): boolean;
  98303. /**
  98304. * Animates the particle system for this frame.
  98305. */
  98306. animate(): void;
  98307. /**
  98308. * Renders the particle system in its current state.
  98309. * @returns the current number of particles
  98310. */
  98311. render(): number;
  98312. /**
  98313. * Dispose the particle system and frees its associated resources.
  98314. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98315. */
  98316. dispose(disposeTexture?: boolean): void;
  98317. /**
  98318. * An event triggered when the system is disposed
  98319. */
  98320. onDisposeObservable: Observable<IParticleSystem>;
  98321. /**
  98322. * An event triggered when the system is stopped
  98323. */
  98324. onStoppedObservable: Observable<IParticleSystem>;
  98325. /**
  98326. * Clones the particle system.
  98327. * @param name The name of the cloned object
  98328. * @param newEmitter The new emitter to use
  98329. * @returns the cloned particle system
  98330. */
  98331. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98332. /**
  98333. * Serializes the particle system to a JSON object
  98334. * @param serializeTexture defines if the texture must be serialized as well
  98335. * @returns the JSON object
  98336. */
  98337. serialize(serializeTexture: boolean): any;
  98338. /**
  98339. * Rebuild the particle system
  98340. */
  98341. rebuild(): void;
  98342. /** Force the system to rebuild all gradients that need to be resync */
  98343. forceRefreshGradients(): void;
  98344. /**
  98345. * Starts the particle system and begins to emit
  98346. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98347. */
  98348. start(delay?: number): void;
  98349. /**
  98350. * Stops the particle system.
  98351. */
  98352. stop(): void;
  98353. /**
  98354. * Remove all active particles
  98355. */
  98356. reset(): void;
  98357. /**
  98358. * Gets a boolean indicating that the system is stopping
  98359. * @returns true if the system is currently stopping
  98360. */
  98361. isStopping(): boolean;
  98362. /**
  98363. * Is this system ready to be used/rendered
  98364. * @return true if the system is ready
  98365. */
  98366. isReady(): boolean;
  98367. /**
  98368. * Returns the string "ParticleSystem"
  98369. * @returns a string containing the class name
  98370. */
  98371. getClassName(): string;
  98372. /**
  98373. * Gets the custom effect used to render the particles
  98374. * @param blendMode Blend mode for which the effect should be retrieved
  98375. * @returns The effect
  98376. */
  98377. getCustomEffect(blendMode: number): Nullable<Effect>;
  98378. /**
  98379. * Sets the custom effect used to render the particles
  98380. * @param effect The effect to set
  98381. * @param blendMode Blend mode for which the effect should be set
  98382. */
  98383. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98384. /**
  98385. * Fill the defines array according to the current settings of the particle system
  98386. * @param defines Array to be updated
  98387. * @param blendMode blend mode to take into account when updating the array
  98388. */
  98389. fillDefines(defines: Array<string>, blendMode: number): void;
  98390. /**
  98391. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98392. * @param uniforms Uniforms array to fill
  98393. * @param attributes Attributes array to fill
  98394. * @param samplers Samplers array to fill
  98395. */
  98396. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98397. /**
  98398. * Observable that will be called just before the particles are drawn
  98399. */
  98400. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98401. /**
  98402. * Gets the name of the particle vertex shader
  98403. */
  98404. vertexShaderName: string;
  98405. /**
  98406. * Adds a new color gradient
  98407. * @param gradient defines the gradient to use (between 0 and 1)
  98408. * @param color1 defines the color to affect to the specified gradient
  98409. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98410. * @returns the current particle system
  98411. */
  98412. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98413. /**
  98414. * Remove a specific color gradient
  98415. * @param gradient defines the gradient to remove
  98416. * @returns the current particle system
  98417. */
  98418. removeColorGradient(gradient: number): IParticleSystem;
  98419. /**
  98420. * Adds a new size gradient
  98421. * @param gradient defines the gradient to use (between 0 and 1)
  98422. * @param factor defines the size factor to affect to the specified gradient
  98423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98424. * @returns the current particle system
  98425. */
  98426. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98427. /**
  98428. * Remove a specific size gradient
  98429. * @param gradient defines the gradient to remove
  98430. * @returns the current particle system
  98431. */
  98432. removeSizeGradient(gradient: number): IParticleSystem;
  98433. /**
  98434. * Gets the current list of color gradients.
  98435. * You must use addColorGradient and removeColorGradient to udpate this list
  98436. * @returns the list of color gradients
  98437. */
  98438. getColorGradients(): Nullable<Array<ColorGradient>>;
  98439. /**
  98440. * Gets the current list of size gradients.
  98441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98442. * @returns the list of size gradients
  98443. */
  98444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98445. /**
  98446. * Gets the current list of angular speed gradients.
  98447. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98448. * @returns the list of angular speed gradients
  98449. */
  98450. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98451. /**
  98452. * Adds a new angular speed gradient
  98453. * @param gradient defines the gradient to use (between 0 and 1)
  98454. * @param factor defines the angular speed to affect to the specified gradient
  98455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98456. * @returns the current particle system
  98457. */
  98458. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98459. /**
  98460. * Remove a specific angular speed gradient
  98461. * @param gradient defines the gradient to remove
  98462. * @returns the current particle system
  98463. */
  98464. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98465. /**
  98466. * Gets the current list of velocity gradients.
  98467. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98468. * @returns the list of velocity gradients
  98469. */
  98470. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98471. /**
  98472. * Adds a new velocity gradient
  98473. * @param gradient defines the gradient to use (between 0 and 1)
  98474. * @param factor defines the velocity to affect to the specified gradient
  98475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98476. * @returns the current particle system
  98477. */
  98478. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98479. /**
  98480. * Remove a specific velocity gradient
  98481. * @param gradient defines the gradient to remove
  98482. * @returns the current particle system
  98483. */
  98484. removeVelocityGradient(gradient: number): IParticleSystem;
  98485. /**
  98486. * Gets the current list of limit velocity gradients.
  98487. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98488. * @returns the list of limit velocity gradients
  98489. */
  98490. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98491. /**
  98492. * Adds a new limit velocity gradient
  98493. * @param gradient defines the gradient to use (between 0 and 1)
  98494. * @param factor defines the limit velocity to affect to the specified gradient
  98495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98496. * @returns the current particle system
  98497. */
  98498. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98499. /**
  98500. * Remove a specific limit velocity gradient
  98501. * @param gradient defines the gradient to remove
  98502. * @returns the current particle system
  98503. */
  98504. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98505. /**
  98506. * Adds a new drag gradient
  98507. * @param gradient defines the gradient to use (between 0 and 1)
  98508. * @param factor defines the drag to affect to the specified gradient
  98509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98510. * @returns the current particle system
  98511. */
  98512. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98513. /**
  98514. * Remove a specific drag gradient
  98515. * @param gradient defines the gradient to remove
  98516. * @returns the current particle system
  98517. */
  98518. removeDragGradient(gradient: number): IParticleSystem;
  98519. /**
  98520. * Gets the current list of drag gradients.
  98521. * You must use addDragGradient and removeDragGradient to udpate this list
  98522. * @returns the list of drag gradients
  98523. */
  98524. getDragGradients(): Nullable<Array<FactorGradient>>;
  98525. /**
  98526. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98527. * @param gradient defines the gradient to use (between 0 and 1)
  98528. * @param factor defines the emit rate to affect to the specified gradient
  98529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98530. * @returns the current particle system
  98531. */
  98532. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98533. /**
  98534. * Remove a specific emit rate gradient
  98535. * @param gradient defines the gradient to remove
  98536. * @returns the current particle system
  98537. */
  98538. removeEmitRateGradient(gradient: number): IParticleSystem;
  98539. /**
  98540. * Gets the current list of emit rate gradients.
  98541. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98542. * @returns the list of emit rate gradients
  98543. */
  98544. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98545. /**
  98546. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98547. * @param gradient defines the gradient to use (between 0 and 1)
  98548. * @param factor defines the start size to affect to the specified gradient
  98549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98550. * @returns the current particle system
  98551. */
  98552. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98553. /**
  98554. * Remove a specific start size gradient
  98555. * @param gradient defines the gradient to remove
  98556. * @returns the current particle system
  98557. */
  98558. removeStartSizeGradient(gradient: number): IParticleSystem;
  98559. /**
  98560. * Gets the current list of start size gradients.
  98561. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98562. * @returns the list of start size gradients
  98563. */
  98564. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98565. /**
  98566. * Adds a new life time gradient
  98567. * @param gradient defines the gradient to use (between 0 and 1)
  98568. * @param factor defines the life time factor to affect to the specified gradient
  98569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98570. * @returns the current particle system
  98571. */
  98572. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98573. /**
  98574. * Remove a specific life time gradient
  98575. * @param gradient defines the gradient to remove
  98576. * @returns the current particle system
  98577. */
  98578. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98579. /**
  98580. * Gets the current list of life time gradients.
  98581. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98582. * @returns the list of life time gradients
  98583. */
  98584. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98585. /**
  98586. * Gets the current list of color gradients.
  98587. * You must use addColorGradient and removeColorGradient to udpate this list
  98588. * @returns the list of color gradients
  98589. */
  98590. getColorGradients(): Nullable<Array<ColorGradient>>;
  98591. /**
  98592. * Adds a new ramp gradient used to remap particle colors
  98593. * @param gradient defines the gradient to use (between 0 and 1)
  98594. * @param color defines the color to affect to the specified gradient
  98595. * @returns the current particle system
  98596. */
  98597. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98598. /**
  98599. * Gets the current list of ramp gradients.
  98600. * You must use addRampGradient and removeRampGradient to udpate this list
  98601. * @returns the list of ramp gradients
  98602. */
  98603. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98604. /** Gets or sets a boolean indicating that ramp gradients must be used
  98605. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98606. */
  98607. useRampGradients: boolean;
  98608. /**
  98609. * Adds a new color remap gradient
  98610. * @param gradient defines the gradient to use (between 0 and 1)
  98611. * @param min defines the color remap minimal range
  98612. * @param max defines the color remap maximal range
  98613. * @returns the current particle system
  98614. */
  98615. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98616. /**
  98617. * Gets the current list of color remap gradients.
  98618. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98619. * @returns the list of color remap gradients
  98620. */
  98621. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98622. /**
  98623. * Adds a new alpha remap gradient
  98624. * @param gradient defines the gradient to use (between 0 and 1)
  98625. * @param min defines the alpha remap minimal range
  98626. * @param max defines the alpha remap maximal range
  98627. * @returns the current particle system
  98628. */
  98629. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98630. /**
  98631. * Gets the current list of alpha remap gradients.
  98632. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98633. * @returns the list of alpha remap gradients
  98634. */
  98635. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98636. /**
  98637. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98640. * @returns the emitter
  98641. */
  98642. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98643. /**
  98644. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98645. * @param radius The radius of the hemisphere to emit from
  98646. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98647. * @returns the emitter
  98648. */
  98649. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98650. /**
  98651. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98652. * @param radius The radius of the sphere to emit from
  98653. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98654. * @returns the emitter
  98655. */
  98656. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98657. /**
  98658. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98659. * @param radius The radius of the sphere to emit from
  98660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98662. * @returns the emitter
  98663. */
  98664. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98665. /**
  98666. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98667. * @param radius The radius of the emission cylinder
  98668. * @param height The height of the emission cylinder
  98669. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98670. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98671. * @returns the emitter
  98672. */
  98673. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98674. /**
  98675. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98676. * @param radius The radius of the cylinder to emit from
  98677. * @param height The height of the emission cylinder
  98678. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98681. * @returns the emitter
  98682. */
  98683. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98684. /**
  98685. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98686. * @param radius The radius of the cone to emit from
  98687. * @param angle The base angle of the cone
  98688. * @returns the emitter
  98689. */
  98690. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98691. /**
  98692. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98695. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98696. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98697. * @returns the emitter
  98698. */
  98699. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98700. /**
  98701. * Get hosting scene
  98702. * @returns the scene
  98703. */
  98704. getScene(): Nullable<Scene>;
  98705. }
  98706. }
  98707. declare module BABYLON {
  98708. /**
  98709. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98710. */
  98711. export class ColorSplitterBlock extends NodeMaterialBlock {
  98712. /**
  98713. * Create a new ColorSplitterBlock
  98714. * @param name defines the block name
  98715. */
  98716. constructor(name: string);
  98717. /**
  98718. * Gets the current class name
  98719. * @returns the class name
  98720. */
  98721. getClassName(): string;
  98722. /**
  98723. * Gets the rgba component (input)
  98724. */
  98725. get rgba(): NodeMaterialConnectionPoint;
  98726. /**
  98727. * Gets the rgb component (input)
  98728. */
  98729. get rgbIn(): NodeMaterialConnectionPoint;
  98730. /**
  98731. * Gets the rgb component (output)
  98732. */
  98733. get rgbOut(): NodeMaterialConnectionPoint;
  98734. /**
  98735. * Gets the r component (output)
  98736. */
  98737. get r(): NodeMaterialConnectionPoint;
  98738. /**
  98739. * Gets the g component (output)
  98740. */
  98741. get g(): NodeMaterialConnectionPoint;
  98742. /**
  98743. * Gets the b component (output)
  98744. */
  98745. get b(): NodeMaterialConnectionPoint;
  98746. /**
  98747. * Gets the a component (output)
  98748. */
  98749. get a(): NodeMaterialConnectionPoint;
  98750. protected _inputRename(name: string): string;
  98751. protected _outputRename(name: string): string;
  98752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98753. }
  98754. }
  98755. declare module BABYLON {
  98756. /**
  98757. * Operations supported by the Trigonometry block
  98758. */
  98759. export enum TrigonometryBlockOperations {
  98760. /** Cos */
  98761. Cos = 0,
  98762. /** Sin */
  98763. Sin = 1,
  98764. /** Abs */
  98765. Abs = 2,
  98766. /** Exp */
  98767. Exp = 3,
  98768. /** Exp2 */
  98769. Exp2 = 4,
  98770. /** Round */
  98771. Round = 5,
  98772. /** Floor */
  98773. Floor = 6,
  98774. /** Ceiling */
  98775. Ceiling = 7,
  98776. /** Square root */
  98777. Sqrt = 8,
  98778. /** Log */
  98779. Log = 9,
  98780. /** Tangent */
  98781. Tan = 10,
  98782. /** Arc tangent */
  98783. ArcTan = 11,
  98784. /** Arc cosinus */
  98785. ArcCos = 12,
  98786. /** Arc sinus */
  98787. ArcSin = 13,
  98788. /** Fraction */
  98789. Fract = 14,
  98790. /** Sign */
  98791. Sign = 15,
  98792. /** To radians (from degrees) */
  98793. Radians = 16,
  98794. /** To degrees (from radians) */
  98795. Degrees = 17
  98796. }
  98797. /**
  98798. * Block used to apply trigonometry operation to floats
  98799. */
  98800. export class TrigonometryBlock extends NodeMaterialBlock {
  98801. /**
  98802. * Gets or sets the operation applied by the block
  98803. */
  98804. operation: TrigonometryBlockOperations;
  98805. /**
  98806. * Creates a new TrigonometryBlock
  98807. * @param name defines the block name
  98808. */
  98809. constructor(name: string);
  98810. /**
  98811. * Gets the current class name
  98812. * @returns the class name
  98813. */
  98814. getClassName(): string;
  98815. /**
  98816. * Gets the input component
  98817. */
  98818. get input(): NodeMaterialConnectionPoint;
  98819. /**
  98820. * Gets the output component
  98821. */
  98822. get output(): NodeMaterialConnectionPoint;
  98823. protected _buildBlock(state: NodeMaterialBuildState): this;
  98824. serialize(): any;
  98825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98826. protected _dumpPropertiesCode(): string;
  98827. }
  98828. }
  98829. declare module BABYLON {
  98830. /**
  98831. * Interface used to configure the node material editor
  98832. */
  98833. export interface INodeMaterialEditorOptions {
  98834. /** Define the URl to load node editor script */
  98835. editorURL?: string;
  98836. }
  98837. /** @hidden */
  98838. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98839. NORMAL: boolean;
  98840. TANGENT: boolean;
  98841. UV1: boolean;
  98842. /** BONES */
  98843. NUM_BONE_INFLUENCERS: number;
  98844. BonesPerMesh: number;
  98845. BONETEXTURE: boolean;
  98846. /** MORPH TARGETS */
  98847. MORPHTARGETS: boolean;
  98848. MORPHTARGETS_NORMAL: boolean;
  98849. MORPHTARGETS_TANGENT: boolean;
  98850. MORPHTARGETS_UV: boolean;
  98851. NUM_MORPH_INFLUENCERS: number;
  98852. /** IMAGE PROCESSING */
  98853. IMAGEPROCESSING: boolean;
  98854. VIGNETTE: boolean;
  98855. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98856. VIGNETTEBLENDMODEOPAQUE: boolean;
  98857. TONEMAPPING: boolean;
  98858. TONEMAPPING_ACES: boolean;
  98859. CONTRAST: boolean;
  98860. EXPOSURE: boolean;
  98861. COLORCURVES: boolean;
  98862. COLORGRADING: boolean;
  98863. COLORGRADING3D: boolean;
  98864. SAMPLER3DGREENDEPTH: boolean;
  98865. SAMPLER3DBGRMAP: boolean;
  98866. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98867. /** MISC. */
  98868. BUMPDIRECTUV: number;
  98869. constructor();
  98870. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98871. }
  98872. /**
  98873. * Class used to configure NodeMaterial
  98874. */
  98875. export interface INodeMaterialOptions {
  98876. /**
  98877. * Defines if blocks should emit comments
  98878. */
  98879. emitComments: boolean;
  98880. }
  98881. /**
  98882. * Class used to create a node based material built by assembling shader blocks
  98883. */
  98884. export class NodeMaterial extends PushMaterial {
  98885. private static _BuildIdGenerator;
  98886. private _options;
  98887. private _vertexCompilationState;
  98888. private _fragmentCompilationState;
  98889. private _sharedData;
  98890. private _buildId;
  98891. private _buildWasSuccessful;
  98892. private _cachedWorldViewMatrix;
  98893. private _cachedWorldViewProjectionMatrix;
  98894. private _optimizers;
  98895. private _animationFrame;
  98896. /** Define the Url to load node editor script */
  98897. static EditorURL: string;
  98898. /** Define the Url to load snippets */
  98899. static SnippetUrl: string;
  98900. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98901. static IgnoreTexturesAtLoadTime: boolean;
  98902. private BJSNODEMATERIALEDITOR;
  98903. /** Get the inspector from bundle or global */
  98904. private _getGlobalNodeMaterialEditor;
  98905. /**
  98906. * Snippet ID if the material was created from the snippet server
  98907. */
  98908. snippetId: string;
  98909. /**
  98910. * Gets or sets data used by visual editor
  98911. * @see https://nme.babylonjs.com
  98912. */
  98913. editorData: any;
  98914. /**
  98915. * 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)
  98916. */
  98917. ignoreAlpha: boolean;
  98918. /**
  98919. * Defines the maximum number of lights that can be used in the material
  98920. */
  98921. maxSimultaneousLights: number;
  98922. /**
  98923. * Observable raised when the material is built
  98924. */
  98925. onBuildObservable: Observable<NodeMaterial>;
  98926. /**
  98927. * Gets or sets the root nodes of the material vertex shader
  98928. */
  98929. _vertexOutputNodes: NodeMaterialBlock[];
  98930. /**
  98931. * Gets or sets the root nodes of the material fragment (pixel) shader
  98932. */
  98933. _fragmentOutputNodes: NodeMaterialBlock[];
  98934. /** Gets or sets options to control the node material overall behavior */
  98935. get options(): INodeMaterialOptions;
  98936. set options(options: INodeMaterialOptions);
  98937. /**
  98938. * Default configuration related to image processing available in the standard Material.
  98939. */
  98940. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98941. /**
  98942. * Gets the image processing configuration used either in this material.
  98943. */
  98944. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98945. /**
  98946. * Sets the Default image processing configuration used either in the this material.
  98947. *
  98948. * If sets to null, the scene one is in use.
  98949. */
  98950. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98951. /**
  98952. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98953. */
  98954. attachedBlocks: NodeMaterialBlock[];
  98955. /**
  98956. * Specifies the mode of the node material
  98957. * @hidden
  98958. */
  98959. _mode: NodeMaterialModes;
  98960. /**
  98961. * Gets the mode property
  98962. */
  98963. get mode(): NodeMaterialModes;
  98964. /**
  98965. * A free comment about the material
  98966. */
  98967. comment: string;
  98968. /**
  98969. * Create a new node based material
  98970. * @param name defines the material name
  98971. * @param scene defines the hosting scene
  98972. * @param options defines creation option
  98973. */
  98974. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98975. /**
  98976. * Gets the current class name of the material e.g. "NodeMaterial"
  98977. * @returns the class name
  98978. */
  98979. getClassName(): string;
  98980. /**
  98981. * Keep track of the image processing observer to allow dispose and replace.
  98982. */
  98983. private _imageProcessingObserver;
  98984. /**
  98985. * Attaches a new image processing configuration to the Standard Material.
  98986. * @param configuration
  98987. */
  98988. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98989. /**
  98990. * Get a block by its name
  98991. * @param name defines the name of the block to retrieve
  98992. * @returns the required block or null if not found
  98993. */
  98994. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98995. /**
  98996. * Get a block by its name
  98997. * @param predicate defines the predicate used to find the good candidate
  98998. * @returns the required block or null if not found
  98999. */
  99000. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99001. /**
  99002. * Get an input block by its name
  99003. * @param predicate defines the predicate used to find the good candidate
  99004. * @returns the required input block or null if not found
  99005. */
  99006. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99007. /**
  99008. * Gets the list of input blocks attached to this material
  99009. * @returns an array of InputBlocks
  99010. */
  99011. getInputBlocks(): InputBlock[];
  99012. /**
  99013. * Adds a new optimizer to the list of optimizers
  99014. * @param optimizer defines the optimizers to add
  99015. * @returns the current material
  99016. */
  99017. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99018. /**
  99019. * Remove an optimizer from the list of optimizers
  99020. * @param optimizer defines the optimizers to remove
  99021. * @returns the current material
  99022. */
  99023. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99024. /**
  99025. * Add a new block to the list of output nodes
  99026. * @param node defines the node to add
  99027. * @returns the current material
  99028. */
  99029. addOutputNode(node: NodeMaterialBlock): this;
  99030. /**
  99031. * Remove a block from the list of root nodes
  99032. * @param node defines the node to remove
  99033. * @returns the current material
  99034. */
  99035. removeOutputNode(node: NodeMaterialBlock): this;
  99036. private _addVertexOutputNode;
  99037. private _removeVertexOutputNode;
  99038. private _addFragmentOutputNode;
  99039. private _removeFragmentOutputNode;
  99040. /**
  99041. * Specifies if the material will require alpha blending
  99042. * @returns a boolean specifying if alpha blending is needed
  99043. */
  99044. needAlphaBlending(): boolean;
  99045. /**
  99046. * Specifies if this material should be rendered in alpha test mode
  99047. * @returns a boolean specifying if an alpha test is needed.
  99048. */
  99049. needAlphaTesting(): boolean;
  99050. private _initializeBlock;
  99051. private _resetDualBlocks;
  99052. /**
  99053. * Remove a block from the current node material
  99054. * @param block defines the block to remove
  99055. */
  99056. removeBlock(block: NodeMaterialBlock): void;
  99057. /**
  99058. * Build the material and generates the inner effect
  99059. * @param verbose defines if the build should log activity
  99060. */
  99061. build(verbose?: boolean): void;
  99062. /**
  99063. * Runs an otpimization phase to try to improve the shader code
  99064. */
  99065. optimize(): void;
  99066. private _prepareDefinesForAttributes;
  99067. /**
  99068. * Create a post process from the material
  99069. * @param camera The camera to apply the render pass to.
  99070. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99072. * @param engine The engine which the post process will be applied. (default: current engine)
  99073. * @param reusable If the post process can be reused on the same frame. (default: false)
  99074. * @param textureType Type of textures used when performing the post process. (default: 0)
  99075. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99076. * @returns the post process created
  99077. */
  99078. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  99079. /**
  99080. * Create the post process effect from the material
  99081. * @param postProcess The post process to create the effect for
  99082. */
  99083. createEffectForPostProcess(postProcess: PostProcess): void;
  99084. private _createEffectForPostProcess;
  99085. /**
  99086. * Create a new procedural texture based on this node material
  99087. * @param size defines the size of the texture
  99088. * @param scene defines the hosting scene
  99089. * @returns the new procedural texture attached to this node material
  99090. */
  99091. createProceduralTexture(size: number | {
  99092. width: number;
  99093. height: number;
  99094. layers?: number;
  99095. }, scene: Scene): Nullable<ProceduralTexture>;
  99096. private _createEffectForParticles;
  99097. private _checkInternals;
  99098. /**
  99099. * Create the effect to be used as the custom effect for a particle system
  99100. * @param particleSystem Particle system to create the effect for
  99101. * @param onCompiled defines a function to call when the effect creation is successful
  99102. * @param onError defines a function to call when the effect creation has failed
  99103. */
  99104. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99105. private _processDefines;
  99106. /**
  99107. * Get if the submesh is ready to be used and all its information available.
  99108. * Child classes can use it to update shaders
  99109. * @param mesh defines the mesh to check
  99110. * @param subMesh defines which submesh to check
  99111. * @param useInstances specifies that instances should be used
  99112. * @returns a boolean indicating that the submesh is ready or not
  99113. */
  99114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99115. /**
  99116. * Get a string representing the shaders built by the current node graph
  99117. */
  99118. get compiledShaders(): string;
  99119. /**
  99120. * Binds the world matrix to the material
  99121. * @param world defines the world transformation matrix
  99122. */
  99123. bindOnlyWorldMatrix(world: Matrix): void;
  99124. /**
  99125. * Binds the submesh to this material by preparing the effect and shader to draw
  99126. * @param world defines the world transformation matrix
  99127. * @param mesh defines the mesh containing the submesh
  99128. * @param subMesh defines the submesh to bind the material to
  99129. */
  99130. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99131. /**
  99132. * Gets the active textures from the material
  99133. * @returns an array of textures
  99134. */
  99135. getActiveTextures(): BaseTexture[];
  99136. /**
  99137. * Gets the list of texture blocks
  99138. * @returns an array of texture blocks
  99139. */
  99140. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99141. /**
  99142. * Specifies if the material uses a texture
  99143. * @param texture defines the texture to check against the material
  99144. * @returns a boolean specifying if the material uses the texture
  99145. */
  99146. hasTexture(texture: BaseTexture): boolean;
  99147. /**
  99148. * Disposes the material
  99149. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99150. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99151. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99152. */
  99153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99154. /** Creates the node editor window. */
  99155. private _createNodeEditor;
  99156. /**
  99157. * Launch the node material editor
  99158. * @param config Define the configuration of the editor
  99159. * @return a promise fulfilled when the node editor is visible
  99160. */
  99161. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99162. /**
  99163. * Clear the current material
  99164. */
  99165. clear(): void;
  99166. /**
  99167. * Clear the current material and set it to a default state
  99168. */
  99169. setToDefault(): void;
  99170. /**
  99171. * Clear the current material and set it to a default state for post process
  99172. */
  99173. setToDefaultPostProcess(): void;
  99174. /**
  99175. * Clear the current material and set it to a default state for procedural texture
  99176. */
  99177. setToDefaultProceduralTexture(): void;
  99178. /**
  99179. * Clear the current material and set it to a default state for particle
  99180. */
  99181. setToDefaultParticle(): void;
  99182. /**
  99183. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99184. * @param url defines the url to load from
  99185. * @returns a promise that will fullfil when the material is fully loaded
  99186. */
  99187. loadAsync(url: string): Promise<void>;
  99188. private _gatherBlocks;
  99189. /**
  99190. * Generate a string containing the code declaration required to create an equivalent of this material
  99191. * @returns a string
  99192. */
  99193. generateCode(): string;
  99194. /**
  99195. * Serializes this material in a JSON representation
  99196. * @returns the serialized material object
  99197. */
  99198. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99199. private _restoreConnections;
  99200. /**
  99201. * Clear the current graph and load a new one from a serialization object
  99202. * @param source defines the JSON representation of the material
  99203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99204. * @param merge defines whether or not the source must be merged or replace the current content
  99205. */
  99206. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99207. /**
  99208. * Makes a duplicate of the current material.
  99209. * @param name - name to use for the new material.
  99210. */
  99211. clone(name: string): NodeMaterial;
  99212. /**
  99213. * Creates a node material from parsed material data
  99214. * @param source defines the JSON representation of the material
  99215. * @param scene defines the hosting scene
  99216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99217. * @returns a new node material
  99218. */
  99219. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99220. /**
  99221. * Creates a node material from a snippet saved in a remote file
  99222. * @param name defines the name of the material to create
  99223. * @param url defines the url to load from
  99224. * @param scene defines the hosting scene
  99225. * @returns a promise that will resolve to the new node material
  99226. */
  99227. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99228. /**
  99229. * Creates a node material from a snippet saved by the node material editor
  99230. * @param snippetId defines the snippet to load
  99231. * @param scene defines the hosting scene
  99232. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99233. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99234. * @returns a promise that will resolve to the new node material
  99235. */
  99236. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99237. /**
  99238. * Creates a new node material set to default basic configuration
  99239. * @param name defines the name of the material
  99240. * @param scene defines the hosting scene
  99241. * @returns a new NodeMaterial
  99242. */
  99243. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99244. }
  99245. }
  99246. declare module BABYLON {
  99247. interface ThinEngine {
  99248. /**
  99249. * Unbind a list of render target textures from the webGL context
  99250. * This is used only when drawBuffer extension or webGL2 are active
  99251. * @param textures defines the render target textures to unbind
  99252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99254. */
  99255. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99256. /**
  99257. * Create a multi render target texture
  99258. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99259. * @param size defines the size of the texture
  99260. * @param options defines the creation options
  99261. * @returns the cube texture as an InternalTexture
  99262. */
  99263. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99264. /**
  99265. * Update the sample count for a given multiple render target texture
  99266. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99267. * @param textures defines the textures to update
  99268. * @param samples defines the sample count to set
  99269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99270. */
  99271. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99272. /**
  99273. * Select a subsets of attachments to draw to.
  99274. * @param attachments gl attachments
  99275. */
  99276. bindAttachments(attachments: number[]): void;
  99277. /**
  99278. * Creates a layout object to draw/clear on specific textures in a MRT
  99279. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99280. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99281. */
  99282. buildTextureLayout(textureStatus: boolean[]): number[];
  99283. /**
  99284. * Restores the webgl state to only draw on the main color attachment
  99285. */
  99286. restoreSingleAttachment(): void;
  99287. }
  99288. }
  99289. declare module BABYLON {
  99290. /**
  99291. * Creation options of the multi render target texture.
  99292. */
  99293. export interface IMultiRenderTargetOptions {
  99294. /**
  99295. * Define if the texture needs to create mip maps after render.
  99296. */
  99297. generateMipMaps?: boolean;
  99298. /**
  99299. * Define the types of all the draw buffers we want to create
  99300. */
  99301. types?: number[];
  99302. /**
  99303. * Define the sampling modes of all the draw buffers we want to create
  99304. */
  99305. samplingModes?: number[];
  99306. /**
  99307. * Define if a depth buffer is required
  99308. */
  99309. generateDepthBuffer?: boolean;
  99310. /**
  99311. * Define if a stencil buffer is required
  99312. */
  99313. generateStencilBuffer?: boolean;
  99314. /**
  99315. * Define if a depth texture is required instead of a depth buffer
  99316. */
  99317. generateDepthTexture?: boolean;
  99318. /**
  99319. * Define the number of desired draw buffers
  99320. */
  99321. textureCount?: number;
  99322. /**
  99323. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99324. */
  99325. doNotChangeAspectRatio?: boolean;
  99326. /**
  99327. * Define the default type of the buffers we are creating
  99328. */
  99329. defaultType?: number;
  99330. }
  99331. /**
  99332. * A multi render target, like a render target provides the ability to render to a texture.
  99333. * Unlike the render target, it can render to several draw buffers in one draw.
  99334. * This is specially interesting in deferred rendering or for any effects requiring more than
  99335. * just one color from a single pass.
  99336. */
  99337. export class MultiRenderTarget extends RenderTargetTexture {
  99338. private _internalTextures;
  99339. private _textures;
  99340. private _multiRenderTargetOptions;
  99341. private _count;
  99342. /**
  99343. * Get if draw buffers are currently supported by the used hardware and browser.
  99344. */
  99345. get isSupported(): boolean;
  99346. /**
  99347. * Get the list of textures generated by the multi render target.
  99348. */
  99349. get textures(): Texture[];
  99350. /**
  99351. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99352. */
  99353. get count(): number;
  99354. /**
  99355. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99356. */
  99357. get depthTexture(): Texture;
  99358. /**
  99359. * Set the wrapping mode on U of all the textures we are rendering to.
  99360. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99361. */
  99362. set wrapU(wrap: number);
  99363. /**
  99364. * Set the wrapping mode on V of all the textures we are rendering to.
  99365. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99366. */
  99367. set wrapV(wrap: number);
  99368. /**
  99369. * Instantiate a new multi render target texture.
  99370. * A multi render target, like a render target provides the ability to render to a texture.
  99371. * Unlike the render target, it can render to several draw buffers in one draw.
  99372. * This is specially interesting in deferred rendering or for any effects requiring more than
  99373. * just one color from a single pass.
  99374. * @param name Define the name of the texture
  99375. * @param size Define the size of the buffers to render to
  99376. * @param count Define the number of target we are rendering into
  99377. * @param scene Define the scene the texture belongs to
  99378. * @param options Define the options used to create the multi render target
  99379. */
  99380. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99381. private _initTypes;
  99382. /** @hidden */
  99383. _rebuild(forceFullRebuild?: boolean): void;
  99384. private _createInternalTextures;
  99385. private _createTextures;
  99386. /**
  99387. * Replaces a texture within the MRT.
  99388. * @param texture The new texture to insert in the MRT
  99389. * @param index The index of the texture to replace
  99390. */
  99391. replaceTexture(texture: Texture, index: number): void;
  99392. /**
  99393. * Define the number of samples used if MSAA is enabled.
  99394. */
  99395. get samples(): number;
  99396. set samples(value: number);
  99397. /**
  99398. * Resize all the textures in the multi render target.
  99399. * Be careful as it will recreate all the data in the new texture.
  99400. * @param size Define the new size
  99401. */
  99402. resize(size: any): void;
  99403. /**
  99404. * Changes the number of render targets in this MRT
  99405. * Be careful as it will recreate all the data in the new texture.
  99406. * @param count new texture count
  99407. * @param options Specifies texture types and sampling modes for new textures
  99408. */
  99409. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99410. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99411. /**
  99412. * Dispose the render targets and their associated resources
  99413. */
  99414. dispose(): void;
  99415. /**
  99416. * Release all the underlying texture used as draw buffers.
  99417. */
  99418. releaseInternalTextures(): void;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /** @hidden */
  99423. export var imageProcessingPixelShader: {
  99424. name: string;
  99425. shader: string;
  99426. };
  99427. }
  99428. declare module BABYLON {
  99429. /**
  99430. * ImageProcessingPostProcess
  99431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99432. */
  99433. export class ImageProcessingPostProcess extends PostProcess {
  99434. /**
  99435. * Default configuration related to image processing available in the PBR Material.
  99436. */
  99437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99438. /**
  99439. * Gets the image processing configuration used either in this material.
  99440. */
  99441. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99442. /**
  99443. * Sets the Default image processing configuration used either in the this material.
  99444. *
  99445. * If sets to null, the scene one is in use.
  99446. */
  99447. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99448. /**
  99449. * Keep track of the image processing observer to allow dispose and replace.
  99450. */
  99451. private _imageProcessingObserver;
  99452. /**
  99453. * Attaches a new image processing configuration to the PBR Material.
  99454. * @param configuration
  99455. */
  99456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99457. /**
  99458. * If the post process is supported.
  99459. */
  99460. get isSupported(): boolean;
  99461. /**
  99462. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99463. */
  99464. get colorCurves(): Nullable<ColorCurves>;
  99465. /**
  99466. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99467. */
  99468. set colorCurves(value: Nullable<ColorCurves>);
  99469. /**
  99470. * Gets wether the color curves effect is enabled.
  99471. */
  99472. get colorCurvesEnabled(): boolean;
  99473. /**
  99474. * Sets wether the color curves effect is enabled.
  99475. */
  99476. set colorCurvesEnabled(value: boolean);
  99477. /**
  99478. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99479. */
  99480. get colorGradingTexture(): Nullable<BaseTexture>;
  99481. /**
  99482. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99483. */
  99484. set colorGradingTexture(value: Nullable<BaseTexture>);
  99485. /**
  99486. * Gets wether the color grading effect is enabled.
  99487. */
  99488. get colorGradingEnabled(): boolean;
  99489. /**
  99490. * Gets wether the color grading effect is enabled.
  99491. */
  99492. set colorGradingEnabled(value: boolean);
  99493. /**
  99494. * Gets exposure used in the effect.
  99495. */
  99496. get exposure(): number;
  99497. /**
  99498. * Sets exposure used in the effect.
  99499. */
  99500. set exposure(value: number);
  99501. /**
  99502. * Gets wether tonemapping is enabled or not.
  99503. */
  99504. get toneMappingEnabled(): boolean;
  99505. /**
  99506. * Sets wether tonemapping is enabled or not
  99507. */
  99508. set toneMappingEnabled(value: boolean);
  99509. /**
  99510. * Gets the type of tone mapping effect.
  99511. */
  99512. get toneMappingType(): number;
  99513. /**
  99514. * Sets the type of tone mapping effect.
  99515. */
  99516. set toneMappingType(value: number);
  99517. /**
  99518. * Gets contrast used in the effect.
  99519. */
  99520. get contrast(): number;
  99521. /**
  99522. * Sets contrast used in the effect.
  99523. */
  99524. set contrast(value: number);
  99525. /**
  99526. * Gets Vignette stretch size.
  99527. */
  99528. get vignetteStretch(): number;
  99529. /**
  99530. * Sets Vignette stretch size.
  99531. */
  99532. set vignetteStretch(value: number);
  99533. /**
  99534. * Gets Vignette centre X Offset.
  99535. */
  99536. get vignetteCentreX(): number;
  99537. /**
  99538. * Sets Vignette centre X Offset.
  99539. */
  99540. set vignetteCentreX(value: number);
  99541. /**
  99542. * Gets Vignette centre Y Offset.
  99543. */
  99544. get vignetteCentreY(): number;
  99545. /**
  99546. * Sets Vignette centre Y Offset.
  99547. */
  99548. set vignetteCentreY(value: number);
  99549. /**
  99550. * Gets Vignette weight or intensity of the vignette effect.
  99551. */
  99552. get vignetteWeight(): number;
  99553. /**
  99554. * Sets Vignette weight or intensity of the vignette effect.
  99555. */
  99556. set vignetteWeight(value: number);
  99557. /**
  99558. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99559. * if vignetteEnabled is set to true.
  99560. */
  99561. get vignetteColor(): Color4;
  99562. /**
  99563. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99564. * if vignetteEnabled is set to true.
  99565. */
  99566. set vignetteColor(value: Color4);
  99567. /**
  99568. * Gets Camera field of view used by the Vignette effect.
  99569. */
  99570. get vignetteCameraFov(): number;
  99571. /**
  99572. * Sets Camera field of view used by the Vignette effect.
  99573. */
  99574. set vignetteCameraFov(value: number);
  99575. /**
  99576. * Gets the vignette blend mode allowing different kind of effect.
  99577. */
  99578. get vignetteBlendMode(): number;
  99579. /**
  99580. * Sets the vignette blend mode allowing different kind of effect.
  99581. */
  99582. set vignetteBlendMode(value: number);
  99583. /**
  99584. * Gets wether the vignette effect is enabled.
  99585. */
  99586. get vignetteEnabled(): boolean;
  99587. /**
  99588. * Sets wether the vignette effect is enabled.
  99589. */
  99590. set vignetteEnabled(value: boolean);
  99591. private _fromLinearSpace;
  99592. /**
  99593. * Gets wether the input of the processing is in Gamma or Linear Space.
  99594. */
  99595. get fromLinearSpace(): boolean;
  99596. /**
  99597. * Sets wether the input of the processing is in Gamma or Linear Space.
  99598. */
  99599. set fromLinearSpace(value: boolean);
  99600. /**
  99601. * Defines cache preventing GC.
  99602. */
  99603. private _defines;
  99604. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99605. /**
  99606. * "ImageProcessingPostProcess"
  99607. * @returns "ImageProcessingPostProcess"
  99608. */
  99609. getClassName(): string;
  99610. /**
  99611. * @hidden
  99612. */
  99613. _updateParameters(): void;
  99614. dispose(camera?: Camera): void;
  99615. }
  99616. }
  99617. declare module BABYLON {
  99618. /**
  99619. * Interface for defining prepass effects in the prepass post-process pipeline
  99620. */
  99621. export interface PrePassEffectConfiguration {
  99622. /**
  99623. * Name of the effect
  99624. */
  99625. name: string;
  99626. /**
  99627. * Post process to attach for this effect
  99628. */
  99629. postProcess?: PostProcess;
  99630. /**
  99631. * Textures required in the MRT
  99632. */
  99633. texturesRequired: number[];
  99634. /**
  99635. * Is the effect enabled
  99636. */
  99637. enabled: boolean;
  99638. /**
  99639. * Disposes the effect configuration
  99640. */
  99641. dispose?: () => void;
  99642. /**
  99643. * Creates the associated post process
  99644. */
  99645. createPostProcess?: () => PostProcess;
  99646. }
  99647. }
  99648. declare module BABYLON {
  99649. /**
  99650. * Options to be used when creating a FresnelParameters.
  99651. */
  99652. export type IFresnelParametersCreationOptions = {
  99653. /**
  99654. * Define the color used on edges (grazing angle)
  99655. */
  99656. leftColor?: Color3;
  99657. /**
  99658. * Define the color used on center
  99659. */
  99660. rightColor?: Color3;
  99661. /**
  99662. * Define bias applied to computed fresnel term
  99663. */
  99664. bias?: number;
  99665. /**
  99666. * Defined the power exponent applied to fresnel term
  99667. */
  99668. power?: number;
  99669. /**
  99670. * Define if the fresnel effect is enable or not.
  99671. */
  99672. isEnabled?: boolean;
  99673. };
  99674. /**
  99675. * Serialized format for FresnelParameters.
  99676. */
  99677. export type IFresnelParametersSerialized = {
  99678. /**
  99679. * Define the color used on edges (grazing angle) [as an array]
  99680. */
  99681. leftColor: number[];
  99682. /**
  99683. * Define the color used on center [as an array]
  99684. */
  99685. rightColor: number[];
  99686. /**
  99687. * Define bias applied to computed fresnel term
  99688. */
  99689. bias: number;
  99690. /**
  99691. * Defined the power exponent applied to fresnel term
  99692. */
  99693. power?: number;
  99694. /**
  99695. * Define if the fresnel effect is enable or not.
  99696. */
  99697. isEnabled: boolean;
  99698. };
  99699. /**
  99700. * This represents all the required information to add a fresnel effect on a material:
  99701. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99702. */
  99703. export class FresnelParameters {
  99704. private _isEnabled;
  99705. /**
  99706. * Define if the fresnel effect is enable or not.
  99707. */
  99708. get isEnabled(): boolean;
  99709. set isEnabled(value: boolean);
  99710. /**
  99711. * Define the color used on edges (grazing angle)
  99712. */
  99713. leftColor: Color3;
  99714. /**
  99715. * Define the color used on center
  99716. */
  99717. rightColor: Color3;
  99718. /**
  99719. * Define bias applied to computed fresnel term
  99720. */
  99721. bias: number;
  99722. /**
  99723. * Defined the power exponent applied to fresnel term
  99724. */
  99725. power: number;
  99726. /**
  99727. * Creates a new FresnelParameters object.
  99728. *
  99729. * @param options provide your own settings to optionally to override defaults
  99730. */
  99731. constructor(options?: IFresnelParametersCreationOptions);
  99732. /**
  99733. * Clones the current fresnel and its valuues
  99734. * @returns a clone fresnel configuration
  99735. */
  99736. clone(): FresnelParameters;
  99737. /**
  99738. * Determines equality between FresnelParameters objects
  99739. * @param otherFresnelParameters defines the second operand
  99740. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99741. */
  99742. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99743. /**
  99744. * Serializes the current fresnel parameters to a JSON representation.
  99745. * @return the JSON serialization
  99746. */
  99747. serialize(): IFresnelParametersSerialized;
  99748. /**
  99749. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99750. * @param parsedFresnelParameters Define the JSON representation
  99751. * @returns the parsed parameters
  99752. */
  99753. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99754. }
  99755. }
  99756. declare module BABYLON {
  99757. /**
  99758. * This groups all the flags used to control the materials channel.
  99759. */
  99760. export class MaterialFlags {
  99761. private static _DiffuseTextureEnabled;
  99762. /**
  99763. * Are diffuse textures enabled in the application.
  99764. */
  99765. static get DiffuseTextureEnabled(): boolean;
  99766. static set DiffuseTextureEnabled(value: boolean);
  99767. private static _DetailTextureEnabled;
  99768. /**
  99769. * Are detail textures enabled in the application.
  99770. */
  99771. static get DetailTextureEnabled(): boolean;
  99772. static set DetailTextureEnabled(value: boolean);
  99773. private static _AmbientTextureEnabled;
  99774. /**
  99775. * Are ambient textures enabled in the application.
  99776. */
  99777. static get AmbientTextureEnabled(): boolean;
  99778. static set AmbientTextureEnabled(value: boolean);
  99779. private static _OpacityTextureEnabled;
  99780. /**
  99781. * Are opacity textures enabled in the application.
  99782. */
  99783. static get OpacityTextureEnabled(): boolean;
  99784. static set OpacityTextureEnabled(value: boolean);
  99785. private static _ReflectionTextureEnabled;
  99786. /**
  99787. * Are reflection textures enabled in the application.
  99788. */
  99789. static get ReflectionTextureEnabled(): boolean;
  99790. static set ReflectionTextureEnabled(value: boolean);
  99791. private static _EmissiveTextureEnabled;
  99792. /**
  99793. * Are emissive textures enabled in the application.
  99794. */
  99795. static get EmissiveTextureEnabled(): boolean;
  99796. static set EmissiveTextureEnabled(value: boolean);
  99797. private static _SpecularTextureEnabled;
  99798. /**
  99799. * Are specular textures enabled in the application.
  99800. */
  99801. static get SpecularTextureEnabled(): boolean;
  99802. static set SpecularTextureEnabled(value: boolean);
  99803. private static _BumpTextureEnabled;
  99804. /**
  99805. * Are bump textures enabled in the application.
  99806. */
  99807. static get BumpTextureEnabled(): boolean;
  99808. static set BumpTextureEnabled(value: boolean);
  99809. private static _LightmapTextureEnabled;
  99810. /**
  99811. * Are lightmap textures enabled in the application.
  99812. */
  99813. static get LightmapTextureEnabled(): boolean;
  99814. static set LightmapTextureEnabled(value: boolean);
  99815. private static _RefractionTextureEnabled;
  99816. /**
  99817. * Are refraction textures enabled in the application.
  99818. */
  99819. static get RefractionTextureEnabled(): boolean;
  99820. static set RefractionTextureEnabled(value: boolean);
  99821. private static _ColorGradingTextureEnabled;
  99822. /**
  99823. * Are color grading textures enabled in the application.
  99824. */
  99825. static get ColorGradingTextureEnabled(): boolean;
  99826. static set ColorGradingTextureEnabled(value: boolean);
  99827. private static _FresnelEnabled;
  99828. /**
  99829. * Are fresnels enabled in the application.
  99830. */
  99831. static get FresnelEnabled(): boolean;
  99832. static set FresnelEnabled(value: boolean);
  99833. private static _ClearCoatTextureEnabled;
  99834. /**
  99835. * Are clear coat textures enabled in the application.
  99836. */
  99837. static get ClearCoatTextureEnabled(): boolean;
  99838. static set ClearCoatTextureEnabled(value: boolean);
  99839. private static _ClearCoatBumpTextureEnabled;
  99840. /**
  99841. * Are clear coat bump textures enabled in the application.
  99842. */
  99843. static get ClearCoatBumpTextureEnabled(): boolean;
  99844. static set ClearCoatBumpTextureEnabled(value: boolean);
  99845. private static _ClearCoatTintTextureEnabled;
  99846. /**
  99847. * Are clear coat tint textures enabled in the application.
  99848. */
  99849. static get ClearCoatTintTextureEnabled(): boolean;
  99850. static set ClearCoatTintTextureEnabled(value: boolean);
  99851. private static _SheenTextureEnabled;
  99852. /**
  99853. * Are sheen textures enabled in the application.
  99854. */
  99855. static get SheenTextureEnabled(): boolean;
  99856. static set SheenTextureEnabled(value: boolean);
  99857. private static _AnisotropicTextureEnabled;
  99858. /**
  99859. * Are anisotropic textures enabled in the application.
  99860. */
  99861. static get AnisotropicTextureEnabled(): boolean;
  99862. static set AnisotropicTextureEnabled(value: boolean);
  99863. private static _ThicknessTextureEnabled;
  99864. /**
  99865. * Are thickness textures enabled in the application.
  99866. */
  99867. static get ThicknessTextureEnabled(): boolean;
  99868. static set ThicknessTextureEnabled(value: boolean);
  99869. }
  99870. }
  99871. declare module BABYLON {
  99872. /** @hidden */
  99873. export var defaultFragmentDeclaration: {
  99874. name: string;
  99875. shader: string;
  99876. };
  99877. }
  99878. declare module BABYLON {
  99879. /** @hidden */
  99880. export var defaultUboDeclaration: {
  99881. name: string;
  99882. shader: string;
  99883. };
  99884. }
  99885. declare module BABYLON {
  99886. /** @hidden */
  99887. export var prePassDeclaration: {
  99888. name: string;
  99889. shader: string;
  99890. };
  99891. }
  99892. declare module BABYLON {
  99893. /** @hidden */
  99894. export var lightFragmentDeclaration: {
  99895. name: string;
  99896. shader: string;
  99897. };
  99898. }
  99899. declare module BABYLON {
  99900. /** @hidden */
  99901. export var lightUboDeclaration: {
  99902. name: string;
  99903. shader: string;
  99904. };
  99905. }
  99906. declare module BABYLON {
  99907. /** @hidden */
  99908. export var lightsFragmentFunctions: {
  99909. name: string;
  99910. shader: string;
  99911. };
  99912. }
  99913. declare module BABYLON {
  99914. /** @hidden */
  99915. export var shadowsFragmentFunctions: {
  99916. name: string;
  99917. shader: string;
  99918. };
  99919. }
  99920. declare module BABYLON {
  99921. /** @hidden */
  99922. export var fresnelFunction: {
  99923. name: string;
  99924. shader: string;
  99925. };
  99926. }
  99927. declare module BABYLON {
  99928. /** @hidden */
  99929. export var bumpFragmentMainFunctions: {
  99930. name: string;
  99931. shader: string;
  99932. };
  99933. }
  99934. declare module BABYLON {
  99935. /** @hidden */
  99936. export var bumpFragmentFunctions: {
  99937. name: string;
  99938. shader: string;
  99939. };
  99940. }
  99941. declare module BABYLON {
  99942. /** @hidden */
  99943. export var logDepthDeclaration: {
  99944. name: string;
  99945. shader: string;
  99946. };
  99947. }
  99948. declare module BABYLON {
  99949. /** @hidden */
  99950. export var fogFragmentDeclaration: {
  99951. name: string;
  99952. shader: string;
  99953. };
  99954. }
  99955. declare module BABYLON {
  99956. /** @hidden */
  99957. export var bumpFragment: {
  99958. name: string;
  99959. shader: string;
  99960. };
  99961. }
  99962. declare module BABYLON {
  99963. /** @hidden */
  99964. export var depthPrePass: {
  99965. name: string;
  99966. shader: string;
  99967. };
  99968. }
  99969. declare module BABYLON {
  99970. /** @hidden */
  99971. export var lightFragment: {
  99972. name: string;
  99973. shader: string;
  99974. };
  99975. }
  99976. declare module BABYLON {
  99977. /** @hidden */
  99978. export var logDepthFragment: {
  99979. name: string;
  99980. shader: string;
  99981. };
  99982. }
  99983. declare module BABYLON {
  99984. /** @hidden */
  99985. export var fogFragment: {
  99986. name: string;
  99987. shader: string;
  99988. };
  99989. }
  99990. declare module BABYLON {
  99991. /** @hidden */
  99992. export var defaultPixelShader: {
  99993. name: string;
  99994. shader: string;
  99995. };
  99996. }
  99997. declare module BABYLON {
  99998. /** @hidden */
  99999. export var defaultVertexDeclaration: {
  100000. name: string;
  100001. shader: string;
  100002. };
  100003. }
  100004. declare module BABYLON {
  100005. /** @hidden */
  100006. export var bonesDeclaration: {
  100007. name: string;
  100008. shader: string;
  100009. };
  100010. }
  100011. declare module BABYLON {
  100012. /** @hidden */
  100013. export var instancesDeclaration: {
  100014. name: string;
  100015. shader: string;
  100016. };
  100017. }
  100018. declare module BABYLON {
  100019. /** @hidden */
  100020. export var prePassVertexDeclaration: {
  100021. name: string;
  100022. shader: string;
  100023. };
  100024. }
  100025. declare module BABYLON {
  100026. /** @hidden */
  100027. export var bumpVertexDeclaration: {
  100028. name: string;
  100029. shader: string;
  100030. };
  100031. }
  100032. declare module BABYLON {
  100033. /** @hidden */
  100034. export var fogVertexDeclaration: {
  100035. name: string;
  100036. shader: string;
  100037. };
  100038. }
  100039. declare module BABYLON {
  100040. /** @hidden */
  100041. export var morphTargetsVertexGlobalDeclaration: {
  100042. name: string;
  100043. shader: string;
  100044. };
  100045. }
  100046. declare module BABYLON {
  100047. /** @hidden */
  100048. export var morphTargetsVertexDeclaration: {
  100049. name: string;
  100050. shader: string;
  100051. };
  100052. }
  100053. declare module BABYLON {
  100054. /** @hidden */
  100055. export var morphTargetsVertex: {
  100056. name: string;
  100057. shader: string;
  100058. };
  100059. }
  100060. declare module BABYLON {
  100061. /** @hidden */
  100062. export var instancesVertex: {
  100063. name: string;
  100064. shader: string;
  100065. };
  100066. }
  100067. declare module BABYLON {
  100068. /** @hidden */
  100069. export var bonesVertex: {
  100070. name: string;
  100071. shader: string;
  100072. };
  100073. }
  100074. declare module BABYLON {
  100075. /** @hidden */
  100076. export var prePassVertex: {
  100077. name: string;
  100078. shader: string;
  100079. };
  100080. }
  100081. declare module BABYLON {
  100082. /** @hidden */
  100083. export var bumpVertex: {
  100084. name: string;
  100085. shader: string;
  100086. };
  100087. }
  100088. declare module BABYLON {
  100089. /** @hidden */
  100090. export var fogVertex: {
  100091. name: string;
  100092. shader: string;
  100093. };
  100094. }
  100095. declare module BABYLON {
  100096. /** @hidden */
  100097. export var shadowsVertex: {
  100098. name: string;
  100099. shader: string;
  100100. };
  100101. }
  100102. declare module BABYLON {
  100103. /** @hidden */
  100104. export var pointCloudVertex: {
  100105. name: string;
  100106. shader: string;
  100107. };
  100108. }
  100109. declare module BABYLON {
  100110. /** @hidden */
  100111. export var logDepthVertex: {
  100112. name: string;
  100113. shader: string;
  100114. };
  100115. }
  100116. declare module BABYLON {
  100117. /** @hidden */
  100118. export var defaultVertexShader: {
  100119. name: string;
  100120. shader: string;
  100121. };
  100122. }
  100123. declare module BABYLON {
  100124. /**
  100125. * @hidden
  100126. */
  100127. export interface IMaterialDetailMapDefines {
  100128. DETAIL: boolean;
  100129. DETAILDIRECTUV: number;
  100130. DETAIL_NORMALBLENDMETHOD: number;
  100131. /** @hidden */
  100132. _areTexturesDirty: boolean;
  100133. }
  100134. /**
  100135. * Define the code related to the detail map parameters of a material
  100136. *
  100137. * Inspired from:
  100138. * 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
  100139. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  100140. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  100141. */
  100142. export class DetailMapConfiguration {
  100143. private _texture;
  100144. /**
  100145. * The detail texture of the material.
  100146. */
  100147. texture: Nullable<BaseTexture>;
  100148. /**
  100149. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  100150. * Bigger values mean stronger blending
  100151. */
  100152. diffuseBlendLevel: number;
  100153. /**
  100154. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  100155. * Bigger values mean stronger blending. Only used with PBR materials
  100156. */
  100157. roughnessBlendLevel: number;
  100158. /**
  100159. * Defines how strong the bump effect from the detail map is
  100160. * Bigger values mean stronger effect
  100161. */
  100162. bumpLevel: number;
  100163. private _normalBlendMethod;
  100164. /**
  100165. * The method used to blend the bump and detail normals together
  100166. */
  100167. normalBlendMethod: number;
  100168. private _isEnabled;
  100169. /**
  100170. * Enable or disable the detail map on this material
  100171. */
  100172. isEnabled: boolean;
  100173. /** @hidden */
  100174. private _internalMarkAllSubMeshesAsTexturesDirty;
  100175. /** @hidden */
  100176. _markAllSubMeshesAsTexturesDirty(): void;
  100177. /**
  100178. * Instantiate a new detail map
  100179. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100180. */
  100181. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100182. /**
  100183. * Gets whether the submesh is ready to be used or not.
  100184. * @param defines the list of "defines" to update.
  100185. * @param scene defines the scene the material belongs to.
  100186. * @returns - boolean indicating that the submesh is ready or not.
  100187. */
  100188. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  100189. /**
  100190. * Update the defines for detail map usage
  100191. * @param defines the list of "defines" to update.
  100192. * @param scene defines the scene the material belongs to.
  100193. */
  100194. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  100195. /**
  100196. * Binds the material data.
  100197. * @param uniformBuffer defines the Uniform buffer to fill in.
  100198. * @param scene defines the scene the material belongs to.
  100199. * @param isFrozen defines whether the material is frozen or not.
  100200. */
  100201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100202. /**
  100203. * Checks to see if a texture is used in the material.
  100204. * @param texture - Base texture to use.
  100205. * @returns - Boolean specifying if a texture is used in the material.
  100206. */
  100207. hasTexture(texture: BaseTexture): boolean;
  100208. /**
  100209. * Returns an array of the actively used textures.
  100210. * @param activeTextures Array of BaseTextures
  100211. */
  100212. getActiveTextures(activeTextures: BaseTexture[]): void;
  100213. /**
  100214. * Returns the animatable textures.
  100215. * @param animatables Array of animatable textures.
  100216. */
  100217. getAnimatables(animatables: IAnimatable[]): void;
  100218. /**
  100219. * Disposes the resources of the material.
  100220. * @param forceDisposeTextures - Forces the disposal of all textures.
  100221. */
  100222. dispose(forceDisposeTextures?: boolean): void;
  100223. /**
  100224. * Get the current class name useful for serialization or dynamic coding.
  100225. * @returns "DetailMap"
  100226. */
  100227. getClassName(): string;
  100228. /**
  100229. * Add the required uniforms to the current list.
  100230. * @param uniforms defines the current uniform list.
  100231. */
  100232. static AddUniforms(uniforms: string[]): void;
  100233. /**
  100234. * Add the required samplers to the current list.
  100235. * @param samplers defines the current sampler list.
  100236. */
  100237. static AddSamplers(samplers: string[]): void;
  100238. /**
  100239. * Add the required uniforms to the current buffer.
  100240. * @param uniformBuffer defines the current uniform buffer.
  100241. */
  100242. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100243. /**
  100244. * Makes a duplicate of the current instance into another one.
  100245. * @param detailMap define the instance where to copy the info
  100246. */
  100247. copyTo(detailMap: DetailMapConfiguration): void;
  100248. /**
  100249. * Serializes this detail map instance
  100250. * @returns - An object with the serialized instance.
  100251. */
  100252. serialize(): any;
  100253. /**
  100254. * Parses a detail map setting from a serialized object.
  100255. * @param source - Serialized object.
  100256. * @param scene Defines the scene we are parsing for
  100257. * @param rootUrl Defines the rootUrl to load from
  100258. */
  100259. parse(source: any, scene: Scene, rootUrl: string): void;
  100260. }
  100261. }
  100262. declare module BABYLON {
  100263. /** @hidden */
  100264. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100265. MAINUV1: boolean;
  100266. MAINUV2: boolean;
  100267. DIFFUSE: boolean;
  100268. DIFFUSEDIRECTUV: number;
  100269. DETAIL: boolean;
  100270. DETAILDIRECTUV: number;
  100271. DETAIL_NORMALBLENDMETHOD: number;
  100272. AMBIENT: boolean;
  100273. AMBIENTDIRECTUV: number;
  100274. OPACITY: boolean;
  100275. OPACITYDIRECTUV: number;
  100276. OPACITYRGB: boolean;
  100277. REFLECTION: boolean;
  100278. EMISSIVE: boolean;
  100279. EMISSIVEDIRECTUV: number;
  100280. SPECULAR: boolean;
  100281. SPECULARDIRECTUV: number;
  100282. BUMP: boolean;
  100283. BUMPDIRECTUV: number;
  100284. PARALLAX: boolean;
  100285. PARALLAXOCCLUSION: boolean;
  100286. SPECULAROVERALPHA: boolean;
  100287. CLIPPLANE: boolean;
  100288. CLIPPLANE2: boolean;
  100289. CLIPPLANE3: boolean;
  100290. CLIPPLANE4: boolean;
  100291. CLIPPLANE5: boolean;
  100292. CLIPPLANE6: boolean;
  100293. ALPHATEST: boolean;
  100294. DEPTHPREPASS: boolean;
  100295. ALPHAFROMDIFFUSE: boolean;
  100296. POINTSIZE: boolean;
  100297. FOG: boolean;
  100298. SPECULARTERM: boolean;
  100299. DIFFUSEFRESNEL: boolean;
  100300. OPACITYFRESNEL: boolean;
  100301. REFLECTIONFRESNEL: boolean;
  100302. REFRACTIONFRESNEL: boolean;
  100303. EMISSIVEFRESNEL: boolean;
  100304. FRESNEL: boolean;
  100305. NORMAL: boolean;
  100306. UV1: boolean;
  100307. UV2: boolean;
  100308. VERTEXCOLOR: boolean;
  100309. VERTEXALPHA: boolean;
  100310. NUM_BONE_INFLUENCERS: number;
  100311. BonesPerMesh: number;
  100312. BONETEXTURE: boolean;
  100313. BONES_VELOCITY_ENABLED: boolean;
  100314. INSTANCES: boolean;
  100315. THIN_INSTANCES: boolean;
  100316. GLOSSINESS: boolean;
  100317. ROUGHNESS: boolean;
  100318. EMISSIVEASILLUMINATION: boolean;
  100319. LINKEMISSIVEWITHDIFFUSE: boolean;
  100320. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100321. LIGHTMAP: boolean;
  100322. LIGHTMAPDIRECTUV: number;
  100323. OBJECTSPACE_NORMALMAP: boolean;
  100324. USELIGHTMAPASSHADOWMAP: boolean;
  100325. REFLECTIONMAP_3D: boolean;
  100326. REFLECTIONMAP_SPHERICAL: boolean;
  100327. REFLECTIONMAP_PLANAR: boolean;
  100328. REFLECTIONMAP_CUBIC: boolean;
  100329. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100330. REFLECTIONMAP_PROJECTION: boolean;
  100331. REFLECTIONMAP_SKYBOX: boolean;
  100332. REFLECTIONMAP_EXPLICIT: boolean;
  100333. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100334. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100335. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100336. INVERTCUBICMAP: boolean;
  100337. LOGARITHMICDEPTH: boolean;
  100338. REFRACTION: boolean;
  100339. REFRACTIONMAP_3D: boolean;
  100340. REFLECTIONOVERALPHA: boolean;
  100341. TWOSIDEDLIGHTING: boolean;
  100342. SHADOWFLOAT: boolean;
  100343. MORPHTARGETS: boolean;
  100344. MORPHTARGETS_NORMAL: boolean;
  100345. MORPHTARGETS_TANGENT: boolean;
  100346. MORPHTARGETS_UV: boolean;
  100347. NUM_MORPH_INFLUENCERS: number;
  100348. NONUNIFORMSCALING: boolean;
  100349. PREMULTIPLYALPHA: boolean;
  100350. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100351. ALPHABLEND: boolean;
  100352. PREPASS: boolean;
  100353. PREPASS_IRRADIANCE: boolean;
  100354. PREPASS_IRRADIANCE_INDEX: number;
  100355. PREPASS_ALBEDO: boolean;
  100356. PREPASS_ALBEDO_INDEX: number;
  100357. PREPASS_DEPTHNORMAL: boolean;
  100358. PREPASS_DEPTHNORMAL_INDEX: number;
  100359. PREPASS_POSITION: boolean;
  100360. PREPASS_POSITION_INDEX: number;
  100361. PREPASS_VELOCITY: boolean;
  100362. PREPASS_VELOCITY_INDEX: number;
  100363. PREPASS_REFLECTIVITY: boolean;
  100364. PREPASS_REFLECTIVITY_INDEX: number;
  100365. SCENE_MRT_COUNT: number;
  100366. RGBDLIGHTMAP: boolean;
  100367. RGBDREFLECTION: boolean;
  100368. RGBDREFRACTION: boolean;
  100369. IMAGEPROCESSING: boolean;
  100370. VIGNETTE: boolean;
  100371. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100372. VIGNETTEBLENDMODEOPAQUE: boolean;
  100373. TONEMAPPING: boolean;
  100374. TONEMAPPING_ACES: boolean;
  100375. CONTRAST: boolean;
  100376. COLORCURVES: boolean;
  100377. COLORGRADING: boolean;
  100378. COLORGRADING3D: boolean;
  100379. SAMPLER3DGREENDEPTH: boolean;
  100380. SAMPLER3DBGRMAP: boolean;
  100381. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100382. MULTIVIEW: boolean;
  100383. /**
  100384. * If the reflection texture on this material is in linear color space
  100385. * @hidden
  100386. */
  100387. IS_REFLECTION_LINEAR: boolean;
  100388. /**
  100389. * If the refraction texture on this material is in linear color space
  100390. * @hidden
  100391. */
  100392. IS_REFRACTION_LINEAR: boolean;
  100393. EXPOSURE: boolean;
  100394. constructor();
  100395. setReflectionMode(modeToEnable: string): void;
  100396. }
  100397. /**
  100398. * This is the default material used in Babylon. It is the best trade off between quality
  100399. * and performances.
  100400. * @see https://doc.babylonjs.com/babylon101/materials
  100401. */
  100402. export class StandardMaterial extends PushMaterial {
  100403. private _diffuseTexture;
  100404. /**
  100405. * The basic texture of the material as viewed under a light.
  100406. */
  100407. diffuseTexture: Nullable<BaseTexture>;
  100408. private _ambientTexture;
  100409. /**
  100410. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100411. */
  100412. ambientTexture: Nullable<BaseTexture>;
  100413. private _opacityTexture;
  100414. /**
  100415. * Define the transparency of the material from a texture.
  100416. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100417. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100418. */
  100419. opacityTexture: Nullable<BaseTexture>;
  100420. private _reflectionTexture;
  100421. /**
  100422. * Define the texture used to display the reflection.
  100423. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100424. */
  100425. reflectionTexture: Nullable<BaseTexture>;
  100426. private _emissiveTexture;
  100427. /**
  100428. * Define texture of the material as if self lit.
  100429. * This will be mixed in the final result even in the absence of light.
  100430. */
  100431. emissiveTexture: Nullable<BaseTexture>;
  100432. private _specularTexture;
  100433. /**
  100434. * Define how the color and intensity of the highlight given by the light in the material.
  100435. */
  100436. specularTexture: Nullable<BaseTexture>;
  100437. private _bumpTexture;
  100438. /**
  100439. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100440. * 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.
  100441. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100442. */
  100443. bumpTexture: Nullable<BaseTexture>;
  100444. private _lightmapTexture;
  100445. /**
  100446. * Complex lighting can be computationally expensive to compute at runtime.
  100447. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100448. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100449. */
  100450. lightmapTexture: Nullable<BaseTexture>;
  100451. private _refractionTexture;
  100452. /**
  100453. * Define the texture used to display the refraction.
  100454. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100455. */
  100456. refractionTexture: Nullable<BaseTexture>;
  100457. /**
  100458. * The color of the material lit by the environmental background lighting.
  100459. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100460. */
  100461. ambientColor: Color3;
  100462. /**
  100463. * The basic color of the material as viewed under a light.
  100464. */
  100465. diffuseColor: Color3;
  100466. /**
  100467. * Define how the color and intensity of the highlight given by the light in the material.
  100468. */
  100469. specularColor: Color3;
  100470. /**
  100471. * Define the color of the material as if self lit.
  100472. * This will be mixed in the final result even in the absence of light.
  100473. */
  100474. emissiveColor: Color3;
  100475. /**
  100476. * Defines how sharp are the highlights in the material.
  100477. * The bigger the value the sharper giving a more glossy feeling to the result.
  100478. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100479. */
  100480. specularPower: number;
  100481. private _useAlphaFromDiffuseTexture;
  100482. /**
  100483. * Does the transparency come from the diffuse texture alpha channel.
  100484. */
  100485. useAlphaFromDiffuseTexture: boolean;
  100486. private _useEmissiveAsIllumination;
  100487. /**
  100488. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100489. */
  100490. useEmissiveAsIllumination: boolean;
  100491. private _linkEmissiveWithDiffuse;
  100492. /**
  100493. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100494. * the emissive level when the final color is close to one.
  100495. */
  100496. linkEmissiveWithDiffuse: boolean;
  100497. private _useSpecularOverAlpha;
  100498. /**
  100499. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100500. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100501. */
  100502. useSpecularOverAlpha: boolean;
  100503. private _useReflectionOverAlpha;
  100504. /**
  100505. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100506. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100507. */
  100508. useReflectionOverAlpha: boolean;
  100509. private _disableLighting;
  100510. /**
  100511. * Does lights from the scene impacts this material.
  100512. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100513. */
  100514. disableLighting: boolean;
  100515. private _useObjectSpaceNormalMap;
  100516. /**
  100517. * Allows using an object space normal map (instead of tangent space).
  100518. */
  100519. useObjectSpaceNormalMap: boolean;
  100520. private _useParallax;
  100521. /**
  100522. * Is parallax enabled or not.
  100523. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100524. */
  100525. useParallax: boolean;
  100526. private _useParallaxOcclusion;
  100527. /**
  100528. * Is parallax occlusion enabled or not.
  100529. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100530. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100531. */
  100532. useParallaxOcclusion: boolean;
  100533. /**
  100534. * 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.
  100535. */
  100536. parallaxScaleBias: number;
  100537. private _roughness;
  100538. /**
  100539. * Helps to define how blurry the reflections should appears in the material.
  100540. */
  100541. roughness: number;
  100542. /**
  100543. * In case of refraction, define the value of the index of refraction.
  100544. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100545. */
  100546. indexOfRefraction: number;
  100547. /**
  100548. * Invert the refraction texture alongside the y axis.
  100549. * It can be useful with procedural textures or probe for instance.
  100550. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100551. */
  100552. invertRefractionY: boolean;
  100553. /**
  100554. * Defines the alpha limits in alpha test mode.
  100555. */
  100556. alphaCutOff: number;
  100557. private _useLightmapAsShadowmap;
  100558. /**
  100559. * In case of light mapping, define whether the map contains light or shadow informations.
  100560. */
  100561. useLightmapAsShadowmap: boolean;
  100562. private _diffuseFresnelParameters;
  100563. /**
  100564. * Define the diffuse fresnel parameters of the material.
  100565. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100566. */
  100567. diffuseFresnelParameters: FresnelParameters;
  100568. private _opacityFresnelParameters;
  100569. /**
  100570. * Define the opacity fresnel parameters of the material.
  100571. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100572. */
  100573. opacityFresnelParameters: FresnelParameters;
  100574. private _reflectionFresnelParameters;
  100575. /**
  100576. * Define the reflection fresnel parameters of the material.
  100577. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100578. */
  100579. reflectionFresnelParameters: FresnelParameters;
  100580. private _refractionFresnelParameters;
  100581. /**
  100582. * Define the refraction fresnel parameters of the material.
  100583. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100584. */
  100585. refractionFresnelParameters: FresnelParameters;
  100586. private _emissiveFresnelParameters;
  100587. /**
  100588. * Define the emissive fresnel parameters of the material.
  100589. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100590. */
  100591. emissiveFresnelParameters: FresnelParameters;
  100592. private _useReflectionFresnelFromSpecular;
  100593. /**
  100594. * If true automatically deducts the fresnels values from the material specularity.
  100595. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100596. */
  100597. useReflectionFresnelFromSpecular: boolean;
  100598. private _useGlossinessFromSpecularMapAlpha;
  100599. /**
  100600. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100601. */
  100602. useGlossinessFromSpecularMapAlpha: boolean;
  100603. private _maxSimultaneousLights;
  100604. /**
  100605. * Defines the maximum number of lights that can be used in the material
  100606. */
  100607. maxSimultaneousLights: number;
  100608. private _invertNormalMapX;
  100609. /**
  100610. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100611. */
  100612. invertNormalMapX: boolean;
  100613. private _invertNormalMapY;
  100614. /**
  100615. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100616. */
  100617. invertNormalMapY: boolean;
  100618. private _twoSidedLighting;
  100619. /**
  100620. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100621. */
  100622. twoSidedLighting: boolean;
  100623. /**
  100624. * Default configuration related to image processing available in the standard Material.
  100625. */
  100626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100627. /**
  100628. * Gets the image processing configuration used either in this material.
  100629. */
  100630. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100631. /**
  100632. * Sets the Default image processing configuration used either in the this material.
  100633. *
  100634. * If sets to null, the scene one is in use.
  100635. */
  100636. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100637. /**
  100638. * Keep track of the image processing observer to allow dispose and replace.
  100639. */
  100640. private _imageProcessingObserver;
  100641. /**
  100642. * Attaches a new image processing configuration to the Standard Material.
  100643. * @param configuration
  100644. */
  100645. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100646. /**
  100647. * Defines additionnal PrePass parameters for the material.
  100648. */
  100649. readonly prePassConfiguration: PrePassConfiguration;
  100650. /**
  100651. * Gets wether the color curves effect is enabled.
  100652. */
  100653. get cameraColorCurvesEnabled(): boolean;
  100654. /**
  100655. * Sets wether the color curves effect is enabled.
  100656. */
  100657. set cameraColorCurvesEnabled(value: boolean);
  100658. /**
  100659. * Gets wether the color grading effect is enabled.
  100660. */
  100661. get cameraColorGradingEnabled(): boolean;
  100662. /**
  100663. * Gets wether the color grading effect is enabled.
  100664. */
  100665. set cameraColorGradingEnabled(value: boolean);
  100666. /**
  100667. * Gets wether tonemapping is enabled or not.
  100668. */
  100669. get cameraToneMappingEnabled(): boolean;
  100670. /**
  100671. * Sets wether tonemapping is enabled or not
  100672. */
  100673. set cameraToneMappingEnabled(value: boolean);
  100674. /**
  100675. * The camera exposure used on this material.
  100676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100677. * This corresponds to a photographic exposure.
  100678. */
  100679. get cameraExposure(): number;
  100680. /**
  100681. * The camera exposure used on this material.
  100682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100683. * This corresponds to a photographic exposure.
  100684. */
  100685. set cameraExposure(value: number);
  100686. /**
  100687. * Gets The camera contrast used on this material.
  100688. */
  100689. get cameraContrast(): number;
  100690. /**
  100691. * Sets The camera contrast used on this material.
  100692. */
  100693. set cameraContrast(value: number);
  100694. /**
  100695. * Gets the Color Grading 2D Lookup Texture.
  100696. */
  100697. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100698. /**
  100699. * Sets the Color Grading 2D Lookup Texture.
  100700. */
  100701. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100702. /**
  100703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100705. * 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;
  100706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100707. */
  100708. get cameraColorCurves(): Nullable<ColorCurves>;
  100709. /**
  100710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100712. * 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;
  100713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100714. */
  100715. set cameraColorCurves(value: Nullable<ColorCurves>);
  100716. /**
  100717. * Can this material render to several textures at once
  100718. */
  100719. get canRenderToMRT(): boolean;
  100720. /**
  100721. * Defines the detail map parameters for the material.
  100722. */
  100723. readonly detailMap: DetailMapConfiguration;
  100724. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100725. protected _worldViewProjectionMatrix: Matrix;
  100726. protected _globalAmbientColor: Color3;
  100727. protected _useLogarithmicDepth: boolean;
  100728. protected _rebuildInParallel: boolean;
  100729. /**
  100730. * Instantiates a new standard material.
  100731. * This is the default material used in Babylon. It is the best trade off between quality
  100732. * and performances.
  100733. * @see https://doc.babylonjs.com/babylon101/materials
  100734. * @param name Define the name of the material in the scene
  100735. * @param scene Define the scene the material belong to
  100736. */
  100737. constructor(name: string, scene: Scene);
  100738. /**
  100739. * Gets a boolean indicating that current material needs to register RTT
  100740. */
  100741. get hasRenderTargetTextures(): boolean;
  100742. /**
  100743. * Gets the current class name of the material e.g. "StandardMaterial"
  100744. * Mainly use in serialization.
  100745. * @returns the class name
  100746. */
  100747. getClassName(): string;
  100748. /**
  100749. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100750. * You can try switching to logarithmic depth.
  100751. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100752. */
  100753. get useLogarithmicDepth(): boolean;
  100754. set useLogarithmicDepth(value: boolean);
  100755. /**
  100756. * Specifies if the material will require alpha blending
  100757. * @returns a boolean specifying if alpha blending is needed
  100758. */
  100759. needAlphaBlending(): boolean;
  100760. /**
  100761. * Specifies if this material should be rendered in alpha test mode
  100762. * @returns a boolean specifying if an alpha test is needed.
  100763. */
  100764. needAlphaTesting(): boolean;
  100765. /**
  100766. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100767. */
  100768. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100769. /**
  100770. * Specifies whether or not there is a usable alpha channel for transparency.
  100771. */
  100772. protected _hasAlphaChannel(): boolean;
  100773. /**
  100774. * Get the texture used for alpha test purpose.
  100775. * @returns the diffuse texture in case of the standard material.
  100776. */
  100777. getAlphaTestTexture(): Nullable<BaseTexture>;
  100778. /**
  100779. * Get if the submesh is ready to be used and all its information available.
  100780. * Child classes can use it to update shaders
  100781. * @param mesh defines the mesh to check
  100782. * @param subMesh defines which submesh to check
  100783. * @param useInstances specifies that instances should be used
  100784. * @returns a boolean indicating that the submesh is ready or not
  100785. */
  100786. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100787. /**
  100788. * Builds the material UBO layouts.
  100789. * Used internally during the effect preparation.
  100790. */
  100791. buildUniformLayout(): void;
  100792. /**
  100793. * Unbinds the material from the mesh
  100794. */
  100795. unbind(): void;
  100796. /**
  100797. * Binds the submesh to this material by preparing the effect and shader to draw
  100798. * @param world defines the world transformation matrix
  100799. * @param mesh defines the mesh containing the submesh
  100800. * @param subMesh defines the submesh to bind the material to
  100801. */
  100802. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100803. /**
  100804. * Get the list of animatables in the material.
  100805. * @returns the list of animatables object used in the material
  100806. */
  100807. getAnimatables(): IAnimatable[];
  100808. /**
  100809. * Gets the active textures from the material
  100810. * @returns an array of textures
  100811. */
  100812. getActiveTextures(): BaseTexture[];
  100813. /**
  100814. * Specifies if the material uses a texture
  100815. * @param texture defines the texture to check against the material
  100816. * @returns a boolean specifying if the material uses the texture
  100817. */
  100818. hasTexture(texture: BaseTexture): boolean;
  100819. /**
  100820. * Disposes the material
  100821. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100822. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100823. */
  100824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100825. /**
  100826. * Makes a duplicate of the material, and gives it a new name
  100827. * @param name defines the new name for the duplicated material
  100828. * @returns the cloned material
  100829. */
  100830. clone(name: string): StandardMaterial;
  100831. /**
  100832. * Serializes this material in a JSON representation
  100833. * @returns the serialized material object
  100834. */
  100835. serialize(): any;
  100836. /**
  100837. * Creates a standard material from parsed material data
  100838. * @param source defines the JSON representation of the material
  100839. * @param scene defines the hosting scene
  100840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100841. * @returns a new standard material
  100842. */
  100843. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100844. /**
  100845. * Are diffuse textures enabled in the application.
  100846. */
  100847. static get DiffuseTextureEnabled(): boolean;
  100848. static set DiffuseTextureEnabled(value: boolean);
  100849. /**
  100850. * Are detail textures enabled in the application.
  100851. */
  100852. static get DetailTextureEnabled(): boolean;
  100853. static set DetailTextureEnabled(value: boolean);
  100854. /**
  100855. * Are ambient textures enabled in the application.
  100856. */
  100857. static get AmbientTextureEnabled(): boolean;
  100858. static set AmbientTextureEnabled(value: boolean);
  100859. /**
  100860. * Are opacity textures enabled in the application.
  100861. */
  100862. static get OpacityTextureEnabled(): boolean;
  100863. static set OpacityTextureEnabled(value: boolean);
  100864. /**
  100865. * Are reflection textures enabled in the application.
  100866. */
  100867. static get ReflectionTextureEnabled(): boolean;
  100868. static set ReflectionTextureEnabled(value: boolean);
  100869. /**
  100870. * Are emissive textures enabled in the application.
  100871. */
  100872. static get EmissiveTextureEnabled(): boolean;
  100873. static set EmissiveTextureEnabled(value: boolean);
  100874. /**
  100875. * Are specular textures enabled in the application.
  100876. */
  100877. static get SpecularTextureEnabled(): boolean;
  100878. static set SpecularTextureEnabled(value: boolean);
  100879. /**
  100880. * Are bump textures enabled in the application.
  100881. */
  100882. static get BumpTextureEnabled(): boolean;
  100883. static set BumpTextureEnabled(value: boolean);
  100884. /**
  100885. * Are lightmap textures enabled in the application.
  100886. */
  100887. static get LightmapTextureEnabled(): boolean;
  100888. static set LightmapTextureEnabled(value: boolean);
  100889. /**
  100890. * Are refraction textures enabled in the application.
  100891. */
  100892. static get RefractionTextureEnabled(): boolean;
  100893. static set RefractionTextureEnabled(value: boolean);
  100894. /**
  100895. * Are color grading textures enabled in the application.
  100896. */
  100897. static get ColorGradingTextureEnabled(): boolean;
  100898. static set ColorGradingTextureEnabled(value: boolean);
  100899. /**
  100900. * Are fresnels enabled in the application.
  100901. */
  100902. static get FresnelEnabled(): boolean;
  100903. static set FresnelEnabled(value: boolean);
  100904. }
  100905. }
  100906. declare module BABYLON {
  100907. /** @hidden */
  100908. export var rgbdDecodePixelShader: {
  100909. name: string;
  100910. shader: string;
  100911. };
  100912. }
  100913. declare module BABYLON {
  100914. /**
  100915. * Class used to host RGBD texture specific utilities
  100916. */
  100917. export class RGBDTextureTools {
  100918. /**
  100919. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100920. * @param texture the texture to expand.
  100921. */
  100922. static ExpandRGBDTexture(texture: Texture): void;
  100923. }
  100924. }
  100925. declare module BABYLON {
  100926. /**
  100927. * Class used to host texture specific utilities
  100928. */
  100929. export class BRDFTextureTools {
  100930. /**
  100931. * Prevents texture cache collision
  100932. */
  100933. private static _instanceNumber;
  100934. /**
  100935. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100936. * @param scene defines the hosting scene
  100937. * @returns the environment BRDF texture
  100938. */
  100939. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100940. private static _environmentBRDFBase64Texture;
  100941. }
  100942. }
  100943. declare module BABYLON {
  100944. /**
  100945. * @hidden
  100946. */
  100947. export interface IMaterialClearCoatDefines {
  100948. CLEARCOAT: boolean;
  100949. CLEARCOAT_DEFAULTIOR: boolean;
  100950. CLEARCOAT_TEXTURE: boolean;
  100951. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  100952. CLEARCOAT_TEXTUREDIRECTUV: number;
  100953. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  100954. CLEARCOAT_BUMP: boolean;
  100955. CLEARCOAT_BUMPDIRECTUV: number;
  100956. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  100957. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  100958. CLEARCOAT_REMAP_F0: boolean;
  100959. CLEARCOAT_TINT: boolean;
  100960. CLEARCOAT_TINT_TEXTURE: boolean;
  100961. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100962. /** @hidden */
  100963. _areTexturesDirty: boolean;
  100964. }
  100965. /**
  100966. * Define the code related to the clear coat parameters of the pbr material.
  100967. */
  100968. export class PBRClearCoatConfiguration {
  100969. /**
  100970. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100971. * The default fits with a polyurethane material.
  100972. * @hidden
  100973. */
  100974. static readonly _DefaultIndexOfRefraction: number;
  100975. private _isEnabled;
  100976. /**
  100977. * Defines if the clear coat is enabled in the material.
  100978. */
  100979. isEnabled: boolean;
  100980. /**
  100981. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100982. */
  100983. intensity: number;
  100984. /**
  100985. * Defines the clear coat layer roughness.
  100986. */
  100987. roughness: number;
  100988. private _indexOfRefraction;
  100989. /**
  100990. * Defines the index of refraction of the clear coat.
  100991. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100992. * The default fits with a polyurethane material.
  100993. * Changing the default value is more performance intensive.
  100994. */
  100995. indexOfRefraction: number;
  100996. private _texture;
  100997. /**
  100998. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  100999. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  101000. * if textureRoughness is not empty, else no texture roughness is used
  101001. */
  101002. texture: Nullable<BaseTexture>;
  101003. private _useRoughnessFromMainTexture;
  101004. /**
  101005. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  101006. * If false, the green channel from textureRoughness is used for roughness
  101007. */
  101008. useRoughnessFromMainTexture: boolean;
  101009. private _textureRoughness;
  101010. /**
  101011. * Stores the clear coat roughness in a texture (green channel)
  101012. * Not used if useRoughnessFromMainTexture is true
  101013. */
  101014. textureRoughness: Nullable<BaseTexture>;
  101015. private _remapF0OnInterfaceChange;
  101016. /**
  101017. * Defines if the F0 value should be remapped to account for the interface change in the material.
  101018. */
  101019. remapF0OnInterfaceChange: boolean;
  101020. private _bumpTexture;
  101021. /**
  101022. * Define the clear coat specific bump texture.
  101023. */
  101024. bumpTexture: Nullable<BaseTexture>;
  101025. private _isTintEnabled;
  101026. /**
  101027. * Defines if the clear coat tint is enabled in the material.
  101028. */
  101029. isTintEnabled: boolean;
  101030. /**
  101031. * Defines the clear coat tint of the material.
  101032. * This is only use if tint is enabled
  101033. */
  101034. tintColor: Color3;
  101035. /**
  101036. * Defines the distance at which the tint color should be found in the
  101037. * clear coat media.
  101038. * This is only use if tint is enabled
  101039. */
  101040. tintColorAtDistance: number;
  101041. /**
  101042. * Defines the clear coat layer thickness.
  101043. * This is only use if tint is enabled
  101044. */
  101045. tintThickness: number;
  101046. private _tintTexture;
  101047. /**
  101048. * Stores the clear tint values in a texture.
  101049. * rgb is tint
  101050. * a is a thickness factor
  101051. */
  101052. tintTexture: Nullable<BaseTexture>;
  101053. /** @hidden */
  101054. private _internalMarkAllSubMeshesAsTexturesDirty;
  101055. /** @hidden */
  101056. _markAllSubMeshesAsTexturesDirty(): void;
  101057. /**
  101058. * Instantiate a new istance of clear coat configuration.
  101059. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101060. */
  101061. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101062. /**
  101063. * Gets wehter the submesh is ready to be used or not.
  101064. * @param defines the list of "defines" to update.
  101065. * @param scene defines the scene the material belongs to.
  101066. * @param engine defines the engine the material belongs to.
  101067. * @param disableBumpMap defines wether the material disables bump or not.
  101068. * @returns - boolean indicating that the submesh is ready or not.
  101069. */
  101070. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101071. /**
  101072. * Checks to see if a texture is used in the material.
  101073. * @param defines the list of "defines" to update.
  101074. * @param scene defines the scene to the material belongs to.
  101075. */
  101076. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101077. /**
  101078. * Binds the material data.
  101079. * @param uniformBuffer defines the Uniform buffer to fill in.
  101080. * @param scene defines the scene the material belongs to.
  101081. * @param engine defines the engine the material belongs to.
  101082. * @param disableBumpMap defines wether the material disables bump or not.
  101083. * @param isFrozen defines wether the material is frozen or not.
  101084. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101085. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101086. * @param subMesh the submesh to bind data for
  101087. */
  101088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  101089. /**
  101090. * Checks to see if a texture is used in the material.
  101091. * @param texture - Base texture to use.
  101092. * @returns - Boolean specifying if a texture is used in the material.
  101093. */
  101094. hasTexture(texture: BaseTexture): boolean;
  101095. /**
  101096. * Returns an array of the actively used textures.
  101097. * @param activeTextures Array of BaseTextures
  101098. */
  101099. getActiveTextures(activeTextures: BaseTexture[]): void;
  101100. /**
  101101. * Returns the animatable textures.
  101102. * @param animatables Array of animatable textures.
  101103. */
  101104. getAnimatables(animatables: IAnimatable[]): void;
  101105. /**
  101106. * Disposes the resources of the material.
  101107. * @param forceDisposeTextures - Forces the disposal of all textures.
  101108. */
  101109. dispose(forceDisposeTextures?: boolean): void;
  101110. /**
  101111. * Get the current class name of the texture useful for serialization or dynamic coding.
  101112. * @returns "PBRClearCoatConfiguration"
  101113. */
  101114. getClassName(): string;
  101115. /**
  101116. * Add fallbacks to the effect fallbacks list.
  101117. * @param defines defines the Base texture to use.
  101118. * @param fallbacks defines the current fallback list.
  101119. * @param currentRank defines the current fallback rank.
  101120. * @returns the new fallback rank.
  101121. */
  101122. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101123. /**
  101124. * Add the required uniforms to the current list.
  101125. * @param uniforms defines the current uniform list.
  101126. */
  101127. static AddUniforms(uniforms: string[]): void;
  101128. /**
  101129. * Add the required samplers to the current list.
  101130. * @param samplers defines the current sampler list.
  101131. */
  101132. static AddSamplers(samplers: string[]): void;
  101133. /**
  101134. * Add the required uniforms to the current buffer.
  101135. * @param uniformBuffer defines the current uniform buffer.
  101136. */
  101137. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101138. /**
  101139. * Makes a duplicate of the current configuration into another one.
  101140. * @param clearCoatConfiguration define the config where to copy the info
  101141. */
  101142. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101143. /**
  101144. * Serializes this clear coat configuration.
  101145. * @returns - An object with the serialized config.
  101146. */
  101147. serialize(): any;
  101148. /**
  101149. * Parses a anisotropy Configuration from a serialized object.
  101150. * @param source - Serialized object.
  101151. * @param scene Defines the scene we are parsing for
  101152. * @param rootUrl Defines the rootUrl to load from
  101153. */
  101154. parse(source: any, scene: Scene, rootUrl: string): void;
  101155. }
  101156. }
  101157. declare module BABYLON {
  101158. /**
  101159. * @hidden
  101160. */
  101161. export interface IMaterialAnisotropicDefines {
  101162. ANISOTROPIC: boolean;
  101163. ANISOTROPIC_TEXTURE: boolean;
  101164. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101165. MAINUV1: boolean;
  101166. _areTexturesDirty: boolean;
  101167. _needUVs: boolean;
  101168. }
  101169. /**
  101170. * Define the code related to the anisotropic parameters of the pbr material.
  101171. */
  101172. export class PBRAnisotropicConfiguration {
  101173. private _isEnabled;
  101174. /**
  101175. * Defines if the anisotropy is enabled in the material.
  101176. */
  101177. isEnabled: boolean;
  101178. /**
  101179. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101180. */
  101181. intensity: number;
  101182. /**
  101183. * Defines if the effect is along the tangents, bitangents or in between.
  101184. * By default, the effect is "strectching" the highlights along the tangents.
  101185. */
  101186. direction: Vector2;
  101187. private _texture;
  101188. /**
  101189. * Stores the anisotropy values in a texture.
  101190. * rg is direction (like normal from -1 to 1)
  101191. * b is a intensity
  101192. */
  101193. texture: Nullable<BaseTexture>;
  101194. /** @hidden */
  101195. private _internalMarkAllSubMeshesAsTexturesDirty;
  101196. /** @hidden */
  101197. _markAllSubMeshesAsTexturesDirty(): void;
  101198. /**
  101199. * Instantiate a new istance of anisotropy configuration.
  101200. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101201. */
  101202. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101203. /**
  101204. * Specifies that the submesh is ready to be used.
  101205. * @param defines the list of "defines" to update.
  101206. * @param scene defines the scene the material belongs to.
  101207. * @returns - boolean indicating that the submesh is ready or not.
  101208. */
  101209. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101210. /**
  101211. * Checks to see if a texture is used in the material.
  101212. * @param defines the list of "defines" to update.
  101213. * @param mesh the mesh we are preparing the defines for.
  101214. * @param scene defines the scene the material belongs to.
  101215. */
  101216. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101217. /**
  101218. * Binds the material data.
  101219. * @param uniformBuffer defines the Uniform buffer to fill in.
  101220. * @param scene defines the scene the material belongs to.
  101221. * @param isFrozen defines wether the material is frozen or not.
  101222. */
  101223. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101224. /**
  101225. * Checks to see if a texture is used in the material.
  101226. * @param texture - Base texture to use.
  101227. * @returns - Boolean specifying if a texture is used in the material.
  101228. */
  101229. hasTexture(texture: BaseTexture): boolean;
  101230. /**
  101231. * Returns an array of the actively used textures.
  101232. * @param activeTextures Array of BaseTextures
  101233. */
  101234. getActiveTextures(activeTextures: BaseTexture[]): void;
  101235. /**
  101236. * Returns the animatable textures.
  101237. * @param animatables Array of animatable textures.
  101238. */
  101239. getAnimatables(animatables: IAnimatable[]): void;
  101240. /**
  101241. * Disposes the resources of the material.
  101242. * @param forceDisposeTextures - Forces the disposal of all textures.
  101243. */
  101244. dispose(forceDisposeTextures?: boolean): void;
  101245. /**
  101246. * Get the current class name of the texture useful for serialization or dynamic coding.
  101247. * @returns "PBRAnisotropicConfiguration"
  101248. */
  101249. getClassName(): string;
  101250. /**
  101251. * Add fallbacks to the effect fallbacks list.
  101252. * @param defines defines the Base texture to use.
  101253. * @param fallbacks defines the current fallback list.
  101254. * @param currentRank defines the current fallback rank.
  101255. * @returns the new fallback rank.
  101256. */
  101257. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101258. /**
  101259. * Add the required uniforms to the current list.
  101260. * @param uniforms defines the current uniform list.
  101261. */
  101262. static AddUniforms(uniforms: string[]): void;
  101263. /**
  101264. * Add the required uniforms to the current buffer.
  101265. * @param uniformBuffer defines the current uniform buffer.
  101266. */
  101267. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101268. /**
  101269. * Add the required samplers to the current list.
  101270. * @param samplers defines the current sampler list.
  101271. */
  101272. static AddSamplers(samplers: string[]): void;
  101273. /**
  101274. * Makes a duplicate of the current configuration into another one.
  101275. * @param anisotropicConfiguration define the config where to copy the info
  101276. */
  101277. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101278. /**
  101279. * Serializes this anisotropy configuration.
  101280. * @returns - An object with the serialized config.
  101281. */
  101282. serialize(): any;
  101283. /**
  101284. * Parses a anisotropy Configuration from a serialized object.
  101285. * @param source - Serialized object.
  101286. * @param scene Defines the scene we are parsing for
  101287. * @param rootUrl Defines the rootUrl to load from
  101288. */
  101289. parse(source: any, scene: Scene, rootUrl: string): void;
  101290. }
  101291. }
  101292. declare module BABYLON {
  101293. /**
  101294. * @hidden
  101295. */
  101296. export interface IMaterialBRDFDefines {
  101297. BRDF_V_HEIGHT_CORRELATED: boolean;
  101298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101299. SPHERICAL_HARMONICS: boolean;
  101300. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101301. /** @hidden */
  101302. _areMiscDirty: boolean;
  101303. }
  101304. /**
  101305. * Define the code related to the BRDF parameters of the pbr material.
  101306. */
  101307. export class PBRBRDFConfiguration {
  101308. /**
  101309. * Default value used for the energy conservation.
  101310. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101311. */
  101312. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101313. /**
  101314. * Default value used for the Smith Visibility Height Correlated mode.
  101315. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101316. */
  101317. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101318. /**
  101319. * Default value used for the IBL diffuse part.
  101320. * This can help switching back to the polynomials mode globally which is a tiny bit
  101321. * less GPU intensive at the drawback of a lower quality.
  101322. */
  101323. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101324. /**
  101325. * Default value used for activating energy conservation for the specular workflow.
  101326. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101327. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101328. */
  101329. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101330. private _useEnergyConservation;
  101331. /**
  101332. * Defines if the material uses energy conservation.
  101333. */
  101334. useEnergyConservation: boolean;
  101335. private _useSmithVisibilityHeightCorrelated;
  101336. /**
  101337. * LEGACY Mode set to false
  101338. * Defines if the material uses height smith correlated visibility term.
  101339. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101340. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101341. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101342. * Not relying on height correlated will also disable energy conservation.
  101343. */
  101344. useSmithVisibilityHeightCorrelated: boolean;
  101345. private _useSphericalHarmonics;
  101346. /**
  101347. * LEGACY Mode set to false
  101348. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101349. * diffuse part of the IBL.
  101350. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101351. * to the ground truth.
  101352. */
  101353. useSphericalHarmonics: boolean;
  101354. private _useSpecularGlossinessInputEnergyConservation;
  101355. /**
  101356. * Defines if the material uses energy conservation, when the specular workflow is active.
  101357. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101358. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101359. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101360. */
  101361. useSpecularGlossinessInputEnergyConservation: boolean;
  101362. /** @hidden */
  101363. private _internalMarkAllSubMeshesAsMiscDirty;
  101364. /** @hidden */
  101365. _markAllSubMeshesAsMiscDirty(): void;
  101366. /**
  101367. * Instantiate a new istance of clear coat configuration.
  101368. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101369. */
  101370. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101371. /**
  101372. * Checks to see if a texture is used in the material.
  101373. * @param defines the list of "defines" to update.
  101374. */
  101375. prepareDefines(defines: IMaterialBRDFDefines): void;
  101376. /**
  101377. * Get the current class name of the texture useful for serialization or dynamic coding.
  101378. * @returns "PBRClearCoatConfiguration"
  101379. */
  101380. getClassName(): string;
  101381. /**
  101382. * Makes a duplicate of the current configuration into another one.
  101383. * @param brdfConfiguration define the config where to copy the info
  101384. */
  101385. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101386. /**
  101387. * Serializes this BRDF configuration.
  101388. * @returns - An object with the serialized config.
  101389. */
  101390. serialize(): any;
  101391. /**
  101392. * Parses a anisotropy Configuration from a serialized object.
  101393. * @param source - Serialized object.
  101394. * @param scene Defines the scene we are parsing for
  101395. * @param rootUrl Defines the rootUrl to load from
  101396. */
  101397. parse(source: any, scene: Scene, rootUrl: string): void;
  101398. }
  101399. }
  101400. declare module BABYLON {
  101401. /**
  101402. * @hidden
  101403. */
  101404. export interface IMaterialSheenDefines {
  101405. SHEEN: boolean;
  101406. SHEEN_TEXTURE: boolean;
  101407. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101408. SHEEN_TEXTUREDIRECTUV: number;
  101409. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101410. SHEEN_LINKWITHALBEDO: boolean;
  101411. SHEEN_ROUGHNESS: boolean;
  101412. SHEEN_ALBEDOSCALING: boolean;
  101413. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101414. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101415. /** @hidden */
  101416. _areTexturesDirty: boolean;
  101417. }
  101418. /**
  101419. * Define the code related to the Sheen parameters of the pbr material.
  101420. */
  101421. export class PBRSheenConfiguration {
  101422. private _isEnabled;
  101423. /**
  101424. * Defines if the material uses sheen.
  101425. */
  101426. isEnabled: boolean;
  101427. private _linkSheenWithAlbedo;
  101428. /**
  101429. * Defines if the sheen is linked to the sheen color.
  101430. */
  101431. linkSheenWithAlbedo: boolean;
  101432. /**
  101433. * Defines the sheen intensity.
  101434. */
  101435. intensity: number;
  101436. /**
  101437. * Defines the sheen color.
  101438. */
  101439. color: Color3;
  101440. private _texture;
  101441. /**
  101442. * Stores the sheen tint values in a texture.
  101443. * rgb is tint
  101444. * 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)
  101445. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101446. */
  101447. texture: Nullable<BaseTexture>;
  101448. private _useRoughnessFromMainTexture;
  101449. /**
  101450. * Indicates that the alpha channel of the texture property will be used for roughness.
  101451. * Has no effect if the roughness (and texture!) property is not defined
  101452. */
  101453. useRoughnessFromMainTexture: boolean;
  101454. private _roughness;
  101455. /**
  101456. * Defines the sheen roughness.
  101457. * It is not taken into account if linkSheenWithAlbedo is true.
  101458. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101459. */
  101460. roughness: Nullable<number>;
  101461. private _textureRoughness;
  101462. /**
  101463. * Stores the sheen roughness in a texture.
  101464. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101465. */
  101466. textureRoughness: Nullable<BaseTexture>;
  101467. private _albedoScaling;
  101468. /**
  101469. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101470. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101471. * making it easier to setup and tweak the effect
  101472. */
  101473. albedoScaling: boolean;
  101474. /** @hidden */
  101475. private _internalMarkAllSubMeshesAsTexturesDirty;
  101476. /** @hidden */
  101477. _markAllSubMeshesAsTexturesDirty(): void;
  101478. /**
  101479. * Instantiate a new istance of clear coat configuration.
  101480. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101481. */
  101482. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101483. /**
  101484. * Specifies that the submesh is ready to be used.
  101485. * @param defines the list of "defines" to update.
  101486. * @param scene defines the scene the material belongs to.
  101487. * @returns - boolean indicating that the submesh is ready or not.
  101488. */
  101489. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101490. /**
  101491. * Checks to see if a texture is used in the material.
  101492. * @param defines the list of "defines" to update.
  101493. * @param scene defines the scene the material belongs to.
  101494. */
  101495. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101496. /**
  101497. * Binds the material data.
  101498. * @param uniformBuffer defines the Uniform buffer to fill in.
  101499. * @param scene defines the scene the material belongs to.
  101500. * @param isFrozen defines wether the material is frozen or not.
  101501. * @param subMesh the submesh to bind data for
  101502. */
  101503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101504. /**
  101505. * Checks to see if a texture is used in the material.
  101506. * @param texture - Base texture to use.
  101507. * @returns - Boolean specifying if a texture is used in the material.
  101508. */
  101509. hasTexture(texture: BaseTexture): boolean;
  101510. /**
  101511. * Returns an array of the actively used textures.
  101512. * @param activeTextures Array of BaseTextures
  101513. */
  101514. getActiveTextures(activeTextures: BaseTexture[]): void;
  101515. /**
  101516. * Returns the animatable textures.
  101517. * @param animatables Array of animatable textures.
  101518. */
  101519. getAnimatables(animatables: IAnimatable[]): void;
  101520. /**
  101521. * Disposes the resources of the material.
  101522. * @param forceDisposeTextures - Forces the disposal of all textures.
  101523. */
  101524. dispose(forceDisposeTextures?: boolean): void;
  101525. /**
  101526. * Get the current class name of the texture useful for serialization or dynamic coding.
  101527. * @returns "PBRSheenConfiguration"
  101528. */
  101529. getClassName(): string;
  101530. /**
  101531. * Add fallbacks to the effect fallbacks list.
  101532. * @param defines defines the Base texture to use.
  101533. * @param fallbacks defines the current fallback list.
  101534. * @param currentRank defines the current fallback rank.
  101535. * @returns the new fallback rank.
  101536. */
  101537. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101538. /**
  101539. * Add the required uniforms to the current list.
  101540. * @param uniforms defines the current uniform list.
  101541. */
  101542. static AddUniforms(uniforms: string[]): void;
  101543. /**
  101544. * Add the required uniforms to the current buffer.
  101545. * @param uniformBuffer defines the current uniform buffer.
  101546. */
  101547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101548. /**
  101549. * Add the required samplers to the current list.
  101550. * @param samplers defines the current sampler list.
  101551. */
  101552. static AddSamplers(samplers: string[]): void;
  101553. /**
  101554. * Makes a duplicate of the current configuration into another one.
  101555. * @param sheenConfiguration define the config where to copy the info
  101556. */
  101557. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101558. /**
  101559. * Serializes this BRDF configuration.
  101560. * @returns - An object with the serialized config.
  101561. */
  101562. serialize(): any;
  101563. /**
  101564. * Parses a anisotropy Configuration from a serialized object.
  101565. * @param source - Serialized object.
  101566. * @param scene Defines the scene we are parsing for
  101567. * @param rootUrl Defines the rootUrl to load from
  101568. */
  101569. parse(source: any, scene: Scene, rootUrl: string): void;
  101570. }
  101571. }
  101572. declare module BABYLON {
  101573. /**
  101574. * @hidden
  101575. */
  101576. export interface IMaterialSubSurfaceDefines {
  101577. SUBSURFACE: boolean;
  101578. SS_REFRACTION: boolean;
  101579. SS_TRANSLUCENCY: boolean;
  101580. SS_SCATTERING: boolean;
  101581. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101582. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101583. SS_REFRACTIONMAP_3D: boolean;
  101584. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101585. SS_LODINREFRACTIONALPHA: boolean;
  101586. SS_GAMMAREFRACTION: boolean;
  101587. SS_RGBDREFRACTION: boolean;
  101588. SS_LINEARSPECULARREFRACTION: boolean;
  101589. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101590. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101591. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101592. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  101593. /** @hidden */
  101594. _areTexturesDirty: boolean;
  101595. }
  101596. /**
  101597. * Define the code related to the sub surface parameters of the pbr material.
  101598. */
  101599. export class PBRSubSurfaceConfiguration {
  101600. private _isRefractionEnabled;
  101601. /**
  101602. * Defines if the refraction is enabled in the material.
  101603. */
  101604. isRefractionEnabled: boolean;
  101605. private _isTranslucencyEnabled;
  101606. /**
  101607. * Defines if the translucency is enabled in the material.
  101608. */
  101609. isTranslucencyEnabled: boolean;
  101610. private _isScatteringEnabled;
  101611. /**
  101612. * Defines if the sub surface scattering is enabled in the material.
  101613. */
  101614. isScatteringEnabled: boolean;
  101615. private _scatteringDiffusionProfileIndex;
  101616. /**
  101617. * Diffusion profile for subsurface scattering.
  101618. * Useful for better scattering in the skins or foliages.
  101619. */
  101620. get scatteringDiffusionProfile(): Nullable<Color3>;
  101621. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101622. /**
  101623. * Defines the refraction intensity of the material.
  101624. * The refraction when enabled replaces the Diffuse part of the material.
  101625. * The intensity helps transitionning between diffuse and refraction.
  101626. */
  101627. refractionIntensity: number;
  101628. /**
  101629. * Defines the translucency intensity of the material.
  101630. * When translucency has been enabled, this defines how much of the "translucency"
  101631. * is addded to the diffuse part of the material.
  101632. */
  101633. translucencyIntensity: number;
  101634. /**
  101635. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101636. */
  101637. useAlbedoToTintRefraction: boolean;
  101638. private _thicknessTexture;
  101639. /**
  101640. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101641. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101642. * 0 would mean minimumThickness
  101643. * 1 would mean maximumThickness
  101644. * The other channels might be use as a mask to vary the different effects intensity.
  101645. */
  101646. thicknessTexture: Nullable<BaseTexture>;
  101647. private _refractionTexture;
  101648. /**
  101649. * Defines the texture to use for refraction.
  101650. */
  101651. refractionTexture: Nullable<BaseTexture>;
  101652. private _indexOfRefraction;
  101653. /**
  101654. * Index of refraction of the material base layer.
  101655. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101656. *
  101657. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101658. *
  101659. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101660. */
  101661. indexOfRefraction: number;
  101662. private _volumeIndexOfRefraction;
  101663. /**
  101664. * Index of refraction of the material's volume.
  101665. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101666. *
  101667. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101668. * the volume will use the same IOR as the surface.
  101669. */
  101670. get volumeIndexOfRefraction(): number;
  101671. set volumeIndexOfRefraction(value: number);
  101672. private _invertRefractionY;
  101673. /**
  101674. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101675. */
  101676. invertRefractionY: boolean;
  101677. private _linkRefractionWithTransparency;
  101678. /**
  101679. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101680. * Materials half opaque for instance using refraction could benefit from this control.
  101681. */
  101682. linkRefractionWithTransparency: boolean;
  101683. /**
  101684. * Defines the minimum thickness stored in the thickness map.
  101685. * If no thickness map is defined, this value will be used to simulate thickness.
  101686. */
  101687. minimumThickness: number;
  101688. /**
  101689. * Defines the maximum thickness stored in the thickness map.
  101690. */
  101691. maximumThickness: number;
  101692. /**
  101693. * Defines the volume tint of the material.
  101694. * This is used for both translucency and scattering.
  101695. */
  101696. tintColor: Color3;
  101697. /**
  101698. * Defines the distance at which the tint color should be found in the media.
  101699. * This is used for refraction only.
  101700. */
  101701. tintColorAtDistance: number;
  101702. /**
  101703. * Defines how far each channel transmit through the media.
  101704. * It is defined as a color to simplify it selection.
  101705. */
  101706. diffusionDistance: Color3;
  101707. private _useMaskFromThicknessTexture;
  101708. /**
  101709. * Stores the intensity of the different subsurface effects in the thickness texture.
  101710. * * the green channel is the translucency intensity.
  101711. * * the blue channel is the scattering intensity.
  101712. * * the alpha channel is the refraction intensity.
  101713. */
  101714. useMaskFromThicknessTexture: boolean;
  101715. private _scene;
  101716. private _useMaskFromThicknessTextureGltf;
  101717. /**
  101718. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  101719. * matches the channel-packing that is used by glTF.
  101720. * * the red channel is the transmission/translucency intensity.
  101721. * * the green channel is the thickness.
  101722. */
  101723. useMaskFromThicknessTextureGltf: boolean;
  101724. /** @hidden */
  101725. private _internalMarkAllSubMeshesAsTexturesDirty;
  101726. private _internalMarkScenePrePassDirty;
  101727. /** @hidden */
  101728. _markAllSubMeshesAsTexturesDirty(): void;
  101729. /** @hidden */
  101730. _markScenePrePassDirty(): void;
  101731. /**
  101732. * Instantiate a new istance of sub surface configuration.
  101733. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101734. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101735. * @param scene The scene
  101736. */
  101737. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101738. /**
  101739. * Gets wehter the submesh is ready to be used or not.
  101740. * @param defines the list of "defines" to update.
  101741. * @param scene defines the scene the material belongs to.
  101742. * @returns - boolean indicating that the submesh is ready or not.
  101743. */
  101744. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101745. /**
  101746. * Checks to see if a texture is used in the material.
  101747. * @param defines the list of "defines" to update.
  101748. * @param scene defines the scene to the material belongs to.
  101749. */
  101750. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101751. /**
  101752. * Binds the material data.
  101753. * @param uniformBuffer defines the Uniform buffer to fill in.
  101754. * @param scene defines the scene the material belongs to.
  101755. * @param engine defines the engine the material belongs to.
  101756. * @param isFrozen defines whether the material is frozen or not.
  101757. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101758. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101759. */
  101760. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101761. /**
  101762. * Unbinds the material from the mesh.
  101763. * @param activeEffect defines the effect that should be unbound from.
  101764. * @returns true if unbound, otherwise false
  101765. */
  101766. unbind(activeEffect: Effect): boolean;
  101767. /**
  101768. * Returns the texture used for refraction or null if none is used.
  101769. * @param scene defines the scene the material belongs to.
  101770. * @returns - Refraction texture if present. If no refraction texture and refraction
  101771. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101772. */
  101773. private _getRefractionTexture;
  101774. /**
  101775. * Returns true if alpha blending should be disabled.
  101776. */
  101777. get disableAlphaBlending(): boolean;
  101778. /**
  101779. * Fills the list of render target textures.
  101780. * @param renderTargets the list of render targets to update
  101781. */
  101782. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101783. /**
  101784. * Checks to see if a texture is used in the material.
  101785. * @param texture - Base texture to use.
  101786. * @returns - Boolean specifying if a texture is used in the material.
  101787. */
  101788. hasTexture(texture: BaseTexture): boolean;
  101789. /**
  101790. * Gets a boolean indicating that current material needs to register RTT
  101791. * @returns true if this uses a render target otherwise false.
  101792. */
  101793. hasRenderTargetTextures(): boolean;
  101794. /**
  101795. * Returns an array of the actively used textures.
  101796. * @param activeTextures Array of BaseTextures
  101797. */
  101798. getActiveTextures(activeTextures: BaseTexture[]): void;
  101799. /**
  101800. * Returns the animatable textures.
  101801. * @param animatables Array of animatable textures.
  101802. */
  101803. getAnimatables(animatables: IAnimatable[]): void;
  101804. /**
  101805. * Disposes the resources of the material.
  101806. * @param forceDisposeTextures - Forces the disposal of all textures.
  101807. */
  101808. dispose(forceDisposeTextures?: boolean): void;
  101809. /**
  101810. * Get the current class name of the texture useful for serialization or dynamic coding.
  101811. * @returns "PBRSubSurfaceConfiguration"
  101812. */
  101813. getClassName(): string;
  101814. /**
  101815. * Add fallbacks to the effect fallbacks list.
  101816. * @param defines defines the Base texture to use.
  101817. * @param fallbacks defines the current fallback list.
  101818. * @param currentRank defines the current fallback rank.
  101819. * @returns the new fallback rank.
  101820. */
  101821. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101822. /**
  101823. * Add the required uniforms to the current list.
  101824. * @param uniforms defines the current uniform list.
  101825. */
  101826. static AddUniforms(uniforms: string[]): void;
  101827. /**
  101828. * Add the required samplers to the current list.
  101829. * @param samplers defines the current sampler list.
  101830. */
  101831. static AddSamplers(samplers: string[]): void;
  101832. /**
  101833. * Add the required uniforms to the current buffer.
  101834. * @param uniformBuffer defines the current uniform buffer.
  101835. */
  101836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101837. /**
  101838. * Makes a duplicate of the current configuration into another one.
  101839. * @param configuration define the config where to copy the info
  101840. */
  101841. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101842. /**
  101843. * Serializes this Sub Surface configuration.
  101844. * @returns - An object with the serialized config.
  101845. */
  101846. serialize(): any;
  101847. /**
  101848. * Parses a anisotropy Configuration from a serialized object.
  101849. * @param source - Serialized object.
  101850. * @param scene Defines the scene we are parsing for
  101851. * @param rootUrl Defines the rootUrl to load from
  101852. */
  101853. parse(source: any, scene: Scene, rootUrl: string): void;
  101854. }
  101855. }
  101856. declare module BABYLON {
  101857. /**
  101858. * Class representing spherical harmonics coefficients to the 3rd degree
  101859. */
  101860. export class SphericalHarmonics {
  101861. /**
  101862. * Defines whether or not the harmonics have been prescaled for rendering.
  101863. */
  101864. preScaled: boolean;
  101865. /**
  101866. * The l0,0 coefficients of the spherical harmonics
  101867. */
  101868. l00: Vector3;
  101869. /**
  101870. * The l1,-1 coefficients of the spherical harmonics
  101871. */
  101872. l1_1: Vector3;
  101873. /**
  101874. * The l1,0 coefficients of the spherical harmonics
  101875. */
  101876. l10: Vector3;
  101877. /**
  101878. * The l1,1 coefficients of the spherical harmonics
  101879. */
  101880. l11: Vector3;
  101881. /**
  101882. * The l2,-2 coefficients of the spherical harmonics
  101883. */
  101884. l2_2: Vector3;
  101885. /**
  101886. * The l2,-1 coefficients of the spherical harmonics
  101887. */
  101888. l2_1: Vector3;
  101889. /**
  101890. * The l2,0 coefficients of the spherical harmonics
  101891. */
  101892. l20: Vector3;
  101893. /**
  101894. * The l2,1 coefficients of the spherical harmonics
  101895. */
  101896. l21: Vector3;
  101897. /**
  101898. * The l2,2 coefficients of the spherical harmonics
  101899. */
  101900. l22: Vector3;
  101901. /**
  101902. * Adds a light to the spherical harmonics
  101903. * @param direction the direction of the light
  101904. * @param color the color of the light
  101905. * @param deltaSolidAngle the delta solid angle of the light
  101906. */
  101907. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101908. /**
  101909. * Scales the spherical harmonics by the given amount
  101910. * @param scale the amount to scale
  101911. */
  101912. scaleInPlace(scale: number): void;
  101913. /**
  101914. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101915. *
  101916. * ```
  101917. * E_lm = A_l * L_lm
  101918. * ```
  101919. *
  101920. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101921. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101922. * the scaling factors are given in equation 9.
  101923. */
  101924. convertIncidentRadianceToIrradiance(): void;
  101925. /**
  101926. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101927. *
  101928. * ```
  101929. * L = (1/pi) * E * rho
  101930. * ```
  101931. *
  101932. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101933. */
  101934. convertIrradianceToLambertianRadiance(): void;
  101935. /**
  101936. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101937. * required operations at run time.
  101938. *
  101939. * This is simply done by scaling back the SH with Ylm constants parameter.
  101940. * The trigonometric part being applied by the shader at run time.
  101941. */
  101942. preScaleForRendering(): void;
  101943. /**
  101944. * Constructs a spherical harmonics from an array.
  101945. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101946. * @returns the spherical harmonics
  101947. */
  101948. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101949. /**
  101950. * Gets the spherical harmonics from polynomial
  101951. * @param polynomial the spherical polynomial
  101952. * @returns the spherical harmonics
  101953. */
  101954. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101955. }
  101956. /**
  101957. * Class representing spherical polynomial coefficients to the 3rd degree
  101958. */
  101959. export class SphericalPolynomial {
  101960. private _harmonics;
  101961. /**
  101962. * The spherical harmonics used to create the polynomials.
  101963. */
  101964. get preScaledHarmonics(): SphericalHarmonics;
  101965. /**
  101966. * The x coefficients of the spherical polynomial
  101967. */
  101968. x: Vector3;
  101969. /**
  101970. * The y coefficients of the spherical polynomial
  101971. */
  101972. y: Vector3;
  101973. /**
  101974. * The z coefficients of the spherical polynomial
  101975. */
  101976. z: Vector3;
  101977. /**
  101978. * The xx coefficients of the spherical polynomial
  101979. */
  101980. xx: Vector3;
  101981. /**
  101982. * The yy coefficients of the spherical polynomial
  101983. */
  101984. yy: Vector3;
  101985. /**
  101986. * The zz coefficients of the spherical polynomial
  101987. */
  101988. zz: Vector3;
  101989. /**
  101990. * The xy coefficients of the spherical polynomial
  101991. */
  101992. xy: Vector3;
  101993. /**
  101994. * The yz coefficients of the spherical polynomial
  101995. */
  101996. yz: Vector3;
  101997. /**
  101998. * The zx coefficients of the spherical polynomial
  101999. */
  102000. zx: Vector3;
  102001. /**
  102002. * Adds an ambient color to the spherical polynomial
  102003. * @param color the color to add
  102004. */
  102005. addAmbient(color: Color3): void;
  102006. /**
  102007. * Scales the spherical polynomial by the given amount
  102008. * @param scale the amount to scale
  102009. */
  102010. scaleInPlace(scale: number): void;
  102011. /**
  102012. * Gets the spherical polynomial from harmonics
  102013. * @param harmonics the spherical harmonics
  102014. * @returns the spherical polynomial
  102015. */
  102016. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102017. /**
  102018. * Constructs a spherical polynomial from an array.
  102019. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102020. * @returns the spherical polynomial
  102021. */
  102022. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102023. }
  102024. }
  102025. declare module BABYLON {
  102026. /**
  102027. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  102028. */
  102029. export interface CubeMapInfo {
  102030. /**
  102031. * The pixel array for the front face.
  102032. * This is stored in format, left to right, up to down format.
  102033. */
  102034. front: Nullable<ArrayBufferView>;
  102035. /**
  102036. * The pixel array for the back face.
  102037. * This is stored in format, left to right, up to down format.
  102038. */
  102039. back: Nullable<ArrayBufferView>;
  102040. /**
  102041. * The pixel array for the left face.
  102042. * This is stored in format, left to right, up to down format.
  102043. */
  102044. left: Nullable<ArrayBufferView>;
  102045. /**
  102046. * The pixel array for the right face.
  102047. * This is stored in format, left to right, up to down format.
  102048. */
  102049. right: Nullable<ArrayBufferView>;
  102050. /**
  102051. * The pixel array for the up face.
  102052. * This is stored in format, left to right, up to down format.
  102053. */
  102054. up: Nullable<ArrayBufferView>;
  102055. /**
  102056. * The pixel array for the down face.
  102057. * This is stored in format, left to right, up to down format.
  102058. */
  102059. down: Nullable<ArrayBufferView>;
  102060. /**
  102061. * The size of the cubemap stored.
  102062. *
  102063. * Each faces will be size * size pixels.
  102064. */
  102065. size: number;
  102066. /**
  102067. * The format of the texture.
  102068. *
  102069. * RGBA, RGB.
  102070. */
  102071. format: number;
  102072. /**
  102073. * The type of the texture data.
  102074. *
  102075. * UNSIGNED_INT, FLOAT.
  102076. */
  102077. type: number;
  102078. /**
  102079. * Specifies whether the texture is in gamma space.
  102080. */
  102081. gammaSpace: boolean;
  102082. }
  102083. /**
  102084. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  102085. */
  102086. export class PanoramaToCubeMapTools {
  102087. private static FACE_LEFT;
  102088. private static FACE_RIGHT;
  102089. private static FACE_FRONT;
  102090. private static FACE_BACK;
  102091. private static FACE_DOWN;
  102092. private static FACE_UP;
  102093. /**
  102094. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  102095. *
  102096. * @param float32Array The source data.
  102097. * @param inputWidth The width of the input panorama.
  102098. * @param inputHeight The height of the input panorama.
  102099. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  102100. * @return The cubemap data
  102101. */
  102102. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  102103. private static CreateCubemapTexture;
  102104. private static CalcProjectionSpherical;
  102105. }
  102106. }
  102107. declare module BABYLON {
  102108. /**
  102109. * Helper class dealing with the extraction of spherical polynomial dataArray
  102110. * from a cube map.
  102111. */
  102112. export class CubeMapToSphericalPolynomialTools {
  102113. private static FileFaces;
  102114. /**
  102115. * Converts a texture to the according Spherical Polynomial data.
  102116. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102117. *
  102118. * @param texture The texture to extract the information from.
  102119. * @return The Spherical Polynomial data.
  102120. */
  102121. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  102122. /**
  102123. * Converts a cubemap to the according Spherical Polynomial data.
  102124. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102125. *
  102126. * @param cubeInfo The Cube map to extract the information from.
  102127. * @return The Spherical Polynomial data.
  102128. */
  102129. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  102130. }
  102131. }
  102132. declare module BABYLON {
  102133. interface BaseTexture {
  102134. /**
  102135. * Get the polynomial representation of the texture data.
  102136. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  102137. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  102138. */
  102139. sphericalPolynomial: Nullable<SphericalPolynomial>;
  102140. }
  102141. }
  102142. declare module BABYLON {
  102143. /** @hidden */
  102144. export var pbrFragmentDeclaration: {
  102145. name: string;
  102146. shader: string;
  102147. };
  102148. }
  102149. declare module BABYLON {
  102150. /** @hidden */
  102151. export var pbrUboDeclaration: {
  102152. name: string;
  102153. shader: string;
  102154. };
  102155. }
  102156. declare module BABYLON {
  102157. /** @hidden */
  102158. export var pbrFragmentExtraDeclaration: {
  102159. name: string;
  102160. shader: string;
  102161. };
  102162. }
  102163. declare module BABYLON {
  102164. /** @hidden */
  102165. export var pbrFragmentSamplersDeclaration: {
  102166. name: string;
  102167. shader: string;
  102168. };
  102169. }
  102170. declare module BABYLON {
  102171. /** @hidden */
  102172. export var subSurfaceScatteringFunctions: {
  102173. name: string;
  102174. shader: string;
  102175. };
  102176. }
  102177. declare module BABYLON {
  102178. /** @hidden */
  102179. export var importanceSampling: {
  102180. name: string;
  102181. shader: string;
  102182. };
  102183. }
  102184. declare module BABYLON {
  102185. /** @hidden */
  102186. export var pbrHelperFunctions: {
  102187. name: string;
  102188. shader: string;
  102189. };
  102190. }
  102191. declare module BABYLON {
  102192. /** @hidden */
  102193. export var harmonicsFunctions: {
  102194. name: string;
  102195. shader: string;
  102196. };
  102197. }
  102198. declare module BABYLON {
  102199. /** @hidden */
  102200. export var pbrDirectLightingSetupFunctions: {
  102201. name: string;
  102202. shader: string;
  102203. };
  102204. }
  102205. declare module BABYLON {
  102206. /** @hidden */
  102207. export var pbrDirectLightingFalloffFunctions: {
  102208. name: string;
  102209. shader: string;
  102210. };
  102211. }
  102212. declare module BABYLON {
  102213. /** @hidden */
  102214. export var pbrBRDFFunctions: {
  102215. name: string;
  102216. shader: string;
  102217. };
  102218. }
  102219. declare module BABYLON {
  102220. /** @hidden */
  102221. export var hdrFilteringFunctions: {
  102222. name: string;
  102223. shader: string;
  102224. };
  102225. }
  102226. declare module BABYLON {
  102227. /** @hidden */
  102228. export var pbrDirectLightingFunctions: {
  102229. name: string;
  102230. shader: string;
  102231. };
  102232. }
  102233. declare module BABYLON {
  102234. /** @hidden */
  102235. export var pbrIBLFunctions: {
  102236. name: string;
  102237. shader: string;
  102238. };
  102239. }
  102240. declare module BABYLON {
  102241. /** @hidden */
  102242. export var pbrBlockAlbedoOpacity: {
  102243. name: string;
  102244. shader: string;
  102245. };
  102246. }
  102247. declare module BABYLON {
  102248. /** @hidden */
  102249. export var pbrBlockReflectivity: {
  102250. name: string;
  102251. shader: string;
  102252. };
  102253. }
  102254. declare module BABYLON {
  102255. /** @hidden */
  102256. export var pbrBlockAmbientOcclusion: {
  102257. name: string;
  102258. shader: string;
  102259. };
  102260. }
  102261. declare module BABYLON {
  102262. /** @hidden */
  102263. export var pbrBlockAlphaFresnel: {
  102264. name: string;
  102265. shader: string;
  102266. };
  102267. }
  102268. declare module BABYLON {
  102269. /** @hidden */
  102270. export var pbrBlockAnisotropic: {
  102271. name: string;
  102272. shader: string;
  102273. };
  102274. }
  102275. declare module BABYLON {
  102276. /** @hidden */
  102277. export var pbrBlockReflection: {
  102278. name: string;
  102279. shader: string;
  102280. };
  102281. }
  102282. declare module BABYLON {
  102283. /** @hidden */
  102284. export var pbrBlockSheen: {
  102285. name: string;
  102286. shader: string;
  102287. };
  102288. }
  102289. declare module BABYLON {
  102290. /** @hidden */
  102291. export var pbrBlockClearcoat: {
  102292. name: string;
  102293. shader: string;
  102294. };
  102295. }
  102296. declare module BABYLON {
  102297. /** @hidden */
  102298. export var pbrBlockSubSurface: {
  102299. name: string;
  102300. shader: string;
  102301. };
  102302. }
  102303. declare module BABYLON {
  102304. /** @hidden */
  102305. export var pbrBlockNormalGeometric: {
  102306. name: string;
  102307. shader: string;
  102308. };
  102309. }
  102310. declare module BABYLON {
  102311. /** @hidden */
  102312. export var pbrBlockNormalFinal: {
  102313. name: string;
  102314. shader: string;
  102315. };
  102316. }
  102317. declare module BABYLON {
  102318. /** @hidden */
  102319. export var pbrBlockLightmapInit: {
  102320. name: string;
  102321. shader: string;
  102322. };
  102323. }
  102324. declare module BABYLON {
  102325. /** @hidden */
  102326. export var pbrBlockGeometryInfo: {
  102327. name: string;
  102328. shader: string;
  102329. };
  102330. }
  102331. declare module BABYLON {
  102332. /** @hidden */
  102333. export var pbrBlockReflectance0: {
  102334. name: string;
  102335. shader: string;
  102336. };
  102337. }
  102338. declare module BABYLON {
  102339. /** @hidden */
  102340. export var pbrBlockReflectance: {
  102341. name: string;
  102342. shader: string;
  102343. };
  102344. }
  102345. declare module BABYLON {
  102346. /** @hidden */
  102347. export var pbrBlockDirectLighting: {
  102348. name: string;
  102349. shader: string;
  102350. };
  102351. }
  102352. declare module BABYLON {
  102353. /** @hidden */
  102354. export var pbrBlockFinalLitComponents: {
  102355. name: string;
  102356. shader: string;
  102357. };
  102358. }
  102359. declare module BABYLON {
  102360. /** @hidden */
  102361. export var pbrBlockFinalUnlitComponents: {
  102362. name: string;
  102363. shader: string;
  102364. };
  102365. }
  102366. declare module BABYLON {
  102367. /** @hidden */
  102368. export var pbrBlockFinalColorComposition: {
  102369. name: string;
  102370. shader: string;
  102371. };
  102372. }
  102373. declare module BABYLON {
  102374. /** @hidden */
  102375. export var pbrBlockImageProcessing: {
  102376. name: string;
  102377. shader: string;
  102378. };
  102379. }
  102380. declare module BABYLON {
  102381. /** @hidden */
  102382. export var pbrDebug: {
  102383. name: string;
  102384. shader: string;
  102385. };
  102386. }
  102387. declare module BABYLON {
  102388. /** @hidden */
  102389. export var pbrPixelShader: {
  102390. name: string;
  102391. shader: string;
  102392. };
  102393. }
  102394. declare module BABYLON {
  102395. /** @hidden */
  102396. export var pbrVertexDeclaration: {
  102397. name: string;
  102398. shader: string;
  102399. };
  102400. }
  102401. declare module BABYLON {
  102402. /** @hidden */
  102403. export var pbrVertexShader: {
  102404. name: string;
  102405. shader: string;
  102406. };
  102407. }
  102408. declare module BABYLON {
  102409. /**
  102410. * Manages the defines for the PBR Material.
  102411. * @hidden
  102412. */
  102413. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102414. PBR: boolean;
  102415. NUM_SAMPLES: string;
  102416. REALTIME_FILTERING: boolean;
  102417. MAINUV1: boolean;
  102418. MAINUV2: boolean;
  102419. UV1: boolean;
  102420. UV2: boolean;
  102421. ALBEDO: boolean;
  102422. GAMMAALBEDO: boolean;
  102423. ALBEDODIRECTUV: number;
  102424. VERTEXCOLOR: boolean;
  102425. DETAIL: boolean;
  102426. DETAILDIRECTUV: number;
  102427. DETAIL_NORMALBLENDMETHOD: number;
  102428. AMBIENT: boolean;
  102429. AMBIENTDIRECTUV: number;
  102430. AMBIENTINGRAYSCALE: boolean;
  102431. OPACITY: boolean;
  102432. VERTEXALPHA: boolean;
  102433. OPACITYDIRECTUV: number;
  102434. OPACITYRGB: boolean;
  102435. ALPHATEST: boolean;
  102436. DEPTHPREPASS: boolean;
  102437. ALPHABLEND: boolean;
  102438. ALPHAFROMALBEDO: boolean;
  102439. ALPHATESTVALUE: string;
  102440. SPECULAROVERALPHA: boolean;
  102441. RADIANCEOVERALPHA: boolean;
  102442. ALPHAFRESNEL: boolean;
  102443. LINEARALPHAFRESNEL: boolean;
  102444. PREMULTIPLYALPHA: boolean;
  102445. EMISSIVE: boolean;
  102446. EMISSIVEDIRECTUV: number;
  102447. REFLECTIVITY: boolean;
  102448. REFLECTIVITYDIRECTUV: number;
  102449. SPECULARTERM: boolean;
  102450. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102451. MICROSURFACEAUTOMATIC: boolean;
  102452. LODBASEDMICROSFURACE: boolean;
  102453. MICROSURFACEMAP: boolean;
  102454. MICROSURFACEMAPDIRECTUV: number;
  102455. METALLICWORKFLOW: boolean;
  102456. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102457. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102458. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102459. AOSTOREINMETALMAPRED: boolean;
  102460. METALLIC_REFLECTANCE: boolean;
  102461. METALLIC_REFLECTANCEDIRECTUV: number;
  102462. ENVIRONMENTBRDF: boolean;
  102463. ENVIRONMENTBRDF_RGBD: boolean;
  102464. NORMAL: boolean;
  102465. TANGENT: boolean;
  102466. BUMP: boolean;
  102467. BUMPDIRECTUV: number;
  102468. OBJECTSPACE_NORMALMAP: boolean;
  102469. PARALLAX: boolean;
  102470. PARALLAXOCCLUSION: boolean;
  102471. NORMALXYSCALE: boolean;
  102472. LIGHTMAP: boolean;
  102473. LIGHTMAPDIRECTUV: number;
  102474. USELIGHTMAPASSHADOWMAP: boolean;
  102475. GAMMALIGHTMAP: boolean;
  102476. RGBDLIGHTMAP: boolean;
  102477. REFLECTION: boolean;
  102478. REFLECTIONMAP_3D: boolean;
  102479. REFLECTIONMAP_SPHERICAL: boolean;
  102480. REFLECTIONMAP_PLANAR: boolean;
  102481. REFLECTIONMAP_CUBIC: boolean;
  102482. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102483. REFLECTIONMAP_PROJECTION: boolean;
  102484. REFLECTIONMAP_SKYBOX: boolean;
  102485. REFLECTIONMAP_EXPLICIT: boolean;
  102486. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102487. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102488. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102489. INVERTCUBICMAP: boolean;
  102490. USESPHERICALFROMREFLECTIONMAP: boolean;
  102491. USEIRRADIANCEMAP: boolean;
  102492. SPHERICAL_HARMONICS: boolean;
  102493. USESPHERICALINVERTEX: boolean;
  102494. REFLECTIONMAP_OPPOSITEZ: boolean;
  102495. LODINREFLECTIONALPHA: boolean;
  102496. GAMMAREFLECTION: boolean;
  102497. RGBDREFLECTION: boolean;
  102498. LINEARSPECULARREFLECTION: boolean;
  102499. RADIANCEOCCLUSION: boolean;
  102500. HORIZONOCCLUSION: boolean;
  102501. INSTANCES: boolean;
  102502. THIN_INSTANCES: boolean;
  102503. PREPASS: boolean;
  102504. PREPASS_IRRADIANCE: boolean;
  102505. PREPASS_IRRADIANCE_INDEX: number;
  102506. PREPASS_ALBEDO: boolean;
  102507. PREPASS_ALBEDO_INDEX: number;
  102508. PREPASS_DEPTHNORMAL: boolean;
  102509. PREPASS_DEPTHNORMAL_INDEX: number;
  102510. PREPASS_POSITION: boolean;
  102511. PREPASS_POSITION_INDEX: number;
  102512. PREPASS_VELOCITY: boolean;
  102513. PREPASS_VELOCITY_INDEX: number;
  102514. PREPASS_REFLECTIVITY: boolean;
  102515. PREPASS_REFLECTIVITY_INDEX: number;
  102516. SCENE_MRT_COUNT: number;
  102517. NUM_BONE_INFLUENCERS: number;
  102518. BonesPerMesh: number;
  102519. BONETEXTURE: boolean;
  102520. BONES_VELOCITY_ENABLED: boolean;
  102521. NONUNIFORMSCALING: boolean;
  102522. MORPHTARGETS: boolean;
  102523. MORPHTARGETS_NORMAL: boolean;
  102524. MORPHTARGETS_TANGENT: boolean;
  102525. MORPHTARGETS_UV: boolean;
  102526. NUM_MORPH_INFLUENCERS: number;
  102527. IMAGEPROCESSING: boolean;
  102528. VIGNETTE: boolean;
  102529. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102530. VIGNETTEBLENDMODEOPAQUE: boolean;
  102531. TONEMAPPING: boolean;
  102532. TONEMAPPING_ACES: boolean;
  102533. CONTRAST: boolean;
  102534. COLORCURVES: boolean;
  102535. COLORGRADING: boolean;
  102536. COLORGRADING3D: boolean;
  102537. SAMPLER3DGREENDEPTH: boolean;
  102538. SAMPLER3DBGRMAP: boolean;
  102539. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102540. EXPOSURE: boolean;
  102541. MULTIVIEW: boolean;
  102542. USEPHYSICALLIGHTFALLOFF: boolean;
  102543. USEGLTFLIGHTFALLOFF: boolean;
  102544. TWOSIDEDLIGHTING: boolean;
  102545. SHADOWFLOAT: boolean;
  102546. CLIPPLANE: boolean;
  102547. CLIPPLANE2: boolean;
  102548. CLIPPLANE3: boolean;
  102549. CLIPPLANE4: boolean;
  102550. CLIPPLANE5: boolean;
  102551. CLIPPLANE6: boolean;
  102552. POINTSIZE: boolean;
  102553. FOG: boolean;
  102554. LOGARITHMICDEPTH: boolean;
  102555. FORCENORMALFORWARD: boolean;
  102556. SPECULARAA: boolean;
  102557. CLEARCOAT: boolean;
  102558. CLEARCOAT_DEFAULTIOR: boolean;
  102559. CLEARCOAT_TEXTURE: boolean;
  102560. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102561. CLEARCOAT_TEXTUREDIRECTUV: number;
  102562. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102563. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102564. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102565. CLEARCOAT_BUMP: boolean;
  102566. CLEARCOAT_BUMPDIRECTUV: number;
  102567. CLEARCOAT_REMAP_F0: boolean;
  102568. CLEARCOAT_TINT: boolean;
  102569. CLEARCOAT_TINT_TEXTURE: boolean;
  102570. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102571. ANISOTROPIC: boolean;
  102572. ANISOTROPIC_TEXTURE: boolean;
  102573. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102574. BRDF_V_HEIGHT_CORRELATED: boolean;
  102575. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102576. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102577. SHEEN: boolean;
  102578. SHEEN_TEXTURE: boolean;
  102579. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102580. SHEEN_TEXTUREDIRECTUV: number;
  102581. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102582. SHEEN_LINKWITHALBEDO: boolean;
  102583. SHEEN_ROUGHNESS: boolean;
  102584. SHEEN_ALBEDOSCALING: boolean;
  102585. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102586. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102587. SUBSURFACE: boolean;
  102588. SS_REFRACTION: boolean;
  102589. SS_TRANSLUCENCY: boolean;
  102590. SS_SCATTERING: boolean;
  102591. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102592. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102593. SS_REFRACTIONMAP_3D: boolean;
  102594. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102595. SS_LODINREFRACTIONALPHA: boolean;
  102596. SS_GAMMAREFRACTION: boolean;
  102597. SS_RGBDREFRACTION: boolean;
  102598. SS_LINEARSPECULARREFRACTION: boolean;
  102599. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102600. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102601. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102602. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  102603. UNLIT: boolean;
  102604. DEBUGMODE: number;
  102605. /**
  102606. * Initializes the PBR Material defines.
  102607. */
  102608. constructor();
  102609. /**
  102610. * Resets the PBR Material defines.
  102611. */
  102612. reset(): void;
  102613. }
  102614. /**
  102615. * The Physically based material base class of BJS.
  102616. *
  102617. * This offers the main features of a standard PBR material.
  102618. * For more information, please refer to the documentation :
  102619. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102620. */
  102621. export abstract class PBRBaseMaterial extends PushMaterial {
  102622. /**
  102623. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102624. */
  102625. static readonly PBRMATERIAL_OPAQUE: number;
  102626. /**
  102627. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102628. */
  102629. static readonly PBRMATERIAL_ALPHATEST: number;
  102630. /**
  102631. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102632. */
  102633. static readonly PBRMATERIAL_ALPHABLEND: number;
  102634. /**
  102635. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102636. * They are also discarded below the alpha cutoff threshold to improve performances.
  102637. */
  102638. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102639. /**
  102640. * Defines the default value of how much AO map is occluding the analytical lights
  102641. * (point spot...).
  102642. */
  102643. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102644. /**
  102645. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102646. */
  102647. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102648. /**
  102649. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102650. * to enhance interoperability with other engines.
  102651. */
  102652. static readonly LIGHTFALLOFF_GLTF: number;
  102653. /**
  102654. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102655. * to enhance interoperability with other materials.
  102656. */
  102657. static readonly LIGHTFALLOFF_STANDARD: number;
  102658. /**
  102659. * Intensity of the direct lights e.g. the four lights available in your scene.
  102660. * This impacts both the direct diffuse and specular highlights.
  102661. */
  102662. protected _directIntensity: number;
  102663. /**
  102664. * Intensity of the emissive part of the material.
  102665. * This helps controlling the emissive effect without modifying the emissive color.
  102666. */
  102667. protected _emissiveIntensity: number;
  102668. /**
  102669. * Intensity of the environment e.g. how much the environment will light the object
  102670. * either through harmonics for rough material or through the refelction for shiny ones.
  102671. */
  102672. protected _environmentIntensity: number;
  102673. /**
  102674. * This is a special control allowing the reduction of the specular highlights coming from the
  102675. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102676. */
  102677. protected _specularIntensity: number;
  102678. /**
  102679. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102680. */
  102681. private _lightingInfos;
  102682. /**
  102683. * Debug Control allowing disabling the bump map on this material.
  102684. */
  102685. protected _disableBumpMap: boolean;
  102686. /**
  102687. * AKA Diffuse Texture in standard nomenclature.
  102688. */
  102689. protected _albedoTexture: Nullable<BaseTexture>;
  102690. /**
  102691. * AKA Occlusion Texture in other nomenclature.
  102692. */
  102693. protected _ambientTexture: Nullable<BaseTexture>;
  102694. /**
  102695. * AKA Occlusion Texture Intensity in other nomenclature.
  102696. */
  102697. protected _ambientTextureStrength: number;
  102698. /**
  102699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102700. * 1 means it completely occludes it
  102701. * 0 mean it has no impact
  102702. */
  102703. protected _ambientTextureImpactOnAnalyticalLights: number;
  102704. /**
  102705. * Stores the alpha values in a texture.
  102706. */
  102707. protected _opacityTexture: Nullable<BaseTexture>;
  102708. /**
  102709. * Stores the reflection values in a texture.
  102710. */
  102711. protected _reflectionTexture: Nullable<BaseTexture>;
  102712. /**
  102713. * Stores the emissive values in a texture.
  102714. */
  102715. protected _emissiveTexture: Nullable<BaseTexture>;
  102716. /**
  102717. * AKA Specular texture in other nomenclature.
  102718. */
  102719. protected _reflectivityTexture: Nullable<BaseTexture>;
  102720. /**
  102721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102722. */
  102723. protected _metallicTexture: Nullable<BaseTexture>;
  102724. /**
  102725. * Specifies the metallic scalar of the metallic/roughness workflow.
  102726. * Can also be used to scale the metalness values of the metallic texture.
  102727. */
  102728. protected _metallic: Nullable<number>;
  102729. /**
  102730. * Specifies the roughness scalar of the metallic/roughness workflow.
  102731. * Can also be used to scale the roughness values of the metallic texture.
  102732. */
  102733. protected _roughness: Nullable<number>;
  102734. /**
  102735. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102736. * By default the indexOfrefraction is used to compute F0;
  102737. *
  102738. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102739. *
  102740. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102741. * F90 = metallicReflectanceColor;
  102742. */
  102743. protected _metallicF0Factor: number;
  102744. /**
  102745. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102746. * By default the F90 is always 1;
  102747. *
  102748. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102749. *
  102750. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102751. * F90 = metallicReflectanceColor;
  102752. */
  102753. protected _metallicReflectanceColor: Color3;
  102754. /**
  102755. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102756. * This is multiply against the scalar values defined in the material.
  102757. */
  102758. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102759. /**
  102760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102762. */
  102763. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102764. /**
  102765. * Stores surface normal data used to displace a mesh in a texture.
  102766. */
  102767. protected _bumpTexture: Nullable<BaseTexture>;
  102768. /**
  102769. * Stores the pre-calculated light information of a mesh in a texture.
  102770. */
  102771. protected _lightmapTexture: Nullable<BaseTexture>;
  102772. /**
  102773. * The color of a material in ambient lighting.
  102774. */
  102775. protected _ambientColor: Color3;
  102776. /**
  102777. * AKA Diffuse Color in other nomenclature.
  102778. */
  102779. protected _albedoColor: Color3;
  102780. /**
  102781. * AKA Specular Color in other nomenclature.
  102782. */
  102783. protected _reflectivityColor: Color3;
  102784. /**
  102785. * The color applied when light is reflected from a material.
  102786. */
  102787. protected _reflectionColor: Color3;
  102788. /**
  102789. * The color applied when light is emitted from a material.
  102790. */
  102791. protected _emissiveColor: Color3;
  102792. /**
  102793. * AKA Glossiness in other nomenclature.
  102794. */
  102795. protected _microSurface: number;
  102796. /**
  102797. * Specifies that the material will use the light map as a show map.
  102798. */
  102799. protected _useLightmapAsShadowmap: boolean;
  102800. /**
  102801. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102802. * makes the reflect vector face the model (under horizon).
  102803. */
  102804. protected _useHorizonOcclusion: boolean;
  102805. /**
  102806. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102807. * too much the area relying on ambient texture to define their ambient occlusion.
  102808. */
  102809. protected _useRadianceOcclusion: boolean;
  102810. /**
  102811. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102812. */
  102813. protected _useAlphaFromAlbedoTexture: boolean;
  102814. /**
  102815. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102817. */
  102818. protected _useSpecularOverAlpha: boolean;
  102819. /**
  102820. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102821. */
  102822. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102823. /**
  102824. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102825. */
  102826. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102827. /**
  102828. * Specifies if the metallic texture contains the roughness information in its green channel.
  102829. */
  102830. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102831. /**
  102832. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102833. */
  102834. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102835. /**
  102836. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102837. */
  102838. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102839. /**
  102840. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102841. */
  102842. protected _useAmbientInGrayScale: boolean;
  102843. /**
  102844. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102845. * The material will try to infer what glossiness each pixel should be.
  102846. */
  102847. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102848. /**
  102849. * Defines the falloff type used in this material.
  102850. * It by default is Physical.
  102851. */
  102852. protected _lightFalloff: number;
  102853. /**
  102854. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102855. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102856. */
  102857. protected _useRadianceOverAlpha: boolean;
  102858. /**
  102859. * Allows using an object space normal map (instead of tangent space).
  102860. */
  102861. protected _useObjectSpaceNormalMap: boolean;
  102862. /**
  102863. * Allows using the bump map in parallax mode.
  102864. */
  102865. protected _useParallax: boolean;
  102866. /**
  102867. * Allows using the bump map in parallax occlusion mode.
  102868. */
  102869. protected _useParallaxOcclusion: boolean;
  102870. /**
  102871. * Controls the scale bias of the parallax mode.
  102872. */
  102873. protected _parallaxScaleBias: number;
  102874. /**
  102875. * If sets to true, disables all the lights affecting the material.
  102876. */
  102877. protected _disableLighting: boolean;
  102878. /**
  102879. * Number of Simultaneous lights allowed on the material.
  102880. */
  102881. protected _maxSimultaneousLights: number;
  102882. /**
  102883. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102884. */
  102885. protected _invertNormalMapX: boolean;
  102886. /**
  102887. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102888. */
  102889. protected _invertNormalMapY: boolean;
  102890. /**
  102891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102892. */
  102893. protected _twoSidedLighting: boolean;
  102894. /**
  102895. * Defines the alpha limits in alpha test mode.
  102896. */
  102897. protected _alphaCutOff: number;
  102898. /**
  102899. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102900. */
  102901. protected _forceAlphaTest: boolean;
  102902. /**
  102903. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102904. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102905. */
  102906. protected _useAlphaFresnel: boolean;
  102907. /**
  102908. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102909. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102910. */
  102911. protected _useLinearAlphaFresnel: boolean;
  102912. /**
  102913. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102914. * from cos thetav and roughness:
  102915. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102916. */
  102917. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102918. /**
  102919. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102920. */
  102921. protected _forceIrradianceInFragment: boolean;
  102922. private _realTimeFiltering;
  102923. /**
  102924. * Enables realtime filtering on the texture.
  102925. */
  102926. get realTimeFiltering(): boolean;
  102927. set realTimeFiltering(b: boolean);
  102928. private _realTimeFilteringQuality;
  102929. /**
  102930. * Quality switch for realtime filtering
  102931. */
  102932. get realTimeFilteringQuality(): number;
  102933. set realTimeFilteringQuality(n: number);
  102934. /**
  102935. * Can this material render to several textures at once
  102936. */
  102937. get canRenderToMRT(): boolean;
  102938. /**
  102939. * Force normal to face away from face.
  102940. */
  102941. protected _forceNormalForward: boolean;
  102942. /**
  102943. * Enables specular anti aliasing in the PBR shader.
  102944. * It will both interacts on the Geometry for analytical and IBL lighting.
  102945. * It also prefilter the roughness map based on the bump values.
  102946. */
  102947. protected _enableSpecularAntiAliasing: boolean;
  102948. /**
  102949. * Default configuration related to image processing available in the PBR Material.
  102950. */
  102951. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102952. /**
  102953. * Keep track of the image processing observer to allow dispose and replace.
  102954. */
  102955. private _imageProcessingObserver;
  102956. /**
  102957. * Attaches a new image processing configuration to the PBR Material.
  102958. * @param configuration
  102959. */
  102960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102961. /**
  102962. * Stores the available render targets.
  102963. */
  102964. private _renderTargets;
  102965. /**
  102966. * Sets the global ambient color for the material used in lighting calculations.
  102967. */
  102968. private _globalAmbientColor;
  102969. /**
  102970. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102971. */
  102972. private _useLogarithmicDepth;
  102973. /**
  102974. * If set to true, no lighting calculations will be applied.
  102975. */
  102976. private _unlit;
  102977. private _debugMode;
  102978. /**
  102979. * @hidden
  102980. * This is reserved for the inspector.
  102981. * Defines the material debug mode.
  102982. * It helps seeing only some components of the material while troubleshooting.
  102983. */
  102984. debugMode: number;
  102985. /**
  102986. * @hidden
  102987. * This is reserved for the inspector.
  102988. * Specify from where on screen the debug mode should start.
  102989. * The value goes from -1 (full screen) to 1 (not visible)
  102990. * It helps with side by side comparison against the final render
  102991. * This defaults to -1
  102992. */
  102993. private debugLimit;
  102994. /**
  102995. * @hidden
  102996. * This is reserved for the inspector.
  102997. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102998. * You can use the factor to better multiply the final value.
  102999. */
  103000. private debugFactor;
  103001. /**
  103002. * Defines the clear coat layer parameters for the material.
  103003. */
  103004. readonly clearCoat: PBRClearCoatConfiguration;
  103005. /**
  103006. * Defines the anisotropic parameters for the material.
  103007. */
  103008. readonly anisotropy: PBRAnisotropicConfiguration;
  103009. /**
  103010. * Defines the BRDF parameters for the material.
  103011. */
  103012. readonly brdf: PBRBRDFConfiguration;
  103013. /**
  103014. * Defines the Sheen parameters for the material.
  103015. */
  103016. readonly sheen: PBRSheenConfiguration;
  103017. /**
  103018. * Defines the SubSurface parameters for the material.
  103019. */
  103020. readonly subSurface: PBRSubSurfaceConfiguration;
  103021. /**
  103022. * Defines additionnal PrePass parameters for the material.
  103023. */
  103024. readonly prePassConfiguration: PrePassConfiguration;
  103025. /**
  103026. * Defines the detail map parameters for the material.
  103027. */
  103028. readonly detailMap: DetailMapConfiguration;
  103029. protected _rebuildInParallel: boolean;
  103030. /**
  103031. * Instantiates a new PBRMaterial instance.
  103032. *
  103033. * @param name The material name
  103034. * @param scene The scene the material will be use in.
  103035. */
  103036. constructor(name: string, scene: Scene);
  103037. /**
  103038. * Gets a boolean indicating that current material needs to register RTT
  103039. */
  103040. get hasRenderTargetTextures(): boolean;
  103041. /**
  103042. * Gets the name of the material class.
  103043. */
  103044. getClassName(): string;
  103045. /**
  103046. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103047. */
  103048. get useLogarithmicDepth(): boolean;
  103049. /**
  103050. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103051. */
  103052. set useLogarithmicDepth(value: boolean);
  103053. /**
  103054. * Returns true if alpha blending should be disabled.
  103055. */
  103056. protected get _disableAlphaBlending(): boolean;
  103057. /**
  103058. * Specifies whether or not this material should be rendered in alpha blend mode.
  103059. */
  103060. needAlphaBlending(): boolean;
  103061. /**
  103062. * Specifies whether or not this material should be rendered in alpha test mode.
  103063. */
  103064. needAlphaTesting(): boolean;
  103065. /**
  103066. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103067. */
  103068. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103069. /**
  103070. * Specifies whether or not there is a usable alpha channel for transparency.
  103071. */
  103072. protected _hasAlphaChannel(): boolean;
  103073. /**
  103074. * Gets the texture used for the alpha test.
  103075. */
  103076. getAlphaTestTexture(): Nullable<BaseTexture>;
  103077. /**
  103078. * Specifies that the submesh is ready to be used.
  103079. * @param mesh - BJS mesh.
  103080. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103081. * @param useInstances - Specifies that instances should be used.
  103082. * @returns - boolean indicating that the submesh is ready or not.
  103083. */
  103084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103085. /**
  103086. * Specifies if the material uses metallic roughness workflow.
  103087. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103088. */
  103089. isMetallicWorkflow(): boolean;
  103090. private _prepareEffect;
  103091. private _prepareDefines;
  103092. /**
  103093. * Force shader compilation
  103094. */
  103095. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  103096. /**
  103097. * Initializes the uniform buffer layout for the shader.
  103098. */
  103099. buildUniformLayout(): void;
  103100. /**
  103101. * Unbinds the material from the mesh
  103102. */
  103103. unbind(): void;
  103104. /**
  103105. * Binds the submesh data.
  103106. * @param world - The world matrix.
  103107. * @param mesh - The BJS mesh.
  103108. * @param subMesh - A submesh of the BJS mesh.
  103109. */
  103110. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103111. /**
  103112. * Returns the animatable textures.
  103113. * @returns - Array of animatable textures.
  103114. */
  103115. getAnimatables(): IAnimatable[];
  103116. /**
  103117. * Returns the texture used for reflections.
  103118. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103119. */
  103120. private _getReflectionTexture;
  103121. /**
  103122. * Returns an array of the actively used textures.
  103123. * @returns - Array of BaseTextures
  103124. */
  103125. getActiveTextures(): BaseTexture[];
  103126. /**
  103127. * Checks to see if a texture is used in the material.
  103128. * @param texture - Base texture to use.
  103129. * @returns - Boolean specifying if a texture is used in the material.
  103130. */
  103131. hasTexture(texture: BaseTexture): boolean;
  103132. /**
  103133. * Sets the required values to the prepass renderer.
  103134. * @param prePassRenderer defines the prepass renderer to setup
  103135. */
  103136. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103137. /**
  103138. * Disposes the resources of the material.
  103139. * @param forceDisposeEffect - Forces the disposal of effects.
  103140. * @param forceDisposeTextures - Forces the disposal of all textures.
  103141. */
  103142. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103143. }
  103144. }
  103145. declare module BABYLON {
  103146. /**
  103147. * The Physically based material of BJS.
  103148. *
  103149. * This offers the main features of a standard PBR material.
  103150. * For more information, please refer to the documentation :
  103151. * https://doc.babylonjs.com/how_to/physically_based_rendering
  103152. */
  103153. export class PBRMaterial extends PBRBaseMaterial {
  103154. /**
  103155. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103156. */
  103157. static readonly PBRMATERIAL_OPAQUE: number;
  103158. /**
  103159. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103160. */
  103161. static readonly PBRMATERIAL_ALPHATEST: number;
  103162. /**
  103163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103164. */
  103165. static readonly PBRMATERIAL_ALPHABLEND: number;
  103166. /**
  103167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103168. * They are also discarded below the alpha cutoff threshold to improve performances.
  103169. */
  103170. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103171. /**
  103172. * Defines the default value of how much AO map is occluding the analytical lights
  103173. * (point spot...).
  103174. */
  103175. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103176. /**
  103177. * Intensity of the direct lights e.g. the four lights available in your scene.
  103178. * This impacts both the direct diffuse and specular highlights.
  103179. */
  103180. directIntensity: number;
  103181. /**
  103182. * Intensity of the emissive part of the material.
  103183. * This helps controlling the emissive effect without modifying the emissive color.
  103184. */
  103185. emissiveIntensity: number;
  103186. /**
  103187. * Intensity of the environment e.g. how much the environment will light the object
  103188. * either through harmonics for rough material or through the refelction for shiny ones.
  103189. */
  103190. environmentIntensity: number;
  103191. /**
  103192. * This is a special control allowing the reduction of the specular highlights coming from the
  103193. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103194. */
  103195. specularIntensity: number;
  103196. /**
  103197. * Debug Control allowing disabling the bump map on this material.
  103198. */
  103199. disableBumpMap: boolean;
  103200. /**
  103201. * AKA Diffuse Texture in standard nomenclature.
  103202. */
  103203. albedoTexture: BaseTexture;
  103204. /**
  103205. * AKA Occlusion Texture in other nomenclature.
  103206. */
  103207. ambientTexture: BaseTexture;
  103208. /**
  103209. * AKA Occlusion Texture Intensity in other nomenclature.
  103210. */
  103211. ambientTextureStrength: number;
  103212. /**
  103213. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103214. * 1 means it completely occludes it
  103215. * 0 mean it has no impact
  103216. */
  103217. ambientTextureImpactOnAnalyticalLights: number;
  103218. /**
  103219. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  103220. */
  103221. opacityTexture: BaseTexture;
  103222. /**
  103223. * Stores the reflection values in a texture.
  103224. */
  103225. reflectionTexture: Nullable<BaseTexture>;
  103226. /**
  103227. * Stores the emissive values in a texture.
  103228. */
  103229. emissiveTexture: BaseTexture;
  103230. /**
  103231. * AKA Specular texture in other nomenclature.
  103232. */
  103233. reflectivityTexture: BaseTexture;
  103234. /**
  103235. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103236. */
  103237. metallicTexture: BaseTexture;
  103238. /**
  103239. * Specifies the metallic scalar of the metallic/roughness workflow.
  103240. * Can also be used to scale the metalness values of the metallic texture.
  103241. */
  103242. metallic: Nullable<number>;
  103243. /**
  103244. * Specifies the roughness scalar of the metallic/roughness workflow.
  103245. * Can also be used to scale the roughness values of the metallic texture.
  103246. */
  103247. roughness: Nullable<number>;
  103248. /**
  103249. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  103250. * By default the indexOfrefraction is used to compute F0;
  103251. *
  103252. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  103253. *
  103254. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103255. * F90 = metallicReflectanceColor;
  103256. */
  103257. metallicF0Factor: number;
  103258. /**
  103259. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103260. * By default the F90 is always 1;
  103261. *
  103262. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103263. *
  103264. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103265. * F90 = metallicReflectanceColor;
  103266. */
  103267. metallicReflectanceColor: Color3;
  103268. /**
  103269. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103270. * This is multiply against the scalar values defined in the material.
  103271. */
  103272. metallicReflectanceTexture: Nullable<BaseTexture>;
  103273. /**
  103274. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103275. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103276. */
  103277. microSurfaceTexture: BaseTexture;
  103278. /**
  103279. * Stores surface normal data used to displace a mesh in a texture.
  103280. */
  103281. bumpTexture: BaseTexture;
  103282. /**
  103283. * Stores the pre-calculated light information of a mesh in a texture.
  103284. */
  103285. lightmapTexture: BaseTexture;
  103286. /**
  103287. * Stores the refracted light information in a texture.
  103288. */
  103289. get refractionTexture(): Nullable<BaseTexture>;
  103290. set refractionTexture(value: Nullable<BaseTexture>);
  103291. /**
  103292. * The color of a material in ambient lighting.
  103293. */
  103294. ambientColor: Color3;
  103295. /**
  103296. * AKA Diffuse Color in other nomenclature.
  103297. */
  103298. albedoColor: Color3;
  103299. /**
  103300. * AKA Specular Color in other nomenclature.
  103301. */
  103302. reflectivityColor: Color3;
  103303. /**
  103304. * The color reflected from the material.
  103305. */
  103306. reflectionColor: Color3;
  103307. /**
  103308. * The color emitted from the material.
  103309. */
  103310. emissiveColor: Color3;
  103311. /**
  103312. * AKA Glossiness in other nomenclature.
  103313. */
  103314. microSurface: number;
  103315. /**
  103316. * Index of refraction of the material base layer.
  103317. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103318. *
  103319. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103320. *
  103321. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103322. */
  103323. get indexOfRefraction(): number;
  103324. set indexOfRefraction(value: number);
  103325. /**
  103326. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103327. */
  103328. get invertRefractionY(): boolean;
  103329. set invertRefractionY(value: boolean);
  103330. /**
  103331. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103332. * Materials half opaque for instance using refraction could benefit from this control.
  103333. */
  103334. get linkRefractionWithTransparency(): boolean;
  103335. set linkRefractionWithTransparency(value: boolean);
  103336. /**
  103337. * If true, the light map contains occlusion information instead of lighting info.
  103338. */
  103339. useLightmapAsShadowmap: boolean;
  103340. /**
  103341. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103342. */
  103343. useAlphaFromAlbedoTexture: boolean;
  103344. /**
  103345. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103346. */
  103347. forceAlphaTest: boolean;
  103348. /**
  103349. * Defines the alpha limits in alpha test mode.
  103350. */
  103351. alphaCutOff: number;
  103352. /**
  103353. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103354. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103355. */
  103356. useSpecularOverAlpha: boolean;
  103357. /**
  103358. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103359. */
  103360. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103361. /**
  103362. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103363. */
  103364. useRoughnessFromMetallicTextureAlpha: boolean;
  103365. /**
  103366. * Specifies if the metallic texture contains the roughness information in its green channel.
  103367. */
  103368. useRoughnessFromMetallicTextureGreen: boolean;
  103369. /**
  103370. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103371. */
  103372. useMetallnessFromMetallicTextureBlue: boolean;
  103373. /**
  103374. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103375. */
  103376. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103377. /**
  103378. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103379. */
  103380. useAmbientInGrayScale: boolean;
  103381. /**
  103382. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103383. * The material will try to infer what glossiness each pixel should be.
  103384. */
  103385. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103386. /**
  103387. * BJS is using an harcoded light falloff based on a manually sets up range.
  103388. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103389. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103390. */
  103391. get usePhysicalLightFalloff(): boolean;
  103392. /**
  103393. * BJS is using an harcoded light falloff based on a manually sets up range.
  103394. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103395. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103396. */
  103397. set usePhysicalLightFalloff(value: boolean);
  103398. /**
  103399. * In order to support the falloff compatibility with gltf, a special mode has been added
  103400. * to reproduce the gltf light falloff.
  103401. */
  103402. get useGLTFLightFalloff(): boolean;
  103403. /**
  103404. * In order to support the falloff compatibility with gltf, a special mode has been added
  103405. * to reproduce the gltf light falloff.
  103406. */
  103407. set useGLTFLightFalloff(value: boolean);
  103408. /**
  103409. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103410. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103411. */
  103412. useRadianceOverAlpha: boolean;
  103413. /**
  103414. * Allows using an object space normal map (instead of tangent space).
  103415. */
  103416. useObjectSpaceNormalMap: boolean;
  103417. /**
  103418. * Allows using the bump map in parallax mode.
  103419. */
  103420. useParallax: boolean;
  103421. /**
  103422. * Allows using the bump map in parallax occlusion mode.
  103423. */
  103424. useParallaxOcclusion: boolean;
  103425. /**
  103426. * Controls the scale bias of the parallax mode.
  103427. */
  103428. parallaxScaleBias: number;
  103429. /**
  103430. * If sets to true, disables all the lights affecting the material.
  103431. */
  103432. disableLighting: boolean;
  103433. /**
  103434. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103435. */
  103436. forceIrradianceInFragment: boolean;
  103437. /**
  103438. * Number of Simultaneous lights allowed on the material.
  103439. */
  103440. maxSimultaneousLights: number;
  103441. /**
  103442. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103443. */
  103444. invertNormalMapX: boolean;
  103445. /**
  103446. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103447. */
  103448. invertNormalMapY: boolean;
  103449. /**
  103450. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103451. */
  103452. twoSidedLighting: boolean;
  103453. /**
  103454. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103455. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103456. */
  103457. useAlphaFresnel: boolean;
  103458. /**
  103459. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103460. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103461. */
  103462. useLinearAlphaFresnel: boolean;
  103463. /**
  103464. * Let user defines the brdf lookup texture used for IBL.
  103465. * A default 8bit version is embedded but you could point at :
  103466. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103467. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103468. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103469. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103470. */
  103471. environmentBRDFTexture: Nullable<BaseTexture>;
  103472. /**
  103473. * Force normal to face away from face.
  103474. */
  103475. forceNormalForward: boolean;
  103476. /**
  103477. * Enables specular anti aliasing in the PBR shader.
  103478. * It will both interacts on the Geometry for analytical and IBL lighting.
  103479. * It also prefilter the roughness map based on the bump values.
  103480. */
  103481. enableSpecularAntiAliasing: boolean;
  103482. /**
  103483. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103484. * makes the reflect vector face the model (under horizon).
  103485. */
  103486. useHorizonOcclusion: boolean;
  103487. /**
  103488. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103489. * too much the area relying on ambient texture to define their ambient occlusion.
  103490. */
  103491. useRadianceOcclusion: boolean;
  103492. /**
  103493. * If set to true, no lighting calculations will be applied.
  103494. */
  103495. unlit: boolean;
  103496. /**
  103497. * Gets the image processing configuration used either in this material.
  103498. */
  103499. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103500. /**
  103501. * Sets the Default image processing configuration used either in the this material.
  103502. *
  103503. * If sets to null, the scene one is in use.
  103504. */
  103505. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103506. /**
  103507. * Gets wether the color curves effect is enabled.
  103508. */
  103509. get cameraColorCurvesEnabled(): boolean;
  103510. /**
  103511. * Sets wether the color curves effect is enabled.
  103512. */
  103513. set cameraColorCurvesEnabled(value: boolean);
  103514. /**
  103515. * Gets wether the color grading effect is enabled.
  103516. */
  103517. get cameraColorGradingEnabled(): boolean;
  103518. /**
  103519. * Gets wether the color grading effect is enabled.
  103520. */
  103521. set cameraColorGradingEnabled(value: boolean);
  103522. /**
  103523. * Gets wether tonemapping is enabled or not.
  103524. */
  103525. get cameraToneMappingEnabled(): boolean;
  103526. /**
  103527. * Sets wether tonemapping is enabled or not
  103528. */
  103529. set cameraToneMappingEnabled(value: boolean);
  103530. /**
  103531. * The camera exposure used on this material.
  103532. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103533. * This corresponds to a photographic exposure.
  103534. */
  103535. get cameraExposure(): number;
  103536. /**
  103537. * The camera exposure used on this material.
  103538. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103539. * This corresponds to a photographic exposure.
  103540. */
  103541. set cameraExposure(value: number);
  103542. /**
  103543. * Gets The camera contrast used on this material.
  103544. */
  103545. get cameraContrast(): number;
  103546. /**
  103547. * Sets The camera contrast used on this material.
  103548. */
  103549. set cameraContrast(value: number);
  103550. /**
  103551. * Gets the Color Grading 2D Lookup Texture.
  103552. */
  103553. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103554. /**
  103555. * Sets the Color Grading 2D Lookup Texture.
  103556. */
  103557. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103558. /**
  103559. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103560. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103561. * 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;
  103562. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103563. */
  103564. get cameraColorCurves(): Nullable<ColorCurves>;
  103565. /**
  103566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103568. * 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;
  103569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103570. */
  103571. set cameraColorCurves(value: Nullable<ColorCurves>);
  103572. /**
  103573. * Instantiates a new PBRMaterial instance.
  103574. *
  103575. * @param name The material name
  103576. * @param scene The scene the material will be use in.
  103577. */
  103578. constructor(name: string, scene: Scene);
  103579. /**
  103580. * Returns the name of this material class.
  103581. */
  103582. getClassName(): string;
  103583. /**
  103584. * Makes a duplicate of the current material.
  103585. * @param name - name to use for the new material.
  103586. */
  103587. clone(name: string): PBRMaterial;
  103588. /**
  103589. * Serializes this PBR Material.
  103590. * @returns - An object with the serialized material.
  103591. */
  103592. serialize(): any;
  103593. /**
  103594. * Parses a PBR Material from a serialized object.
  103595. * @param source - Serialized object.
  103596. * @param scene - BJS scene instance.
  103597. * @param rootUrl - url for the scene object
  103598. * @returns - PBRMaterial
  103599. */
  103600. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103601. }
  103602. }
  103603. declare module BABYLON {
  103604. /** @hidden */
  103605. export var mrtFragmentDeclaration: {
  103606. name: string;
  103607. shader: string;
  103608. };
  103609. }
  103610. declare module BABYLON {
  103611. /** @hidden */
  103612. export var geometryPixelShader: {
  103613. name: string;
  103614. shader: string;
  103615. };
  103616. }
  103617. declare module BABYLON {
  103618. /** @hidden */
  103619. export var geometryVertexShader: {
  103620. name: string;
  103621. shader: string;
  103622. };
  103623. }
  103624. declare module BABYLON {
  103625. /** @hidden */
  103626. interface ISavedTransformationMatrix {
  103627. world: Matrix;
  103628. viewProjection: Matrix;
  103629. }
  103630. /**
  103631. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103632. */
  103633. export class GeometryBufferRenderer {
  103634. /**
  103635. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103636. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103637. */
  103638. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103639. /**
  103640. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103641. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103642. */
  103643. static readonly POSITION_TEXTURE_TYPE: number;
  103644. /**
  103645. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103646. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103647. */
  103648. static readonly VELOCITY_TEXTURE_TYPE: number;
  103649. /**
  103650. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103651. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103652. */
  103653. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103654. /**
  103655. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103656. * in order to compute objects velocities when enableVelocity is set to "true"
  103657. * @hidden
  103658. */
  103659. _previousTransformationMatrices: {
  103660. [index: number]: ISavedTransformationMatrix;
  103661. };
  103662. /**
  103663. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103664. * in order to compute objects velocities when enableVelocity is set to "true"
  103665. * @hidden
  103666. */
  103667. _previousBonesTransformationMatrices: {
  103668. [index: number]: Float32Array;
  103669. };
  103670. /**
  103671. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103672. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103673. */
  103674. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103675. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103676. renderTransparentMeshes: boolean;
  103677. private _scene;
  103678. private _resizeObserver;
  103679. private _multiRenderTarget;
  103680. private _ratio;
  103681. private _enablePosition;
  103682. private _enableVelocity;
  103683. private _enableReflectivity;
  103684. private _positionIndex;
  103685. private _velocityIndex;
  103686. private _reflectivityIndex;
  103687. private _depthNormalIndex;
  103688. private _linkedWithPrePass;
  103689. private _prePassRenderer;
  103690. private _attachments;
  103691. protected _effect: Effect;
  103692. protected _cachedDefines: string;
  103693. /**
  103694. * @hidden
  103695. * Sets up internal structures to share outputs with PrePassRenderer
  103696. * This method should only be called by the PrePassRenderer itself
  103697. */
  103698. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103699. /**
  103700. * @hidden
  103701. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103702. * This method should only be called by the PrePassRenderer itself
  103703. */
  103704. _unlinkPrePassRenderer(): void;
  103705. /**
  103706. * @hidden
  103707. * Resets the geometry buffer layout
  103708. */
  103709. _resetLayout(): void;
  103710. /**
  103711. * @hidden
  103712. * Replaces a texture in the geometry buffer renderer
  103713. * Useful when linking textures of the prepass renderer
  103714. */
  103715. _forceTextureType(geometryBufferType: number, index: number): void;
  103716. /**
  103717. * @hidden
  103718. * Sets texture attachments
  103719. * Useful when linking textures of the prepass renderer
  103720. */
  103721. _setAttachments(attachments: number[]): void;
  103722. /**
  103723. * @hidden
  103724. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103725. * Useful when linking textures of the prepass renderer
  103726. */
  103727. _linkInternalTexture(internalTexture: InternalTexture): void;
  103728. /**
  103729. * Gets the render list (meshes to be rendered) used in the G buffer.
  103730. */
  103731. get renderList(): Nullable<AbstractMesh[]>;
  103732. /**
  103733. * Set the render list (meshes to be rendered) used in the G buffer.
  103734. */
  103735. set renderList(meshes: Nullable<AbstractMesh[]>);
  103736. /**
  103737. * Gets wether or not G buffer are supported by the running hardware.
  103738. * This requires draw buffer supports
  103739. */
  103740. get isSupported(): boolean;
  103741. /**
  103742. * Returns the index of the given texture type in the G-Buffer textures array
  103743. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103744. * @returns the index of the given texture type in the G-Buffer textures array
  103745. */
  103746. getTextureIndex(textureType: number): number;
  103747. /**
  103748. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103749. */
  103750. get enablePosition(): boolean;
  103751. /**
  103752. * Sets whether or not objects positions are enabled for the G buffer.
  103753. */
  103754. set enablePosition(enable: boolean);
  103755. /**
  103756. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103757. */
  103758. get enableVelocity(): boolean;
  103759. /**
  103760. * Sets wether or not objects velocities are enabled for the G buffer.
  103761. */
  103762. set enableVelocity(enable: boolean);
  103763. /**
  103764. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103765. */
  103766. get enableReflectivity(): boolean;
  103767. /**
  103768. * Sets wether or not objects roughness are enabled for the G buffer.
  103769. */
  103770. set enableReflectivity(enable: boolean);
  103771. /**
  103772. * Gets the scene associated with the buffer.
  103773. */
  103774. get scene(): Scene;
  103775. /**
  103776. * Gets the ratio used by the buffer during its creation.
  103777. * How big is the buffer related to the main canvas.
  103778. */
  103779. get ratio(): number;
  103780. /** @hidden */
  103781. static _SceneComponentInitialization: (scene: Scene) => void;
  103782. /**
  103783. * Creates a new G Buffer for the scene
  103784. * @param scene The scene the buffer belongs to
  103785. * @param ratio How big is the buffer related to the main canvas.
  103786. */
  103787. constructor(scene: Scene, ratio?: number);
  103788. /**
  103789. * Checks wether everything is ready to render a submesh to the G buffer.
  103790. * @param subMesh the submesh to check readiness for
  103791. * @param useInstances is the mesh drawn using instance or not
  103792. * @returns true if ready otherwise false
  103793. */
  103794. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103795. /**
  103796. * Gets the current underlying G Buffer.
  103797. * @returns the buffer
  103798. */
  103799. getGBuffer(): MultiRenderTarget;
  103800. /**
  103801. * Gets the number of samples used to render the buffer (anti aliasing).
  103802. */
  103803. get samples(): number;
  103804. /**
  103805. * Sets the number of samples used to render the buffer (anti aliasing).
  103806. */
  103807. set samples(value: number);
  103808. /**
  103809. * Disposes the renderer and frees up associated resources.
  103810. */
  103811. dispose(): void;
  103812. private _assignRenderTargetIndices;
  103813. protected _createRenderTargets(): void;
  103814. private _copyBonesTransformationMatrices;
  103815. }
  103816. }
  103817. declare module BABYLON {
  103818. /**
  103819. * Renders a pre pass of the scene
  103820. * This means every mesh in the scene will be rendered to a render target texture
  103821. * And then this texture will be composited to the rendering canvas with post processes
  103822. * It is necessary for effects like subsurface scattering or deferred shading
  103823. */
  103824. export class PrePassRenderer {
  103825. /** @hidden */
  103826. static _SceneComponentInitialization: (scene: Scene) => void;
  103827. private _textureFormats;
  103828. /**
  103829. * To save performance, we can excluded skinned meshes from the prepass
  103830. */
  103831. excludedSkinnedMesh: AbstractMesh[];
  103832. /**
  103833. * Force material to be excluded from the prepass
  103834. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103835. * and you don't want a material to show in the effect.
  103836. */
  103837. excludedMaterials: Material[];
  103838. private _textureIndices;
  103839. private _scene;
  103840. private _engine;
  103841. private _isDirty;
  103842. /**
  103843. * Number of textures in the multi render target texture where the scene is directly rendered
  103844. */
  103845. mrtCount: number;
  103846. /**
  103847. * The render target where the scene is directly rendered
  103848. */
  103849. prePassRT: MultiRenderTarget;
  103850. private _multiRenderAttachments;
  103851. private _defaultAttachments;
  103852. private _clearAttachments;
  103853. private _postProcesses;
  103854. private readonly _clearColor;
  103855. /**
  103856. * Image processing post process for composition
  103857. */
  103858. imageProcessingPostProcess: ImageProcessingPostProcess;
  103859. /**
  103860. * Configuration for prepass effects
  103861. */
  103862. private _effectConfigurations;
  103863. private _mrtFormats;
  103864. private _mrtLayout;
  103865. private _enabled;
  103866. /**
  103867. * Indicates if the prepass is enabled
  103868. */
  103869. get enabled(): boolean;
  103870. /**
  103871. * How many samples are used for MSAA of the scene render target
  103872. */
  103873. get samples(): number;
  103874. set samples(n: number);
  103875. private _geometryBuffer;
  103876. private _useGeometryBufferFallback;
  103877. /**
  103878. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103879. */
  103880. get useGeometryBufferFallback(): boolean;
  103881. set useGeometryBufferFallback(value: boolean);
  103882. /**
  103883. * Set to true to disable gamma transform in PrePass.
  103884. * Can be useful in case you already proceed to gamma transform on a material level
  103885. * and your post processes don't need to be in linear color space.
  103886. */
  103887. disableGammaTransform: boolean;
  103888. /**
  103889. * Instanciates a prepass renderer
  103890. * @param scene The scene
  103891. */
  103892. constructor(scene: Scene);
  103893. private _initializeAttachments;
  103894. private _createCompositionEffect;
  103895. /**
  103896. * Indicates if rendering a prepass is supported
  103897. */
  103898. get isSupported(): boolean;
  103899. /**
  103900. * Sets the proper output textures to draw in the engine.
  103901. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103902. * @param subMesh Submesh on which the effect is applied
  103903. */
  103904. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103905. /**
  103906. * Restores attachments for single texture draw.
  103907. */
  103908. restoreAttachments(): void;
  103909. /**
  103910. * @hidden
  103911. */
  103912. _beforeCameraDraw(): void;
  103913. /**
  103914. * @hidden
  103915. */
  103916. _afterCameraDraw(): void;
  103917. private _checkRTSize;
  103918. private _bindFrameBuffer;
  103919. /**
  103920. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103921. */
  103922. clear(): void;
  103923. private _setState;
  103924. private _updateGeometryBufferLayout;
  103925. /**
  103926. * Adds an effect configuration to the prepass.
  103927. * If an effect has already been added, it won't add it twice and will return the configuration
  103928. * already present.
  103929. * @param cfg the effect configuration
  103930. * @return the effect configuration now used by the prepass
  103931. */
  103932. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103933. /**
  103934. * Returns the index of a texture in the multi render target texture array.
  103935. * @param type Texture type
  103936. * @return The index
  103937. */
  103938. getIndex(type: number): number;
  103939. private _enable;
  103940. private _disable;
  103941. private _resetLayout;
  103942. private _resetPostProcessChain;
  103943. private _bindPostProcessChain;
  103944. /**
  103945. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103946. */
  103947. markAsDirty(): void;
  103948. /**
  103949. * Enables a texture on the MultiRenderTarget for prepass
  103950. */
  103951. private _enableTextures;
  103952. private _update;
  103953. private _markAllMaterialsAsPrePassDirty;
  103954. /**
  103955. * Disposes the prepass renderer.
  103956. */
  103957. dispose(): void;
  103958. }
  103959. }
  103960. declare module BABYLON {
  103961. /**
  103962. * Size options for a post process
  103963. */
  103964. export type PostProcessOptions = {
  103965. width: number;
  103966. height: number;
  103967. };
  103968. /**
  103969. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103970. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103971. */
  103972. export class PostProcess {
  103973. /**
  103974. * Gets or sets the unique id of the post process
  103975. */
  103976. uniqueId: number;
  103977. /** Name of the PostProcess. */
  103978. name: string;
  103979. /**
  103980. * Width of the texture to apply the post process on
  103981. */
  103982. width: number;
  103983. /**
  103984. * Height of the texture to apply the post process on
  103985. */
  103986. height: number;
  103987. /**
  103988. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103989. */
  103990. nodeMaterialSource: Nullable<NodeMaterial>;
  103991. /**
  103992. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103993. * @hidden
  103994. */
  103995. _outputTexture: Nullable<InternalTexture>;
  103996. /**
  103997. * Sampling mode used by the shader
  103998. * See https://doc.babylonjs.com/classes/3.1/texture
  103999. */
  104000. renderTargetSamplingMode: number;
  104001. /**
  104002. * Clear color to use when screen clearing
  104003. */
  104004. clearColor: Color4;
  104005. /**
  104006. * If the buffer needs to be cleared before applying the post process. (default: true)
  104007. * Should be set to false if shader will overwrite all previous pixels.
  104008. */
  104009. autoClear: boolean;
  104010. /**
  104011. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  104012. */
  104013. alphaMode: number;
  104014. /**
  104015. * Sets the setAlphaBlendConstants of the babylon engine
  104016. */
  104017. alphaConstants: Color4;
  104018. /**
  104019. * Animations to be used for the post processing
  104020. */
  104021. animations: Animation[];
  104022. /**
  104023. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  104024. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  104025. */
  104026. enablePixelPerfectMode: boolean;
  104027. /**
  104028. * Force the postprocess to be applied without taking in account viewport
  104029. */
  104030. forceFullscreenViewport: boolean;
  104031. /**
  104032. * List of inspectable custom properties (used by the Inspector)
  104033. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104034. */
  104035. inspectableCustomProperties: IInspectable[];
  104036. /**
  104037. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  104038. *
  104039. * | Value | Type | Description |
  104040. * | ----- | ----------------------------------- | ----------- |
  104041. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  104042. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  104043. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  104044. *
  104045. */
  104046. scaleMode: number;
  104047. /**
  104048. * Force textures to be a power of two (default: false)
  104049. */
  104050. alwaysForcePOT: boolean;
  104051. private _samples;
  104052. /**
  104053. * Number of sample textures (default: 1)
  104054. */
  104055. get samples(): number;
  104056. set samples(n: number);
  104057. /**
  104058. * Modify the scale of the post process to be the same as the viewport (default: false)
  104059. */
  104060. adaptScaleToCurrentViewport: boolean;
  104061. private _camera;
  104062. protected _scene: Scene;
  104063. private _engine;
  104064. private _options;
  104065. private _reusable;
  104066. private _textureType;
  104067. private _textureFormat;
  104068. /**
  104069. * Smart array of input and output textures for the post process.
  104070. * @hidden
  104071. */
  104072. _textures: SmartArray<InternalTexture>;
  104073. /**
  104074. * The index in _textures that corresponds to the output texture.
  104075. * @hidden
  104076. */
  104077. _currentRenderTextureInd: number;
  104078. private _effect;
  104079. private _samplers;
  104080. private _fragmentUrl;
  104081. private _vertexUrl;
  104082. private _parameters;
  104083. private _scaleRatio;
  104084. protected _indexParameters: any;
  104085. private _shareOutputWithPostProcess;
  104086. private _texelSize;
  104087. private _forcedOutputTexture;
  104088. /**
  104089. * Prepass configuration in case this post process needs a texture from prepass
  104090. * @hidden
  104091. */
  104092. _prePassEffectConfiguration: PrePassEffectConfiguration;
  104093. /**
  104094. * Returns the fragment url or shader name used in the post process.
  104095. * @returns the fragment url or name in the shader store.
  104096. */
  104097. getEffectName(): string;
  104098. /**
  104099. * An event triggered when the postprocess is activated.
  104100. */
  104101. onActivateObservable: Observable<Camera>;
  104102. private _onActivateObserver;
  104103. /**
  104104. * A function that is added to the onActivateObservable
  104105. */
  104106. set onActivate(callback: Nullable<(camera: Camera) => void>);
  104107. /**
  104108. * An event triggered when the postprocess changes its size.
  104109. */
  104110. onSizeChangedObservable: Observable<PostProcess>;
  104111. private _onSizeChangedObserver;
  104112. /**
  104113. * A function that is added to the onSizeChangedObservable
  104114. */
  104115. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  104116. /**
  104117. * An event triggered when the postprocess applies its effect.
  104118. */
  104119. onApplyObservable: Observable<Effect>;
  104120. private _onApplyObserver;
  104121. /**
  104122. * A function that is added to the onApplyObservable
  104123. */
  104124. set onApply(callback: (effect: Effect) => void);
  104125. /**
  104126. * An event triggered before rendering the postprocess
  104127. */
  104128. onBeforeRenderObservable: Observable<Effect>;
  104129. private _onBeforeRenderObserver;
  104130. /**
  104131. * A function that is added to the onBeforeRenderObservable
  104132. */
  104133. set onBeforeRender(callback: (effect: Effect) => void);
  104134. /**
  104135. * An event triggered after rendering the postprocess
  104136. */
  104137. onAfterRenderObservable: Observable<Effect>;
  104138. private _onAfterRenderObserver;
  104139. /**
  104140. * A function that is added to the onAfterRenderObservable
  104141. */
  104142. set onAfterRender(callback: (efect: Effect) => void);
  104143. /**
  104144. * 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
  104145. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  104146. */
  104147. get inputTexture(): InternalTexture;
  104148. set inputTexture(value: InternalTexture);
  104149. /**
  104150. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  104151. * the only way to unset it is to use this function to restore its internal state
  104152. */
  104153. restoreDefaultInputTexture(): void;
  104154. /**
  104155. * Gets the camera which post process is applied to.
  104156. * @returns The camera the post process is applied to.
  104157. */
  104158. getCamera(): Camera;
  104159. /**
  104160. * Gets the texel size of the postprocess.
  104161. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104162. */
  104163. get texelSize(): Vector2;
  104164. /**
  104165. * Creates a new instance PostProcess
  104166. * @param name The name of the PostProcess.
  104167. * @param fragmentUrl The url of the fragment shader to be used.
  104168. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104169. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104170. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104171. * @param camera The camera to apply the render pass to.
  104172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104173. * @param engine The engine which the post process will be applied. (default: current engine)
  104174. * @param reusable If the post process can be reused on the same frame. (default: false)
  104175. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104176. * @param textureType Type of textures used when performing the post process. (default: 0)
  104177. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104178. * @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
  104179. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104180. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104181. */
  104182. 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);
  104183. /**
  104184. * Gets a string identifying the name of the class
  104185. * @returns "PostProcess" string
  104186. */
  104187. getClassName(): string;
  104188. /**
  104189. * Gets the engine which this post process belongs to.
  104190. * @returns The engine the post process was enabled with.
  104191. */
  104192. getEngine(): Engine;
  104193. /**
  104194. * The effect that is created when initializing the post process.
  104195. * @returns The created effect corresponding the the postprocess.
  104196. */
  104197. getEffect(): Effect;
  104198. /**
  104199. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104200. * @param postProcess The post process to share the output with.
  104201. * @returns This post process.
  104202. */
  104203. shareOutputWith(postProcess: PostProcess): PostProcess;
  104204. /**
  104205. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104206. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104207. */
  104208. useOwnOutput(): void;
  104209. /**
  104210. * Updates the effect with the current post process compile time values and recompiles the shader.
  104211. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104212. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104213. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104214. * @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
  104215. * @param onCompiled Called when the shader has been compiled.
  104216. * @param onError Called if there is an error when compiling a shader.
  104217. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104218. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104219. */
  104220. 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;
  104221. /**
  104222. * The post process is reusable if it can be used multiple times within one frame.
  104223. * @returns If the post process is reusable
  104224. */
  104225. isReusable(): boolean;
  104226. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104227. markTextureDirty(): void;
  104228. /**
  104229. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104230. * 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.
  104231. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104232. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104233. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104234. * @returns The target texture that was bound to be written to.
  104235. */
  104236. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104237. /**
  104238. * If the post process is supported.
  104239. */
  104240. get isSupported(): boolean;
  104241. /**
  104242. * The aspect ratio of the output texture.
  104243. */
  104244. get aspectRatio(): number;
  104245. /**
  104246. * Get a value indicating if the post-process is ready to be used
  104247. * @returns true if the post-process is ready (shader is compiled)
  104248. */
  104249. isReady(): boolean;
  104250. /**
  104251. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104252. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104253. */
  104254. apply(): Nullable<Effect>;
  104255. private _disposeTextures;
  104256. /**
  104257. * Sets the required values to the prepass renderer.
  104258. * @param prePassRenderer defines the prepass renderer to setup.
  104259. * @returns true if the pre pass is needed.
  104260. */
  104261. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104262. /**
  104263. * Disposes the post process.
  104264. * @param camera The camera to dispose the post process on.
  104265. */
  104266. dispose(camera?: Camera): void;
  104267. /**
  104268. * Serializes the particle system to a JSON object
  104269. * @returns the JSON object
  104270. */
  104271. serialize(): any;
  104272. /**
  104273. * Creates a material from parsed material data
  104274. * @param parsedPostProcess defines parsed post process data
  104275. * @param scene defines the hosting scene
  104276. * @param rootUrl defines the root URL to use to load textures
  104277. * @returns a new post process
  104278. */
  104279. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104280. }
  104281. }
  104282. declare module BABYLON {
  104283. /** @hidden */
  104284. export var kernelBlurVaryingDeclaration: {
  104285. name: string;
  104286. shader: string;
  104287. };
  104288. }
  104289. declare module BABYLON {
  104290. /** @hidden */
  104291. export var packingFunctions: {
  104292. name: string;
  104293. shader: string;
  104294. };
  104295. }
  104296. declare module BABYLON {
  104297. /** @hidden */
  104298. export var kernelBlurFragment: {
  104299. name: string;
  104300. shader: string;
  104301. };
  104302. }
  104303. declare module BABYLON {
  104304. /** @hidden */
  104305. export var kernelBlurFragment2: {
  104306. name: string;
  104307. shader: string;
  104308. };
  104309. }
  104310. declare module BABYLON {
  104311. /** @hidden */
  104312. export var kernelBlurPixelShader: {
  104313. name: string;
  104314. shader: string;
  104315. };
  104316. }
  104317. declare module BABYLON {
  104318. /** @hidden */
  104319. export var kernelBlurVertex: {
  104320. name: string;
  104321. shader: string;
  104322. };
  104323. }
  104324. declare module BABYLON {
  104325. /** @hidden */
  104326. export var kernelBlurVertexShader: {
  104327. name: string;
  104328. shader: string;
  104329. };
  104330. }
  104331. declare module BABYLON {
  104332. /**
  104333. * The Blur Post Process which blurs an image based on a kernel and direction.
  104334. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104335. */
  104336. export class BlurPostProcess extends PostProcess {
  104337. private blockCompilation;
  104338. protected _kernel: number;
  104339. protected _idealKernel: number;
  104340. protected _packedFloat: boolean;
  104341. private _staticDefines;
  104342. /** The direction in which to blur the image. */
  104343. direction: Vector2;
  104344. /**
  104345. * Sets the length in pixels of the blur sample region
  104346. */
  104347. set kernel(v: number);
  104348. /**
  104349. * Gets the length in pixels of the blur sample region
  104350. */
  104351. get kernel(): number;
  104352. /**
  104353. * Sets wether or not the blur needs to unpack/repack floats
  104354. */
  104355. set packedFloat(v: boolean);
  104356. /**
  104357. * Gets wether or not the blur is unpacking/repacking floats
  104358. */
  104359. get packedFloat(): boolean;
  104360. /**
  104361. * Gets a string identifying the name of the class
  104362. * @returns "BlurPostProcess" string
  104363. */
  104364. getClassName(): string;
  104365. /**
  104366. * Creates a new instance BlurPostProcess
  104367. * @param name The name of the effect.
  104368. * @param direction The direction in which to blur the image.
  104369. * @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.
  104370. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104371. * @param camera The camera to apply the render pass to.
  104372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104373. * @param engine The engine which the post process will be applied. (default: current engine)
  104374. * @param reusable If the post process can be reused on the same frame. (default: false)
  104375. * @param textureType Type of textures used when performing the post process. (default: 0)
  104376. * @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)
  104377. */
  104378. 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);
  104379. /**
  104380. * Updates the effect with the current post process compile time values and recompiles the shader.
  104381. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104382. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104383. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104384. * @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
  104385. * @param onCompiled Called when the shader has been compiled.
  104386. * @param onError Called if there is an error when compiling a shader.
  104387. */
  104388. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104389. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104390. /**
  104391. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104392. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104393. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104394. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104395. * The gaps between physical kernels are compensated for in the weighting of the samples
  104396. * @param idealKernel Ideal blur kernel.
  104397. * @return Nearest best kernel.
  104398. */
  104399. protected _nearestBestKernel(idealKernel: number): number;
  104400. /**
  104401. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104402. * @param x The point on the Gaussian distribution to sample.
  104403. * @return the value of the Gaussian function at x.
  104404. */
  104405. protected _gaussianWeight(x: number): number;
  104406. /**
  104407. * Generates a string that can be used as a floating point number in GLSL.
  104408. * @param x Value to print.
  104409. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104410. * @return GLSL float string.
  104411. */
  104412. protected _glslFloat(x: number, decimalFigures?: number): string;
  104413. /** @hidden */
  104414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104415. }
  104416. }
  104417. declare module BABYLON {
  104418. /**
  104419. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104420. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104421. * You can then easily use it as a reflectionTexture on a flat surface.
  104422. * In case the surface is not a plane, please consider relying on reflection probes.
  104423. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104424. */
  104425. export class MirrorTexture extends RenderTargetTexture {
  104426. private scene;
  104427. /**
  104428. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104429. * 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.
  104430. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104431. */
  104432. mirrorPlane: Plane;
  104433. /**
  104434. * Define the blur ratio used to blur the reflection if needed.
  104435. */
  104436. set blurRatio(value: number);
  104437. get blurRatio(): number;
  104438. /**
  104439. * Define the adaptive blur kernel used to blur the reflection if needed.
  104440. * This will autocompute the closest best match for the `blurKernel`
  104441. */
  104442. set adaptiveBlurKernel(value: number);
  104443. /**
  104444. * Define the blur kernel used to blur the reflection if needed.
  104445. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104446. */
  104447. set blurKernel(value: number);
  104448. /**
  104449. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104450. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104451. */
  104452. set blurKernelX(value: number);
  104453. get blurKernelX(): number;
  104454. /**
  104455. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104456. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104457. */
  104458. set blurKernelY(value: number);
  104459. get blurKernelY(): number;
  104460. private _autoComputeBlurKernel;
  104461. protected _onRatioRescale(): void;
  104462. private _updateGammaSpace;
  104463. private _imageProcessingConfigChangeObserver;
  104464. private _transformMatrix;
  104465. private _mirrorMatrix;
  104466. private _savedViewMatrix;
  104467. private _blurX;
  104468. private _blurY;
  104469. private _adaptiveBlurKernel;
  104470. private _blurKernelX;
  104471. private _blurKernelY;
  104472. private _blurRatio;
  104473. /**
  104474. * Instantiates a Mirror Texture.
  104475. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104476. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104477. * You can then easily use it as a reflectionTexture on a flat surface.
  104478. * In case the surface is not a plane, please consider relying on reflection probes.
  104479. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104480. * @param name
  104481. * @param size
  104482. * @param scene
  104483. * @param generateMipMaps
  104484. * @param type
  104485. * @param samplingMode
  104486. * @param generateDepthBuffer
  104487. */
  104488. constructor(name: string, size: number | {
  104489. width: number;
  104490. height: number;
  104491. } | {
  104492. ratio: number;
  104493. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104494. private _preparePostProcesses;
  104495. /**
  104496. * Clone the mirror texture.
  104497. * @returns the cloned texture
  104498. */
  104499. clone(): MirrorTexture;
  104500. /**
  104501. * Serialize the texture to a JSON representation you could use in Parse later on
  104502. * @returns the serialized JSON representation
  104503. */
  104504. serialize(): any;
  104505. /**
  104506. * Dispose the texture and release its associated resources.
  104507. */
  104508. dispose(): void;
  104509. }
  104510. }
  104511. declare module BABYLON {
  104512. /**
  104513. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104514. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104515. */
  104516. export class Texture extends BaseTexture {
  104517. /**
  104518. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104519. */
  104520. static SerializeBuffers: boolean;
  104521. /**
  104522. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104523. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104524. */
  104525. static ForceSerializeBuffers: boolean;
  104526. /** @hidden */
  104527. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104528. /** @hidden */
  104529. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104530. /** @hidden */
  104531. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104532. /** nearest is mag = nearest and min = nearest and mip = linear */
  104533. static readonly NEAREST_SAMPLINGMODE: number;
  104534. /** nearest is mag = nearest and min = nearest and mip = linear */
  104535. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104537. static readonly BILINEAR_SAMPLINGMODE: number;
  104538. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104539. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104540. /** Trilinear is mag = linear and min = linear and mip = linear */
  104541. static readonly TRILINEAR_SAMPLINGMODE: number;
  104542. /** Trilinear is mag = linear and min = linear and mip = linear */
  104543. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104544. /** mag = nearest and min = nearest and mip = nearest */
  104545. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104546. /** mag = nearest and min = linear and mip = nearest */
  104547. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104548. /** mag = nearest and min = linear and mip = linear */
  104549. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104550. /** mag = nearest and min = linear and mip = none */
  104551. static readonly NEAREST_LINEAR: number;
  104552. /** mag = nearest and min = nearest and mip = none */
  104553. static readonly NEAREST_NEAREST: number;
  104554. /** mag = linear and min = nearest and mip = nearest */
  104555. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104556. /** mag = linear and min = nearest and mip = linear */
  104557. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104558. /** mag = linear and min = linear and mip = none */
  104559. static readonly LINEAR_LINEAR: number;
  104560. /** mag = linear and min = nearest and mip = none */
  104561. static readonly LINEAR_NEAREST: number;
  104562. /** Explicit coordinates mode */
  104563. static readonly EXPLICIT_MODE: number;
  104564. /** Spherical coordinates mode */
  104565. static readonly SPHERICAL_MODE: number;
  104566. /** Planar coordinates mode */
  104567. static readonly PLANAR_MODE: number;
  104568. /** Cubic coordinates mode */
  104569. static readonly CUBIC_MODE: number;
  104570. /** Projection coordinates mode */
  104571. static readonly PROJECTION_MODE: number;
  104572. /** Inverse Cubic coordinates mode */
  104573. static readonly SKYBOX_MODE: number;
  104574. /** Inverse Cubic coordinates mode */
  104575. static readonly INVCUBIC_MODE: number;
  104576. /** Equirectangular coordinates mode */
  104577. static readonly EQUIRECTANGULAR_MODE: number;
  104578. /** Equirectangular Fixed coordinates mode */
  104579. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104580. /** Equirectangular Fixed Mirrored coordinates mode */
  104581. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104582. /** Texture is not repeating outside of 0..1 UVs */
  104583. static readonly CLAMP_ADDRESSMODE: number;
  104584. /** Texture is repeating outside of 0..1 UVs */
  104585. static readonly WRAP_ADDRESSMODE: number;
  104586. /** Texture is repeating and mirrored */
  104587. static readonly MIRROR_ADDRESSMODE: number;
  104588. /**
  104589. * 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
  104590. */
  104591. static UseSerializedUrlIfAny: boolean;
  104592. /**
  104593. * Define the url of the texture.
  104594. */
  104595. url: Nullable<string>;
  104596. /**
  104597. * Define an offset on the texture to offset the u coordinates of the UVs
  104598. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104599. */
  104600. uOffset: number;
  104601. /**
  104602. * Define an offset on the texture to offset the v coordinates of the UVs
  104603. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104604. */
  104605. vOffset: number;
  104606. /**
  104607. * Define an offset on the texture to scale the u coordinates of the UVs
  104608. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104609. */
  104610. uScale: number;
  104611. /**
  104612. * Define an offset on the texture to scale the v coordinates of the UVs
  104613. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104614. */
  104615. vScale: number;
  104616. /**
  104617. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104618. * @see https://doc.babylonjs.com/how_to/more_materials
  104619. */
  104620. uAng: number;
  104621. /**
  104622. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104623. * @see https://doc.babylonjs.com/how_to/more_materials
  104624. */
  104625. vAng: number;
  104626. /**
  104627. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104628. * @see https://doc.babylonjs.com/how_to/more_materials
  104629. */
  104630. wAng: number;
  104631. /**
  104632. * Defines the center of rotation (U)
  104633. */
  104634. uRotationCenter: number;
  104635. /**
  104636. * Defines the center of rotation (V)
  104637. */
  104638. vRotationCenter: number;
  104639. /**
  104640. * Defines the center of rotation (W)
  104641. */
  104642. wRotationCenter: number;
  104643. /**
  104644. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104645. */
  104646. homogeneousRotationInUVTransform: boolean;
  104647. /**
  104648. * Are mip maps generated for this texture or not.
  104649. */
  104650. get noMipmap(): boolean;
  104651. /**
  104652. * List of inspectable custom properties (used by the Inspector)
  104653. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104654. */
  104655. inspectableCustomProperties: Nullable<IInspectable[]>;
  104656. private _noMipmap;
  104657. /** @hidden */
  104658. _invertY: boolean;
  104659. private _rowGenerationMatrix;
  104660. private _cachedTextureMatrix;
  104661. private _projectionModeMatrix;
  104662. private _t0;
  104663. private _t1;
  104664. private _t2;
  104665. private _cachedUOffset;
  104666. private _cachedVOffset;
  104667. private _cachedUScale;
  104668. private _cachedVScale;
  104669. private _cachedUAng;
  104670. private _cachedVAng;
  104671. private _cachedWAng;
  104672. private _cachedProjectionMatrixId;
  104673. private _cachedURotationCenter;
  104674. private _cachedVRotationCenter;
  104675. private _cachedWRotationCenter;
  104676. private _cachedHomogeneousRotationInUVTransform;
  104677. private _cachedCoordinatesMode;
  104678. /** @hidden */
  104679. protected _initialSamplingMode: number;
  104680. /** @hidden */
  104681. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104682. private _deleteBuffer;
  104683. protected _format: Nullable<number>;
  104684. private _delayedOnLoad;
  104685. private _delayedOnError;
  104686. private _mimeType?;
  104687. private _loaderOptions?;
  104688. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104689. get mimeType(): string | undefined;
  104690. /**
  104691. * Observable triggered once the texture has been loaded.
  104692. */
  104693. onLoadObservable: Observable<Texture>;
  104694. protected _isBlocking: boolean;
  104695. /**
  104696. * Is the texture preventing material to render while loading.
  104697. * If false, a default texture will be used instead of the loading one during the preparation step.
  104698. */
  104699. set isBlocking(value: boolean);
  104700. get isBlocking(): boolean;
  104701. /**
  104702. * Get the current sampling mode associated with the texture.
  104703. */
  104704. get samplingMode(): number;
  104705. /**
  104706. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104707. */
  104708. get invertY(): boolean;
  104709. /**
  104710. * Instantiates a new texture.
  104711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104712. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104713. * @param url defines the url of the picture to load as a texture
  104714. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104715. * @param noMipmap defines if the texture will require mip maps or not
  104716. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104717. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104718. * @param onLoad defines a callback triggered when the texture has been loaded
  104719. * @param onError defines a callback triggered when an error occurred during the loading session
  104720. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104721. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104722. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104723. * @param mimeType defines an optional mime type information
  104724. * @param loaderOptions options to be passed to the loader
  104725. */
  104726. 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);
  104727. /**
  104728. * Update the url (and optional buffer) of this texture if url was null during construction.
  104729. * @param url the url of the texture
  104730. * @param buffer the buffer of the texture (defaults to null)
  104731. * @param onLoad callback called when the texture is loaded (defaults to null)
  104732. */
  104733. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104734. /**
  104735. * Finish the loading sequence of a texture flagged as delayed load.
  104736. * @hidden
  104737. */
  104738. delayLoad(): void;
  104739. private _prepareRowForTextureGeneration;
  104740. /**
  104741. * Checks if the texture has the same transform matrix than another texture
  104742. * @param texture texture to check against
  104743. * @returns true if the transforms are the same, else false
  104744. */
  104745. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104746. /**
  104747. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104748. * @returns the transform matrix of the texture.
  104749. */
  104750. getTextureMatrix(uBase?: number): Matrix;
  104751. /**
  104752. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104753. * @returns The reflection texture transform
  104754. */
  104755. getReflectionTextureMatrix(): Matrix;
  104756. /**
  104757. * Clones the texture.
  104758. * @returns the cloned texture
  104759. */
  104760. clone(): Texture;
  104761. /**
  104762. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104763. * @returns The JSON representation of the texture
  104764. */
  104765. serialize(): any;
  104766. /**
  104767. * Get the current class name of the texture useful for serialization or dynamic coding.
  104768. * @returns "Texture"
  104769. */
  104770. getClassName(): string;
  104771. /**
  104772. * Dispose the texture and release its associated resources.
  104773. */
  104774. dispose(): void;
  104775. /**
  104776. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104777. * @param parsedTexture Define the JSON representation of the texture
  104778. * @param scene Define the scene the parsed texture should be instantiated in
  104779. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104780. * @returns The parsed texture if successful
  104781. */
  104782. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104783. /**
  104784. * Creates a texture from its base 64 representation.
  104785. * @param data Define the base64 payload without the data: prefix
  104786. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104787. * @param scene Define the scene the texture should belong to
  104788. * @param noMipmap Forces the texture to not create mip map information if true
  104789. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104790. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104791. * @param onLoad define a callback triggered when the texture has been loaded
  104792. * @param onError define a callback triggered when an error occurred during the loading session
  104793. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104794. * @returns the created texture
  104795. */
  104796. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104797. /**
  104798. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104799. * @param data Define the base64 payload without the data: prefix
  104800. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104801. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104802. * @param scene Define the scene the texture should belong to
  104803. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104804. * @param noMipmap Forces the texture to not create mip map information if true
  104805. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104806. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104807. * @param onLoad define a callback triggered when the texture has been loaded
  104808. * @param onError define a callback triggered when an error occurred during the loading session
  104809. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104810. * @returns the created texture
  104811. */
  104812. 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;
  104813. }
  104814. }
  104815. declare module BABYLON {
  104816. /**
  104817. * ThinSprite Class used to represent a thin sprite
  104818. * This is the base class for sprites but can also directly be used with ThinEngine
  104819. * @see https://doc.babylonjs.com/babylon101/sprites
  104820. */
  104821. export class ThinSprite {
  104822. /** Gets or sets the cell index in the sprite sheet */
  104823. cellIndex: number;
  104824. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104825. cellRef: string;
  104826. /** Gets or sets the current world position */
  104827. position: IVector3Like;
  104828. /** Gets or sets the main color */
  104829. color: IColor4Like;
  104830. /** Gets or sets the width */
  104831. width: number;
  104832. /** Gets or sets the height */
  104833. height: number;
  104834. /** Gets or sets rotation angle */
  104835. angle: number;
  104836. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104837. invertU: boolean;
  104838. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104839. invertV: boolean;
  104840. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104841. isVisible: boolean;
  104842. /**
  104843. * Returns a boolean indicating if the animation is started
  104844. */
  104845. get animationStarted(): boolean;
  104846. /** Gets the initial key for the animation (setting it will restart the animation) */
  104847. get fromIndex(): number;
  104848. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104849. get toIndex(): number;
  104850. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104851. get loopAnimation(): boolean;
  104852. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104853. get delay(): number;
  104854. /** @hidden */
  104855. _xOffset: number;
  104856. /** @hidden */
  104857. _yOffset: number;
  104858. /** @hidden */
  104859. _xSize: number;
  104860. /** @hidden */
  104861. _ySize: number;
  104862. private _animationStarted;
  104863. protected _loopAnimation: boolean;
  104864. protected _fromIndex: number;
  104865. protected _toIndex: number;
  104866. protected _delay: number;
  104867. private _direction;
  104868. private _time;
  104869. private _onBaseAnimationEnd;
  104870. /**
  104871. * Creates a new Thin Sprite
  104872. */
  104873. constructor();
  104874. /**
  104875. * Starts an animation
  104876. * @param from defines the initial key
  104877. * @param to defines the end key
  104878. * @param loop defines if the animation must loop
  104879. * @param delay defines the start delay (in ms)
  104880. * @param onAnimationEnd defines a callback for when the animation ends
  104881. */
  104882. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104883. /** Stops current animation (if any) */
  104884. stopAnimation(): void;
  104885. /** @hidden */
  104886. _animate(deltaTime: number): void;
  104887. }
  104888. }
  104889. declare module BABYLON {
  104890. /** @hidden */
  104891. export var imageProcessingCompatibility: {
  104892. name: string;
  104893. shader: string;
  104894. };
  104895. }
  104896. declare module BABYLON {
  104897. /** @hidden */
  104898. export var spritesPixelShader: {
  104899. name: string;
  104900. shader: string;
  104901. };
  104902. }
  104903. declare module BABYLON {
  104904. /** @hidden */
  104905. export var spritesVertexShader: {
  104906. name: string;
  104907. shader: string;
  104908. };
  104909. }
  104910. declare module BABYLON {
  104911. /**
  104912. * Class used to render sprites.
  104913. *
  104914. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104915. */
  104916. export class SpriteRenderer {
  104917. /**
  104918. * Defines the texture of the spritesheet
  104919. */
  104920. texture: Nullable<ThinTexture>;
  104921. /**
  104922. * Defines the default width of a cell in the spritesheet
  104923. */
  104924. cellWidth: number;
  104925. /**
  104926. * Defines the default height of a cell in the spritesheet
  104927. */
  104928. cellHeight: number;
  104929. /**
  104930. * Blend mode use to render the particle, it can be any of
  104931. * the static Constants.ALPHA_x properties provided in this class.
  104932. * Default value is Constants.ALPHA_COMBINE
  104933. */
  104934. blendMode: number;
  104935. /**
  104936. * Gets or sets a boolean indicating if alpha mode is automatically
  104937. * reset.
  104938. */
  104939. autoResetAlpha: boolean;
  104940. /**
  104941. * Disables writing to the depth buffer when rendering the sprites.
  104942. * It can be handy to disable depth writing when using textures without alpha channel
  104943. * and setting some specific blend modes.
  104944. */
  104945. disableDepthWrite: boolean;
  104946. /**
  104947. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  104948. */
  104949. fogEnabled: boolean;
  104950. /**
  104951. * Gets the capacity of the manager
  104952. */
  104953. get capacity(): number;
  104954. private readonly _engine;
  104955. private readonly _useVAO;
  104956. private readonly _useInstancing;
  104957. private readonly _scene;
  104958. private readonly _capacity;
  104959. private readonly _epsilon;
  104960. private _vertexBufferSize;
  104961. private _vertexData;
  104962. private _buffer;
  104963. private _vertexBuffers;
  104964. private _spriteBuffer;
  104965. private _indexBuffer;
  104966. private _effectBase;
  104967. private _effectFog;
  104968. private _vertexArrayObject;
  104969. /**
  104970. * Creates a new sprite Renderer
  104971. * @param engine defines the engine the renderer works with
  104972. * @param capacity defines the maximum allowed number of sprites
  104973. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104974. * @param scene defines the hosting scene
  104975. */
  104976. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  104977. /**
  104978. * Render all child sprites
  104979. * @param sprites defines the list of sprites to render
  104980. * @param deltaTime defines the time since last frame
  104981. * @param viewMatrix defines the viewMatrix to use to render the sprites
  104982. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  104983. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  104984. */
  104985. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  104986. private _appendSpriteVertex;
  104987. /**
  104988. * Release associated resources
  104989. */
  104990. dispose(): void;
  104991. }
  104992. }
  104993. declare module BABYLON {
  104994. /**
  104995. * Defines the minimum interface to fullfil in order to be a sprite manager.
  104996. */
  104997. export interface ISpriteManager extends IDisposable {
  104998. /**
  104999. * Gets manager's name
  105000. */
  105001. name: string;
  105002. /**
  105003. * Restricts the camera to viewing objects with the same layerMask.
  105004. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  105005. */
  105006. layerMask: number;
  105007. /**
  105008. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  105009. */
  105010. isPickable: boolean;
  105011. /**
  105012. * Gets the hosting scene
  105013. */
  105014. scene: Scene;
  105015. /**
  105016. * Specifies the rendering group id for this mesh (0 by default)
  105017. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  105018. */
  105019. renderingGroupId: number;
  105020. /**
  105021. * Defines the list of sprites managed by the manager.
  105022. */
  105023. sprites: Array<Sprite>;
  105024. /**
  105025. * Gets or sets the spritesheet texture
  105026. */
  105027. texture: Texture;
  105028. /** Defines the default width of a cell in the spritesheet */
  105029. cellWidth: number;
  105030. /** Defines the default height of a cell in the spritesheet */
  105031. cellHeight: number;
  105032. /**
  105033. * Tests the intersection of a sprite with a specific ray.
  105034. * @param ray The ray we are sending to test the collision
  105035. * @param camera The camera space we are sending rays in
  105036. * @param predicate A predicate allowing excluding sprites from the list of object to test
  105037. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105038. * @returns picking info or null.
  105039. */
  105040. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105041. /**
  105042. * Intersects the sprites with a ray
  105043. * @param ray defines the ray to intersect with
  105044. * @param camera defines the current active camera
  105045. * @param predicate defines a predicate used to select candidate sprites
  105046. * @returns null if no hit or a PickingInfo array
  105047. */
  105048. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105049. /**
  105050. * Renders the list of sprites on screen.
  105051. */
  105052. render(): void;
  105053. }
  105054. /**
  105055. * Class used to manage multiple sprites on the same spritesheet
  105056. * @see https://doc.babylonjs.com/babylon101/sprites
  105057. */
  105058. export class SpriteManager implements ISpriteManager {
  105059. /** defines the manager's name */
  105060. name: string;
  105061. /** Define the Url to load snippets */
  105062. static SnippetUrl: string;
  105063. /** Snippet ID if the manager was created from the snippet server */
  105064. snippetId: string;
  105065. /** Gets the list of sprites */
  105066. sprites: Sprite[];
  105067. /** Gets or sets the rendering group id (0 by default) */
  105068. renderingGroupId: number;
  105069. /** Gets or sets camera layer mask */
  105070. layerMask: number;
  105071. /** Gets or sets a boolean indicating if the sprites are pickable */
  105072. isPickable: boolean;
  105073. /**
  105074. * An event triggered when the manager is disposed.
  105075. */
  105076. onDisposeObservable: Observable<SpriteManager>;
  105077. /**
  105078. * Callback called when the manager is disposed
  105079. */
  105080. set onDispose(callback: () => void);
  105081. /**
  105082. * Gets or sets the unique id of the sprite
  105083. */
  105084. uniqueId: number;
  105085. /**
  105086. * Gets the array of sprites
  105087. */
  105088. get children(): Sprite[];
  105089. /**
  105090. * Gets the hosting scene
  105091. */
  105092. get scene(): Scene;
  105093. /**
  105094. * Gets the capacity of the manager
  105095. */
  105096. get capacity(): number;
  105097. /**
  105098. * Gets or sets the spritesheet texture
  105099. */
  105100. get texture(): Texture;
  105101. set texture(value: Texture);
  105102. /** Defines the default width of a cell in the spritesheet */
  105103. get cellWidth(): number;
  105104. set cellWidth(value: number);
  105105. /** Defines the default height of a cell in the spritesheet */
  105106. get cellHeight(): number;
  105107. set cellHeight(value: number);
  105108. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  105109. get fogEnabled(): boolean;
  105110. set fogEnabled(value: boolean);
  105111. /**
  105112. * Blend mode use to render the particle, it can be any of
  105113. * the static Constants.ALPHA_x properties provided in this class.
  105114. * Default value is Constants.ALPHA_COMBINE
  105115. */
  105116. get blendMode(): number;
  105117. set blendMode(blendMode: number);
  105118. /** Disables writing to the depth buffer when rendering the sprites.
  105119. * It can be handy to disable depth writing when using textures without alpha channel
  105120. * and setting some specific blend modes.
  105121. */
  105122. disableDepthWrite: boolean;
  105123. private _spriteRenderer;
  105124. /** Associative array from JSON sprite data file */
  105125. private _cellData;
  105126. /** Array of sprite names from JSON sprite data file */
  105127. private _spriteMap;
  105128. /** True when packed cell data from JSON file is ready*/
  105129. private _packedAndReady;
  105130. private _textureContent;
  105131. private _onDisposeObserver;
  105132. private _fromPacked;
  105133. private _scene;
  105134. /**
  105135. * Creates a new sprite manager
  105136. * @param name defines the manager's name
  105137. * @param imgUrl defines the sprite sheet url
  105138. * @param capacity defines the maximum allowed number of sprites
  105139. * @param cellSize defines the size of a sprite cell
  105140. * @param scene defines the hosting scene
  105141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  105142. * @param samplingMode defines the smapling mode to use with spritesheet
  105143. * @param fromPacked set to false; do not alter
  105144. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  105145. */
  105146. constructor(
  105147. /** defines the manager's name */
  105148. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  105149. /**
  105150. * Returns the string "SpriteManager"
  105151. * @returns "SpriteManager"
  105152. */
  105153. getClassName(): string;
  105154. private _makePacked;
  105155. private _checkTextureAlpha;
  105156. /**
  105157. * Intersects the sprites with a ray
  105158. * @param ray defines the ray to intersect with
  105159. * @param camera defines the current active camera
  105160. * @param predicate defines a predicate used to select candidate sprites
  105161. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  105162. * @returns null if no hit or a PickingInfo
  105163. */
  105164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105165. /**
  105166. * Intersects the sprites with a ray
  105167. * @param ray defines the ray to intersect with
  105168. * @param camera defines the current active camera
  105169. * @param predicate defines a predicate used to select candidate sprites
  105170. * @returns null if no hit or a PickingInfo array
  105171. */
  105172. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105173. /**
  105174. * Render all child sprites
  105175. */
  105176. render(): void;
  105177. private _customUpdate;
  105178. /**
  105179. * Release associated resources
  105180. */
  105181. dispose(): void;
  105182. /**
  105183. * Serializes the sprite manager to a JSON object
  105184. * @param serializeTexture defines if the texture must be serialized as well
  105185. * @returns the JSON object
  105186. */
  105187. serialize(serializeTexture?: boolean): any;
  105188. /**
  105189. * Parses a JSON object to create a new sprite manager.
  105190. * @param parsedManager The JSON object to parse
  105191. * @param scene The scene to create the sprite managerin
  105192. * @param rootUrl The root url to use to load external dependencies like texture
  105193. * @returns the new sprite manager
  105194. */
  105195. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  105196. /**
  105197. * Creates a sprite manager from a snippet saved in a remote file
  105198. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  105199. * @param url defines the url to load from
  105200. * @param scene defines the hosting scene
  105201. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105202. * @returns a promise that will resolve to the new sprite manager
  105203. */
  105204. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105205. /**
  105206. * Creates a sprite manager from a snippet saved by the sprite editor
  105207. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  105208. * @param scene defines the hosting scene
  105209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105210. * @returns a promise that will resolve to the new sprite manager
  105211. */
  105212. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105213. }
  105214. }
  105215. declare module BABYLON {
  105216. /**
  105217. * Class used to represent a sprite
  105218. * @see https://doc.babylonjs.com/babylon101/sprites
  105219. */
  105220. export class Sprite extends ThinSprite implements IAnimatable {
  105221. /** defines the name */
  105222. name: string;
  105223. /** Gets or sets the current world position */
  105224. position: Vector3;
  105225. /** Gets or sets the main color */
  105226. color: Color4;
  105227. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  105228. disposeWhenFinishedAnimating: boolean;
  105229. /** Gets the list of attached animations */
  105230. animations: Nullable<Array<Animation>>;
  105231. /** Gets or sets a boolean indicating if the sprite can be picked */
  105232. isPickable: boolean;
  105233. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  105234. useAlphaForPicking: boolean;
  105235. /**
  105236. * Gets or sets the associated action manager
  105237. */
  105238. actionManager: Nullable<ActionManager>;
  105239. /**
  105240. * An event triggered when the control has been disposed
  105241. */
  105242. onDisposeObservable: Observable<Sprite>;
  105243. private _manager;
  105244. private _onAnimationEnd;
  105245. /**
  105246. * Gets or sets the sprite size
  105247. */
  105248. get size(): number;
  105249. set size(value: number);
  105250. /**
  105251. * Gets or sets the unique id of the sprite
  105252. */
  105253. uniqueId: number;
  105254. /**
  105255. * Gets the manager of this sprite
  105256. */
  105257. get manager(): ISpriteManager;
  105258. /**
  105259. * Creates a new Sprite
  105260. * @param name defines the name
  105261. * @param manager defines the manager
  105262. */
  105263. constructor(
  105264. /** defines the name */
  105265. name: string, manager: ISpriteManager);
  105266. /**
  105267. * Returns the string "Sprite"
  105268. * @returns "Sprite"
  105269. */
  105270. getClassName(): string;
  105271. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105272. get fromIndex(): number;
  105273. set fromIndex(value: number);
  105274. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105275. get toIndex(): number;
  105276. set toIndex(value: number);
  105277. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105278. get loopAnimation(): boolean;
  105279. set loopAnimation(value: boolean);
  105280. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105281. get delay(): number;
  105282. set delay(value: number);
  105283. /**
  105284. * Starts an animation
  105285. * @param from defines the initial key
  105286. * @param to defines the end key
  105287. * @param loop defines if the animation must loop
  105288. * @param delay defines the start delay (in ms)
  105289. * @param onAnimationEnd defines a callback to call when animation ends
  105290. */
  105291. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105292. private _endAnimation;
  105293. /** Release associated resources */
  105294. dispose(): void;
  105295. /**
  105296. * Serializes the sprite to a JSON object
  105297. * @returns the JSON object
  105298. */
  105299. serialize(): any;
  105300. /**
  105301. * Parses a JSON object to create a new sprite
  105302. * @param parsedSprite The JSON object to parse
  105303. * @param manager defines the hosting manager
  105304. * @returns the new sprite
  105305. */
  105306. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. /**
  105311. * Information about the result of picking within a scene
  105312. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105313. */
  105314. export class PickingInfo {
  105315. /** @hidden */
  105316. _pickingUnavailable: boolean;
  105317. /**
  105318. * If the pick collided with an object
  105319. */
  105320. hit: boolean;
  105321. /**
  105322. * Distance away where the pick collided
  105323. */
  105324. distance: number;
  105325. /**
  105326. * The location of pick collision
  105327. */
  105328. pickedPoint: Nullable<Vector3>;
  105329. /**
  105330. * The mesh corresponding the the pick collision
  105331. */
  105332. pickedMesh: Nullable<AbstractMesh>;
  105333. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105334. bu: number;
  105335. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105336. bv: number;
  105337. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105338. faceId: number;
  105339. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105340. subMeshFaceId: number;
  105341. /** Id of the the submesh that was picked */
  105342. subMeshId: number;
  105343. /** If a sprite was picked, this will be the sprite the pick collided with */
  105344. pickedSprite: Nullable<Sprite>;
  105345. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105346. thinInstanceIndex: number;
  105347. /**
  105348. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105349. */
  105350. originMesh: Nullable<AbstractMesh>;
  105351. /**
  105352. * The ray that was used to perform the picking.
  105353. */
  105354. ray: Nullable<Ray>;
  105355. /**
  105356. * Gets the normal correspodning to the face the pick collided with
  105357. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105358. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105359. * @returns The normal correspodning to the face the pick collided with
  105360. */
  105361. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105362. /**
  105363. * Gets the texture coordinates of where the pick occured
  105364. * @returns the vector containing the coordnates of the texture
  105365. */
  105366. getTextureCoordinates(): Nullable<Vector2>;
  105367. }
  105368. }
  105369. declare module BABYLON {
  105370. /**
  105371. * Gather the list of pointer event types as constants.
  105372. */
  105373. export class PointerEventTypes {
  105374. /**
  105375. * 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.
  105376. */
  105377. static readonly POINTERDOWN: number;
  105378. /**
  105379. * The pointerup event is fired when a pointer is no longer active.
  105380. */
  105381. static readonly POINTERUP: number;
  105382. /**
  105383. * The pointermove event is fired when a pointer changes coordinates.
  105384. */
  105385. static readonly POINTERMOVE: number;
  105386. /**
  105387. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105388. */
  105389. static readonly POINTERWHEEL: number;
  105390. /**
  105391. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105392. */
  105393. static readonly POINTERPICK: number;
  105394. /**
  105395. * The pointertap event is fired when a the object has been touched and released without drag.
  105396. */
  105397. static readonly POINTERTAP: number;
  105398. /**
  105399. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105400. */
  105401. static readonly POINTERDOUBLETAP: number;
  105402. }
  105403. /**
  105404. * Base class of pointer info types.
  105405. */
  105406. export class PointerInfoBase {
  105407. /**
  105408. * Defines the type of event (PointerEventTypes)
  105409. */
  105410. type: number;
  105411. /**
  105412. * Defines the related dom event
  105413. */
  105414. event: PointerEvent | MouseWheelEvent;
  105415. /**
  105416. * Instantiates the base class of pointers info.
  105417. * @param type Defines the type of event (PointerEventTypes)
  105418. * @param event Defines the related dom event
  105419. */
  105420. constructor(
  105421. /**
  105422. * Defines the type of event (PointerEventTypes)
  105423. */
  105424. type: number,
  105425. /**
  105426. * Defines the related dom event
  105427. */
  105428. event: PointerEvent | MouseWheelEvent);
  105429. }
  105430. /**
  105431. * This class is used to store pointer related info for the onPrePointerObservable event.
  105432. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105433. */
  105434. export class PointerInfoPre extends PointerInfoBase {
  105435. /**
  105436. * Ray from a pointer if availible (eg. 6dof controller)
  105437. */
  105438. ray: Nullable<Ray>;
  105439. /**
  105440. * Defines the local position of the pointer on the canvas.
  105441. */
  105442. localPosition: Vector2;
  105443. /**
  105444. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105445. */
  105446. skipOnPointerObservable: boolean;
  105447. /**
  105448. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105449. * @param type Defines the type of event (PointerEventTypes)
  105450. * @param event Defines the related dom event
  105451. * @param localX Defines the local x coordinates of the pointer when the event occured
  105452. * @param localY Defines the local y coordinates of the pointer when the event occured
  105453. */
  105454. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105455. }
  105456. /**
  105457. * This type contains all the data related to a pointer event in Babylon.js.
  105458. * 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.
  105459. */
  105460. export class PointerInfo extends PointerInfoBase {
  105461. /**
  105462. * Defines the picking info associated to the info (if any)\
  105463. */
  105464. pickInfo: Nullable<PickingInfo>;
  105465. /**
  105466. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105467. * @param type Defines the type of event (PointerEventTypes)
  105468. * @param event Defines the related dom event
  105469. * @param pickInfo Defines the picking info associated to the info (if any)\
  105470. */
  105471. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105472. /**
  105473. * Defines the picking info associated to the info (if any)\
  105474. */
  105475. pickInfo: Nullable<PickingInfo>);
  105476. }
  105477. /**
  105478. * Data relating to a touch event on the screen.
  105479. */
  105480. export interface PointerTouch {
  105481. /**
  105482. * X coordinate of touch.
  105483. */
  105484. x: number;
  105485. /**
  105486. * Y coordinate of touch.
  105487. */
  105488. y: number;
  105489. /**
  105490. * Id of touch. Unique for each finger.
  105491. */
  105492. pointerId: number;
  105493. /**
  105494. * Event type passed from DOM.
  105495. */
  105496. type: any;
  105497. }
  105498. }
  105499. declare module BABYLON {
  105500. /**
  105501. * Manage the mouse inputs to control the movement of a free camera.
  105502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105503. */
  105504. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105505. /**
  105506. * Define if touch is enabled in the mouse input
  105507. */
  105508. touchEnabled: boolean;
  105509. /**
  105510. * Defines the camera the input is attached to.
  105511. */
  105512. camera: FreeCamera;
  105513. /**
  105514. * Defines the buttons associated with the input to handle camera move.
  105515. */
  105516. buttons: number[];
  105517. /**
  105518. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105519. */
  105520. angularSensibility: number;
  105521. private _pointerInput;
  105522. private _onMouseMove;
  105523. private _observer;
  105524. private previousPosition;
  105525. /**
  105526. * Observable for when a pointer move event occurs containing the move offset
  105527. */
  105528. onPointerMovedObservable: Observable<{
  105529. offsetX: number;
  105530. offsetY: number;
  105531. }>;
  105532. /**
  105533. * @hidden
  105534. * If the camera should be rotated automatically based on pointer movement
  105535. */
  105536. _allowCameraRotation: boolean;
  105537. /**
  105538. * Manage the mouse inputs to control the movement of a free camera.
  105539. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105540. * @param touchEnabled Defines if touch is enabled or not
  105541. */
  105542. constructor(
  105543. /**
  105544. * Define if touch is enabled in the mouse input
  105545. */
  105546. touchEnabled?: boolean);
  105547. /**
  105548. * Attach the input controls to a specific dom element to get the input from.
  105549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105550. */
  105551. attachControl(noPreventDefault?: boolean): void;
  105552. /**
  105553. * Called on JS contextmenu event.
  105554. * Override this method to provide functionality.
  105555. */
  105556. protected onContextMenu(evt: PointerEvent): void;
  105557. /**
  105558. * Detach the current controls from the specified dom element.
  105559. */
  105560. detachControl(): void;
  105561. /**
  105562. * Gets the class name of the current intput.
  105563. * @returns the class name
  105564. */
  105565. getClassName(): string;
  105566. /**
  105567. * Get the friendly name associated with the input class.
  105568. * @returns the input friendly name
  105569. */
  105570. getSimpleName(): string;
  105571. }
  105572. }
  105573. declare module BABYLON {
  105574. /**
  105575. * Base class for mouse wheel input..
  105576. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105577. * for example usage.
  105578. */
  105579. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105580. /**
  105581. * Defines the camera the input is attached to.
  105582. */
  105583. abstract camera: Camera;
  105584. /**
  105585. * How fast is the camera moves in relation to X axis mouseWheel events.
  105586. * Use negative value to reverse direction.
  105587. */
  105588. wheelPrecisionX: number;
  105589. /**
  105590. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105591. * Use negative value to reverse direction.
  105592. */
  105593. wheelPrecisionY: number;
  105594. /**
  105595. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105596. * Use negative value to reverse direction.
  105597. */
  105598. wheelPrecisionZ: number;
  105599. /**
  105600. * Observable for when a mouse wheel move event occurs.
  105601. */
  105602. onChangedObservable: Observable<{
  105603. wheelDeltaX: number;
  105604. wheelDeltaY: number;
  105605. wheelDeltaZ: number;
  105606. }>;
  105607. private _wheel;
  105608. private _observer;
  105609. /**
  105610. * Attach the input controls to a specific dom element to get the input from.
  105611. * @param noPreventDefault Defines whether event caught by the controls
  105612. * should call preventdefault().
  105613. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105614. */
  105615. attachControl(noPreventDefault?: boolean): void;
  105616. /**
  105617. * Detach the current controls from the specified dom element.
  105618. */
  105619. detachControl(): void;
  105620. /**
  105621. * Called for each rendered frame.
  105622. */
  105623. checkInputs(): void;
  105624. /**
  105625. * Gets the class name of the current intput.
  105626. * @returns the class name
  105627. */
  105628. getClassName(): string;
  105629. /**
  105630. * Get the friendly name associated with the input class.
  105631. * @returns the input friendly name
  105632. */
  105633. getSimpleName(): string;
  105634. /**
  105635. * Incremental value of multiple mouse wheel movements of the X axis.
  105636. * Should be zero-ed when read.
  105637. */
  105638. protected _wheelDeltaX: number;
  105639. /**
  105640. * Incremental value of multiple mouse wheel movements of the Y axis.
  105641. * Should be zero-ed when read.
  105642. */
  105643. protected _wheelDeltaY: number;
  105644. /**
  105645. * Incremental value of multiple mouse wheel movements of the Z axis.
  105646. * Should be zero-ed when read.
  105647. */
  105648. protected _wheelDeltaZ: number;
  105649. /**
  105650. * Firefox uses a different scheme to report scroll distances to other
  105651. * browsers. Rather than use complicated methods to calculate the exact
  105652. * multiple we need to apply, let's just cheat and use a constant.
  105653. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105654. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105655. */
  105656. private readonly _ffMultiplier;
  105657. /**
  105658. * Different event attributes for wheel data fall into a few set ranges.
  105659. * Some relevant but dated date here:
  105660. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105661. */
  105662. private readonly _normalize;
  105663. }
  105664. }
  105665. declare module BABYLON {
  105666. /**
  105667. * Manage the mouse wheel inputs to control a free camera.
  105668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105669. */
  105670. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105671. /**
  105672. * Defines the camera the input is attached to.
  105673. */
  105674. camera: FreeCamera;
  105675. /**
  105676. * Gets the class name of the current input.
  105677. * @returns the class name
  105678. */
  105679. getClassName(): string;
  105680. /**
  105681. * Set which movement axis (relative to camera's orientation) the mouse
  105682. * wheel's X axis controls.
  105683. * @param axis The axis to be moved. Set null to clear.
  105684. */
  105685. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105686. /**
  105687. * Get the configured movement axis (relative to camera's orientation) the
  105688. * mouse wheel's X axis controls.
  105689. * @returns The configured axis or null if none.
  105690. */
  105691. get wheelXMoveRelative(): Nullable<Coordinate>;
  105692. /**
  105693. * Set which movement axis (relative to camera's orientation) the mouse
  105694. * wheel's Y axis controls.
  105695. * @param axis The axis to be moved. Set null to clear.
  105696. */
  105697. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105698. /**
  105699. * Get the configured movement axis (relative to camera's orientation) the
  105700. * mouse wheel's Y axis controls.
  105701. * @returns The configured axis or null if none.
  105702. */
  105703. get wheelYMoveRelative(): Nullable<Coordinate>;
  105704. /**
  105705. * Set which movement axis (relative to camera's orientation) the mouse
  105706. * wheel's Z axis controls.
  105707. * @param axis The axis to be moved. Set null to clear.
  105708. */
  105709. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105710. /**
  105711. * Get the configured movement axis (relative to camera's orientation) the
  105712. * mouse wheel's Z axis controls.
  105713. * @returns The configured axis or null if none.
  105714. */
  105715. get wheelZMoveRelative(): Nullable<Coordinate>;
  105716. /**
  105717. * Set which rotation axis (relative to camera's orientation) the mouse
  105718. * wheel's X axis controls.
  105719. * @param axis The axis to be moved. Set null to clear.
  105720. */
  105721. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105722. /**
  105723. * Get the configured rotation axis (relative to camera's orientation) the
  105724. * mouse wheel's X axis controls.
  105725. * @returns The configured axis or null if none.
  105726. */
  105727. get wheelXRotateRelative(): Nullable<Coordinate>;
  105728. /**
  105729. * Set which rotation axis (relative to camera's orientation) the mouse
  105730. * wheel's Y axis controls.
  105731. * @param axis The axis to be moved. Set null to clear.
  105732. */
  105733. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105734. /**
  105735. * Get the configured rotation axis (relative to camera's orientation) the
  105736. * mouse wheel's Y axis controls.
  105737. * @returns The configured axis or null if none.
  105738. */
  105739. get wheelYRotateRelative(): Nullable<Coordinate>;
  105740. /**
  105741. * Set which rotation axis (relative to camera's orientation) the mouse
  105742. * wheel's Z axis controls.
  105743. * @param axis The axis to be moved. Set null to clear.
  105744. */
  105745. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105746. /**
  105747. * Get the configured rotation axis (relative to camera's orientation) the
  105748. * mouse wheel's Z axis controls.
  105749. * @returns The configured axis or null if none.
  105750. */
  105751. get wheelZRotateRelative(): Nullable<Coordinate>;
  105752. /**
  105753. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105754. * controls.
  105755. * @param axis The axis to be moved. Set null to clear.
  105756. */
  105757. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105758. /**
  105759. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105760. * X axis controls.
  105761. * @returns The configured axis or null if none.
  105762. */
  105763. get wheelXMoveScene(): Nullable<Coordinate>;
  105764. /**
  105765. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105766. * controls.
  105767. * @param axis The axis to be moved. Set null to clear.
  105768. */
  105769. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105770. /**
  105771. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105772. * Y axis controls.
  105773. * @returns The configured axis or null if none.
  105774. */
  105775. get wheelYMoveScene(): Nullable<Coordinate>;
  105776. /**
  105777. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105778. * controls.
  105779. * @param axis The axis to be moved. Set null to clear.
  105780. */
  105781. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105782. /**
  105783. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105784. * Z axis controls.
  105785. * @returns The configured axis or null if none.
  105786. */
  105787. get wheelZMoveScene(): Nullable<Coordinate>;
  105788. /**
  105789. * Called for each rendered frame.
  105790. */
  105791. checkInputs(): void;
  105792. private _moveRelative;
  105793. private _rotateRelative;
  105794. private _moveScene;
  105795. /**
  105796. * These are set to the desired default behaviour.
  105797. */
  105798. private _wheelXAction;
  105799. private _wheelXActionCoordinate;
  105800. private _wheelYAction;
  105801. private _wheelYActionCoordinate;
  105802. private _wheelZAction;
  105803. private _wheelZActionCoordinate;
  105804. /**
  105805. * Update the camera according to any configured properties for the 3
  105806. * mouse-wheel axis.
  105807. */
  105808. private _updateCamera;
  105809. }
  105810. }
  105811. declare module BABYLON {
  105812. /**
  105813. * Manage the touch inputs to control the movement of a free camera.
  105814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105815. */
  105816. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105817. /**
  105818. * Define if mouse events can be treated as touch events
  105819. */
  105820. allowMouse: boolean;
  105821. /**
  105822. * Defines the camera the input is attached to.
  105823. */
  105824. camera: FreeCamera;
  105825. /**
  105826. * Defines the touch sensibility for rotation.
  105827. * The higher the faster.
  105828. */
  105829. touchAngularSensibility: number;
  105830. /**
  105831. * Defines the touch sensibility for move.
  105832. * The higher the faster.
  105833. */
  105834. touchMoveSensibility: number;
  105835. private _offsetX;
  105836. private _offsetY;
  105837. private _pointerPressed;
  105838. private _pointerInput?;
  105839. private _observer;
  105840. private _onLostFocus;
  105841. /**
  105842. * Manage the touch inputs to control the movement of a free camera.
  105843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105844. * @param allowMouse Defines if mouse events can be treated as touch events
  105845. */
  105846. constructor(
  105847. /**
  105848. * Define if mouse events can be treated as touch events
  105849. */
  105850. allowMouse?: boolean);
  105851. /**
  105852. * Attach the input controls to a specific dom element to get the input from.
  105853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105854. */
  105855. attachControl(noPreventDefault?: boolean): void;
  105856. /**
  105857. * Detach the current controls from the specified dom element.
  105858. */
  105859. detachControl(): void;
  105860. /**
  105861. * Update the current camera state depending on the inputs that have been used this frame.
  105862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105863. */
  105864. checkInputs(): void;
  105865. /**
  105866. * Gets the class name of the current intput.
  105867. * @returns the class name
  105868. */
  105869. getClassName(): string;
  105870. /**
  105871. * Get the friendly name associated with the input class.
  105872. * @returns the input friendly name
  105873. */
  105874. getSimpleName(): string;
  105875. }
  105876. }
  105877. declare module BABYLON {
  105878. /**
  105879. * Default Inputs manager for the FreeCamera.
  105880. * It groups all the default supported inputs for ease of use.
  105881. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105882. */
  105883. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105884. /**
  105885. * @hidden
  105886. */
  105887. _mouseInput: Nullable<FreeCameraMouseInput>;
  105888. /**
  105889. * @hidden
  105890. */
  105891. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105892. /**
  105893. * Instantiates a new FreeCameraInputsManager.
  105894. * @param camera Defines the camera the inputs belong to
  105895. */
  105896. constructor(camera: FreeCamera);
  105897. /**
  105898. * Add keyboard input support to the input manager.
  105899. * @returns the current input manager
  105900. */
  105901. addKeyboard(): FreeCameraInputsManager;
  105902. /**
  105903. * Add mouse input support to the input manager.
  105904. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105905. * @returns the current input manager
  105906. */
  105907. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105908. /**
  105909. * Removes the mouse input support from the manager
  105910. * @returns the current input manager
  105911. */
  105912. removeMouse(): FreeCameraInputsManager;
  105913. /**
  105914. * Add mouse wheel input support to the input manager.
  105915. * @returns the current input manager
  105916. */
  105917. addMouseWheel(): FreeCameraInputsManager;
  105918. /**
  105919. * Removes the mouse wheel input support from the manager
  105920. * @returns the current input manager
  105921. */
  105922. removeMouseWheel(): FreeCameraInputsManager;
  105923. /**
  105924. * Add touch input support to the input manager.
  105925. * @returns the current input manager
  105926. */
  105927. addTouch(): FreeCameraInputsManager;
  105928. /**
  105929. * Remove all attached input methods from a camera
  105930. */
  105931. clear(): void;
  105932. }
  105933. }
  105934. declare module BABYLON {
  105935. /**
  105936. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105937. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  105938. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105939. */
  105940. export class FreeCamera extends TargetCamera {
  105941. /**
  105942. * Define the collision ellipsoid of the camera.
  105943. * This is helpful to simulate a camera body like the player body around the camera
  105944. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105945. */
  105946. ellipsoid: Vector3;
  105947. /**
  105948. * Define an offset for the position of the ellipsoid around the camera.
  105949. * This can be helpful to determine the center of the body near the gravity center of the body
  105950. * instead of its head.
  105951. */
  105952. ellipsoidOffset: Vector3;
  105953. /**
  105954. * Enable or disable collisions of the camera with the rest of the scene objects.
  105955. */
  105956. checkCollisions: boolean;
  105957. /**
  105958. * Enable or disable gravity on the camera.
  105959. */
  105960. applyGravity: boolean;
  105961. /**
  105962. * Define the input manager associated to the camera.
  105963. */
  105964. inputs: FreeCameraInputsManager;
  105965. /**
  105966. * Gets the input sensibility for a mouse input. (default is 2000.0)
  105967. * Higher values reduce sensitivity.
  105968. */
  105969. get angularSensibility(): number;
  105970. /**
  105971. * Sets the input sensibility for a mouse input. (default is 2000.0)
  105972. * Higher values reduce sensitivity.
  105973. */
  105974. set angularSensibility(value: number);
  105975. /**
  105976. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  105977. */
  105978. get keysUp(): number[];
  105979. set keysUp(value: number[]);
  105980. /**
  105981. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  105982. */
  105983. get keysUpward(): number[];
  105984. set keysUpward(value: number[]);
  105985. /**
  105986. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  105987. */
  105988. get keysDown(): number[];
  105989. set keysDown(value: number[]);
  105990. /**
  105991. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  105992. */
  105993. get keysDownward(): number[];
  105994. set keysDownward(value: number[]);
  105995. /**
  105996. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  105997. */
  105998. get keysLeft(): number[];
  105999. set keysLeft(value: number[]);
  106000. /**
  106001. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  106002. */
  106003. get keysRight(): number[];
  106004. set keysRight(value: number[]);
  106005. /**
  106006. * Event raised when the camera collide with a mesh in the scene.
  106007. */
  106008. onCollide: (collidedMesh: AbstractMesh) => void;
  106009. private _collider;
  106010. private _needMoveForGravity;
  106011. private _oldPosition;
  106012. private _diffPosition;
  106013. private _newPosition;
  106014. /** @hidden */
  106015. _localDirection: Vector3;
  106016. /** @hidden */
  106017. _transformedDirection: Vector3;
  106018. /**
  106019. * Instantiates a Free Camera.
  106020. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106021. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  106022. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  106023. * @param name Define the name of the camera in the scene
  106024. * @param position Define the start position of the camera in the scene
  106025. * @param scene Define the scene the camera belongs to
  106026. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  106027. */
  106028. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106029. /**
  106030. * Attach the input controls to a specific dom element to get the input from.
  106031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106032. */
  106033. attachControl(noPreventDefault?: boolean): void;
  106034. /**
  106035. * Attach the input controls to a specific dom element to get the input from.
  106036. * @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
  106037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106038. * BACK COMPAT SIGNATURE ONLY.
  106039. */
  106040. attachControl(ignored: any, noPreventDefault?: boolean): void;
  106041. /**
  106042. * Detach the current controls from the specified dom element.
  106043. */
  106044. detachControl(): void;
  106045. /**
  106046. * Detach the current controls from the specified dom element.
  106047. * @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
  106048. */
  106049. detachControl(ignored: any): void;
  106050. private _collisionMask;
  106051. /**
  106052. * Define a collision mask to limit the list of object the camera can collide with
  106053. */
  106054. get collisionMask(): number;
  106055. set collisionMask(mask: number);
  106056. /** @hidden */
  106057. _collideWithWorld(displacement: Vector3): void;
  106058. private _onCollisionPositionChange;
  106059. /** @hidden */
  106060. _checkInputs(): void;
  106061. /** @hidden */
  106062. _decideIfNeedsToMove(): boolean;
  106063. /** @hidden */
  106064. _updatePosition(): void;
  106065. /**
  106066. * Destroy the camera and release the current resources hold by it.
  106067. */
  106068. dispose(): void;
  106069. /**
  106070. * Gets the current object class name.
  106071. * @return the class name
  106072. */
  106073. getClassName(): string;
  106074. }
  106075. }
  106076. declare module BABYLON {
  106077. /**
  106078. * Represents a gamepad control stick position
  106079. */
  106080. export class StickValues {
  106081. /**
  106082. * The x component of the control stick
  106083. */
  106084. x: number;
  106085. /**
  106086. * The y component of the control stick
  106087. */
  106088. y: number;
  106089. /**
  106090. * Initializes the gamepad x and y control stick values
  106091. * @param x The x component of the gamepad control stick value
  106092. * @param y The y component of the gamepad control stick value
  106093. */
  106094. constructor(
  106095. /**
  106096. * The x component of the control stick
  106097. */
  106098. x: number,
  106099. /**
  106100. * The y component of the control stick
  106101. */
  106102. y: number);
  106103. }
  106104. /**
  106105. * An interface which manages callbacks for gamepad button changes
  106106. */
  106107. export interface GamepadButtonChanges {
  106108. /**
  106109. * Called when a gamepad has been changed
  106110. */
  106111. changed: boolean;
  106112. /**
  106113. * Called when a gamepad press event has been triggered
  106114. */
  106115. pressChanged: boolean;
  106116. /**
  106117. * Called when a touch event has been triggered
  106118. */
  106119. touchChanged: boolean;
  106120. /**
  106121. * Called when a value has changed
  106122. */
  106123. valueChanged: boolean;
  106124. }
  106125. /**
  106126. * Represents a gamepad
  106127. */
  106128. export class Gamepad {
  106129. /**
  106130. * The id of the gamepad
  106131. */
  106132. id: string;
  106133. /**
  106134. * The index of the gamepad
  106135. */
  106136. index: number;
  106137. /**
  106138. * The browser gamepad
  106139. */
  106140. browserGamepad: any;
  106141. /**
  106142. * Specifies what type of gamepad this represents
  106143. */
  106144. type: number;
  106145. private _leftStick;
  106146. private _rightStick;
  106147. /** @hidden */
  106148. _isConnected: boolean;
  106149. private _leftStickAxisX;
  106150. private _leftStickAxisY;
  106151. private _rightStickAxisX;
  106152. private _rightStickAxisY;
  106153. /**
  106154. * Triggered when the left control stick has been changed
  106155. */
  106156. private _onleftstickchanged;
  106157. /**
  106158. * Triggered when the right control stick has been changed
  106159. */
  106160. private _onrightstickchanged;
  106161. /**
  106162. * Represents a gamepad controller
  106163. */
  106164. static GAMEPAD: number;
  106165. /**
  106166. * Represents a generic controller
  106167. */
  106168. static GENERIC: number;
  106169. /**
  106170. * Represents an XBox controller
  106171. */
  106172. static XBOX: number;
  106173. /**
  106174. * Represents a pose-enabled controller
  106175. */
  106176. static POSE_ENABLED: number;
  106177. /**
  106178. * Represents an Dual Shock controller
  106179. */
  106180. static DUALSHOCK: number;
  106181. /**
  106182. * Specifies whether the left control stick should be Y-inverted
  106183. */
  106184. protected _invertLeftStickY: boolean;
  106185. /**
  106186. * Specifies if the gamepad has been connected
  106187. */
  106188. get isConnected(): boolean;
  106189. /**
  106190. * Initializes the gamepad
  106191. * @param id The id of the gamepad
  106192. * @param index The index of the gamepad
  106193. * @param browserGamepad The browser gamepad
  106194. * @param leftStickX The x component of the left joystick
  106195. * @param leftStickY The y component of the left joystick
  106196. * @param rightStickX The x component of the right joystick
  106197. * @param rightStickY The y component of the right joystick
  106198. */
  106199. constructor(
  106200. /**
  106201. * The id of the gamepad
  106202. */
  106203. id: string,
  106204. /**
  106205. * The index of the gamepad
  106206. */
  106207. index: number,
  106208. /**
  106209. * The browser gamepad
  106210. */
  106211. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  106212. /**
  106213. * Callback triggered when the left joystick has changed
  106214. * @param callback
  106215. */
  106216. onleftstickchanged(callback: (values: StickValues) => void): void;
  106217. /**
  106218. * Callback triggered when the right joystick has changed
  106219. * @param callback
  106220. */
  106221. onrightstickchanged(callback: (values: StickValues) => void): void;
  106222. /**
  106223. * Gets the left joystick
  106224. */
  106225. get leftStick(): StickValues;
  106226. /**
  106227. * Sets the left joystick values
  106228. */
  106229. set leftStick(newValues: StickValues);
  106230. /**
  106231. * Gets the right joystick
  106232. */
  106233. get rightStick(): StickValues;
  106234. /**
  106235. * Sets the right joystick value
  106236. */
  106237. set rightStick(newValues: StickValues);
  106238. /**
  106239. * Updates the gamepad joystick positions
  106240. */
  106241. update(): void;
  106242. /**
  106243. * Disposes the gamepad
  106244. */
  106245. dispose(): void;
  106246. }
  106247. /**
  106248. * Represents a generic gamepad
  106249. */
  106250. export class GenericPad extends Gamepad {
  106251. private _buttons;
  106252. private _onbuttondown;
  106253. private _onbuttonup;
  106254. /**
  106255. * Observable triggered when a button has been pressed
  106256. */
  106257. onButtonDownObservable: Observable<number>;
  106258. /**
  106259. * Observable triggered when a button has been released
  106260. */
  106261. onButtonUpObservable: Observable<number>;
  106262. /**
  106263. * Callback triggered when a button has been pressed
  106264. * @param callback Called when a button has been pressed
  106265. */
  106266. onbuttondown(callback: (buttonPressed: number) => void): void;
  106267. /**
  106268. * Callback triggered when a button has been released
  106269. * @param callback Called when a button has been released
  106270. */
  106271. onbuttonup(callback: (buttonReleased: number) => void): void;
  106272. /**
  106273. * Initializes the generic gamepad
  106274. * @param id The id of the generic gamepad
  106275. * @param index The index of the generic gamepad
  106276. * @param browserGamepad The browser gamepad
  106277. */
  106278. constructor(id: string, index: number, browserGamepad: any);
  106279. private _setButtonValue;
  106280. /**
  106281. * Updates the generic gamepad
  106282. */
  106283. update(): void;
  106284. /**
  106285. * Disposes the generic gamepad
  106286. */
  106287. dispose(): void;
  106288. }
  106289. }
  106290. declare module BABYLON {
  106291. /**
  106292. * Defines a runtime animation
  106293. */
  106294. export class RuntimeAnimation {
  106295. private _events;
  106296. /**
  106297. * The current frame of the runtime animation
  106298. */
  106299. private _currentFrame;
  106300. /**
  106301. * The animation used by the runtime animation
  106302. */
  106303. private _animation;
  106304. /**
  106305. * The target of the runtime animation
  106306. */
  106307. private _target;
  106308. /**
  106309. * The initiating animatable
  106310. */
  106311. private _host;
  106312. /**
  106313. * The original value of the runtime animation
  106314. */
  106315. private _originalValue;
  106316. /**
  106317. * The original blend value of the runtime animation
  106318. */
  106319. private _originalBlendValue;
  106320. /**
  106321. * The offsets cache of the runtime animation
  106322. */
  106323. private _offsetsCache;
  106324. /**
  106325. * The high limits cache of the runtime animation
  106326. */
  106327. private _highLimitsCache;
  106328. /**
  106329. * Specifies if the runtime animation has been stopped
  106330. */
  106331. private _stopped;
  106332. /**
  106333. * The blending factor of the runtime animation
  106334. */
  106335. private _blendingFactor;
  106336. /**
  106337. * The BabylonJS scene
  106338. */
  106339. private _scene;
  106340. /**
  106341. * The current value of the runtime animation
  106342. */
  106343. private _currentValue;
  106344. /** @hidden */
  106345. _animationState: _IAnimationState;
  106346. /**
  106347. * The active target of the runtime animation
  106348. */
  106349. private _activeTargets;
  106350. private _currentActiveTarget;
  106351. private _directTarget;
  106352. /**
  106353. * The target path of the runtime animation
  106354. */
  106355. private _targetPath;
  106356. /**
  106357. * The weight of the runtime animation
  106358. */
  106359. private _weight;
  106360. /**
  106361. * The ratio offset of the runtime animation
  106362. */
  106363. private _ratioOffset;
  106364. /**
  106365. * The previous delay of the runtime animation
  106366. */
  106367. private _previousDelay;
  106368. /**
  106369. * The previous ratio of the runtime animation
  106370. */
  106371. private _previousRatio;
  106372. private _enableBlending;
  106373. private _keys;
  106374. private _minFrame;
  106375. private _maxFrame;
  106376. private _minValue;
  106377. private _maxValue;
  106378. private _targetIsArray;
  106379. /**
  106380. * Gets the current frame of the runtime animation
  106381. */
  106382. get currentFrame(): number;
  106383. /**
  106384. * Gets the weight of the runtime animation
  106385. */
  106386. get weight(): number;
  106387. /**
  106388. * Gets the current value of the runtime animation
  106389. */
  106390. get currentValue(): any;
  106391. /**
  106392. * Gets the target path of the runtime animation
  106393. */
  106394. get targetPath(): string;
  106395. /**
  106396. * Gets the actual target of the runtime animation
  106397. */
  106398. get target(): any;
  106399. /**
  106400. * Gets the additive state of the runtime animation
  106401. */
  106402. get isAdditive(): boolean;
  106403. /** @hidden */
  106404. _onLoop: () => void;
  106405. /**
  106406. * Create a new RuntimeAnimation object
  106407. * @param target defines the target of the animation
  106408. * @param animation defines the source animation object
  106409. * @param scene defines the hosting scene
  106410. * @param host defines the initiating Animatable
  106411. */
  106412. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106413. private _preparePath;
  106414. /**
  106415. * Gets the animation from the runtime animation
  106416. */
  106417. get animation(): Animation;
  106418. /**
  106419. * Resets the runtime animation to the beginning
  106420. * @param restoreOriginal defines whether to restore the target property to the original value
  106421. */
  106422. reset(restoreOriginal?: boolean): void;
  106423. /**
  106424. * Specifies if the runtime animation is stopped
  106425. * @returns Boolean specifying if the runtime animation is stopped
  106426. */
  106427. isStopped(): boolean;
  106428. /**
  106429. * Disposes of the runtime animation
  106430. */
  106431. dispose(): void;
  106432. /**
  106433. * Apply the interpolated value to the target
  106434. * @param currentValue defines the value computed by the animation
  106435. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106436. */
  106437. setValue(currentValue: any, weight: number): void;
  106438. private _getOriginalValues;
  106439. private _setValue;
  106440. /**
  106441. * Gets the loop pmode of the runtime animation
  106442. * @returns Loop Mode
  106443. */
  106444. private _getCorrectLoopMode;
  106445. /**
  106446. * Move the current animation to a given frame
  106447. * @param frame defines the frame to move to
  106448. */
  106449. goToFrame(frame: number): void;
  106450. /**
  106451. * @hidden Internal use only
  106452. */
  106453. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106454. /**
  106455. * Execute the current animation
  106456. * @param delay defines the delay to add to the current frame
  106457. * @param from defines the lower bound of the animation range
  106458. * @param to defines the upper bound of the animation range
  106459. * @param loop defines if the current animation must loop
  106460. * @param speedRatio defines the current speed ratio
  106461. * @param weight defines the weight of the animation (default is -1 so no weight)
  106462. * @param onLoop optional callback called when animation loops
  106463. * @returns a boolean indicating if the animation is running
  106464. */
  106465. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106466. }
  106467. }
  106468. declare module BABYLON {
  106469. /**
  106470. * Class used to store an actual running animation
  106471. */
  106472. export class Animatable {
  106473. /** defines the target object */
  106474. target: any;
  106475. /** defines the starting frame number (default is 0) */
  106476. fromFrame: number;
  106477. /** defines the ending frame number (default is 100) */
  106478. toFrame: number;
  106479. /** defines if the animation must loop (default is false) */
  106480. loopAnimation: boolean;
  106481. /** defines a callback to call when animation ends if it is not looping */
  106482. onAnimationEnd?: (() => void) | null | undefined;
  106483. /** defines a callback to call when animation loops */
  106484. onAnimationLoop?: (() => void) | null | undefined;
  106485. /** defines whether the animation should be evaluated additively */
  106486. isAdditive: boolean;
  106487. private _localDelayOffset;
  106488. private _pausedDelay;
  106489. private _runtimeAnimations;
  106490. private _paused;
  106491. private _scene;
  106492. private _speedRatio;
  106493. private _weight;
  106494. private _syncRoot;
  106495. /**
  106496. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106497. * This will only apply for non looping animation (default is true)
  106498. */
  106499. disposeOnEnd: boolean;
  106500. /**
  106501. * Gets a boolean indicating if the animation has started
  106502. */
  106503. animationStarted: boolean;
  106504. /**
  106505. * Observer raised when the animation ends
  106506. */
  106507. onAnimationEndObservable: Observable<Animatable>;
  106508. /**
  106509. * Observer raised when the animation loops
  106510. */
  106511. onAnimationLoopObservable: Observable<Animatable>;
  106512. /**
  106513. * Gets the root Animatable used to synchronize and normalize animations
  106514. */
  106515. get syncRoot(): Nullable<Animatable>;
  106516. /**
  106517. * Gets the current frame of the first RuntimeAnimation
  106518. * Used to synchronize Animatables
  106519. */
  106520. get masterFrame(): number;
  106521. /**
  106522. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106523. */
  106524. get weight(): number;
  106525. set weight(value: number);
  106526. /**
  106527. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106528. */
  106529. get speedRatio(): number;
  106530. set speedRatio(value: number);
  106531. /**
  106532. * Creates a new Animatable
  106533. * @param scene defines the hosting scene
  106534. * @param target defines the target object
  106535. * @param fromFrame defines the starting frame number (default is 0)
  106536. * @param toFrame defines the ending frame number (default is 100)
  106537. * @param loopAnimation defines if the animation must loop (default is false)
  106538. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106539. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106540. * @param animations defines a group of animation to add to the new Animatable
  106541. * @param onAnimationLoop defines a callback to call when animation loops
  106542. * @param isAdditive defines whether the animation should be evaluated additively
  106543. */
  106544. constructor(scene: Scene,
  106545. /** defines the target object */
  106546. target: any,
  106547. /** defines the starting frame number (default is 0) */
  106548. fromFrame?: number,
  106549. /** defines the ending frame number (default is 100) */
  106550. toFrame?: number,
  106551. /** defines if the animation must loop (default is false) */
  106552. loopAnimation?: boolean, speedRatio?: number,
  106553. /** defines a callback to call when animation ends if it is not looping */
  106554. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106555. /** defines a callback to call when animation loops */
  106556. onAnimationLoop?: (() => void) | null | undefined,
  106557. /** defines whether the animation should be evaluated additively */
  106558. isAdditive?: boolean);
  106559. /**
  106560. * Synchronize and normalize current Animatable with a source Animatable
  106561. * This is useful when using animation weights and when animations are not of the same length
  106562. * @param root defines the root Animatable to synchronize with
  106563. * @returns the current Animatable
  106564. */
  106565. syncWith(root: Animatable): Animatable;
  106566. /**
  106567. * Gets the list of runtime animations
  106568. * @returns an array of RuntimeAnimation
  106569. */
  106570. getAnimations(): RuntimeAnimation[];
  106571. /**
  106572. * Adds more animations to the current animatable
  106573. * @param target defines the target of the animations
  106574. * @param animations defines the new animations to add
  106575. */
  106576. appendAnimations(target: any, animations: Animation[]): void;
  106577. /**
  106578. * Gets the source animation for a specific property
  106579. * @param property defines the propertyu to look for
  106580. * @returns null or the source animation for the given property
  106581. */
  106582. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106583. /**
  106584. * Gets the runtime animation for a specific property
  106585. * @param property defines the propertyu to look for
  106586. * @returns null or the runtime animation for the given property
  106587. */
  106588. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106589. /**
  106590. * Resets the animatable to its original state
  106591. */
  106592. reset(): void;
  106593. /**
  106594. * Allows the animatable to blend with current running animations
  106595. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106596. * @param blendingSpeed defines the blending speed to use
  106597. */
  106598. enableBlending(blendingSpeed: number): void;
  106599. /**
  106600. * Disable animation blending
  106601. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106602. */
  106603. disableBlending(): void;
  106604. /**
  106605. * Jump directly to a given frame
  106606. * @param frame defines the frame to jump to
  106607. */
  106608. goToFrame(frame: number): void;
  106609. /**
  106610. * Pause the animation
  106611. */
  106612. pause(): void;
  106613. /**
  106614. * Restart the animation
  106615. */
  106616. restart(): void;
  106617. private _raiseOnAnimationEnd;
  106618. /**
  106619. * Stop and delete the current animation
  106620. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106621. * @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)
  106622. */
  106623. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106624. /**
  106625. * Wait asynchronously for the animation to end
  106626. * @returns a promise which will be fullfilled when the animation ends
  106627. */
  106628. waitAsync(): Promise<Animatable>;
  106629. /** @hidden */
  106630. _animate(delay: number): boolean;
  106631. }
  106632. interface Scene {
  106633. /** @hidden */
  106634. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106635. /** @hidden */
  106636. _processLateAnimationBindingsForMatrices(holder: {
  106637. totalWeight: number;
  106638. totalAdditiveWeight: number;
  106639. animations: RuntimeAnimation[];
  106640. additiveAnimations: RuntimeAnimation[];
  106641. originalValue: Matrix;
  106642. }): any;
  106643. /** @hidden */
  106644. _processLateAnimationBindingsForQuaternions(holder: {
  106645. totalWeight: number;
  106646. totalAdditiveWeight: number;
  106647. animations: RuntimeAnimation[];
  106648. additiveAnimations: RuntimeAnimation[];
  106649. originalValue: Quaternion;
  106650. }, refQuaternion: Quaternion): Quaternion;
  106651. /** @hidden */
  106652. _processLateAnimationBindings(): void;
  106653. /**
  106654. * Will start the animation sequence of a given target
  106655. * @param target defines the target
  106656. * @param from defines from which frame should animation start
  106657. * @param to defines until which frame should animation run.
  106658. * @param weight defines the weight to apply to the animation (1.0 by default)
  106659. * @param loop defines if the animation loops
  106660. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106661. * @param onAnimationEnd defines the function to be executed when the animation ends
  106662. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106663. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106664. * @param onAnimationLoop defines the callback to call when an animation loops
  106665. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106666. * @returns the animatable object created for this animation
  106667. */
  106668. 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;
  106669. /**
  106670. * Will start the animation sequence of a given target
  106671. * @param target defines the target
  106672. * @param from defines from which frame should animation start
  106673. * @param to defines until which frame should animation run.
  106674. * @param loop defines if the animation loops
  106675. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106676. * @param onAnimationEnd defines the function to be executed when the animation ends
  106677. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106678. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106679. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106680. * @param onAnimationLoop defines the callback to call when an animation loops
  106681. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106682. * @returns the animatable object created for this animation
  106683. */
  106684. 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;
  106685. /**
  106686. * Will start the animation sequence of a given target and its hierarchy
  106687. * @param target defines the target
  106688. * @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.
  106689. * @param from defines from which frame should animation start
  106690. * @param to defines until which frame should animation run.
  106691. * @param loop defines if the animation loops
  106692. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106693. * @param onAnimationEnd defines the function to be executed when the animation ends
  106694. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106695. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106696. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106697. * @param onAnimationLoop defines the callback to call when an animation loops
  106698. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106699. * @returns the list of created animatables
  106700. */
  106701. 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[];
  106702. /**
  106703. * Begin a new animation on a given node
  106704. * @param target defines the target where the animation will take place
  106705. * @param animations defines the list of animations to start
  106706. * @param from defines the initial value
  106707. * @param to defines the final value
  106708. * @param loop defines if you want animation to loop (off by default)
  106709. * @param speedRatio defines the speed ratio to apply to all animations
  106710. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106711. * @param onAnimationLoop defines the callback to call when an animation loops
  106712. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106713. * @returns the list of created animatables
  106714. */
  106715. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106716. /**
  106717. * Begin a new animation on a given node and its hierarchy
  106718. * @param target defines the root node where the animation will take place
  106719. * @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.
  106720. * @param animations defines the list of animations to start
  106721. * @param from defines the initial value
  106722. * @param to defines the final value
  106723. * @param loop defines if you want animation to loop (off by default)
  106724. * @param speedRatio defines the speed ratio to apply to all animations
  106725. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106726. * @param onAnimationLoop defines the callback to call when an animation loops
  106727. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106728. * @returns the list of animatables created for all nodes
  106729. */
  106730. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106731. /**
  106732. * Gets the animatable associated with a specific target
  106733. * @param target defines the target of the animatable
  106734. * @returns the required animatable if found
  106735. */
  106736. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106737. /**
  106738. * Gets all animatables associated with a given target
  106739. * @param target defines the target to look animatables for
  106740. * @returns an array of Animatables
  106741. */
  106742. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106743. /**
  106744. * Stops and removes all animations that have been applied to the scene
  106745. */
  106746. stopAllAnimations(): void;
  106747. /**
  106748. * Gets the current delta time used by animation engine
  106749. */
  106750. deltaTime: number;
  106751. }
  106752. interface Bone {
  106753. /**
  106754. * Copy an animation range from another bone
  106755. * @param source defines the source bone
  106756. * @param rangeName defines the range name to copy
  106757. * @param frameOffset defines the frame offset
  106758. * @param rescaleAsRequired defines if rescaling must be applied if required
  106759. * @param skelDimensionsRatio defines the scaling ratio
  106760. * @returns true if operation was successful
  106761. */
  106762. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106763. }
  106764. }
  106765. declare module BABYLON {
  106766. /**
  106767. * Class used to override all child animations of a given target
  106768. */
  106769. export class AnimationPropertiesOverride {
  106770. /**
  106771. * Gets or sets a value indicating if animation blending must be used
  106772. */
  106773. enableBlending: boolean;
  106774. /**
  106775. * Gets or sets the blending speed to use when enableBlending is true
  106776. */
  106777. blendingSpeed: number;
  106778. /**
  106779. * Gets or sets the default loop mode to use
  106780. */
  106781. loopMode: number;
  106782. }
  106783. }
  106784. declare module BABYLON {
  106785. /**
  106786. * Class used to handle skinning animations
  106787. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106788. */
  106789. export class Skeleton implements IAnimatable {
  106790. /** defines the skeleton name */
  106791. name: string;
  106792. /** defines the skeleton Id */
  106793. id: string;
  106794. /**
  106795. * Defines the list of child bones
  106796. */
  106797. bones: Bone[];
  106798. /**
  106799. * Defines an estimate of the dimension of the skeleton at rest
  106800. */
  106801. dimensionsAtRest: Vector3;
  106802. /**
  106803. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106804. */
  106805. needInitialSkinMatrix: boolean;
  106806. /**
  106807. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106808. */
  106809. overrideMesh: Nullable<AbstractMesh>;
  106810. /**
  106811. * Gets the list of animations attached to this skeleton
  106812. */
  106813. animations: Array<Animation>;
  106814. private _scene;
  106815. private _isDirty;
  106816. private _transformMatrices;
  106817. private _transformMatrixTexture;
  106818. private _meshesWithPoseMatrix;
  106819. private _animatables;
  106820. private _identity;
  106821. private _synchronizedWithMesh;
  106822. private _ranges;
  106823. private _lastAbsoluteTransformsUpdateId;
  106824. private _canUseTextureForBones;
  106825. private _uniqueId;
  106826. /** @hidden */
  106827. _numBonesWithLinkedTransformNode: number;
  106828. /** @hidden */
  106829. _hasWaitingData: Nullable<boolean>;
  106830. /** @hidden */
  106831. _waitingOverrideMeshId: Nullable<string>;
  106832. /**
  106833. * Specifies if the skeleton should be serialized
  106834. */
  106835. doNotSerialize: boolean;
  106836. private _useTextureToStoreBoneMatrices;
  106837. /**
  106838. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106839. * Please note that this option is not available if the hardware does not support it
  106840. */
  106841. get useTextureToStoreBoneMatrices(): boolean;
  106842. set useTextureToStoreBoneMatrices(value: boolean);
  106843. private _animationPropertiesOverride;
  106844. /**
  106845. * Gets or sets the animation properties override
  106846. */
  106847. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106848. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106849. /**
  106850. * List of inspectable custom properties (used by the Inspector)
  106851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106852. */
  106853. inspectableCustomProperties: IInspectable[];
  106854. /**
  106855. * An observable triggered before computing the skeleton's matrices
  106856. */
  106857. onBeforeComputeObservable: Observable<Skeleton>;
  106858. /**
  106859. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106860. */
  106861. get isUsingTextureForMatrices(): boolean;
  106862. /**
  106863. * Gets the unique ID of this skeleton
  106864. */
  106865. get uniqueId(): number;
  106866. /**
  106867. * Creates a new skeleton
  106868. * @param name defines the skeleton name
  106869. * @param id defines the skeleton Id
  106870. * @param scene defines the hosting scene
  106871. */
  106872. constructor(
  106873. /** defines the skeleton name */
  106874. name: string,
  106875. /** defines the skeleton Id */
  106876. id: string, scene: Scene);
  106877. /**
  106878. * Gets the current object class name.
  106879. * @return the class name
  106880. */
  106881. getClassName(): string;
  106882. /**
  106883. * Returns an array containing the root bones
  106884. * @returns an array containing the root bones
  106885. */
  106886. getChildren(): Array<Bone>;
  106887. /**
  106888. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106889. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106890. * @returns a Float32Array containing matrices data
  106891. */
  106892. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106893. /**
  106894. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106895. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106896. * @returns a raw texture containing the data
  106897. */
  106898. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106899. /**
  106900. * Gets the current hosting scene
  106901. * @returns a scene object
  106902. */
  106903. getScene(): Scene;
  106904. /**
  106905. * Gets a string representing the current skeleton data
  106906. * @param fullDetails defines a boolean indicating if we want a verbose version
  106907. * @returns a string representing the current skeleton data
  106908. */
  106909. toString(fullDetails?: boolean): string;
  106910. /**
  106911. * Get bone's index searching by name
  106912. * @param name defines bone's name to search for
  106913. * @return the indice of the bone. Returns -1 if not found
  106914. */
  106915. getBoneIndexByName(name: string): number;
  106916. /**
  106917. * Creater a new animation range
  106918. * @param name defines the name of the range
  106919. * @param from defines the start key
  106920. * @param to defines the end key
  106921. */
  106922. createAnimationRange(name: string, from: number, to: number): void;
  106923. /**
  106924. * Delete a specific animation range
  106925. * @param name defines the name of the range
  106926. * @param deleteFrames defines if frames must be removed as well
  106927. */
  106928. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106929. /**
  106930. * Gets a specific animation range
  106931. * @param name defines the name of the range to look for
  106932. * @returns the requested animation range or null if not found
  106933. */
  106934. getAnimationRange(name: string): Nullable<AnimationRange>;
  106935. /**
  106936. * Gets the list of all animation ranges defined on this skeleton
  106937. * @returns an array
  106938. */
  106939. getAnimationRanges(): Nullable<AnimationRange>[];
  106940. /**
  106941. * Copy animation range from a source skeleton.
  106942. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  106943. * @param source defines the source skeleton
  106944. * @param name defines the name of the range to copy
  106945. * @param rescaleAsRequired defines if rescaling must be applied if required
  106946. * @returns true if operation was successful
  106947. */
  106948. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  106949. /**
  106950. * Forces the skeleton to go to rest pose
  106951. */
  106952. returnToRest(): void;
  106953. private _getHighestAnimationFrame;
  106954. /**
  106955. * Begin a specific animation range
  106956. * @param name defines the name of the range to start
  106957. * @param loop defines if looping must be turned on (false by default)
  106958. * @param speedRatio defines the speed ratio to apply (1 by default)
  106959. * @param onAnimationEnd defines a callback which will be called when animation will end
  106960. * @returns a new animatable
  106961. */
  106962. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  106963. /**
  106964. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  106965. * @param skeleton defines the Skeleton containing the animation range to convert
  106966. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  106967. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  106968. * @returns the original skeleton
  106969. */
  106970. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  106971. /** @hidden */
  106972. _markAsDirty(): void;
  106973. /** @hidden */
  106974. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106975. /** @hidden */
  106976. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106977. private _computeTransformMatrices;
  106978. /**
  106979. * Build all resources required to render a skeleton
  106980. */
  106981. prepare(): void;
  106982. /**
  106983. * Gets the list of animatables currently running for this skeleton
  106984. * @returns an array of animatables
  106985. */
  106986. getAnimatables(): IAnimatable[];
  106987. /**
  106988. * Clone the current skeleton
  106989. * @param name defines the name of the new skeleton
  106990. * @param id defines the id of the new skeleton
  106991. * @returns the new skeleton
  106992. */
  106993. clone(name: string, id?: string): Skeleton;
  106994. /**
  106995. * Enable animation blending for this skeleton
  106996. * @param blendingSpeed defines the blending speed to apply
  106997. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106998. */
  106999. enableBlending(blendingSpeed?: number): void;
  107000. /**
  107001. * Releases all resources associated with the current skeleton
  107002. */
  107003. dispose(): void;
  107004. /**
  107005. * Serialize the skeleton in a JSON object
  107006. * @returns a JSON object
  107007. */
  107008. serialize(): any;
  107009. /**
  107010. * Creates a new skeleton from serialized data
  107011. * @param parsedSkeleton defines the serialized data
  107012. * @param scene defines the hosting scene
  107013. * @returns a new skeleton
  107014. */
  107015. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  107016. /**
  107017. * Compute all node absolute transforms
  107018. * @param forceUpdate defines if computation must be done even if cache is up to date
  107019. */
  107020. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  107021. /**
  107022. * Gets the root pose matrix
  107023. * @returns a matrix
  107024. */
  107025. getPoseMatrix(): Nullable<Matrix>;
  107026. /**
  107027. * Sorts bones per internal index
  107028. */
  107029. sortBones(): void;
  107030. private _sortBones;
  107031. /**
  107032. * Set the current local matrix as the restPose for all bones in the skeleton.
  107033. */
  107034. setCurrentPoseAsRest(): void;
  107035. }
  107036. }
  107037. declare module BABYLON {
  107038. /**
  107039. * Class used to store bone information
  107040. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107041. */
  107042. export class Bone extends Node {
  107043. /**
  107044. * defines the bone name
  107045. */
  107046. name: string;
  107047. private static _tmpVecs;
  107048. private static _tmpQuat;
  107049. private static _tmpMats;
  107050. /**
  107051. * Gets the list of child bones
  107052. */
  107053. children: Bone[];
  107054. /** Gets the animations associated with this bone */
  107055. animations: Animation[];
  107056. /**
  107057. * Gets or sets bone length
  107058. */
  107059. length: number;
  107060. /**
  107061. * @hidden Internal only
  107062. * Set this value to map this bone to a different index in the transform matrices
  107063. * Set this value to -1 to exclude the bone from the transform matrices
  107064. */
  107065. _index: Nullable<number>;
  107066. private _skeleton;
  107067. private _localMatrix;
  107068. private _restPose;
  107069. private _bindPose;
  107070. private _baseMatrix;
  107071. private _absoluteTransform;
  107072. private _invertedAbsoluteTransform;
  107073. private _parent;
  107074. private _scalingDeterminant;
  107075. private _worldTransform;
  107076. private _localScaling;
  107077. private _localRotation;
  107078. private _localPosition;
  107079. private _needToDecompose;
  107080. private _needToCompose;
  107081. /** @hidden */
  107082. _linkedTransformNode: Nullable<TransformNode>;
  107083. /** @hidden */
  107084. _waitingTransformNodeId: Nullable<string>;
  107085. /** @hidden */
  107086. get _matrix(): Matrix;
  107087. /** @hidden */
  107088. set _matrix(value: Matrix);
  107089. /**
  107090. * Create a new bone
  107091. * @param name defines the bone name
  107092. * @param skeleton defines the parent skeleton
  107093. * @param parentBone defines the parent (can be null if the bone is the root)
  107094. * @param localMatrix defines the local matrix
  107095. * @param restPose defines the rest pose matrix
  107096. * @param baseMatrix defines the base matrix
  107097. * @param index defines index of the bone in the hiearchy
  107098. */
  107099. constructor(
  107100. /**
  107101. * defines the bone name
  107102. */
  107103. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  107104. /**
  107105. * Gets the current object class name.
  107106. * @return the class name
  107107. */
  107108. getClassName(): string;
  107109. /**
  107110. * Gets the parent skeleton
  107111. * @returns a skeleton
  107112. */
  107113. getSkeleton(): Skeleton;
  107114. /**
  107115. * Gets parent bone
  107116. * @returns a bone or null if the bone is the root of the bone hierarchy
  107117. */
  107118. getParent(): Nullable<Bone>;
  107119. /**
  107120. * Returns an array containing the root bones
  107121. * @returns an array containing the root bones
  107122. */
  107123. getChildren(): Array<Bone>;
  107124. /**
  107125. * Gets the node index in matrix array generated for rendering
  107126. * @returns the node index
  107127. */
  107128. getIndex(): number;
  107129. /**
  107130. * Sets the parent bone
  107131. * @param parent defines the parent (can be null if the bone is the root)
  107132. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107133. */
  107134. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  107135. /**
  107136. * Gets the local matrix
  107137. * @returns a matrix
  107138. */
  107139. getLocalMatrix(): Matrix;
  107140. /**
  107141. * Gets the base matrix (initial matrix which remains unchanged)
  107142. * @returns a matrix
  107143. */
  107144. getBaseMatrix(): Matrix;
  107145. /**
  107146. * Gets the rest pose matrix
  107147. * @returns a matrix
  107148. */
  107149. getRestPose(): Matrix;
  107150. /**
  107151. * Sets the rest pose matrix
  107152. * @param matrix the local-space rest pose to set for this bone
  107153. */
  107154. setRestPose(matrix: Matrix): void;
  107155. /**
  107156. * Gets the bind pose matrix
  107157. * @returns the bind pose matrix
  107158. */
  107159. getBindPose(): Matrix;
  107160. /**
  107161. * Sets the bind pose matrix
  107162. * @param matrix the local-space bind pose to set for this bone
  107163. */
  107164. setBindPose(matrix: Matrix): void;
  107165. /**
  107166. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  107167. */
  107168. getWorldMatrix(): Matrix;
  107169. /**
  107170. * Sets the local matrix to rest pose matrix
  107171. */
  107172. returnToRest(): void;
  107173. /**
  107174. * Gets the inverse of the absolute transform matrix.
  107175. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  107176. * @returns a matrix
  107177. */
  107178. getInvertedAbsoluteTransform(): Matrix;
  107179. /**
  107180. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  107181. * @returns a matrix
  107182. */
  107183. getAbsoluteTransform(): Matrix;
  107184. /**
  107185. * Links with the given transform node.
  107186. * The local matrix of this bone is copied from the transform node every frame.
  107187. * @param transformNode defines the transform node to link to
  107188. */
  107189. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  107190. /**
  107191. * Gets the node used to drive the bone's transformation
  107192. * @returns a transform node or null
  107193. */
  107194. getTransformNode(): Nullable<TransformNode>;
  107195. /** Gets or sets current position (in local space) */
  107196. get position(): Vector3;
  107197. set position(newPosition: Vector3);
  107198. /** Gets or sets current rotation (in local space) */
  107199. get rotation(): Vector3;
  107200. set rotation(newRotation: Vector3);
  107201. /** Gets or sets current rotation quaternion (in local space) */
  107202. get rotationQuaternion(): Quaternion;
  107203. set rotationQuaternion(newRotation: Quaternion);
  107204. /** Gets or sets current scaling (in local space) */
  107205. get scaling(): Vector3;
  107206. set scaling(newScaling: Vector3);
  107207. /**
  107208. * Gets the animation properties override
  107209. */
  107210. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107211. private _decompose;
  107212. private _compose;
  107213. /**
  107214. * Update the base and local matrices
  107215. * @param matrix defines the new base or local matrix
  107216. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107217. * @param updateLocalMatrix defines if the local matrix should be updated
  107218. */
  107219. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  107220. /** @hidden */
  107221. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  107222. /**
  107223. * Flag the bone as dirty (Forcing it to update everything)
  107224. */
  107225. markAsDirty(): void;
  107226. /** @hidden */
  107227. _markAsDirtyAndCompose(): void;
  107228. private _markAsDirtyAndDecompose;
  107229. /**
  107230. * Translate the bone in local or world space
  107231. * @param vec The amount to translate the bone
  107232. * @param space The space that the translation is in
  107233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107234. */
  107235. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107236. /**
  107237. * Set the postion of the bone in local or world space
  107238. * @param position The position to set the bone
  107239. * @param space The space that the position is in
  107240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107241. */
  107242. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107243. /**
  107244. * Set the absolute position of the bone (world space)
  107245. * @param position The position to set the bone
  107246. * @param mesh The mesh that this bone is attached to
  107247. */
  107248. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  107249. /**
  107250. * Scale the bone on the x, y and z axes (in local space)
  107251. * @param x The amount to scale the bone on the x axis
  107252. * @param y The amount to scale the bone on the y axis
  107253. * @param z The amount to scale the bone on the z axis
  107254. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  107255. */
  107256. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  107257. /**
  107258. * Set the bone scaling in local space
  107259. * @param scale defines the scaling vector
  107260. */
  107261. setScale(scale: Vector3): void;
  107262. /**
  107263. * Gets the current scaling in local space
  107264. * @returns the current scaling vector
  107265. */
  107266. getScale(): Vector3;
  107267. /**
  107268. * Gets the current scaling in local space and stores it in a target vector
  107269. * @param result defines the target vector
  107270. */
  107271. getScaleToRef(result: Vector3): void;
  107272. /**
  107273. * Set the yaw, pitch, and roll of the bone in local or world space
  107274. * @param yaw The rotation of the bone on the y axis
  107275. * @param pitch The rotation of the bone on the x axis
  107276. * @param roll The rotation of the bone on the z axis
  107277. * @param space The space that the axes of rotation are in
  107278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107279. */
  107280. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107281. /**
  107282. * Add a rotation to the bone on an axis in local or world space
  107283. * @param axis The axis to rotate the bone on
  107284. * @param amount The amount to rotate the bone
  107285. * @param space The space that the axis is in
  107286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107287. */
  107288. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107289. /**
  107290. * Set the rotation of the bone to a particular axis angle in local or world space
  107291. * @param axis The axis to rotate the bone on
  107292. * @param angle The angle that the bone should be rotated to
  107293. * @param space The space that the axis is in
  107294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107295. */
  107296. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107297. /**
  107298. * Set the euler rotation of the bone in local or world space
  107299. * @param rotation The euler rotation that the bone should be set to
  107300. * @param space The space that the rotation is in
  107301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107302. */
  107303. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107304. /**
  107305. * Set the quaternion rotation of the bone in local or world space
  107306. * @param quat The quaternion rotation that the bone should be set to
  107307. * @param space The space that the rotation is in
  107308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107309. */
  107310. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107311. /**
  107312. * Set the rotation matrix of the bone in local or world space
  107313. * @param rotMat The rotation matrix that the bone should be set to
  107314. * @param space The space that the rotation is in
  107315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107316. */
  107317. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107318. private _rotateWithMatrix;
  107319. private _getNegativeRotationToRef;
  107320. /**
  107321. * Get the position of the bone in local or world space
  107322. * @param space The space that the returned position is in
  107323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107324. * @returns The position of the bone
  107325. */
  107326. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107327. /**
  107328. * Copy the position of the bone to a vector3 in local or world space
  107329. * @param space The space that the returned position is in
  107330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107331. * @param result The vector3 to copy the position to
  107332. */
  107333. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107334. /**
  107335. * Get the absolute position of the bone (world space)
  107336. * @param mesh The mesh that this bone is attached to
  107337. * @returns The absolute position of the bone
  107338. */
  107339. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107340. /**
  107341. * Copy the absolute position of the bone (world space) to the result param
  107342. * @param mesh The mesh that this bone is attached to
  107343. * @param result The vector3 to copy the absolute position to
  107344. */
  107345. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107346. /**
  107347. * Compute the absolute transforms of this bone and its children
  107348. */
  107349. computeAbsoluteTransforms(): void;
  107350. /**
  107351. * Get the world direction from an axis that is in the local space of the bone
  107352. * @param localAxis The local direction that is used to compute the world direction
  107353. * @param mesh The mesh that this bone is attached to
  107354. * @returns The world direction
  107355. */
  107356. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107357. /**
  107358. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107359. * @param localAxis The local direction that is used to compute the world direction
  107360. * @param mesh The mesh that this bone is attached to
  107361. * @param result The vector3 that the world direction will be copied to
  107362. */
  107363. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107364. /**
  107365. * Get the euler rotation of the bone in local or world space
  107366. * @param space The space that the rotation should be in
  107367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107368. * @returns The euler rotation
  107369. */
  107370. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107371. /**
  107372. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107373. * @param space The space that the rotation should be in
  107374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107375. * @param result The vector3 that the rotation should be copied to
  107376. */
  107377. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107378. /**
  107379. * Get the quaternion rotation of the bone in either local or world space
  107380. * @param space The space that the rotation should be in
  107381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107382. * @returns The quaternion rotation
  107383. */
  107384. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107385. /**
  107386. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107387. * @param space The space that the rotation should be in
  107388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107389. * @param result The quaternion that the rotation should be copied to
  107390. */
  107391. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107392. /**
  107393. * Get the rotation matrix of the bone in local or world space
  107394. * @param space The space that the rotation should be in
  107395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107396. * @returns The rotation matrix
  107397. */
  107398. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107399. /**
  107400. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107401. * @param space The space that the rotation should be in
  107402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107403. * @param result The quaternion that the rotation should be copied to
  107404. */
  107405. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107406. /**
  107407. * Get the world position of a point that is in the local space of the bone
  107408. * @param position The local position
  107409. * @param mesh The mesh that this bone is attached to
  107410. * @returns The world position
  107411. */
  107412. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107413. /**
  107414. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107415. * @param position The local position
  107416. * @param mesh The mesh that this bone is attached to
  107417. * @param result The vector3 that the world position should be copied to
  107418. */
  107419. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107420. /**
  107421. * Get the local position of a point that is in world space
  107422. * @param position The world position
  107423. * @param mesh The mesh that this bone is attached to
  107424. * @returns The local position
  107425. */
  107426. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107427. /**
  107428. * Get the local position of a point that is in world space and copy it to the result param
  107429. * @param position The world position
  107430. * @param mesh The mesh that this bone is attached to
  107431. * @param result The vector3 that the local position should be copied to
  107432. */
  107433. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107434. /**
  107435. * Set the current local matrix as the restPose for this bone.
  107436. */
  107437. setCurrentPoseAsRest(): void;
  107438. }
  107439. }
  107440. declare module BABYLON {
  107441. /**
  107442. * 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.
  107443. * @see https://doc.babylonjs.com/how_to/transformnode
  107444. */
  107445. export class TransformNode extends Node {
  107446. /**
  107447. * Object will not rotate to face the camera
  107448. */
  107449. static BILLBOARDMODE_NONE: number;
  107450. /**
  107451. * Object will rotate to face the camera but only on the x axis
  107452. */
  107453. static BILLBOARDMODE_X: number;
  107454. /**
  107455. * Object will rotate to face the camera but only on the y axis
  107456. */
  107457. static BILLBOARDMODE_Y: number;
  107458. /**
  107459. * Object will rotate to face the camera but only on the z axis
  107460. */
  107461. static BILLBOARDMODE_Z: number;
  107462. /**
  107463. * Object will rotate to face the camera
  107464. */
  107465. static BILLBOARDMODE_ALL: number;
  107466. /**
  107467. * Object will rotate to face the camera's position instead of orientation
  107468. */
  107469. static BILLBOARDMODE_USE_POSITION: number;
  107470. private static _TmpRotation;
  107471. private static _TmpScaling;
  107472. private static _TmpTranslation;
  107473. private _forward;
  107474. private _forwardInverted;
  107475. private _up;
  107476. private _right;
  107477. private _rightInverted;
  107478. private _position;
  107479. private _rotation;
  107480. private _rotationQuaternion;
  107481. protected _scaling: Vector3;
  107482. protected _isDirty: boolean;
  107483. private _transformToBoneReferal;
  107484. private _isAbsoluteSynced;
  107485. private _billboardMode;
  107486. /**
  107487. * Gets or sets the billboard mode. Default is 0.
  107488. *
  107489. * | Value | Type | Description |
  107490. * | --- | --- | --- |
  107491. * | 0 | BILLBOARDMODE_NONE | |
  107492. * | 1 | BILLBOARDMODE_X | |
  107493. * | 2 | BILLBOARDMODE_Y | |
  107494. * | 4 | BILLBOARDMODE_Z | |
  107495. * | 7 | BILLBOARDMODE_ALL | |
  107496. *
  107497. */
  107498. get billboardMode(): number;
  107499. set billboardMode(value: number);
  107500. private _preserveParentRotationForBillboard;
  107501. /**
  107502. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107503. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107504. */
  107505. get preserveParentRotationForBillboard(): boolean;
  107506. set preserveParentRotationForBillboard(value: boolean);
  107507. /**
  107508. * 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
  107509. */
  107510. scalingDeterminant: number;
  107511. private _infiniteDistance;
  107512. /**
  107513. * Gets or sets the distance of the object to max, often used by skybox
  107514. */
  107515. get infiniteDistance(): boolean;
  107516. set infiniteDistance(value: boolean);
  107517. /**
  107518. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107519. * By default the system will update normals to compensate
  107520. */
  107521. ignoreNonUniformScaling: boolean;
  107522. /**
  107523. * 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
  107524. */
  107525. reIntegrateRotationIntoRotationQuaternion: boolean;
  107526. /** @hidden */
  107527. _poseMatrix: Nullable<Matrix>;
  107528. /** @hidden */
  107529. _localMatrix: Matrix;
  107530. private _usePivotMatrix;
  107531. private _absolutePosition;
  107532. private _absoluteScaling;
  107533. private _absoluteRotationQuaternion;
  107534. private _pivotMatrix;
  107535. private _pivotMatrixInverse;
  107536. /** @hidden */
  107537. _postMultiplyPivotMatrix: boolean;
  107538. protected _isWorldMatrixFrozen: boolean;
  107539. /** @hidden */
  107540. _indexInSceneTransformNodesArray: number;
  107541. /**
  107542. * An event triggered after the world matrix is updated
  107543. */
  107544. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107545. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107546. /**
  107547. * Gets a string identifying the name of the class
  107548. * @returns "TransformNode" string
  107549. */
  107550. getClassName(): string;
  107551. /**
  107552. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107553. */
  107554. get position(): Vector3;
  107555. set position(newPosition: Vector3);
  107556. /**
  107557. * 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)).
  107558. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107559. */
  107560. get rotation(): Vector3;
  107561. set rotation(newRotation: Vector3);
  107562. /**
  107563. * 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)).
  107564. */
  107565. get scaling(): Vector3;
  107566. set scaling(newScaling: Vector3);
  107567. /**
  107568. * 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).
  107569. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107570. */
  107571. get rotationQuaternion(): Nullable<Quaternion>;
  107572. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107573. /**
  107574. * The forward direction of that transform in world space.
  107575. */
  107576. get forward(): Vector3;
  107577. /**
  107578. * The up direction of that transform in world space.
  107579. */
  107580. get up(): Vector3;
  107581. /**
  107582. * The right direction of that transform in world space.
  107583. */
  107584. get right(): Vector3;
  107585. /**
  107586. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107587. * @param matrix the matrix to copy the pose from
  107588. * @returns this TransformNode.
  107589. */
  107590. updatePoseMatrix(matrix: Matrix): TransformNode;
  107591. /**
  107592. * Returns the mesh Pose matrix.
  107593. * @returns the pose matrix
  107594. */
  107595. getPoseMatrix(): Matrix;
  107596. /** @hidden */
  107597. _isSynchronized(): boolean;
  107598. /** @hidden */
  107599. _initCache(): void;
  107600. /**
  107601. * Flag the transform node as dirty (Forcing it to update everything)
  107602. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107603. * @returns this transform node
  107604. */
  107605. markAsDirty(property: string): TransformNode;
  107606. /**
  107607. * Returns the current mesh absolute position.
  107608. * Returns a Vector3.
  107609. */
  107610. get absolutePosition(): Vector3;
  107611. /**
  107612. * Returns the current mesh absolute scaling.
  107613. * Returns a Vector3.
  107614. */
  107615. get absoluteScaling(): Vector3;
  107616. /**
  107617. * Returns the current mesh absolute rotation.
  107618. * Returns a Quaternion.
  107619. */
  107620. get absoluteRotationQuaternion(): Quaternion;
  107621. /**
  107622. * Sets a new matrix to apply before all other transformation
  107623. * @param matrix defines the transform matrix
  107624. * @returns the current TransformNode
  107625. */
  107626. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107627. /**
  107628. * Sets a new pivot matrix to the current node
  107629. * @param matrix defines the new pivot matrix to use
  107630. * @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
  107631. * @returns the current TransformNode
  107632. */
  107633. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107634. /**
  107635. * Returns the mesh pivot matrix.
  107636. * Default : Identity.
  107637. * @returns the matrix
  107638. */
  107639. getPivotMatrix(): Matrix;
  107640. /**
  107641. * Instantiate (when possible) or clone that node with its hierarchy
  107642. * @param newParent defines the new parent to use for the instance (or clone)
  107643. * @param options defines options to configure how copy is done
  107644. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107645. * @returns an instance (or a clone) of the current node with its hiearchy
  107646. */
  107647. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107648. doNotInstantiate: boolean;
  107649. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107650. /**
  107651. * Prevents the World matrix to be computed any longer
  107652. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107653. * @returns the TransformNode.
  107654. */
  107655. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107656. /**
  107657. * Allows back the World matrix computation.
  107658. * @returns the TransformNode.
  107659. */
  107660. unfreezeWorldMatrix(): this;
  107661. /**
  107662. * True if the World matrix has been frozen.
  107663. */
  107664. get isWorldMatrixFrozen(): boolean;
  107665. /**
  107666. * Retuns the mesh absolute position in the World.
  107667. * @returns a Vector3.
  107668. */
  107669. getAbsolutePosition(): Vector3;
  107670. /**
  107671. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107672. * @param absolutePosition the absolute position to set
  107673. * @returns the TransformNode.
  107674. */
  107675. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107676. /**
  107677. * Sets the mesh position in its local space.
  107678. * @param vector3 the position to set in localspace
  107679. * @returns the TransformNode.
  107680. */
  107681. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107682. /**
  107683. * Returns the mesh position in the local space from the current World matrix values.
  107684. * @returns a new Vector3.
  107685. */
  107686. getPositionExpressedInLocalSpace(): Vector3;
  107687. /**
  107688. * Translates the mesh along the passed Vector3 in its local space.
  107689. * @param vector3 the distance to translate in localspace
  107690. * @returns the TransformNode.
  107691. */
  107692. locallyTranslate(vector3: Vector3): TransformNode;
  107693. private static _lookAtVectorCache;
  107694. /**
  107695. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107696. * @param targetPoint the position (must be in same space as current mesh) to look at
  107697. * @param yawCor optional yaw (y-axis) correction in radians
  107698. * @param pitchCor optional pitch (x-axis) correction in radians
  107699. * @param rollCor optional roll (z-axis) correction in radians
  107700. * @param space the choosen space of the target
  107701. * @returns the TransformNode.
  107702. */
  107703. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107704. /**
  107705. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107706. * This Vector3 is expressed in the World space.
  107707. * @param localAxis axis to rotate
  107708. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107709. */
  107710. getDirection(localAxis: Vector3): Vector3;
  107711. /**
  107712. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107713. * localAxis is expressed in the mesh local space.
  107714. * result is computed in the Wordl space from the mesh World matrix.
  107715. * @param localAxis axis to rotate
  107716. * @param result the resulting transformnode
  107717. * @returns this TransformNode.
  107718. */
  107719. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107720. /**
  107721. * Sets this transform node rotation to the given local axis.
  107722. * @param localAxis the axis in local space
  107723. * @param yawCor optional yaw (y-axis) correction in radians
  107724. * @param pitchCor optional pitch (x-axis) correction in radians
  107725. * @param rollCor optional roll (z-axis) correction in radians
  107726. * @returns this TransformNode
  107727. */
  107728. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107729. /**
  107730. * Sets a new pivot point to the current node
  107731. * @param point defines the new pivot point to use
  107732. * @param space defines if the point is in world or local space (local by default)
  107733. * @returns the current TransformNode
  107734. */
  107735. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107736. /**
  107737. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107738. * @returns the pivot point
  107739. */
  107740. getPivotPoint(): Vector3;
  107741. /**
  107742. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107743. * @param result the vector3 to store the result
  107744. * @returns this TransformNode.
  107745. */
  107746. getPivotPointToRef(result: Vector3): TransformNode;
  107747. /**
  107748. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107749. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107750. */
  107751. getAbsolutePivotPoint(): Vector3;
  107752. /**
  107753. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107754. * @param result vector3 to store the result
  107755. * @returns this TransformNode.
  107756. */
  107757. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107758. /**
  107759. * Defines the passed node as the parent of the current node.
  107760. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107761. * @see https://doc.babylonjs.com/how_to/parenting
  107762. * @param node the node ot set as the parent
  107763. * @returns this TransformNode.
  107764. */
  107765. setParent(node: Nullable<Node>): TransformNode;
  107766. private _nonUniformScaling;
  107767. /**
  107768. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107769. */
  107770. get nonUniformScaling(): boolean;
  107771. /** @hidden */
  107772. _updateNonUniformScalingState(value: boolean): boolean;
  107773. /**
  107774. * Attach the current TransformNode to another TransformNode associated with a bone
  107775. * @param bone Bone affecting the TransformNode
  107776. * @param affectedTransformNode TransformNode associated with the bone
  107777. * @returns this object
  107778. */
  107779. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107780. /**
  107781. * Detach the transform node if its associated with a bone
  107782. * @returns this object
  107783. */
  107784. detachFromBone(): TransformNode;
  107785. private static _rotationAxisCache;
  107786. /**
  107787. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107788. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107789. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107790. * The passed axis is also normalized.
  107791. * @param axis the axis to rotate around
  107792. * @param amount the amount to rotate in radians
  107793. * @param space Space to rotate in (Default: local)
  107794. * @returns the TransformNode.
  107795. */
  107796. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107797. /**
  107798. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107799. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107800. * The passed axis is also normalized. .
  107801. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107802. * @param point the point to rotate around
  107803. * @param axis the axis to rotate around
  107804. * @param amount the amount to rotate in radians
  107805. * @returns the TransformNode
  107806. */
  107807. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107808. /**
  107809. * Translates the mesh along the axis vector for the passed distance in the given space.
  107810. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107811. * @param axis the axis to translate in
  107812. * @param distance the distance to translate
  107813. * @param space Space to rotate in (Default: local)
  107814. * @returns the TransformNode.
  107815. */
  107816. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107817. /**
  107818. * Adds a rotation step to the mesh current rotation.
  107819. * x, y, z are Euler angles expressed in radians.
  107820. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107821. * This means this rotation is made in the mesh local space only.
  107822. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107823. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107824. * ```javascript
  107825. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107826. * ```
  107827. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107828. * 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.
  107829. * @param x Rotation to add
  107830. * @param y Rotation to add
  107831. * @param z Rotation to add
  107832. * @returns the TransformNode.
  107833. */
  107834. addRotation(x: number, y: number, z: number): TransformNode;
  107835. /**
  107836. * @hidden
  107837. */
  107838. protected _getEffectiveParent(): Nullable<Node>;
  107839. /**
  107840. * Computes the world matrix of the node
  107841. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107842. * @returns the world matrix
  107843. */
  107844. computeWorldMatrix(force?: boolean): Matrix;
  107845. /**
  107846. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107847. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107848. */
  107849. resetLocalMatrix(independentOfChildren?: boolean): void;
  107850. protected _afterComputeWorldMatrix(): void;
  107851. /**
  107852. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107853. * @param func callback function to add
  107854. *
  107855. * @returns the TransformNode.
  107856. */
  107857. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107858. /**
  107859. * Removes a registered callback function.
  107860. * @param func callback function to remove
  107861. * @returns the TransformNode.
  107862. */
  107863. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107864. /**
  107865. * Gets the position of the current mesh in camera space
  107866. * @param camera defines the camera to use
  107867. * @returns a position
  107868. */
  107869. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107870. /**
  107871. * Returns the distance from the mesh to the active camera
  107872. * @param camera defines the camera to use
  107873. * @returns the distance
  107874. */
  107875. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107876. /**
  107877. * Clone the current transform node
  107878. * @param name Name of the new clone
  107879. * @param newParent New parent for the clone
  107880. * @param doNotCloneChildren Do not clone children hierarchy
  107881. * @returns the new transform node
  107882. */
  107883. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107884. /**
  107885. * Serializes the objects information.
  107886. * @param currentSerializationObject defines the object to serialize in
  107887. * @returns the serialized object
  107888. */
  107889. serialize(currentSerializationObject?: any): any;
  107890. /**
  107891. * Returns a new TransformNode object parsed from the source provided.
  107892. * @param parsedTransformNode is the source.
  107893. * @param scene the scne the object belongs to
  107894. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107895. * @returns a new TransformNode object parsed from the source provided.
  107896. */
  107897. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107898. /**
  107899. * Get all child-transformNodes of this node
  107900. * @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
  107901. * @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
  107902. * @returns an array of TransformNode
  107903. */
  107904. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107905. /**
  107906. * Releases resources associated with this transform node.
  107907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107909. */
  107910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107911. /**
  107912. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107913. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107914. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107915. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107916. * @returns the current mesh
  107917. */
  107918. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107919. private _syncAbsoluteScalingAndRotation;
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /**
  107924. * Defines the types of pose enabled controllers that are supported
  107925. */
  107926. export enum PoseEnabledControllerType {
  107927. /**
  107928. * HTC Vive
  107929. */
  107930. VIVE = 0,
  107931. /**
  107932. * Oculus Rift
  107933. */
  107934. OCULUS = 1,
  107935. /**
  107936. * Windows mixed reality
  107937. */
  107938. WINDOWS = 2,
  107939. /**
  107940. * Samsung gear VR
  107941. */
  107942. GEAR_VR = 3,
  107943. /**
  107944. * Google Daydream
  107945. */
  107946. DAYDREAM = 4,
  107947. /**
  107948. * Generic
  107949. */
  107950. GENERIC = 5
  107951. }
  107952. /**
  107953. * Defines the MutableGamepadButton interface for the state of a gamepad button
  107954. */
  107955. export interface MutableGamepadButton {
  107956. /**
  107957. * Value of the button/trigger
  107958. */
  107959. value: number;
  107960. /**
  107961. * If the button/trigger is currently touched
  107962. */
  107963. touched: boolean;
  107964. /**
  107965. * If the button/trigger is currently pressed
  107966. */
  107967. pressed: boolean;
  107968. }
  107969. /**
  107970. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  107971. * @hidden
  107972. */
  107973. export interface ExtendedGamepadButton extends GamepadButton {
  107974. /**
  107975. * If the button/trigger is currently pressed
  107976. */
  107977. readonly pressed: boolean;
  107978. /**
  107979. * If the button/trigger is currently touched
  107980. */
  107981. readonly touched: boolean;
  107982. /**
  107983. * Value of the button/trigger
  107984. */
  107985. readonly value: number;
  107986. }
  107987. /** @hidden */
  107988. export interface _GamePadFactory {
  107989. /**
  107990. * Returns whether or not the current gamepad can be created for this type of controller.
  107991. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107992. * @returns true if it can be created, otherwise false
  107993. */
  107994. canCreate(gamepadInfo: any): boolean;
  107995. /**
  107996. * Creates a new instance of the Gamepad.
  107997. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107998. * @returns the new gamepad instance
  107999. */
  108000. create(gamepadInfo: any): Gamepad;
  108001. }
  108002. /**
  108003. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  108004. */
  108005. export class PoseEnabledControllerHelper {
  108006. /** @hidden */
  108007. static _ControllerFactories: _GamePadFactory[];
  108008. /** @hidden */
  108009. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  108010. /**
  108011. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  108012. * @param vrGamepad the gamepad to initialized
  108013. * @returns a vr controller of the type the gamepad identified as
  108014. */
  108015. static InitiateController(vrGamepad: any): Gamepad;
  108016. }
  108017. /**
  108018. * Defines the PoseEnabledController object that contains state of a vr capable controller
  108019. */
  108020. export class PoseEnabledController extends Gamepad implements PoseControlled {
  108021. /**
  108022. * If the controller is used in a webXR session
  108023. */
  108024. isXR: boolean;
  108025. private _deviceRoomPosition;
  108026. private _deviceRoomRotationQuaternion;
  108027. /**
  108028. * The device position in babylon space
  108029. */
  108030. devicePosition: Vector3;
  108031. /**
  108032. * The device rotation in babylon space
  108033. */
  108034. deviceRotationQuaternion: Quaternion;
  108035. /**
  108036. * The scale factor of the device in babylon space
  108037. */
  108038. deviceScaleFactor: number;
  108039. /**
  108040. * (Likely devicePosition should be used instead) The device position in its room space
  108041. */
  108042. position: Vector3;
  108043. /**
  108044. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  108045. */
  108046. rotationQuaternion: Quaternion;
  108047. /**
  108048. * The type of controller (Eg. Windows mixed reality)
  108049. */
  108050. controllerType: PoseEnabledControllerType;
  108051. protected _calculatedPosition: Vector3;
  108052. private _calculatedRotation;
  108053. /**
  108054. * The raw pose from the device
  108055. */
  108056. rawPose: DevicePose;
  108057. private _trackPosition;
  108058. private _maxRotationDistFromHeadset;
  108059. private _draggedRoomRotation;
  108060. /**
  108061. * @hidden
  108062. */
  108063. _disableTrackPosition(fixedPosition: Vector3): void;
  108064. /**
  108065. * Internal, the mesh attached to the controller
  108066. * @hidden
  108067. */
  108068. _mesh: Nullable<AbstractMesh>;
  108069. private _poseControlledCamera;
  108070. private _leftHandSystemQuaternion;
  108071. /**
  108072. * Internal, matrix used to convert room space to babylon space
  108073. * @hidden
  108074. */
  108075. _deviceToWorld: Matrix;
  108076. /**
  108077. * Node to be used when casting a ray from the controller
  108078. * @hidden
  108079. */
  108080. _pointingPoseNode: Nullable<TransformNode>;
  108081. /**
  108082. * Name of the child mesh that can be used to cast a ray from the controller
  108083. */
  108084. static readonly POINTING_POSE: string;
  108085. /**
  108086. * Creates a new PoseEnabledController from a gamepad
  108087. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  108088. */
  108089. constructor(browserGamepad: any);
  108090. private _workingMatrix;
  108091. /**
  108092. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  108093. */
  108094. update(): void;
  108095. /**
  108096. * Updates only the pose device and mesh without doing any button event checking
  108097. */
  108098. protected _updatePoseAndMesh(): void;
  108099. /**
  108100. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  108101. * @param poseData raw pose fromthe device
  108102. */
  108103. updateFromDevice(poseData: DevicePose): void;
  108104. /**
  108105. * @hidden
  108106. */
  108107. _meshAttachedObservable: Observable<AbstractMesh>;
  108108. /**
  108109. * Attaches a mesh to the controller
  108110. * @param mesh the mesh to be attached
  108111. */
  108112. attachToMesh(mesh: AbstractMesh): void;
  108113. /**
  108114. * Attaches the controllers mesh to a camera
  108115. * @param camera the camera the mesh should be attached to
  108116. */
  108117. attachToPoseControlledCamera(camera: TargetCamera): void;
  108118. /**
  108119. * Disposes of the controller
  108120. */
  108121. dispose(): void;
  108122. /**
  108123. * The mesh that is attached to the controller
  108124. */
  108125. get mesh(): Nullable<AbstractMesh>;
  108126. /**
  108127. * Gets the ray of the controller in the direction the controller is pointing
  108128. * @param length the length the resulting ray should be
  108129. * @returns a ray in the direction the controller is pointing
  108130. */
  108131. getForwardRay(length?: number): Ray;
  108132. }
  108133. }
  108134. declare module BABYLON {
  108135. /**
  108136. * Defines the WebVRController object that represents controllers tracked in 3D space
  108137. */
  108138. export abstract class WebVRController extends PoseEnabledController {
  108139. /**
  108140. * Internal, the default controller model for the controller
  108141. */
  108142. protected _defaultModel: Nullable<AbstractMesh>;
  108143. /**
  108144. * Fired when the trigger state has changed
  108145. */
  108146. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108147. /**
  108148. * Fired when the main button state has changed
  108149. */
  108150. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108151. /**
  108152. * Fired when the secondary button state has changed
  108153. */
  108154. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108155. /**
  108156. * Fired when the pad state has changed
  108157. */
  108158. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  108159. /**
  108160. * Fired when controllers stick values have changed
  108161. */
  108162. onPadValuesChangedObservable: Observable<StickValues>;
  108163. /**
  108164. * Array of button availible on the controller
  108165. */
  108166. protected _buttons: Array<MutableGamepadButton>;
  108167. private _onButtonStateChange;
  108168. /**
  108169. * Fired when a controller button's state has changed
  108170. * @param callback the callback containing the button that was modified
  108171. */
  108172. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  108173. /**
  108174. * X and Y axis corresponding to the controllers joystick
  108175. */
  108176. pad: StickValues;
  108177. /**
  108178. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  108179. */
  108180. hand: string;
  108181. /**
  108182. * The default controller model for the controller
  108183. */
  108184. get defaultModel(): Nullable<AbstractMesh>;
  108185. /**
  108186. * Creates a new WebVRController from a gamepad
  108187. * @param vrGamepad the gamepad that the WebVRController should be created from
  108188. */
  108189. constructor(vrGamepad: any);
  108190. /**
  108191. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  108192. */
  108193. update(): void;
  108194. /**
  108195. * Function to be called when a button is modified
  108196. */
  108197. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108198. /**
  108199. * Loads a mesh and attaches it to the controller
  108200. * @param scene the scene the mesh should be added to
  108201. * @param meshLoaded callback for when the mesh has been loaded
  108202. */
  108203. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108204. private _setButtonValue;
  108205. private _changes;
  108206. private _checkChanges;
  108207. /**
  108208. * Disposes of th webVRCOntroller
  108209. */
  108210. dispose(): void;
  108211. }
  108212. }
  108213. declare module BABYLON {
  108214. /**
  108215. * The HemisphericLight simulates the ambient environment light,
  108216. * so the passed direction is the light reflection direction, not the incoming direction.
  108217. */
  108218. export class HemisphericLight extends Light {
  108219. /**
  108220. * The groundColor is the light in the opposite direction to the one specified during creation.
  108221. * 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.
  108222. */
  108223. groundColor: Color3;
  108224. /**
  108225. * The light reflection direction, not the incoming direction.
  108226. */
  108227. direction: Vector3;
  108228. /**
  108229. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  108230. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  108231. * The HemisphericLight can't cast shadows.
  108232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108233. * @param name The friendly name of the light
  108234. * @param direction The direction of the light reflection
  108235. * @param scene The scene the light belongs to
  108236. */
  108237. constructor(name: string, direction: Vector3, scene: Scene);
  108238. protected _buildUniformLayout(): void;
  108239. /**
  108240. * Returns the string "HemisphericLight".
  108241. * @return The class name
  108242. */
  108243. getClassName(): string;
  108244. /**
  108245. * Sets the HemisphericLight direction towards the passed target (Vector3).
  108246. * Returns the updated direction.
  108247. * @param target The target the direction should point to
  108248. * @return The computed direction
  108249. */
  108250. setDirectionToTarget(target: Vector3): Vector3;
  108251. /**
  108252. * Returns the shadow generator associated to the light.
  108253. * @returns Always null for hemispheric lights because it does not support shadows.
  108254. */
  108255. getShadowGenerator(): Nullable<IShadowGenerator>;
  108256. /**
  108257. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  108258. * @param effect The effect to update
  108259. * @param lightIndex The index of the light in the effect to update
  108260. * @returns The hemispheric light
  108261. */
  108262. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  108263. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  108264. /**
  108265. * Computes the world matrix of the node
  108266. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108267. * @param useWasUpdatedFlag defines a reserved property
  108268. * @returns the world matrix
  108269. */
  108270. computeWorldMatrix(): Matrix;
  108271. /**
  108272. * Returns the integer 3.
  108273. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108274. */
  108275. getTypeID(): number;
  108276. /**
  108277. * Prepares the list of defines specific to the light type.
  108278. * @param defines the list of defines
  108279. * @param lightIndex defines the index of the light for the effect
  108280. */
  108281. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108282. }
  108283. }
  108284. declare module BABYLON {
  108285. /** @hidden */
  108286. export var vrMultiviewToSingleviewPixelShader: {
  108287. name: string;
  108288. shader: string;
  108289. };
  108290. }
  108291. declare module BABYLON {
  108292. /**
  108293. * Renders to multiple views with a single draw call
  108294. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108295. */
  108296. export class MultiviewRenderTarget extends RenderTargetTexture {
  108297. /**
  108298. * Creates a multiview render target
  108299. * @param scene scene used with the render target
  108300. * @param size the size of the render target (used for each view)
  108301. */
  108302. constructor(scene: Scene, size?: number | {
  108303. width: number;
  108304. height: number;
  108305. } | {
  108306. ratio: number;
  108307. });
  108308. /**
  108309. * @hidden
  108310. * @param faceIndex the face index, if its a cube texture
  108311. */
  108312. _bindFrameBuffer(faceIndex?: number): void;
  108313. /**
  108314. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108315. * @returns the view count
  108316. */
  108317. getViewCount(): number;
  108318. }
  108319. }
  108320. declare module BABYLON {
  108321. interface Engine {
  108322. /**
  108323. * Creates a new multiview render target
  108324. * @param width defines the width of the texture
  108325. * @param height defines the height of the texture
  108326. * @returns the created multiview texture
  108327. */
  108328. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108329. /**
  108330. * Binds a multiview framebuffer to be drawn to
  108331. * @param multiviewTexture texture to bind
  108332. */
  108333. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108334. }
  108335. interface Camera {
  108336. /**
  108337. * @hidden
  108338. * 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)
  108339. */
  108340. _useMultiviewToSingleView: boolean;
  108341. /**
  108342. * @hidden
  108343. * 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)
  108344. */
  108345. _multiviewTexture: Nullable<RenderTargetTexture>;
  108346. /**
  108347. * @hidden
  108348. * ensures the multiview texture of the camera exists and has the specified width/height
  108349. * @param width height to set on the multiview texture
  108350. * @param height width to set on the multiview texture
  108351. */
  108352. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108353. }
  108354. interface Scene {
  108355. /** @hidden */
  108356. _transformMatrixR: Matrix;
  108357. /** @hidden */
  108358. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108359. /** @hidden */
  108360. _createMultiviewUbo(): void;
  108361. /** @hidden */
  108362. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108363. /** @hidden */
  108364. _renderMultiviewToSingleView(camera: Camera): void;
  108365. }
  108366. }
  108367. declare module BABYLON {
  108368. /**
  108369. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108370. * This will not be used for webXR as it supports displaying texture arrays directly
  108371. */
  108372. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108373. /**
  108374. * Gets a string identifying the name of the class
  108375. * @returns "VRMultiviewToSingleviewPostProcess" string
  108376. */
  108377. getClassName(): string;
  108378. /**
  108379. * Initializes a VRMultiviewToSingleview
  108380. * @param name name of the post process
  108381. * @param camera camera to be applied to
  108382. * @param scaleFactor scaling factor to the size of the output texture
  108383. */
  108384. constructor(name: string, camera: Camera, scaleFactor: number);
  108385. }
  108386. }
  108387. declare module BABYLON {
  108388. /**
  108389. * Interface used to define additional presentation attributes
  108390. */
  108391. export interface IVRPresentationAttributes {
  108392. /**
  108393. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108394. */
  108395. highRefreshRate: boolean;
  108396. /**
  108397. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108398. */
  108399. foveationLevel: number;
  108400. }
  108401. interface Engine {
  108402. /** @hidden */
  108403. _vrDisplay: any;
  108404. /** @hidden */
  108405. _vrSupported: boolean;
  108406. /** @hidden */
  108407. _oldSize: Size;
  108408. /** @hidden */
  108409. _oldHardwareScaleFactor: number;
  108410. /** @hidden */
  108411. _vrExclusivePointerMode: boolean;
  108412. /** @hidden */
  108413. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108414. /** @hidden */
  108415. _onVRDisplayPointerRestricted: () => void;
  108416. /** @hidden */
  108417. _onVRDisplayPointerUnrestricted: () => void;
  108418. /** @hidden */
  108419. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108420. /** @hidden */
  108421. _onVrDisplayDisconnect: Nullable<() => void>;
  108422. /** @hidden */
  108423. _onVrDisplayPresentChange: Nullable<() => void>;
  108424. /**
  108425. * Observable signaled when VR display mode changes
  108426. */
  108427. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108428. /**
  108429. * Observable signaled when VR request present is complete
  108430. */
  108431. onVRRequestPresentComplete: Observable<boolean>;
  108432. /**
  108433. * Observable signaled when VR request present starts
  108434. */
  108435. onVRRequestPresentStart: Observable<Engine>;
  108436. /**
  108437. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108438. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108439. */
  108440. isInVRExclusivePointerMode: boolean;
  108441. /**
  108442. * Gets a boolean indicating if a webVR device was detected
  108443. * @returns true if a webVR device was detected
  108444. */
  108445. isVRDevicePresent(): boolean;
  108446. /**
  108447. * Gets the current webVR device
  108448. * @returns the current webVR device (or null)
  108449. */
  108450. getVRDevice(): any;
  108451. /**
  108452. * Initializes a webVR display and starts listening to display change events
  108453. * The onVRDisplayChangedObservable will be notified upon these changes
  108454. * @returns A promise containing a VRDisplay and if vr is supported
  108455. */
  108456. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108457. /** @hidden */
  108458. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108459. /**
  108460. * Gets or sets the presentation attributes used to configure VR rendering
  108461. */
  108462. vrPresentationAttributes?: IVRPresentationAttributes;
  108463. /**
  108464. * Call this function to switch to webVR mode
  108465. * Will do nothing if webVR is not supported or if there is no webVR device
  108466. * @param options the webvr options provided to the camera. mainly used for multiview
  108467. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108468. */
  108469. enableVR(options: WebVROptions): void;
  108470. /** @hidden */
  108471. _onVRFullScreenTriggered(): void;
  108472. }
  108473. }
  108474. declare module BABYLON {
  108475. /**
  108476. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108477. * IMPORTANT!! The data is right-hand data.
  108478. * @export
  108479. * @interface DevicePose
  108480. */
  108481. export interface DevicePose {
  108482. /**
  108483. * The position of the device, values in array are [x,y,z].
  108484. */
  108485. readonly position: Nullable<Float32Array>;
  108486. /**
  108487. * The linearVelocity of the device, values in array are [x,y,z].
  108488. */
  108489. readonly linearVelocity: Nullable<Float32Array>;
  108490. /**
  108491. * The linearAcceleration of the device, values in array are [x,y,z].
  108492. */
  108493. readonly linearAcceleration: Nullable<Float32Array>;
  108494. /**
  108495. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108496. */
  108497. readonly orientation: Nullable<Float32Array>;
  108498. /**
  108499. * The angularVelocity of the device, values in array are [x,y,z].
  108500. */
  108501. readonly angularVelocity: Nullable<Float32Array>;
  108502. /**
  108503. * The angularAcceleration of the device, values in array are [x,y,z].
  108504. */
  108505. readonly angularAcceleration: Nullable<Float32Array>;
  108506. }
  108507. /**
  108508. * Interface representing a pose controlled object in Babylon.
  108509. * A pose controlled object has both regular pose values as well as pose values
  108510. * from an external device such as a VR head mounted display
  108511. */
  108512. export interface PoseControlled {
  108513. /**
  108514. * The position of the object in babylon space.
  108515. */
  108516. position: Vector3;
  108517. /**
  108518. * The rotation quaternion of the object in babylon space.
  108519. */
  108520. rotationQuaternion: Quaternion;
  108521. /**
  108522. * The position of the device in babylon space.
  108523. */
  108524. devicePosition?: Vector3;
  108525. /**
  108526. * The rotation quaternion of the device in babylon space.
  108527. */
  108528. deviceRotationQuaternion: Quaternion;
  108529. /**
  108530. * The raw pose coming from the device.
  108531. */
  108532. rawPose: Nullable<DevicePose>;
  108533. /**
  108534. * The scale of the device to be used when translating from device space to babylon space.
  108535. */
  108536. deviceScaleFactor: number;
  108537. /**
  108538. * Updates the poseControlled values based on the input device pose.
  108539. * @param poseData the pose data to update the object with
  108540. */
  108541. updateFromDevice(poseData: DevicePose): void;
  108542. }
  108543. /**
  108544. * Set of options to customize the webVRCamera
  108545. */
  108546. export interface WebVROptions {
  108547. /**
  108548. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108549. */
  108550. trackPosition?: boolean;
  108551. /**
  108552. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108553. */
  108554. positionScale?: number;
  108555. /**
  108556. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108557. */
  108558. displayName?: string;
  108559. /**
  108560. * Should the native controller meshes be initialized. (default: true)
  108561. */
  108562. controllerMeshes?: boolean;
  108563. /**
  108564. * Creating a default HemiLight only on controllers. (default: true)
  108565. */
  108566. defaultLightingOnControllers?: boolean;
  108567. /**
  108568. * If you don't want to use the default VR button of the helper. (default: false)
  108569. */
  108570. useCustomVRButton?: boolean;
  108571. /**
  108572. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108573. */
  108574. customVRButton?: HTMLButtonElement;
  108575. /**
  108576. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108577. */
  108578. rayLength?: number;
  108579. /**
  108580. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108581. */
  108582. defaultHeight?: number;
  108583. /**
  108584. * If multiview should be used if availible (default: false)
  108585. */
  108586. useMultiview?: boolean;
  108587. }
  108588. /**
  108589. * This represents a WebVR camera.
  108590. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108591. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108592. */
  108593. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108594. private webVROptions;
  108595. /**
  108596. * @hidden
  108597. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108598. */
  108599. _vrDevice: any;
  108600. /**
  108601. * The rawPose of the vrDevice.
  108602. */
  108603. rawPose: Nullable<DevicePose>;
  108604. private _onVREnabled;
  108605. private _specsVersion;
  108606. private _attached;
  108607. private _frameData;
  108608. protected _descendants: Array<Node>;
  108609. private _deviceRoomPosition;
  108610. /** @hidden */
  108611. _deviceRoomRotationQuaternion: Quaternion;
  108612. private _standingMatrix;
  108613. /**
  108614. * Represents device position in babylon space.
  108615. */
  108616. devicePosition: Vector3;
  108617. /**
  108618. * Represents device rotation in babylon space.
  108619. */
  108620. deviceRotationQuaternion: Quaternion;
  108621. /**
  108622. * The scale of the device to be used when translating from device space to babylon space.
  108623. */
  108624. deviceScaleFactor: number;
  108625. private _deviceToWorld;
  108626. private _worldToDevice;
  108627. /**
  108628. * References to the webVR controllers for the vrDevice.
  108629. */
  108630. controllers: Array<WebVRController>;
  108631. /**
  108632. * Emits an event when a controller is attached.
  108633. */
  108634. onControllersAttachedObservable: Observable<WebVRController[]>;
  108635. /**
  108636. * Emits an event when a controller's mesh has been loaded;
  108637. */
  108638. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108639. /**
  108640. * Emits an event when the HMD's pose has been updated.
  108641. */
  108642. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108643. private _poseSet;
  108644. /**
  108645. * If the rig cameras be used as parent instead of this camera.
  108646. */
  108647. rigParenting: boolean;
  108648. private _lightOnControllers;
  108649. private _defaultHeight?;
  108650. /**
  108651. * Instantiates a WebVRFreeCamera.
  108652. * @param name The name of the WebVRFreeCamera
  108653. * @param position The starting anchor position for the camera
  108654. * @param scene The scene the camera belongs to
  108655. * @param webVROptions a set of customizable options for the webVRCamera
  108656. */
  108657. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108658. /**
  108659. * Gets the device distance from the ground in meters.
  108660. * @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.
  108661. */
  108662. deviceDistanceToRoomGround(): number;
  108663. /**
  108664. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108665. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108666. */
  108667. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108668. /**
  108669. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108670. * @returns A promise with a boolean set to if the standing matrix is supported.
  108671. */
  108672. useStandingMatrixAsync(): Promise<boolean>;
  108673. /**
  108674. * Disposes the camera
  108675. */
  108676. dispose(): void;
  108677. /**
  108678. * Gets a vrController by name.
  108679. * @param name The name of the controller to retreive
  108680. * @returns the controller matching the name specified or null if not found
  108681. */
  108682. getControllerByName(name: string): Nullable<WebVRController>;
  108683. private _leftController;
  108684. /**
  108685. * The controller corresponding to the users left hand.
  108686. */
  108687. get leftController(): Nullable<WebVRController>;
  108688. private _rightController;
  108689. /**
  108690. * The controller corresponding to the users right hand.
  108691. */
  108692. get rightController(): Nullable<WebVRController>;
  108693. /**
  108694. * Casts a ray forward from the vrCamera's gaze.
  108695. * @param length Length of the ray (default: 100)
  108696. * @returns the ray corresponding to the gaze
  108697. */
  108698. getForwardRay(length?: number): Ray;
  108699. /**
  108700. * @hidden
  108701. * Updates the camera based on device's frame data
  108702. */
  108703. _checkInputs(): void;
  108704. /**
  108705. * Updates the poseControlled values based on the input device pose.
  108706. * @param poseData Pose coming from the device
  108707. */
  108708. updateFromDevice(poseData: DevicePose): void;
  108709. private _detachIfAttached;
  108710. /**
  108711. * WebVR's attach control will start broadcasting frames to the device.
  108712. * Note that in certain browsers (chrome for example) this function must be called
  108713. * within a user-interaction callback. Example:
  108714. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108715. *
  108716. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108717. */
  108718. attachControl(noPreventDefault?: boolean): void;
  108719. /**
  108720. * Detach the current controls from the specified dom element.
  108721. */
  108722. detachControl(): void;
  108723. /**
  108724. * @returns the name of this class
  108725. */
  108726. getClassName(): string;
  108727. /**
  108728. * Calls resetPose on the vrDisplay
  108729. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108730. */
  108731. resetToCurrentRotation(): void;
  108732. /**
  108733. * @hidden
  108734. * Updates the rig cameras (left and right eye)
  108735. */
  108736. _updateRigCameras(): void;
  108737. private _workingVector;
  108738. private _oneVector;
  108739. private _workingMatrix;
  108740. private updateCacheCalled;
  108741. private _correctPositionIfNotTrackPosition;
  108742. /**
  108743. * @hidden
  108744. * Updates the cached values of the camera
  108745. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108746. */
  108747. _updateCache(ignoreParentClass?: boolean): void;
  108748. /**
  108749. * @hidden
  108750. * Get current device position in babylon world
  108751. */
  108752. _computeDevicePosition(): void;
  108753. /**
  108754. * Updates the current device position and rotation in the babylon world
  108755. */
  108756. update(): void;
  108757. /**
  108758. * @hidden
  108759. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108760. * @returns an identity matrix
  108761. */
  108762. _getViewMatrix(): Matrix;
  108763. private _tmpMatrix;
  108764. /**
  108765. * This function is called by the two RIG cameras.
  108766. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108767. * @hidden
  108768. */
  108769. _getWebVRViewMatrix(): Matrix;
  108770. /** @hidden */
  108771. _getWebVRProjectionMatrix(): Matrix;
  108772. private _onGamepadConnectedObserver;
  108773. private _onGamepadDisconnectedObserver;
  108774. private _updateCacheWhenTrackingDisabledObserver;
  108775. /**
  108776. * Initializes the controllers and their meshes
  108777. */
  108778. initControllers(): void;
  108779. }
  108780. }
  108781. declare module BABYLON {
  108782. /**
  108783. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108784. *
  108785. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108786. *
  108787. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108788. */
  108789. export class MaterialHelper {
  108790. /**
  108791. * Bind the current view position to an effect.
  108792. * @param effect The effect to be bound
  108793. * @param scene The scene the eyes position is used from
  108794. * @param variableName name of the shader variable that will hold the eye position
  108795. */
  108796. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108797. /**
  108798. * Helps preparing the defines values about the UVs in used in the effect.
  108799. * UVs are shared as much as we can accross channels in the shaders.
  108800. * @param texture The texture we are preparing the UVs for
  108801. * @param defines The defines to update
  108802. * @param key The channel key "diffuse", "specular"... used in the shader
  108803. */
  108804. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108805. /**
  108806. * Binds a texture matrix value to its corrsponding uniform
  108807. * @param texture The texture to bind the matrix for
  108808. * @param uniformBuffer The uniform buffer receivin the data
  108809. * @param key The channel key "diffuse", "specular"... used in the shader
  108810. */
  108811. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108812. /**
  108813. * Gets the current status of the fog (should it be enabled?)
  108814. * @param mesh defines the mesh to evaluate for fog support
  108815. * @param scene defines the hosting scene
  108816. * @returns true if fog must be enabled
  108817. */
  108818. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108819. /**
  108820. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108821. * @param mesh defines the current mesh
  108822. * @param scene defines the current scene
  108823. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108824. * @param pointsCloud defines if point cloud rendering has to be turned on
  108825. * @param fogEnabled defines if fog has to be turned on
  108826. * @param alphaTest defines if alpha testing has to be turned on
  108827. * @param defines defines the current list of defines
  108828. */
  108829. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108830. /**
  108831. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108832. * @param scene defines the current scene
  108833. * @param engine defines the current engine
  108834. * @param defines specifies the list of active defines
  108835. * @param useInstances defines if instances have to be turned on
  108836. * @param useClipPlane defines if clip plane have to be turned on
  108837. * @param useInstances defines if instances have to be turned on
  108838. * @param useThinInstances defines if thin instances have to be turned on
  108839. */
  108840. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108841. /**
  108842. * Prepares the defines for bones
  108843. * @param mesh The mesh containing the geometry data we will draw
  108844. * @param defines The defines to update
  108845. */
  108846. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108847. /**
  108848. * Prepares the defines for morph targets
  108849. * @param mesh The mesh containing the geometry data we will draw
  108850. * @param defines The defines to update
  108851. */
  108852. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108853. /**
  108854. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108855. * @param mesh The mesh containing the geometry data we will draw
  108856. * @param defines The defines to update
  108857. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108858. * @param useBones Precise whether bones should be used or not (override mesh info)
  108859. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108860. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108861. * @returns false if defines are considered not dirty and have not been checked
  108862. */
  108863. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108864. /**
  108865. * Prepares the defines related to multiview
  108866. * @param scene The scene we are intending to draw
  108867. * @param defines The defines to update
  108868. */
  108869. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108870. /**
  108871. * Prepares the defines related to the prepass
  108872. * @param scene The scene we are intending to draw
  108873. * @param defines The defines to update
  108874. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108875. */
  108876. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108877. /**
  108878. * Prepares the defines related to the light information passed in parameter
  108879. * @param scene The scene we are intending to draw
  108880. * @param mesh The mesh the effect is compiling for
  108881. * @param light The light the effect is compiling for
  108882. * @param lightIndex The index of the light
  108883. * @param defines The defines to update
  108884. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108885. * @param state Defines the current state regarding what is needed (normals, etc...)
  108886. */
  108887. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108888. needNormals: boolean;
  108889. needRebuild: boolean;
  108890. shadowEnabled: boolean;
  108891. specularEnabled: boolean;
  108892. lightmapMode: boolean;
  108893. }): void;
  108894. /**
  108895. * Prepares the defines related to the light information passed in parameter
  108896. * @param scene The scene we are intending to draw
  108897. * @param mesh The mesh the effect is compiling for
  108898. * @param defines The defines to update
  108899. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108900. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108901. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108902. * @returns true if normals will be required for the rest of the effect
  108903. */
  108904. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108905. /**
  108906. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108907. * @param lightIndex defines the light index
  108908. * @param uniformsList The uniform list
  108909. * @param samplersList The sampler list
  108910. * @param projectedLightTexture defines if projected texture must be used
  108911. * @param uniformBuffersList defines an optional list of uniform buffers
  108912. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  108913. */
  108914. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  108915. /**
  108916. * Prepares the uniforms and samplers list to be used in the effect
  108917. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108918. * @param samplersList The sampler list
  108919. * @param defines The defines helping in the list generation
  108920. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108921. */
  108922. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108923. /**
  108924. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108925. * @param defines The defines to update while falling back
  108926. * @param fallbacks The authorized effect fallbacks
  108927. * @param maxSimultaneousLights The maximum number of lights allowed
  108928. * @param rank the current rank of the Effect
  108929. * @returns The newly affected rank
  108930. */
  108931. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108932. private static _TmpMorphInfluencers;
  108933. /**
  108934. * Prepares the list of attributes required for morph targets according to the effect defines.
  108935. * @param attribs The current list of supported attribs
  108936. * @param mesh The mesh to prepare the morph targets attributes for
  108937. * @param influencers The number of influencers
  108938. */
  108939. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  108940. /**
  108941. * Prepares the list of attributes required for morph targets according to the effect defines.
  108942. * @param attribs The current list of supported attribs
  108943. * @param mesh The mesh to prepare the morph targets attributes for
  108944. * @param defines The current Defines of the effect
  108945. */
  108946. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  108947. /**
  108948. * Prepares the list of attributes required for bones according to the effect defines.
  108949. * @param attribs The current list of supported attribs
  108950. * @param mesh The mesh to prepare the bones attributes for
  108951. * @param defines The current Defines of the effect
  108952. * @param fallbacks The current efffect fallback strategy
  108953. */
  108954. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  108955. /**
  108956. * Check and prepare the list of attributes required for instances according to the effect defines.
  108957. * @param attribs The current list of supported attribs
  108958. * @param defines The current MaterialDefines of the effect
  108959. */
  108960. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  108961. /**
  108962. * Add the list of attributes required for instances to the attribs array.
  108963. * @param attribs The current list of supported attribs
  108964. */
  108965. static PushAttributesForInstances(attribs: string[]): void;
  108966. /**
  108967. * Binds the light information to the effect.
  108968. * @param light The light containing the generator
  108969. * @param effect The effect we are binding the data to
  108970. * @param lightIndex The light index in the effect used to render
  108971. */
  108972. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  108973. /**
  108974. * Binds the lights information from the scene to the effect for the given mesh.
  108975. * @param light Light to bind
  108976. * @param lightIndex Light index
  108977. * @param scene The scene where the light belongs to
  108978. * @param effect The effect we are binding the data to
  108979. * @param useSpecular Defines if specular is supported
  108980. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108981. */
  108982. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  108983. /**
  108984. * Binds the lights information from the scene to the effect for the given mesh.
  108985. * @param scene The scene the lights belongs to
  108986. * @param mesh The mesh we are binding the information to render
  108987. * @param effect The effect we are binding the data to
  108988. * @param defines The generated defines for the effect
  108989. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  108990. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108991. */
  108992. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  108993. private static _tempFogColor;
  108994. /**
  108995. * Binds the fog information from the scene to the effect for the given mesh.
  108996. * @param scene The scene the lights belongs to
  108997. * @param mesh The mesh we are binding the information to render
  108998. * @param effect The effect we are binding the data to
  108999. * @param linearSpace Defines if the fog effect is applied in linear space
  109000. */
  109001. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  109002. /**
  109003. * Binds the bones information from the mesh to the effect.
  109004. * @param mesh The mesh we are binding the information to render
  109005. * @param effect The effect we are binding the data to
  109006. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  109007. */
  109008. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  109009. private static _CopyBonesTransformationMatrices;
  109010. /**
  109011. * Binds the morph targets information from the mesh to the effect.
  109012. * @param abstractMesh The mesh we are binding the information to render
  109013. * @param effect The effect we are binding the data to
  109014. */
  109015. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  109016. /**
  109017. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  109018. * @param defines The generated defines used in the effect
  109019. * @param effect The effect we are binding the data to
  109020. * @param scene The scene we are willing to render with logarithmic scale for
  109021. */
  109022. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  109023. /**
  109024. * Binds the clip plane information from the scene to the effect.
  109025. * @param scene The scene the clip plane information are extracted from
  109026. * @param effect The effect we are binding the data to
  109027. */
  109028. static BindClipPlane(effect: Effect, scene: Scene): void;
  109029. }
  109030. }
  109031. declare module BABYLON {
  109032. /** @hidden */
  109033. export var bayerDitherFunctions: {
  109034. name: string;
  109035. shader: string;
  109036. };
  109037. }
  109038. declare module BABYLON {
  109039. /** @hidden */
  109040. export var shadowMapFragmentDeclaration: {
  109041. name: string;
  109042. shader: string;
  109043. };
  109044. }
  109045. declare module BABYLON {
  109046. /** @hidden */
  109047. export var shadowMapFragment: {
  109048. name: string;
  109049. shader: string;
  109050. };
  109051. }
  109052. declare module BABYLON {
  109053. /** @hidden */
  109054. export var shadowMapPixelShader: {
  109055. name: string;
  109056. shader: string;
  109057. };
  109058. }
  109059. declare module BABYLON {
  109060. /** @hidden */
  109061. export var shadowMapVertexDeclaration: {
  109062. name: string;
  109063. shader: string;
  109064. };
  109065. }
  109066. declare module BABYLON {
  109067. /** @hidden */
  109068. export var shadowMapVertexNormalBias: {
  109069. name: string;
  109070. shader: string;
  109071. };
  109072. }
  109073. declare module BABYLON {
  109074. /** @hidden */
  109075. export var shadowMapVertexMetric: {
  109076. name: string;
  109077. shader: string;
  109078. };
  109079. }
  109080. declare module BABYLON {
  109081. /** @hidden */
  109082. export var shadowMapVertexShader: {
  109083. name: string;
  109084. shader: string;
  109085. };
  109086. }
  109087. declare module BABYLON {
  109088. /** @hidden */
  109089. export var depthBoxBlurPixelShader: {
  109090. name: string;
  109091. shader: string;
  109092. };
  109093. }
  109094. declare module BABYLON {
  109095. /** @hidden */
  109096. export var shadowMapFragmentSoftTransparentShadow: {
  109097. name: string;
  109098. shader: string;
  109099. };
  109100. }
  109101. declare module BABYLON {
  109102. /**
  109103. * Creates an instance based on a source mesh.
  109104. */
  109105. export class InstancedMesh extends AbstractMesh {
  109106. private _sourceMesh;
  109107. private _currentLOD;
  109108. /** @hidden */
  109109. _indexInSourceMeshInstanceArray: number;
  109110. constructor(name: string, source: Mesh);
  109111. /**
  109112. * Returns the string "InstancedMesh".
  109113. */
  109114. getClassName(): string;
  109115. /** Gets the list of lights affecting that mesh */
  109116. get lightSources(): Light[];
  109117. _resyncLightSources(): void;
  109118. _resyncLightSource(light: Light): void;
  109119. _removeLightSource(light: Light, dispose: boolean): void;
  109120. /**
  109121. * If the source mesh receives shadows
  109122. */
  109123. get receiveShadows(): boolean;
  109124. /**
  109125. * The material of the source mesh
  109126. */
  109127. get material(): Nullable<Material>;
  109128. /**
  109129. * Visibility of the source mesh
  109130. */
  109131. get visibility(): number;
  109132. /**
  109133. * Skeleton of the source mesh
  109134. */
  109135. get skeleton(): Nullable<Skeleton>;
  109136. /**
  109137. * Rendering ground id of the source mesh
  109138. */
  109139. get renderingGroupId(): number;
  109140. set renderingGroupId(value: number);
  109141. /**
  109142. * Returns the total number of vertices (integer).
  109143. */
  109144. getTotalVertices(): number;
  109145. /**
  109146. * Returns a positive integer : the total number of indices in this mesh geometry.
  109147. * @returns the numner of indices or zero if the mesh has no geometry.
  109148. */
  109149. getTotalIndices(): number;
  109150. /**
  109151. * The source mesh of the instance
  109152. */
  109153. get sourceMesh(): Mesh;
  109154. /**
  109155. * Creates a new InstancedMesh object from the mesh model.
  109156. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109157. * @param name defines the name of the new instance
  109158. * @returns a new InstancedMesh
  109159. */
  109160. createInstance(name: string): InstancedMesh;
  109161. /**
  109162. * Is this node ready to be used/rendered
  109163. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109164. * @return {boolean} is it ready
  109165. */
  109166. isReady(completeCheck?: boolean): boolean;
  109167. /**
  109168. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109169. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  109170. * @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.
  109171. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  109172. */
  109173. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  109174. /**
  109175. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109176. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109177. * The `data` are either a numeric array either a Float32Array.
  109178. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  109179. * 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).
  109180. * Note that a new underlying VertexBuffer object is created each call.
  109181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109182. *
  109183. * Possible `kind` values :
  109184. * - VertexBuffer.PositionKind
  109185. * - VertexBuffer.UVKind
  109186. * - VertexBuffer.UV2Kind
  109187. * - VertexBuffer.UV3Kind
  109188. * - VertexBuffer.UV4Kind
  109189. * - VertexBuffer.UV5Kind
  109190. * - VertexBuffer.UV6Kind
  109191. * - VertexBuffer.ColorKind
  109192. * - VertexBuffer.MatricesIndicesKind
  109193. * - VertexBuffer.MatricesIndicesExtraKind
  109194. * - VertexBuffer.MatricesWeightsKind
  109195. * - VertexBuffer.MatricesWeightsExtraKind
  109196. *
  109197. * Returns the Mesh.
  109198. */
  109199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109200. /**
  109201. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109202. * If the mesh has no geometry, it is simply returned as it is.
  109203. * The `data` are either a numeric array either a Float32Array.
  109204. * No new underlying VertexBuffer object is created.
  109205. * 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.
  109206. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  109207. *
  109208. * Possible `kind` values :
  109209. * - VertexBuffer.PositionKind
  109210. * - VertexBuffer.UVKind
  109211. * - VertexBuffer.UV2Kind
  109212. * - VertexBuffer.UV3Kind
  109213. * - VertexBuffer.UV4Kind
  109214. * - VertexBuffer.UV5Kind
  109215. * - VertexBuffer.UV6Kind
  109216. * - VertexBuffer.ColorKind
  109217. * - VertexBuffer.MatricesIndicesKind
  109218. * - VertexBuffer.MatricesIndicesExtraKind
  109219. * - VertexBuffer.MatricesWeightsKind
  109220. * - VertexBuffer.MatricesWeightsExtraKind
  109221. *
  109222. * Returns the Mesh.
  109223. */
  109224. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  109225. /**
  109226. * Sets the mesh indices.
  109227. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  109228. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109229. * This method creates a new index buffer each call.
  109230. * Returns the Mesh.
  109231. */
  109232. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  109233. /**
  109234. * Boolean : True if the mesh owns the requested kind of data.
  109235. */
  109236. isVerticesDataPresent(kind: string): boolean;
  109237. /**
  109238. * Returns an array of indices (IndicesArray).
  109239. */
  109240. getIndices(): Nullable<IndicesArray>;
  109241. get _positions(): Nullable<Vector3[]>;
  109242. /**
  109243. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109244. * This means the mesh underlying bounding box and sphere are recomputed.
  109245. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109246. * @returns the current mesh
  109247. */
  109248. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  109249. /** @hidden */
  109250. _preActivate(): InstancedMesh;
  109251. /** @hidden */
  109252. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109253. /** @hidden */
  109254. _postActivate(): void;
  109255. getWorldMatrix(): Matrix;
  109256. get isAnInstance(): boolean;
  109257. /**
  109258. * Returns the current associated LOD AbstractMesh.
  109259. */
  109260. getLOD(camera: Camera): AbstractMesh;
  109261. /** @hidden */
  109262. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109263. /** @hidden */
  109264. _syncSubMeshes(): InstancedMesh;
  109265. /** @hidden */
  109266. _generatePointsArray(): boolean;
  109267. /** @hidden */
  109268. _updateBoundingInfo(): AbstractMesh;
  109269. /**
  109270. * Creates a new InstancedMesh from the current mesh.
  109271. * - name (string) : the cloned mesh name
  109272. * - newParent (optional Node) : the optional Node to parent the clone to.
  109273. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109274. *
  109275. * Returns the clone.
  109276. */
  109277. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109278. /**
  109279. * Disposes the InstancedMesh.
  109280. * Returns nothing.
  109281. */
  109282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109283. }
  109284. interface Mesh {
  109285. /**
  109286. * Register a custom buffer that will be instanced
  109287. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109288. * @param kind defines the buffer kind
  109289. * @param stride defines the stride in floats
  109290. */
  109291. registerInstancedBuffer(kind: string, stride: number): void;
  109292. /**
  109293. * true to use the edge renderer for all instances of this mesh
  109294. */
  109295. edgesShareWithInstances: boolean;
  109296. /** @hidden */
  109297. _userInstancedBuffersStorage: {
  109298. data: {
  109299. [key: string]: Float32Array;
  109300. };
  109301. sizes: {
  109302. [key: string]: number;
  109303. };
  109304. vertexBuffers: {
  109305. [key: string]: Nullable<VertexBuffer>;
  109306. };
  109307. strides: {
  109308. [key: string]: number;
  109309. };
  109310. };
  109311. }
  109312. interface AbstractMesh {
  109313. /**
  109314. * Object used to store instanced buffers defined by user
  109315. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109316. */
  109317. instancedBuffers: {
  109318. [key: string]: any;
  109319. };
  109320. }
  109321. }
  109322. declare module BABYLON {
  109323. /**
  109324. * Defines the options associated with the creation of a shader material.
  109325. */
  109326. export interface IShaderMaterialOptions {
  109327. /**
  109328. * Does the material work in alpha blend mode
  109329. */
  109330. needAlphaBlending: boolean;
  109331. /**
  109332. * Does the material work in alpha test mode
  109333. */
  109334. needAlphaTesting: boolean;
  109335. /**
  109336. * The list of attribute names used in the shader
  109337. */
  109338. attributes: string[];
  109339. /**
  109340. * The list of unifrom names used in the shader
  109341. */
  109342. uniforms: string[];
  109343. /**
  109344. * The list of UBO names used in the shader
  109345. */
  109346. uniformBuffers: string[];
  109347. /**
  109348. * The list of sampler names used in the shader
  109349. */
  109350. samplers: string[];
  109351. /**
  109352. * The list of defines used in the shader
  109353. */
  109354. defines: string[];
  109355. }
  109356. /**
  109357. * 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.
  109358. *
  109359. * This returned material effects how the mesh will look based on the code in the shaders.
  109360. *
  109361. * @see https://doc.babylonjs.com/how_to/shader_material
  109362. */
  109363. export class ShaderMaterial extends Material {
  109364. private _shaderPath;
  109365. private _options;
  109366. private _textures;
  109367. private _textureArrays;
  109368. private _floats;
  109369. private _ints;
  109370. private _floatsArrays;
  109371. private _colors3;
  109372. private _colors3Arrays;
  109373. private _colors4;
  109374. private _colors4Arrays;
  109375. private _vectors2;
  109376. private _vectors3;
  109377. private _vectors4;
  109378. private _matrices;
  109379. private _matrixArrays;
  109380. private _matrices3x3;
  109381. private _matrices2x2;
  109382. private _vectors2Arrays;
  109383. private _vectors3Arrays;
  109384. private _vectors4Arrays;
  109385. private _cachedWorldViewMatrix;
  109386. private _cachedWorldViewProjectionMatrix;
  109387. private _renderId;
  109388. private _multiview;
  109389. private _cachedDefines;
  109390. /** Define the Url to load snippets */
  109391. static SnippetUrl: string;
  109392. /** Snippet ID if the material was created from the snippet server */
  109393. snippetId: string;
  109394. /**
  109395. * Instantiate a new shader material.
  109396. * 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.
  109397. * This returned material effects how the mesh will look based on the code in the shaders.
  109398. * @see https://doc.babylonjs.com/how_to/shader_material
  109399. * @param name Define the name of the material in the scene
  109400. * @param scene Define the scene the material belongs to
  109401. * @param shaderPath Defines the route to the shader code in one of three ways:
  109402. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109403. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109404. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109405. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109406. * @param options Define the options used to create the shader
  109407. */
  109408. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109409. /**
  109410. * Gets the shader path used to define the shader code
  109411. * It can be modified to trigger a new compilation
  109412. */
  109413. get shaderPath(): any;
  109414. /**
  109415. * Sets the shader path used to define the shader code
  109416. * It can be modified to trigger a new compilation
  109417. */
  109418. set shaderPath(shaderPath: any);
  109419. /**
  109420. * Gets the options used to compile the shader.
  109421. * They can be modified to trigger a new compilation
  109422. */
  109423. get options(): IShaderMaterialOptions;
  109424. /**
  109425. * Gets the current class name of the material e.g. "ShaderMaterial"
  109426. * Mainly use in serialization.
  109427. * @returns the class name
  109428. */
  109429. getClassName(): string;
  109430. /**
  109431. * Specifies if the material will require alpha blending
  109432. * @returns a boolean specifying if alpha blending is needed
  109433. */
  109434. needAlphaBlending(): boolean;
  109435. /**
  109436. * Specifies if this material should be rendered in alpha test mode
  109437. * @returns a boolean specifying if an alpha test is needed.
  109438. */
  109439. needAlphaTesting(): boolean;
  109440. private _checkUniform;
  109441. /**
  109442. * Set a texture in the shader.
  109443. * @param name Define the name of the uniform samplers as defined in the shader
  109444. * @param texture Define the texture to bind to this sampler
  109445. * @return the material itself allowing "fluent" like uniform updates
  109446. */
  109447. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109448. /**
  109449. * Set a texture array in the shader.
  109450. * @param name Define the name of the uniform sampler array as defined in the shader
  109451. * @param textures Define the list of textures to bind to this sampler
  109452. * @return the material itself allowing "fluent" like uniform updates
  109453. */
  109454. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109455. /**
  109456. * Set a float in the shader.
  109457. * @param name Define the name of the uniform as defined in the shader
  109458. * @param value Define the value to give to the uniform
  109459. * @return the material itself allowing "fluent" like uniform updates
  109460. */
  109461. setFloat(name: string, value: number): ShaderMaterial;
  109462. /**
  109463. * Set a int in the shader.
  109464. * @param name Define the name of the uniform as defined in the shader
  109465. * @param value Define the value to give to the uniform
  109466. * @return the material itself allowing "fluent" like uniform updates
  109467. */
  109468. setInt(name: string, value: number): ShaderMaterial;
  109469. /**
  109470. * Set an array of floats in the shader.
  109471. * @param name Define the name of the uniform as defined in the shader
  109472. * @param value Define the value to give to the uniform
  109473. * @return the material itself allowing "fluent" like uniform updates
  109474. */
  109475. setFloats(name: string, value: number[]): ShaderMaterial;
  109476. /**
  109477. * Set a vec3 in the shader from a Color3.
  109478. * @param name Define the name of the uniform as defined in the shader
  109479. * @param value Define the value to give to the uniform
  109480. * @return the material itself allowing "fluent" like uniform updates
  109481. */
  109482. setColor3(name: string, value: Color3): ShaderMaterial;
  109483. /**
  109484. * Set a vec3 array in the shader from a Color3 array.
  109485. * @param name Define the name of the uniform as defined in the shader
  109486. * @param value Define the value to give to the uniform
  109487. * @return the material itself allowing "fluent" like uniform updates
  109488. */
  109489. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109490. /**
  109491. * Set a vec4 in the shader from a Color4.
  109492. * @param name Define the name of the uniform as defined in the shader
  109493. * @param value Define the value to give to the uniform
  109494. * @return the material itself allowing "fluent" like uniform updates
  109495. */
  109496. setColor4(name: string, value: Color4): ShaderMaterial;
  109497. /**
  109498. * Set a vec4 array in the shader from a Color4 array.
  109499. * @param name Define the name of the uniform as defined in the shader
  109500. * @param value Define the value to give to the uniform
  109501. * @return the material itself allowing "fluent" like uniform updates
  109502. */
  109503. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109504. /**
  109505. * Set a vec2 in the shader from a Vector2.
  109506. * @param name Define the name of the uniform as defined in the shader
  109507. * @param value Define the value to give to the uniform
  109508. * @return the material itself allowing "fluent" like uniform updates
  109509. */
  109510. setVector2(name: string, value: Vector2): ShaderMaterial;
  109511. /**
  109512. * Set a vec3 in the shader from a Vector3.
  109513. * @param name Define the name of the uniform as defined in the shader
  109514. * @param value Define the value to give to the uniform
  109515. * @return the material itself allowing "fluent" like uniform updates
  109516. */
  109517. setVector3(name: string, value: Vector3): ShaderMaterial;
  109518. /**
  109519. * Set a vec4 in the shader from a Vector4.
  109520. * @param name Define the name of the uniform as defined in the shader
  109521. * @param value Define the value to give to the uniform
  109522. * @return the material itself allowing "fluent" like uniform updates
  109523. */
  109524. setVector4(name: string, value: Vector4): ShaderMaterial;
  109525. /**
  109526. * Set a mat4 in the shader from a Matrix.
  109527. * @param name Define the name of the uniform as defined in the shader
  109528. * @param value Define the value to give to the uniform
  109529. * @return the material itself allowing "fluent" like uniform updates
  109530. */
  109531. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109532. /**
  109533. * Set a float32Array in the shader from a matrix array.
  109534. * @param name Define the name of the uniform as defined in the shader
  109535. * @param value Define the value to give to the uniform
  109536. * @return the material itself allowing "fluent" like uniform updates
  109537. */
  109538. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109539. /**
  109540. * Set a mat3 in the shader from a Float32Array.
  109541. * @param name Define the name of the uniform as defined in the shader
  109542. * @param value Define the value to give to the uniform
  109543. * @return the material itself allowing "fluent" like uniform updates
  109544. */
  109545. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109546. /**
  109547. * Set a mat2 in the shader from a Float32Array.
  109548. * @param name Define the name of the uniform as defined in the shader
  109549. * @param value Define the value to give to the uniform
  109550. * @return the material itself allowing "fluent" like uniform updates
  109551. */
  109552. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109553. /**
  109554. * Set a vec2 array in the shader from a number array.
  109555. * @param name Define the name of the uniform as defined in the shader
  109556. * @param value Define the value to give to the uniform
  109557. * @return the material itself allowing "fluent" like uniform updates
  109558. */
  109559. setArray2(name: string, value: number[]): ShaderMaterial;
  109560. /**
  109561. * Set a vec3 array in the shader from a number array.
  109562. * @param name Define the name of the uniform as defined in the shader
  109563. * @param value Define the value to give to the uniform
  109564. * @return the material itself allowing "fluent" like uniform updates
  109565. */
  109566. setArray3(name: string, value: number[]): ShaderMaterial;
  109567. /**
  109568. * Set a vec4 array in the shader from a number array.
  109569. * @param name Define the name of the uniform as defined in the shader
  109570. * @param value Define the value to give to the uniform
  109571. * @return the material itself allowing "fluent" like uniform updates
  109572. */
  109573. setArray4(name: string, value: number[]): ShaderMaterial;
  109574. private _checkCache;
  109575. /**
  109576. * Specifies that the submesh is ready to be used
  109577. * @param mesh defines the mesh to check
  109578. * @param subMesh defines which submesh to check
  109579. * @param useInstances specifies that instances should be used
  109580. * @returns a boolean indicating that the submesh is ready or not
  109581. */
  109582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109583. /**
  109584. * Checks if the material is ready to render the requested mesh
  109585. * @param mesh Define the mesh to render
  109586. * @param useInstances Define whether or not the material is used with instances
  109587. * @returns true if ready, otherwise false
  109588. */
  109589. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109590. /**
  109591. * Binds the world matrix to the material
  109592. * @param world defines the world transformation matrix
  109593. * @param effectOverride - If provided, use this effect instead of internal effect
  109594. */
  109595. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109596. /**
  109597. * Binds the submesh to this material by preparing the effect and shader to draw
  109598. * @param world defines the world transformation matrix
  109599. * @param mesh defines the mesh containing the submesh
  109600. * @param subMesh defines the submesh to bind the material to
  109601. */
  109602. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109603. /**
  109604. * Binds the material to the mesh
  109605. * @param world defines the world transformation matrix
  109606. * @param mesh defines the mesh to bind the material to
  109607. * @param effectOverride - If provided, use this effect instead of internal effect
  109608. */
  109609. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109610. protected _afterBind(mesh?: Mesh): void;
  109611. /**
  109612. * Gets the active textures from the material
  109613. * @returns an array of textures
  109614. */
  109615. getActiveTextures(): BaseTexture[];
  109616. /**
  109617. * Specifies if the material uses a texture
  109618. * @param texture defines the texture to check against the material
  109619. * @returns a boolean specifying if the material uses the texture
  109620. */
  109621. hasTexture(texture: BaseTexture): boolean;
  109622. /**
  109623. * Makes a duplicate of the material, and gives it a new name
  109624. * @param name defines the new name for the duplicated material
  109625. * @returns the cloned material
  109626. */
  109627. clone(name: string): ShaderMaterial;
  109628. /**
  109629. * Disposes the material
  109630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109632. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109633. */
  109634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109635. /**
  109636. * Serializes this material in a JSON representation
  109637. * @returns the serialized material object
  109638. */
  109639. serialize(): any;
  109640. /**
  109641. * Creates a shader material from parsed shader material data
  109642. * @param source defines the JSON represnetation of the material
  109643. * @param scene defines the hosting scene
  109644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109645. * @returns a new material
  109646. */
  109647. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109648. /**
  109649. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109650. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109651. * @param url defines the url to load from
  109652. * @param scene defines the hosting scene
  109653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109654. * @returns a promise that will resolve to the new ShaderMaterial
  109655. */
  109656. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109657. /**
  109658. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109659. * @param snippetId defines the snippet to load
  109660. * @param scene defines the hosting scene
  109661. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109662. * @returns a promise that will resolve to the new ShaderMaterial
  109663. */
  109664. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. /** @hidden */
  109669. export var colorPixelShader: {
  109670. name: string;
  109671. shader: string;
  109672. };
  109673. }
  109674. declare module BABYLON {
  109675. /** @hidden */
  109676. export var colorVertexShader: {
  109677. name: string;
  109678. shader: string;
  109679. };
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * Line mesh
  109684. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109685. */
  109686. export class LinesMesh extends Mesh {
  109687. /**
  109688. * If vertex color should be applied to the mesh
  109689. */
  109690. readonly useVertexColor?: boolean | undefined;
  109691. /**
  109692. * If vertex alpha should be applied to the mesh
  109693. */
  109694. readonly useVertexAlpha?: boolean | undefined;
  109695. /**
  109696. * Color of the line (Default: White)
  109697. */
  109698. color: Color3;
  109699. /**
  109700. * Alpha of the line (Default: 1)
  109701. */
  109702. alpha: number;
  109703. /**
  109704. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109705. * This margin is expressed in world space coordinates, so its value may vary.
  109706. * Default value is 0.1
  109707. */
  109708. intersectionThreshold: number;
  109709. private _colorShader;
  109710. private color4;
  109711. /**
  109712. * Creates a new LinesMesh
  109713. * @param name defines the name
  109714. * @param scene defines the hosting scene
  109715. * @param parent defines the parent mesh if any
  109716. * @param source defines the optional source LinesMesh used to clone data from
  109717. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109718. * When false, achieved by calling a clone(), also passing False.
  109719. * This will make creation of children, recursive.
  109720. * @param useVertexColor defines if this LinesMesh supports vertex color
  109721. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109722. */
  109723. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109724. /**
  109725. * If vertex color should be applied to the mesh
  109726. */
  109727. useVertexColor?: boolean | undefined,
  109728. /**
  109729. * If vertex alpha should be applied to the mesh
  109730. */
  109731. useVertexAlpha?: boolean | undefined);
  109732. private _addClipPlaneDefine;
  109733. private _removeClipPlaneDefine;
  109734. isReady(): boolean;
  109735. /**
  109736. * Returns the string "LineMesh"
  109737. */
  109738. getClassName(): string;
  109739. /**
  109740. * @hidden
  109741. */
  109742. get material(): Material;
  109743. /**
  109744. * @hidden
  109745. */
  109746. set material(value: Material);
  109747. /**
  109748. * @hidden
  109749. */
  109750. get checkCollisions(): boolean;
  109751. /** @hidden */
  109752. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109753. /** @hidden */
  109754. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109755. /**
  109756. * Disposes of the line mesh
  109757. * @param doNotRecurse If children should be disposed
  109758. */
  109759. dispose(doNotRecurse?: boolean): void;
  109760. /**
  109761. * Returns a new LineMesh object cloned from the current one.
  109762. */
  109763. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109764. /**
  109765. * Creates a new InstancedLinesMesh object from the mesh model.
  109766. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109767. * @param name defines the name of the new instance
  109768. * @returns a new InstancedLinesMesh
  109769. */
  109770. createInstance(name: string): InstancedLinesMesh;
  109771. }
  109772. /**
  109773. * Creates an instance based on a source LinesMesh
  109774. */
  109775. export class InstancedLinesMesh extends InstancedMesh {
  109776. /**
  109777. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109778. * This margin is expressed in world space coordinates, so its value may vary.
  109779. * Initilized with the intersectionThreshold value of the source LinesMesh
  109780. */
  109781. intersectionThreshold: number;
  109782. constructor(name: string, source: LinesMesh);
  109783. /**
  109784. * Returns the string "InstancedLinesMesh".
  109785. */
  109786. getClassName(): string;
  109787. }
  109788. }
  109789. declare module BABYLON {
  109790. /** @hidden */
  109791. export var linePixelShader: {
  109792. name: string;
  109793. shader: string;
  109794. };
  109795. }
  109796. declare module BABYLON {
  109797. /** @hidden */
  109798. export var lineVertexShader: {
  109799. name: string;
  109800. shader: string;
  109801. };
  109802. }
  109803. declare module BABYLON {
  109804. interface Scene {
  109805. /** @hidden */
  109806. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109807. }
  109808. interface AbstractMesh {
  109809. /**
  109810. * Gets the edgesRenderer associated with the mesh
  109811. */
  109812. edgesRenderer: Nullable<EdgesRenderer>;
  109813. }
  109814. interface LinesMesh {
  109815. /**
  109816. * Enables the edge rendering mode on the mesh.
  109817. * This mode makes the mesh edges visible
  109818. * @param epsilon defines the maximal distance between two angles to detect a face
  109819. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109820. * @returns the currentAbstractMesh
  109821. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109822. */
  109823. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109824. }
  109825. interface InstancedLinesMesh {
  109826. /**
  109827. * Enables the edge rendering mode on the mesh.
  109828. * This mode makes the mesh edges visible
  109829. * @param epsilon defines the maximal distance between two angles to detect a face
  109830. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109831. * @returns the current InstancedLinesMesh
  109832. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109833. */
  109834. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109835. }
  109836. /**
  109837. * Defines the minimum contract an Edges renderer should follow.
  109838. */
  109839. export interface IEdgesRenderer extends IDisposable {
  109840. /**
  109841. * Gets or sets a boolean indicating if the edgesRenderer is active
  109842. */
  109843. isEnabled: boolean;
  109844. /**
  109845. * Renders the edges of the attached mesh,
  109846. */
  109847. render(): void;
  109848. /**
  109849. * Checks wether or not the edges renderer is ready to render.
  109850. * @return true if ready, otherwise false.
  109851. */
  109852. isReady(): boolean;
  109853. /**
  109854. * List of instances to render in case the source mesh has instances
  109855. */
  109856. customInstances: SmartArray<Matrix>;
  109857. }
  109858. /**
  109859. * Defines the additional options of the edges renderer
  109860. */
  109861. export interface IEdgesRendererOptions {
  109862. /**
  109863. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109864. * If not defined, the default value is true
  109865. */
  109866. useAlternateEdgeFinder?: boolean;
  109867. /**
  109868. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109869. * If not defined, the default value is true.
  109870. * 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)
  109871. * This option is used only if useAlternateEdgeFinder = true
  109872. */
  109873. useFastVertexMerger?: boolean;
  109874. /**
  109875. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109876. * The default value is 1e-6
  109877. * This option is used only if useAlternateEdgeFinder = true
  109878. */
  109879. epsilonVertexMerge?: number;
  109880. /**
  109881. * 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
  109882. * 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.
  109883. * This option is used only if useAlternateEdgeFinder = true
  109884. */
  109885. applyTessellation?: boolean;
  109886. /**
  109887. * 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
  109888. * The default value is 1e-6
  109889. * This option is used only if useAlternateEdgeFinder = true
  109890. */
  109891. epsilonVertexAligned?: number;
  109892. }
  109893. /**
  109894. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109895. */
  109896. export class EdgesRenderer implements IEdgesRenderer {
  109897. /**
  109898. * Define the size of the edges with an orthographic camera
  109899. */
  109900. edgesWidthScalerForOrthographic: number;
  109901. /**
  109902. * Define the size of the edges with a perspective camera
  109903. */
  109904. edgesWidthScalerForPerspective: number;
  109905. protected _source: AbstractMesh;
  109906. protected _linesPositions: number[];
  109907. protected _linesNormals: number[];
  109908. protected _linesIndices: number[];
  109909. protected _epsilon: number;
  109910. protected _indicesCount: number;
  109911. protected _lineShader: ShaderMaterial;
  109912. protected _ib: DataBuffer;
  109913. protected _buffers: {
  109914. [key: string]: Nullable<VertexBuffer>;
  109915. };
  109916. protected _buffersForInstances: {
  109917. [key: string]: Nullable<VertexBuffer>;
  109918. };
  109919. protected _checkVerticesInsteadOfIndices: boolean;
  109920. protected _options: Nullable<IEdgesRendererOptions>;
  109921. private _meshRebuildObserver;
  109922. private _meshDisposeObserver;
  109923. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109924. isEnabled: boolean;
  109925. /** Gets the vertices generated by the edge renderer */
  109926. get linesPositions(): Immutable<Array<number>>;
  109927. /** Gets the normals generated by the edge renderer */
  109928. get linesNormals(): Immutable<Array<number>>;
  109929. /** Gets the indices generated by the edge renderer */
  109930. get linesIndices(): Immutable<Array<number>>;
  109931. /**
  109932. * List of instances to render in case the source mesh has instances
  109933. */
  109934. customInstances: SmartArray<Matrix>;
  109935. private static GetShader;
  109936. /**
  109937. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  109938. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  109939. * @param source Mesh used to create edges
  109940. * @param epsilon sum of angles in adjacency to check for edge
  109941. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  109942. * @param generateEdgesLines - should generate Lines or only prepare resources.
  109943. * @param options The options to apply when generating the edges
  109944. */
  109945. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  109946. protected _prepareRessources(): void;
  109947. /** @hidden */
  109948. _rebuild(): void;
  109949. /**
  109950. * Releases the required resources for the edges renderer
  109951. */
  109952. dispose(): void;
  109953. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  109954. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  109955. /**
  109956. * Checks if the pair of p0 and p1 is en edge
  109957. * @param faceIndex
  109958. * @param edge
  109959. * @param faceNormals
  109960. * @param p0
  109961. * @param p1
  109962. * @private
  109963. */
  109964. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  109965. /**
  109966. * push line into the position, normal and index buffer
  109967. * @protected
  109968. */
  109969. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  109970. /**
  109971. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  109972. */
  109973. private _tessellateTriangle;
  109974. private _generateEdgesLinesAlternate;
  109975. /**
  109976. * Generates lines edges from adjacencjes
  109977. * @private
  109978. */
  109979. _generateEdgesLines(): void;
  109980. /**
  109981. * Checks wether or not the edges renderer is ready to render.
  109982. * @return true if ready, otherwise false.
  109983. */
  109984. isReady(): boolean;
  109985. /**
  109986. * Renders the edges of the attached mesh,
  109987. */
  109988. render(): void;
  109989. }
  109990. /**
  109991. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  109992. */
  109993. export class LineEdgesRenderer extends EdgesRenderer {
  109994. /**
  109995. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  109996. * @param source LineMesh used to generate edges
  109997. * @param epsilon not important (specified angle for edge detection)
  109998. * @param checkVerticesInsteadOfIndices not important for LineMesh
  109999. */
  110000. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  110001. /**
  110002. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  110003. */
  110004. _generateEdgesLines(): void;
  110005. }
  110006. }
  110007. declare module BABYLON {
  110008. /**
  110009. * This represents the object necessary to create a rendering group.
  110010. * This is exclusively used and created by the rendering manager.
  110011. * To modify the behavior, you use the available helpers in your scene or meshes.
  110012. * @hidden
  110013. */
  110014. export class RenderingGroup {
  110015. index: number;
  110016. private static _zeroVector;
  110017. private _scene;
  110018. private _opaqueSubMeshes;
  110019. private _transparentSubMeshes;
  110020. private _alphaTestSubMeshes;
  110021. private _depthOnlySubMeshes;
  110022. private _particleSystems;
  110023. private _spriteManagers;
  110024. private _opaqueSortCompareFn;
  110025. private _alphaTestSortCompareFn;
  110026. private _transparentSortCompareFn;
  110027. private _renderOpaque;
  110028. private _renderAlphaTest;
  110029. private _renderTransparent;
  110030. /** @hidden */
  110031. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  110032. onBeforeTransparentRendering: () => void;
  110033. /**
  110034. * Set the opaque sort comparison function.
  110035. * If null the sub meshes will be render in the order they were created
  110036. */
  110037. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110038. /**
  110039. * Set the alpha test sort comparison function.
  110040. * If null the sub meshes will be render in the order they were created
  110041. */
  110042. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110043. /**
  110044. * Set the transparent sort comparison function.
  110045. * If null the sub meshes will be render in the order they were created
  110046. */
  110047. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110048. /**
  110049. * Creates a new rendering group.
  110050. * @param index The rendering group index
  110051. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  110052. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  110053. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  110054. */
  110055. 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>);
  110056. /**
  110057. * Render all the sub meshes contained in the group.
  110058. * @param customRenderFunction Used to override the default render behaviour of the group.
  110059. * @returns true if rendered some submeshes.
  110060. */
  110061. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  110062. /**
  110063. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  110064. * @param subMeshes The submeshes to render
  110065. */
  110066. private renderOpaqueSorted;
  110067. /**
  110068. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  110069. * @param subMeshes The submeshes to render
  110070. */
  110071. private renderAlphaTestSorted;
  110072. /**
  110073. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  110074. * @param subMeshes The submeshes to render
  110075. */
  110076. private renderTransparentSorted;
  110077. /**
  110078. * Renders the submeshes in a specified order.
  110079. * @param subMeshes The submeshes to sort before render
  110080. * @param sortCompareFn The comparison function use to sort
  110081. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  110082. * @param transparent Specifies to activate blending if true
  110083. */
  110084. private static renderSorted;
  110085. /**
  110086. * Renders the submeshes in the order they were dispatched (no sort applied).
  110087. * @param subMeshes The submeshes to render
  110088. */
  110089. private static renderUnsorted;
  110090. /**
  110091. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110092. * are rendered back to front if in the same alpha index.
  110093. *
  110094. * @param a The first submesh
  110095. * @param b The second submesh
  110096. * @returns The result of the comparison
  110097. */
  110098. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  110099. /**
  110100. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110101. * are rendered back to front.
  110102. *
  110103. * @param a The first submesh
  110104. * @param b The second submesh
  110105. * @returns The result of the comparison
  110106. */
  110107. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  110108. /**
  110109. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110110. * are rendered front to back (prevent overdraw).
  110111. *
  110112. * @param a The first submesh
  110113. * @param b The second submesh
  110114. * @returns The result of the comparison
  110115. */
  110116. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  110117. /**
  110118. * Resets the different lists of submeshes to prepare a new frame.
  110119. */
  110120. prepare(): void;
  110121. dispose(): void;
  110122. /**
  110123. * Inserts the submesh in its correct queue depending on its material.
  110124. * @param subMesh The submesh to dispatch
  110125. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110126. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110127. */
  110128. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110129. dispatchSprites(spriteManager: ISpriteManager): void;
  110130. dispatchParticles(particleSystem: IParticleSystem): void;
  110131. private _renderParticles;
  110132. private _renderSprites;
  110133. }
  110134. }
  110135. declare module BABYLON {
  110136. /**
  110137. * Interface describing the different options available in the rendering manager
  110138. * regarding Auto Clear between groups.
  110139. */
  110140. export interface IRenderingManagerAutoClearSetup {
  110141. /**
  110142. * Defines whether or not autoclear is enable.
  110143. */
  110144. autoClear: boolean;
  110145. /**
  110146. * Defines whether or not to autoclear the depth buffer.
  110147. */
  110148. depth: boolean;
  110149. /**
  110150. * Defines whether or not to autoclear the stencil buffer.
  110151. */
  110152. stencil: boolean;
  110153. }
  110154. /**
  110155. * This class is used by the onRenderingGroupObservable
  110156. */
  110157. export class RenderingGroupInfo {
  110158. /**
  110159. * The Scene that being rendered
  110160. */
  110161. scene: Scene;
  110162. /**
  110163. * The camera currently used for the rendering pass
  110164. */
  110165. camera: Nullable<Camera>;
  110166. /**
  110167. * The ID of the renderingGroup being processed
  110168. */
  110169. renderingGroupId: number;
  110170. }
  110171. /**
  110172. * This is the manager responsible of all the rendering for meshes sprites and particles.
  110173. * It is enable to manage the different groups as well as the different necessary sort functions.
  110174. * This should not be used directly aside of the few static configurations
  110175. */
  110176. export class RenderingManager {
  110177. /**
  110178. * The max id used for rendering groups (not included)
  110179. */
  110180. static MAX_RENDERINGGROUPS: number;
  110181. /**
  110182. * The min id used for rendering groups (included)
  110183. */
  110184. static MIN_RENDERINGGROUPS: number;
  110185. /**
  110186. * Used to globally prevent autoclearing scenes.
  110187. */
  110188. static AUTOCLEAR: boolean;
  110189. /**
  110190. * @hidden
  110191. */
  110192. _useSceneAutoClearSetup: boolean;
  110193. private _scene;
  110194. private _renderingGroups;
  110195. private _depthStencilBufferAlreadyCleaned;
  110196. private _autoClearDepthStencil;
  110197. private _customOpaqueSortCompareFn;
  110198. private _customAlphaTestSortCompareFn;
  110199. private _customTransparentSortCompareFn;
  110200. private _renderingGroupInfo;
  110201. /**
  110202. * Instantiates a new rendering group for a particular scene
  110203. * @param scene Defines the scene the groups belongs to
  110204. */
  110205. constructor(scene: Scene);
  110206. private _clearDepthStencilBuffer;
  110207. /**
  110208. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  110209. * @hidden
  110210. */
  110211. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  110212. /**
  110213. * Resets the different information of the group to prepare a new frame
  110214. * @hidden
  110215. */
  110216. reset(): void;
  110217. /**
  110218. * Dispose and release the group and its associated resources.
  110219. * @hidden
  110220. */
  110221. dispose(): void;
  110222. /**
  110223. * Clear the info related to rendering groups preventing retention points during dispose.
  110224. */
  110225. freeRenderingGroups(): void;
  110226. private _prepareRenderingGroup;
  110227. /**
  110228. * Add a sprite manager to the rendering manager in order to render it this frame.
  110229. * @param spriteManager Define the sprite manager to render
  110230. */
  110231. dispatchSprites(spriteManager: ISpriteManager): void;
  110232. /**
  110233. * Add a particle system to the rendering manager in order to render it this frame.
  110234. * @param particleSystem Define the particle system to render
  110235. */
  110236. dispatchParticles(particleSystem: IParticleSystem): void;
  110237. /**
  110238. * Add a submesh to the manager in order to render it this frame
  110239. * @param subMesh The submesh to dispatch
  110240. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110241. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110242. */
  110243. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110244. /**
  110245. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110246. * This allowed control for front to back rendering or reversly depending of the special needs.
  110247. *
  110248. * @param renderingGroupId The rendering group id corresponding to its index
  110249. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110250. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110251. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110252. */
  110253. 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;
  110254. /**
  110255. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110256. *
  110257. * @param renderingGroupId The rendering group id corresponding to its index
  110258. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110259. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110260. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110261. */
  110262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110263. /**
  110264. * Gets the current auto clear configuration for one rendering group of the rendering
  110265. * manager.
  110266. * @param index the rendering group index to get the information for
  110267. * @returns The auto clear setup for the requested rendering group
  110268. */
  110269. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110270. }
  110271. }
  110272. declare module BABYLON {
  110273. /**
  110274. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110275. */
  110276. export interface ICustomShaderOptions {
  110277. /**
  110278. * Gets or sets the custom shader name to use
  110279. */
  110280. shaderName: string;
  110281. /**
  110282. * The list of attribute names used in the shader
  110283. */
  110284. attributes?: string[];
  110285. /**
  110286. * The list of unifrom names used in the shader
  110287. */
  110288. uniforms?: string[];
  110289. /**
  110290. * The list of sampler names used in the shader
  110291. */
  110292. samplers?: string[];
  110293. /**
  110294. * The list of defines used in the shader
  110295. */
  110296. defines?: string[];
  110297. }
  110298. /**
  110299. * Interface to implement to create a shadow generator compatible with BJS.
  110300. */
  110301. export interface IShadowGenerator {
  110302. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110303. id: string;
  110304. /**
  110305. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110306. * @returns The render target texture if present otherwise, null
  110307. */
  110308. getShadowMap(): Nullable<RenderTargetTexture>;
  110309. /**
  110310. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110311. * @param subMesh The submesh we want to render in the shadow map
  110312. * @param useInstances Defines wether will draw in the map using instances
  110313. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110314. * @returns true if ready otherwise, false
  110315. */
  110316. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110317. /**
  110318. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110319. * @param defines Defines of the material we want to update
  110320. * @param lightIndex Index of the light in the enabled light list of the material
  110321. */
  110322. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110323. /**
  110324. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110325. * defined in the generator but impacting the effect).
  110326. * It implies the unifroms available on the materials are the standard BJS ones.
  110327. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110328. * @param effect The effect we are binfing the information for
  110329. */
  110330. bindShadowLight(lightIndex: string, effect: Effect): void;
  110331. /**
  110332. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110333. * (eq to shadow prjection matrix * light transform matrix)
  110334. * @returns The transform matrix used to create the shadow map
  110335. */
  110336. getTransformMatrix(): Matrix;
  110337. /**
  110338. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110339. * Cube and 2D textures for instance.
  110340. */
  110341. recreateShadowMap(): void;
  110342. /**
  110343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110344. * @param onCompiled Callback triggered at the and of the effects compilation
  110345. * @param options Sets of optional options forcing the compilation with different modes
  110346. */
  110347. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110348. useInstances: boolean;
  110349. }>): void;
  110350. /**
  110351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110352. * @param options Sets of optional options forcing the compilation with different modes
  110353. * @returns A promise that resolves when the compilation completes
  110354. */
  110355. forceCompilationAsync(options?: Partial<{
  110356. useInstances: boolean;
  110357. }>): Promise<void>;
  110358. /**
  110359. * Serializes the shadow generator setup to a json object.
  110360. * @returns The serialized JSON object
  110361. */
  110362. serialize(): any;
  110363. /**
  110364. * Disposes the Shadow map and related Textures and effects.
  110365. */
  110366. dispose(): void;
  110367. }
  110368. /**
  110369. * Default implementation IShadowGenerator.
  110370. * This is the main object responsible of generating shadows in the framework.
  110371. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110372. */
  110373. export class ShadowGenerator implements IShadowGenerator {
  110374. /**
  110375. * Name of the shadow generator class
  110376. */
  110377. static CLASSNAME: string;
  110378. /**
  110379. * Shadow generator mode None: no filtering applied.
  110380. */
  110381. static readonly FILTER_NONE: number;
  110382. /**
  110383. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110385. */
  110386. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110387. /**
  110388. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110389. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110390. */
  110391. static readonly FILTER_POISSONSAMPLING: number;
  110392. /**
  110393. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110395. */
  110396. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110397. /**
  110398. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110399. * edge artifacts on steep falloff.
  110400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110401. */
  110402. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110403. /**
  110404. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110405. * edge artifacts on steep falloff.
  110406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110407. */
  110408. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110409. /**
  110410. * Shadow generator mode PCF: Percentage Closer Filtering
  110411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110412. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110413. */
  110414. static readonly FILTER_PCF: number;
  110415. /**
  110416. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110417. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110418. * Contact Hardening
  110419. */
  110420. static readonly FILTER_PCSS: number;
  110421. /**
  110422. * Reserved for PCF and PCSS
  110423. * Highest Quality.
  110424. *
  110425. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110426. *
  110427. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110428. */
  110429. static readonly QUALITY_HIGH: number;
  110430. /**
  110431. * Reserved for PCF and PCSS
  110432. * Good tradeoff for quality/perf cross devices
  110433. *
  110434. * Execute PCF on a 3*3 kernel.
  110435. *
  110436. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110437. */
  110438. static readonly QUALITY_MEDIUM: number;
  110439. /**
  110440. * Reserved for PCF and PCSS
  110441. * The lowest quality but the fastest.
  110442. *
  110443. * Execute PCF on a 1*1 kernel.
  110444. *
  110445. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110446. */
  110447. static readonly QUALITY_LOW: number;
  110448. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110449. id: string;
  110450. /** Gets or sets the custom shader name to use */
  110451. customShaderOptions: ICustomShaderOptions;
  110452. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  110453. customAllowRendering: (subMesh: SubMesh) => boolean;
  110454. /**
  110455. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110456. */
  110457. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110458. /**
  110459. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110460. */
  110461. onAfterShadowMapRenderObservable: Observable<Effect>;
  110462. /**
  110463. * Observable triggered before a mesh is rendered in the shadow map.
  110464. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110465. */
  110466. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110467. /**
  110468. * Observable triggered after a mesh is rendered in the shadow map.
  110469. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110470. */
  110471. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110472. protected _bias: number;
  110473. /**
  110474. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110475. */
  110476. get bias(): number;
  110477. /**
  110478. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110479. */
  110480. set bias(bias: number);
  110481. protected _normalBias: number;
  110482. /**
  110483. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110484. */
  110485. get normalBias(): number;
  110486. /**
  110487. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110488. */
  110489. set normalBias(normalBias: number);
  110490. protected _blurBoxOffset: number;
  110491. /**
  110492. * Gets the blur box offset: offset applied during the blur pass.
  110493. * Only useful if useKernelBlur = false
  110494. */
  110495. get blurBoxOffset(): number;
  110496. /**
  110497. * Sets the blur box offset: offset applied during the blur pass.
  110498. * Only useful if useKernelBlur = false
  110499. */
  110500. set blurBoxOffset(value: number);
  110501. protected _blurScale: number;
  110502. /**
  110503. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110504. * 2 means half of the size.
  110505. */
  110506. get blurScale(): number;
  110507. /**
  110508. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110509. * 2 means half of the size.
  110510. */
  110511. set blurScale(value: number);
  110512. protected _blurKernel: number;
  110513. /**
  110514. * Gets the blur kernel: kernel size of the blur pass.
  110515. * Only useful if useKernelBlur = true
  110516. */
  110517. get blurKernel(): number;
  110518. /**
  110519. * Sets the blur kernel: kernel size of the blur pass.
  110520. * Only useful if useKernelBlur = true
  110521. */
  110522. set blurKernel(value: number);
  110523. protected _useKernelBlur: boolean;
  110524. /**
  110525. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110526. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110527. */
  110528. get useKernelBlur(): boolean;
  110529. /**
  110530. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110531. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110532. */
  110533. set useKernelBlur(value: boolean);
  110534. protected _depthScale: number;
  110535. /**
  110536. * Gets the depth scale used in ESM mode.
  110537. */
  110538. get depthScale(): number;
  110539. /**
  110540. * Sets the depth scale used in ESM mode.
  110541. * This can override the scale stored on the light.
  110542. */
  110543. set depthScale(value: number);
  110544. protected _validateFilter(filter: number): number;
  110545. protected _filter: number;
  110546. /**
  110547. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110548. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110549. */
  110550. get filter(): number;
  110551. /**
  110552. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110553. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110554. */
  110555. set filter(value: number);
  110556. /**
  110557. * Gets if the current filter is set to Poisson Sampling.
  110558. */
  110559. get usePoissonSampling(): boolean;
  110560. /**
  110561. * Sets the current filter to Poisson Sampling.
  110562. */
  110563. set usePoissonSampling(value: boolean);
  110564. /**
  110565. * Gets if the current filter is set to ESM.
  110566. */
  110567. get useExponentialShadowMap(): boolean;
  110568. /**
  110569. * Sets the current filter is to ESM.
  110570. */
  110571. set useExponentialShadowMap(value: boolean);
  110572. /**
  110573. * Gets if the current filter is set to filtered ESM.
  110574. */
  110575. get useBlurExponentialShadowMap(): boolean;
  110576. /**
  110577. * Gets if the current filter is set to filtered ESM.
  110578. */
  110579. set useBlurExponentialShadowMap(value: boolean);
  110580. /**
  110581. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110582. * exponential to prevent steep falloff artifacts).
  110583. */
  110584. get useCloseExponentialShadowMap(): boolean;
  110585. /**
  110586. * Sets the current filter to "close ESM" (using the inverse of the
  110587. * exponential to prevent steep falloff artifacts).
  110588. */
  110589. set useCloseExponentialShadowMap(value: boolean);
  110590. /**
  110591. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110592. * exponential to prevent steep falloff artifacts).
  110593. */
  110594. get useBlurCloseExponentialShadowMap(): boolean;
  110595. /**
  110596. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110597. * exponential to prevent steep falloff artifacts).
  110598. */
  110599. set useBlurCloseExponentialShadowMap(value: boolean);
  110600. /**
  110601. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110602. */
  110603. get usePercentageCloserFiltering(): boolean;
  110604. /**
  110605. * Sets the current filter to "PCF" (percentage closer filtering).
  110606. */
  110607. set usePercentageCloserFiltering(value: boolean);
  110608. protected _filteringQuality: number;
  110609. /**
  110610. * Gets the PCF or PCSS Quality.
  110611. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110612. */
  110613. get filteringQuality(): number;
  110614. /**
  110615. * Sets the PCF or PCSS Quality.
  110616. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110617. */
  110618. set filteringQuality(filteringQuality: number);
  110619. /**
  110620. * Gets if the current filter is set to "PCSS" (contact hardening).
  110621. */
  110622. get useContactHardeningShadow(): boolean;
  110623. /**
  110624. * Sets the current filter to "PCSS" (contact hardening).
  110625. */
  110626. set useContactHardeningShadow(value: boolean);
  110627. protected _contactHardeningLightSizeUVRatio: number;
  110628. /**
  110629. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110630. * Using a ratio helps keeping shape stability independently of the map size.
  110631. *
  110632. * It does not account for the light projection as it was having too much
  110633. * instability during the light setup or during light position changes.
  110634. *
  110635. * Only valid if useContactHardeningShadow is true.
  110636. */
  110637. get contactHardeningLightSizeUVRatio(): number;
  110638. /**
  110639. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110640. * Using a ratio helps keeping shape stability independently of the map size.
  110641. *
  110642. * It does not account for the light projection as it was having too much
  110643. * instability during the light setup or during light position changes.
  110644. *
  110645. * Only valid if useContactHardeningShadow is true.
  110646. */
  110647. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110648. protected _darkness: number;
  110649. /** Gets or sets the actual darkness of a shadow */
  110650. get darkness(): number;
  110651. set darkness(value: number);
  110652. /**
  110653. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110654. * 0 means strongest and 1 would means no shadow.
  110655. * @returns the darkness.
  110656. */
  110657. getDarkness(): number;
  110658. /**
  110659. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110660. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110661. * @returns the shadow generator allowing fluent coding.
  110662. */
  110663. setDarkness(darkness: number): ShadowGenerator;
  110664. protected _transparencyShadow: boolean;
  110665. /** Gets or sets the ability to have transparent shadow */
  110666. get transparencyShadow(): boolean;
  110667. set transparencyShadow(value: boolean);
  110668. /**
  110669. * Sets the ability to have transparent shadow (boolean).
  110670. * @param transparent True if transparent else False
  110671. * @returns the shadow generator allowing fluent coding
  110672. */
  110673. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110674. /**
  110675. * Enables or disables shadows with varying strength based on the transparency
  110676. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110677. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110678. * mesh.visibility * alphaTexture.a
  110679. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110680. */
  110681. enableSoftTransparentShadow: boolean;
  110682. protected _shadowMap: Nullable<RenderTargetTexture>;
  110683. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110684. /**
  110685. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110686. * @returns The render target texture if present otherwise, null
  110687. */
  110688. getShadowMap(): Nullable<RenderTargetTexture>;
  110689. /**
  110690. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110691. * @returns The render target texture if the shadow map is present otherwise, null
  110692. */
  110693. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110694. /**
  110695. * Gets the class name of that object
  110696. * @returns "ShadowGenerator"
  110697. */
  110698. getClassName(): string;
  110699. /**
  110700. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110701. * @param mesh Mesh to add
  110702. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110703. * @returns the Shadow Generator itself
  110704. */
  110705. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110706. /**
  110707. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110708. * @param mesh Mesh to remove
  110709. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110710. * @returns the Shadow Generator itself
  110711. */
  110712. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110713. /**
  110714. * Controls the extent to which the shadows fade out at the edge of the frustum
  110715. */
  110716. frustumEdgeFalloff: number;
  110717. protected _light: IShadowLight;
  110718. /**
  110719. * Returns the associated light object.
  110720. * @returns the light generating the shadow
  110721. */
  110722. getLight(): IShadowLight;
  110723. /**
  110724. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110725. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110726. * It might on the other hand introduce peter panning.
  110727. */
  110728. forceBackFacesOnly: boolean;
  110729. protected _scene: Scene;
  110730. protected _lightDirection: Vector3;
  110731. protected _effect: Effect;
  110732. protected _viewMatrix: Matrix;
  110733. protected _projectionMatrix: Matrix;
  110734. protected _transformMatrix: Matrix;
  110735. protected _cachedPosition: Vector3;
  110736. protected _cachedDirection: Vector3;
  110737. protected _cachedDefines: string;
  110738. protected _currentRenderID: number;
  110739. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110740. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110741. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110742. protected _blurPostProcesses: PostProcess[];
  110743. protected _mapSize: number;
  110744. protected _currentFaceIndex: number;
  110745. protected _currentFaceIndexCache: number;
  110746. protected _textureType: number;
  110747. protected _defaultTextureMatrix: Matrix;
  110748. protected _storedUniqueId: Nullable<number>;
  110749. /** @hidden */
  110750. static _SceneComponentInitialization: (scene: Scene) => void;
  110751. /**
  110752. * Gets or sets the size of the texture what stores the shadows
  110753. */
  110754. get mapSize(): number;
  110755. set mapSize(size: number);
  110756. /**
  110757. * Creates a ShadowGenerator object.
  110758. * A ShadowGenerator is the required tool to use the shadows.
  110759. * Each light casting shadows needs to use its own ShadowGenerator.
  110760. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110761. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110762. * @param light The light object generating the shadows.
  110763. * @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.
  110764. */
  110765. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110766. protected _initializeGenerator(): void;
  110767. protected _createTargetRenderTexture(): void;
  110768. protected _initializeShadowMap(): void;
  110769. protected _initializeBlurRTTAndPostProcesses(): void;
  110770. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110771. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110772. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110773. protected _applyFilterValues(): void;
  110774. /**
  110775. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110776. * @param onCompiled Callback triggered at the and of the effects compilation
  110777. * @param options Sets of optional options forcing the compilation with different modes
  110778. */
  110779. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110780. useInstances: boolean;
  110781. }>): void;
  110782. /**
  110783. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110784. * @param options Sets of optional options forcing the compilation with different modes
  110785. * @returns A promise that resolves when the compilation completes
  110786. */
  110787. forceCompilationAsync(options?: Partial<{
  110788. useInstances: boolean;
  110789. }>): Promise<void>;
  110790. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110791. private _prepareShadowDefines;
  110792. /**
  110793. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110794. * @param subMesh The submesh we want to render in the shadow map
  110795. * @param useInstances Defines wether will draw in the map using instances
  110796. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110797. * @returns true if ready otherwise, false
  110798. */
  110799. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110800. /**
  110801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110802. * @param defines Defines of the material we want to update
  110803. * @param lightIndex Index of the light in the enabled light list of the material
  110804. */
  110805. prepareDefines(defines: any, lightIndex: number): void;
  110806. /**
  110807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110808. * defined in the generator but impacting the effect).
  110809. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110810. * @param effect The effect we are binfing the information for
  110811. */
  110812. bindShadowLight(lightIndex: string, effect: Effect): void;
  110813. /**
  110814. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110815. * (eq to shadow prjection matrix * light transform matrix)
  110816. * @returns The transform matrix used to create the shadow map
  110817. */
  110818. getTransformMatrix(): Matrix;
  110819. /**
  110820. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110821. * Cube and 2D textures for instance.
  110822. */
  110823. recreateShadowMap(): void;
  110824. protected _disposeBlurPostProcesses(): void;
  110825. protected _disposeRTTandPostProcesses(): void;
  110826. /**
  110827. * Disposes the ShadowGenerator.
  110828. * Returns nothing.
  110829. */
  110830. dispose(): void;
  110831. /**
  110832. * Serializes the shadow generator setup to a json object.
  110833. * @returns The serialized JSON object
  110834. */
  110835. serialize(): any;
  110836. /**
  110837. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110838. * @param parsedShadowGenerator The JSON object to parse
  110839. * @param scene The scene to create the shadow map for
  110840. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110841. * @returns The parsed shadow generator
  110842. */
  110843. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110844. }
  110845. }
  110846. declare module BABYLON {
  110847. /**
  110848. * Options to be used when creating a shadow depth material
  110849. */
  110850. export interface IIOptionShadowDepthMaterial {
  110851. /** Variables in the vertex shader code that need to have their names remapped.
  110852. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110853. * "var_name" should be either: worldPos or vNormalW
  110854. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110855. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110856. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110857. */
  110858. remappedVariables?: string[];
  110859. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110860. standalone?: boolean;
  110861. }
  110862. /**
  110863. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110864. */
  110865. export class ShadowDepthWrapper {
  110866. private _scene;
  110867. private _options?;
  110868. private _baseMaterial;
  110869. private _onEffectCreatedObserver;
  110870. private _subMeshToEffect;
  110871. private _subMeshToDepthEffect;
  110872. private _meshes;
  110873. /** @hidden */
  110874. _matriceNames: any;
  110875. /** Gets the standalone status of the wrapper */
  110876. get standalone(): boolean;
  110877. /** Gets the base material the wrapper is built upon */
  110878. get baseMaterial(): Material;
  110879. /**
  110880. * Instantiate a new shadow depth wrapper.
  110881. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110882. * generate the shadow depth map. For more information, please refer to the documentation:
  110883. * https://doc.babylonjs.com/babylon101/shadows
  110884. * @param baseMaterial Material to wrap
  110885. * @param scene Define the scene the material belongs to
  110886. * @param options Options used to create the wrapper
  110887. */
  110888. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110889. /**
  110890. * Gets the effect to use to generate the depth map
  110891. * @param subMesh subMesh to get the effect for
  110892. * @param shadowGenerator shadow generator to get the effect for
  110893. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110894. */
  110895. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110896. /**
  110897. * Specifies that the submesh is ready to be used for depth rendering
  110898. * @param subMesh submesh to check
  110899. * @param defines the list of defines to take into account when checking the effect
  110900. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110901. * @param useInstances specifies that instances should be used
  110902. * @returns a boolean indicating that the submesh is ready or not
  110903. */
  110904. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110905. /**
  110906. * Disposes the resources
  110907. */
  110908. dispose(): void;
  110909. private _makeEffect;
  110910. }
  110911. }
  110912. declare module BABYLON {
  110913. /**
  110914. * Options for compiling materials.
  110915. */
  110916. export interface IMaterialCompilationOptions {
  110917. /**
  110918. * Defines whether clip planes are enabled.
  110919. */
  110920. clipPlane: boolean;
  110921. /**
  110922. * Defines whether instances are enabled.
  110923. */
  110924. useInstances: boolean;
  110925. }
  110926. /**
  110927. * Options passed when calling customShaderNameResolve
  110928. */
  110929. export interface ICustomShaderNameResolveOptions {
  110930. /**
  110931. * 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
  110932. */
  110933. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110934. }
  110935. /**
  110936. * Base class for the main features of a material in Babylon.js
  110937. */
  110938. export class Material implements IAnimatable {
  110939. /**
  110940. * Returns the triangle fill mode
  110941. */
  110942. static readonly TriangleFillMode: number;
  110943. /**
  110944. * Returns the wireframe mode
  110945. */
  110946. static readonly WireFrameFillMode: number;
  110947. /**
  110948. * Returns the point fill mode
  110949. */
  110950. static readonly PointFillMode: number;
  110951. /**
  110952. * Returns the point list draw mode
  110953. */
  110954. static readonly PointListDrawMode: number;
  110955. /**
  110956. * Returns the line list draw mode
  110957. */
  110958. static readonly LineListDrawMode: number;
  110959. /**
  110960. * Returns the line loop draw mode
  110961. */
  110962. static readonly LineLoopDrawMode: number;
  110963. /**
  110964. * Returns the line strip draw mode
  110965. */
  110966. static readonly LineStripDrawMode: number;
  110967. /**
  110968. * Returns the triangle strip draw mode
  110969. */
  110970. static readonly TriangleStripDrawMode: number;
  110971. /**
  110972. * Returns the triangle fan draw mode
  110973. */
  110974. static readonly TriangleFanDrawMode: number;
  110975. /**
  110976. * Stores the clock-wise side orientation
  110977. */
  110978. static readonly ClockWiseSideOrientation: number;
  110979. /**
  110980. * Stores the counter clock-wise side orientation
  110981. */
  110982. static readonly CounterClockWiseSideOrientation: number;
  110983. /**
  110984. * The dirty texture flag value
  110985. */
  110986. static readonly TextureDirtyFlag: number;
  110987. /**
  110988. * The dirty light flag value
  110989. */
  110990. static readonly LightDirtyFlag: number;
  110991. /**
  110992. * The dirty fresnel flag value
  110993. */
  110994. static readonly FresnelDirtyFlag: number;
  110995. /**
  110996. * The dirty attribute flag value
  110997. */
  110998. static readonly AttributesDirtyFlag: number;
  110999. /**
  111000. * The dirty misc flag value
  111001. */
  111002. static readonly MiscDirtyFlag: number;
  111003. /**
  111004. * The dirty prepass flag value
  111005. */
  111006. static readonly PrePassDirtyFlag: number;
  111007. /**
  111008. * The all dirty flag value
  111009. */
  111010. static readonly AllDirtyFlag: number;
  111011. /**
  111012. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111013. */
  111014. static readonly MATERIAL_OPAQUE: number;
  111015. /**
  111016. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111017. */
  111018. static readonly MATERIAL_ALPHATEST: number;
  111019. /**
  111020. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111021. */
  111022. static readonly MATERIAL_ALPHABLEND: number;
  111023. /**
  111024. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111025. * They are also discarded below the alpha cutoff threshold to improve performances.
  111026. */
  111027. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  111028. /**
  111029. * The Whiteout method is used to blend normals.
  111030. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111031. */
  111032. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  111033. /**
  111034. * The Reoriented Normal Mapping method is used to blend normals.
  111035. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111036. */
  111037. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  111038. /**
  111039. * Custom callback helping to override the default shader used in the material.
  111040. */
  111041. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  111042. /**
  111043. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  111044. */
  111045. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  111046. /**
  111047. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  111048. * This means that the material can keep using a previous shader while a new one is being compiled.
  111049. * This is mostly used when shader parallel compilation is supported (true by default)
  111050. */
  111051. allowShaderHotSwapping: boolean;
  111052. /**
  111053. * The ID of the material
  111054. */
  111055. id: string;
  111056. /**
  111057. * Gets or sets the unique id of the material
  111058. */
  111059. uniqueId: number;
  111060. /**
  111061. * The name of the material
  111062. */
  111063. name: string;
  111064. /**
  111065. * Gets or sets user defined metadata
  111066. */
  111067. metadata: any;
  111068. /**
  111069. * For internal use only. Please do not use.
  111070. */
  111071. reservedDataStore: any;
  111072. /**
  111073. * Specifies if the ready state should be checked on each call
  111074. */
  111075. checkReadyOnEveryCall: boolean;
  111076. /**
  111077. * Specifies if the ready state should be checked once
  111078. */
  111079. checkReadyOnlyOnce: boolean;
  111080. /**
  111081. * The state of the material
  111082. */
  111083. state: string;
  111084. /**
  111085. * If the material can be rendered to several textures with MRT extension
  111086. */
  111087. get canRenderToMRT(): boolean;
  111088. /**
  111089. * The alpha value of the material
  111090. */
  111091. protected _alpha: number;
  111092. /**
  111093. * List of inspectable custom properties (used by the Inspector)
  111094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111095. */
  111096. inspectableCustomProperties: IInspectable[];
  111097. /**
  111098. * Sets the alpha value of the material
  111099. */
  111100. set alpha(value: number);
  111101. /**
  111102. * Gets the alpha value of the material
  111103. */
  111104. get alpha(): number;
  111105. /**
  111106. * Specifies if back face culling is enabled
  111107. */
  111108. protected _backFaceCulling: boolean;
  111109. /**
  111110. * Sets the back-face culling state
  111111. */
  111112. set backFaceCulling(value: boolean);
  111113. /**
  111114. * Gets the back-face culling state
  111115. */
  111116. get backFaceCulling(): boolean;
  111117. /**
  111118. * Stores the value for side orientation
  111119. */
  111120. sideOrientation: number;
  111121. /**
  111122. * Callback triggered when the material is compiled
  111123. */
  111124. onCompiled: Nullable<(effect: Effect) => void>;
  111125. /**
  111126. * Callback triggered when an error occurs
  111127. */
  111128. onError: Nullable<(effect: Effect, errors: string) => void>;
  111129. /**
  111130. * Callback triggered to get the render target textures
  111131. */
  111132. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  111133. /**
  111134. * Gets a boolean indicating that current material needs to register RTT
  111135. */
  111136. get hasRenderTargetTextures(): boolean;
  111137. /**
  111138. * Specifies if the material should be serialized
  111139. */
  111140. doNotSerialize: boolean;
  111141. /**
  111142. * @hidden
  111143. */
  111144. _storeEffectOnSubMeshes: boolean;
  111145. /**
  111146. * Stores the animations for the material
  111147. */
  111148. animations: Nullable<Array<Animation>>;
  111149. /**
  111150. * An event triggered when the material is disposed
  111151. */
  111152. onDisposeObservable: Observable<Material>;
  111153. /**
  111154. * An observer which watches for dispose events
  111155. */
  111156. private _onDisposeObserver;
  111157. private _onUnBindObservable;
  111158. /**
  111159. * Called during a dispose event
  111160. */
  111161. set onDispose(callback: () => void);
  111162. private _onBindObservable;
  111163. /**
  111164. * An event triggered when the material is bound
  111165. */
  111166. get onBindObservable(): Observable<AbstractMesh>;
  111167. /**
  111168. * An observer which watches for bind events
  111169. */
  111170. private _onBindObserver;
  111171. /**
  111172. * Called during a bind event
  111173. */
  111174. set onBind(callback: (Mesh: AbstractMesh) => void);
  111175. /**
  111176. * An event triggered when the material is unbound
  111177. */
  111178. get onUnBindObservable(): Observable<Material>;
  111179. protected _onEffectCreatedObservable: Nullable<Observable<{
  111180. effect: Effect;
  111181. subMesh: Nullable<SubMesh>;
  111182. }>>;
  111183. /**
  111184. * An event triggered when the effect is (re)created
  111185. */
  111186. get onEffectCreatedObservable(): Observable<{
  111187. effect: Effect;
  111188. subMesh: Nullable<SubMesh>;
  111189. }>;
  111190. /**
  111191. * Stores the value of the alpha mode
  111192. */
  111193. private _alphaMode;
  111194. /**
  111195. * Sets the value of the alpha mode.
  111196. *
  111197. * | Value | Type | Description |
  111198. * | --- | --- | --- |
  111199. * | 0 | ALPHA_DISABLE | |
  111200. * | 1 | ALPHA_ADD | |
  111201. * | 2 | ALPHA_COMBINE | |
  111202. * | 3 | ALPHA_SUBTRACT | |
  111203. * | 4 | ALPHA_MULTIPLY | |
  111204. * | 5 | ALPHA_MAXIMIZED | |
  111205. * | 6 | ALPHA_ONEONE | |
  111206. * | 7 | ALPHA_PREMULTIPLIED | |
  111207. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  111208. * | 9 | ALPHA_INTERPOLATE | |
  111209. * | 10 | ALPHA_SCREENMODE | |
  111210. *
  111211. */
  111212. set alphaMode(value: number);
  111213. /**
  111214. * Gets the value of the alpha mode
  111215. */
  111216. get alphaMode(): number;
  111217. /**
  111218. * Stores the state of the need depth pre-pass value
  111219. */
  111220. private _needDepthPrePass;
  111221. /**
  111222. * Sets the need depth pre-pass value
  111223. */
  111224. set needDepthPrePass(value: boolean);
  111225. /**
  111226. * Gets the depth pre-pass value
  111227. */
  111228. get needDepthPrePass(): boolean;
  111229. /**
  111230. * Specifies if depth writing should be disabled
  111231. */
  111232. disableDepthWrite: boolean;
  111233. /**
  111234. * Specifies if color writing should be disabled
  111235. */
  111236. disableColorWrite: boolean;
  111237. /**
  111238. * Specifies if depth writing should be forced
  111239. */
  111240. forceDepthWrite: boolean;
  111241. /**
  111242. * Specifies the depth function that should be used. 0 means the default engine function
  111243. */
  111244. depthFunction: number;
  111245. /**
  111246. * Specifies if there should be a separate pass for culling
  111247. */
  111248. separateCullingPass: boolean;
  111249. /**
  111250. * Stores the state specifing if fog should be enabled
  111251. */
  111252. private _fogEnabled;
  111253. /**
  111254. * Sets the state for enabling fog
  111255. */
  111256. set fogEnabled(value: boolean);
  111257. /**
  111258. * Gets the value of the fog enabled state
  111259. */
  111260. get fogEnabled(): boolean;
  111261. /**
  111262. * Stores the size of points
  111263. */
  111264. pointSize: number;
  111265. /**
  111266. * Stores the z offset value
  111267. */
  111268. zOffset: number;
  111269. get wireframe(): boolean;
  111270. /**
  111271. * Sets the state of wireframe mode
  111272. */
  111273. set wireframe(value: boolean);
  111274. /**
  111275. * Gets the value specifying if point clouds are enabled
  111276. */
  111277. get pointsCloud(): boolean;
  111278. /**
  111279. * Sets the state of point cloud mode
  111280. */
  111281. set pointsCloud(value: boolean);
  111282. /**
  111283. * Gets the material fill mode
  111284. */
  111285. get fillMode(): number;
  111286. /**
  111287. * Sets the material fill mode
  111288. */
  111289. set fillMode(value: number);
  111290. /**
  111291. * @hidden
  111292. * Stores the effects for the material
  111293. */
  111294. _effect: Nullable<Effect>;
  111295. /**
  111296. * Specifies if uniform buffers should be used
  111297. */
  111298. private _useUBO;
  111299. /**
  111300. * Stores a reference to the scene
  111301. */
  111302. private _scene;
  111303. /**
  111304. * Stores the fill mode state
  111305. */
  111306. private _fillMode;
  111307. /**
  111308. * Specifies if the depth write state should be cached
  111309. */
  111310. private _cachedDepthWriteState;
  111311. /**
  111312. * Specifies if the color write state should be cached
  111313. */
  111314. private _cachedColorWriteState;
  111315. /**
  111316. * Specifies if the depth function state should be cached
  111317. */
  111318. private _cachedDepthFunctionState;
  111319. /**
  111320. * Stores the uniform buffer
  111321. */
  111322. protected _uniformBuffer: UniformBuffer;
  111323. /** @hidden */
  111324. _indexInSceneMaterialArray: number;
  111325. /** @hidden */
  111326. meshMap: Nullable<{
  111327. [id: string]: AbstractMesh | undefined;
  111328. }>;
  111329. /**
  111330. * Creates a material instance
  111331. * @param name defines the name of the material
  111332. * @param scene defines the scene to reference
  111333. * @param doNotAdd specifies if the material should be added to the scene
  111334. */
  111335. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111336. /**
  111337. * Returns a string representation of the current material
  111338. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111339. * @returns a string with material information
  111340. */
  111341. toString(fullDetails?: boolean): string;
  111342. /**
  111343. * Gets the class name of the material
  111344. * @returns a string with the class name of the material
  111345. */
  111346. getClassName(): string;
  111347. /**
  111348. * Specifies if updates for the material been locked
  111349. */
  111350. get isFrozen(): boolean;
  111351. /**
  111352. * Locks updates for the material
  111353. */
  111354. freeze(): void;
  111355. /**
  111356. * Unlocks updates for the material
  111357. */
  111358. unfreeze(): void;
  111359. /**
  111360. * Specifies if the material is ready to be used
  111361. * @param mesh defines the mesh to check
  111362. * @param useInstances specifies if instances should be used
  111363. * @returns a boolean indicating if the material is ready to be used
  111364. */
  111365. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111366. /**
  111367. * Specifies that the submesh is ready to be used
  111368. * @param mesh defines the mesh to check
  111369. * @param subMesh defines which submesh to check
  111370. * @param useInstances specifies that instances should be used
  111371. * @returns a boolean indicating that the submesh is ready or not
  111372. */
  111373. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111374. /**
  111375. * Returns the material effect
  111376. * @returns the effect associated with the material
  111377. */
  111378. getEffect(): Nullable<Effect>;
  111379. /**
  111380. * Returns the current scene
  111381. * @returns a Scene
  111382. */
  111383. getScene(): Scene;
  111384. /**
  111385. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111386. */
  111387. protected _forceAlphaTest: boolean;
  111388. /**
  111389. * The transparency mode of the material.
  111390. */
  111391. protected _transparencyMode: Nullable<number>;
  111392. /**
  111393. * Gets the current transparency mode.
  111394. */
  111395. get transparencyMode(): Nullable<number>;
  111396. /**
  111397. * Sets the transparency mode of the material.
  111398. *
  111399. * | Value | Type | Description |
  111400. * | ----- | ----------------------------------- | ----------- |
  111401. * | 0 | OPAQUE | |
  111402. * | 1 | ALPHATEST | |
  111403. * | 2 | ALPHABLEND | |
  111404. * | 3 | ALPHATESTANDBLEND | |
  111405. *
  111406. */
  111407. set transparencyMode(value: Nullable<number>);
  111408. /**
  111409. * Returns true if alpha blending should be disabled.
  111410. */
  111411. protected get _disableAlphaBlending(): boolean;
  111412. /**
  111413. * Specifies whether or not this material should be rendered in alpha blend mode.
  111414. * @returns a boolean specifying if alpha blending is needed
  111415. */
  111416. needAlphaBlending(): boolean;
  111417. /**
  111418. * Specifies if the mesh will require alpha blending
  111419. * @param mesh defines the mesh to check
  111420. * @returns a boolean specifying if alpha blending is needed for the mesh
  111421. */
  111422. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111423. /**
  111424. * Specifies whether or not this material should be rendered in alpha test mode.
  111425. * @returns a boolean specifying if an alpha test is needed.
  111426. */
  111427. needAlphaTesting(): boolean;
  111428. /**
  111429. * Specifies if material alpha testing should be turned on for the mesh
  111430. * @param mesh defines the mesh to check
  111431. */
  111432. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111433. /**
  111434. * Gets the texture used for the alpha test
  111435. * @returns the texture to use for alpha testing
  111436. */
  111437. getAlphaTestTexture(): Nullable<BaseTexture>;
  111438. /**
  111439. * Marks the material to indicate that it needs to be re-calculated
  111440. */
  111441. markDirty(): void;
  111442. /** @hidden */
  111443. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111444. /**
  111445. * Binds the material to the mesh
  111446. * @param world defines the world transformation matrix
  111447. * @param mesh defines the mesh to bind the material to
  111448. */
  111449. bind(world: Matrix, mesh?: Mesh): void;
  111450. /**
  111451. * Binds the submesh to the material
  111452. * @param world defines the world transformation matrix
  111453. * @param mesh defines the mesh containing the submesh
  111454. * @param subMesh defines the submesh to bind the material to
  111455. */
  111456. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111457. /**
  111458. * Binds the world matrix to the material
  111459. * @param world defines the world transformation matrix
  111460. */
  111461. bindOnlyWorldMatrix(world: Matrix): void;
  111462. /**
  111463. * Binds the scene's uniform buffer to the effect.
  111464. * @param effect defines the effect to bind to the scene uniform buffer
  111465. * @param sceneUbo defines the uniform buffer storing scene data
  111466. */
  111467. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111468. /**
  111469. * Binds the view matrix to the effect
  111470. * @param effect defines the effect to bind the view matrix to
  111471. */
  111472. bindView(effect: Effect): void;
  111473. /**
  111474. * Binds the view projection matrix to the effect
  111475. * @param effect defines the effect to bind the view projection matrix to
  111476. */
  111477. bindViewProjection(effect: Effect): void;
  111478. /**
  111479. * Processes to execute after binding the material to a mesh
  111480. * @param mesh defines the rendered mesh
  111481. */
  111482. protected _afterBind(mesh?: Mesh): void;
  111483. /**
  111484. * Unbinds the material from the mesh
  111485. */
  111486. unbind(): void;
  111487. /**
  111488. * Gets the active textures from the material
  111489. * @returns an array of textures
  111490. */
  111491. getActiveTextures(): BaseTexture[];
  111492. /**
  111493. * Specifies if the material uses a texture
  111494. * @param texture defines the texture to check against the material
  111495. * @returns a boolean specifying if the material uses the texture
  111496. */
  111497. hasTexture(texture: BaseTexture): boolean;
  111498. /**
  111499. * Makes a duplicate of the material, and gives it a new name
  111500. * @param name defines the new name for the duplicated material
  111501. * @returns the cloned material
  111502. */
  111503. clone(name: string): Nullable<Material>;
  111504. /**
  111505. * Gets the meshes bound to the material
  111506. * @returns an array of meshes bound to the material
  111507. */
  111508. getBindedMeshes(): AbstractMesh[];
  111509. /**
  111510. * Force shader compilation
  111511. * @param mesh defines the mesh associated with this material
  111512. * @param onCompiled defines a function to execute once the material is compiled
  111513. * @param options defines the options to configure the compilation
  111514. * @param onError defines a function to execute if the material fails compiling
  111515. */
  111516. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111517. /**
  111518. * Force shader compilation
  111519. * @param mesh defines the mesh that will use this material
  111520. * @param options defines additional options for compiling the shaders
  111521. * @returns a promise that resolves when the compilation completes
  111522. */
  111523. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111524. private static readonly _AllDirtyCallBack;
  111525. private static readonly _ImageProcessingDirtyCallBack;
  111526. private static readonly _TextureDirtyCallBack;
  111527. private static readonly _FresnelDirtyCallBack;
  111528. private static readonly _MiscDirtyCallBack;
  111529. private static readonly _PrePassDirtyCallBack;
  111530. private static readonly _LightsDirtyCallBack;
  111531. private static readonly _AttributeDirtyCallBack;
  111532. private static _FresnelAndMiscDirtyCallBack;
  111533. private static _TextureAndMiscDirtyCallBack;
  111534. private static readonly _DirtyCallbackArray;
  111535. private static readonly _RunDirtyCallBacks;
  111536. /**
  111537. * Marks a define in the material to indicate that it needs to be re-computed
  111538. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111539. */
  111540. markAsDirty(flag: number): void;
  111541. /**
  111542. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111543. * @param func defines a function which checks material defines against the submeshes
  111544. */
  111545. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111546. /**
  111547. * Indicates that the scene should check if the rendering now needs a prepass
  111548. */
  111549. protected _markScenePrePassDirty(): void;
  111550. /**
  111551. * Indicates that we need to re-calculated for all submeshes
  111552. */
  111553. protected _markAllSubMeshesAsAllDirty(): void;
  111554. /**
  111555. * Indicates that image processing needs to be re-calculated for all submeshes
  111556. */
  111557. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111558. /**
  111559. * Indicates that textures need to be re-calculated for all submeshes
  111560. */
  111561. protected _markAllSubMeshesAsTexturesDirty(): void;
  111562. /**
  111563. * Indicates that fresnel needs to be re-calculated for all submeshes
  111564. */
  111565. protected _markAllSubMeshesAsFresnelDirty(): void;
  111566. /**
  111567. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111568. */
  111569. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111570. /**
  111571. * Indicates that lights need to be re-calculated for all submeshes
  111572. */
  111573. protected _markAllSubMeshesAsLightsDirty(): void;
  111574. /**
  111575. * Indicates that attributes need to be re-calculated for all submeshes
  111576. */
  111577. protected _markAllSubMeshesAsAttributesDirty(): void;
  111578. /**
  111579. * Indicates that misc needs to be re-calculated for all submeshes
  111580. */
  111581. protected _markAllSubMeshesAsMiscDirty(): void;
  111582. /**
  111583. * Indicates that prepass needs to be re-calculated for all submeshes
  111584. */
  111585. protected _markAllSubMeshesAsPrePassDirty(): void;
  111586. /**
  111587. * Indicates that textures and misc need to be re-calculated for all submeshes
  111588. */
  111589. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111590. /**
  111591. * Sets the required values to the prepass renderer.
  111592. * @param prePassRenderer defines the prepass renderer to setup.
  111593. * @returns true if the pre pass is needed.
  111594. */
  111595. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111596. /**
  111597. * Disposes the material
  111598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111599. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111600. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111601. */
  111602. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111603. /** @hidden */
  111604. private releaseVertexArrayObject;
  111605. /**
  111606. * Serializes this material
  111607. * @returns the serialized material object
  111608. */
  111609. serialize(): any;
  111610. /**
  111611. * Creates a material from parsed material data
  111612. * @param parsedMaterial defines parsed material data
  111613. * @param scene defines the hosting scene
  111614. * @param rootUrl defines the root URL to use to load textures
  111615. * @returns a new material
  111616. */
  111617. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111618. }
  111619. }
  111620. declare module BABYLON {
  111621. /**
  111622. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111623. * separate meshes. This can be use to improve performances.
  111624. * @see https://doc.babylonjs.com/how_to/multi_materials
  111625. */
  111626. export class MultiMaterial extends Material {
  111627. private _subMaterials;
  111628. /**
  111629. * Gets or Sets the list of Materials used within the multi material.
  111630. * They need to be ordered according to the submeshes order in the associated mesh
  111631. */
  111632. get subMaterials(): Nullable<Material>[];
  111633. set subMaterials(value: Nullable<Material>[]);
  111634. /**
  111635. * Function used to align with Node.getChildren()
  111636. * @returns the list of Materials used within the multi material
  111637. */
  111638. getChildren(): Nullable<Material>[];
  111639. /**
  111640. * Instantiates a new Multi Material
  111641. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111642. * separate meshes. This can be use to improve performances.
  111643. * @see https://doc.babylonjs.com/how_to/multi_materials
  111644. * @param name Define the name in the scene
  111645. * @param scene Define the scene the material belongs to
  111646. */
  111647. constructor(name: string, scene: Scene);
  111648. private _hookArray;
  111649. /**
  111650. * Get one of the submaterial by its index in the submaterials array
  111651. * @param index The index to look the sub material at
  111652. * @returns The Material if the index has been defined
  111653. */
  111654. getSubMaterial(index: number): Nullable<Material>;
  111655. /**
  111656. * Get the list of active textures for the whole sub materials list.
  111657. * @returns All the textures that will be used during the rendering
  111658. */
  111659. getActiveTextures(): BaseTexture[];
  111660. /**
  111661. * Specifies if any sub-materials of this multi-material use a given texture.
  111662. * @param texture Defines the texture to check against this multi-material's sub-materials.
  111663. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  111664. */
  111665. hasTexture(texture: BaseTexture): boolean;
  111666. /**
  111667. * Gets the current class name of the material e.g. "MultiMaterial"
  111668. * Mainly use in serialization.
  111669. * @returns the class name
  111670. */
  111671. getClassName(): string;
  111672. /**
  111673. * Checks if the material is ready to render the requested sub mesh
  111674. * @param mesh Define the mesh the submesh belongs to
  111675. * @param subMesh Define the sub mesh to look readyness for
  111676. * @param useInstances Define whether or not the material is used with instances
  111677. * @returns true if ready, otherwise false
  111678. */
  111679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111680. /**
  111681. * Clones the current material and its related sub materials
  111682. * @param name Define the name of the newly cloned material
  111683. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111684. * @returns the cloned material
  111685. */
  111686. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111687. /**
  111688. * Serializes the materials into a JSON representation.
  111689. * @returns the JSON representation
  111690. */
  111691. serialize(): any;
  111692. /**
  111693. * Dispose the material and release its associated resources
  111694. * @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)
  111695. * @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)
  111696. * @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)
  111697. */
  111698. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111699. /**
  111700. * Creates a MultiMaterial from parsed MultiMaterial data.
  111701. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111702. * @param scene defines the hosting scene
  111703. * @returns a new MultiMaterial
  111704. */
  111705. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * Defines a subdivision inside a mesh
  111711. */
  111712. export class SubMesh implements ICullable {
  111713. /** the material index to use */
  111714. materialIndex: number;
  111715. /** vertex index start */
  111716. verticesStart: number;
  111717. /** vertices count */
  111718. verticesCount: number;
  111719. /** index start */
  111720. indexStart: number;
  111721. /** indices count */
  111722. indexCount: number;
  111723. /** @hidden */
  111724. _materialDefines: Nullable<MaterialDefines>;
  111725. /** @hidden */
  111726. _materialEffect: Nullable<Effect>;
  111727. /** @hidden */
  111728. _effectOverride: Nullable<Effect>;
  111729. /**
  111730. * Gets material defines used by the effect associated to the sub mesh
  111731. */
  111732. get materialDefines(): Nullable<MaterialDefines>;
  111733. /**
  111734. * Sets material defines used by the effect associated to the sub mesh
  111735. */
  111736. set materialDefines(defines: Nullable<MaterialDefines>);
  111737. /**
  111738. * Gets associated effect
  111739. */
  111740. get effect(): Nullable<Effect>;
  111741. /**
  111742. * Sets associated effect (effect used to render this submesh)
  111743. * @param effect defines the effect to associate with
  111744. * @param defines defines the set of defines used to compile this effect
  111745. */
  111746. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111747. /** @hidden */
  111748. _linesIndexCount: number;
  111749. private _mesh;
  111750. private _renderingMesh;
  111751. private _boundingInfo;
  111752. private _linesIndexBuffer;
  111753. /** @hidden */
  111754. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111755. /** @hidden */
  111756. _trianglePlanes: Plane[];
  111757. /** @hidden */
  111758. _lastColliderTransformMatrix: Nullable<Matrix>;
  111759. /** @hidden */
  111760. _renderId: number;
  111761. /** @hidden */
  111762. _alphaIndex: number;
  111763. /** @hidden */
  111764. _distanceToCamera: number;
  111765. /** @hidden */
  111766. _id: number;
  111767. private _currentMaterial;
  111768. /**
  111769. * Add a new submesh to a mesh
  111770. * @param materialIndex defines the material index to use
  111771. * @param verticesStart defines vertex index start
  111772. * @param verticesCount defines vertices count
  111773. * @param indexStart defines index start
  111774. * @param indexCount defines indices count
  111775. * @param mesh defines the parent mesh
  111776. * @param renderingMesh defines an optional rendering mesh
  111777. * @param createBoundingBox defines if bounding box should be created for this submesh
  111778. * @returns the new submesh
  111779. */
  111780. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111781. /**
  111782. * Creates a new submesh
  111783. * @param materialIndex defines the material index to use
  111784. * @param verticesStart defines vertex index start
  111785. * @param verticesCount defines vertices count
  111786. * @param indexStart defines index start
  111787. * @param indexCount defines indices count
  111788. * @param mesh defines the parent mesh
  111789. * @param renderingMesh defines an optional rendering mesh
  111790. * @param createBoundingBox defines if bounding box should be created for this submesh
  111791. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111792. */
  111793. constructor(
  111794. /** the material index to use */
  111795. materialIndex: number,
  111796. /** vertex index start */
  111797. verticesStart: number,
  111798. /** vertices count */
  111799. verticesCount: number,
  111800. /** index start */
  111801. indexStart: number,
  111802. /** indices count */
  111803. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111804. /**
  111805. * Returns true if this submesh covers the entire parent mesh
  111806. * @ignorenaming
  111807. */
  111808. get IsGlobal(): boolean;
  111809. /**
  111810. * Returns the submesh BoudingInfo object
  111811. * @returns current bounding info (or mesh's one if the submesh is global)
  111812. */
  111813. getBoundingInfo(): BoundingInfo;
  111814. /**
  111815. * Sets the submesh BoundingInfo
  111816. * @param boundingInfo defines the new bounding info to use
  111817. * @returns the SubMesh
  111818. */
  111819. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111820. /**
  111821. * Returns the mesh of the current submesh
  111822. * @return the parent mesh
  111823. */
  111824. getMesh(): AbstractMesh;
  111825. /**
  111826. * Returns the rendering mesh of the submesh
  111827. * @returns the rendering mesh (could be different from parent mesh)
  111828. */
  111829. getRenderingMesh(): Mesh;
  111830. /**
  111831. * Returns the replacement mesh of the submesh
  111832. * @returns the replacement mesh (could be different from parent mesh)
  111833. */
  111834. getReplacementMesh(): Nullable<AbstractMesh>;
  111835. /**
  111836. * Returns the effective mesh of the submesh
  111837. * @returns the effective mesh (could be different from parent mesh)
  111838. */
  111839. getEffectiveMesh(): AbstractMesh;
  111840. /**
  111841. * Returns the submesh material
  111842. * @returns null or the current material
  111843. */
  111844. getMaterial(): Nullable<Material>;
  111845. private _IsMultiMaterial;
  111846. /**
  111847. * Sets a new updated BoundingInfo object to the submesh
  111848. * @param data defines an optional position array to use to determine the bounding info
  111849. * @returns the SubMesh
  111850. */
  111851. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111852. /** @hidden */
  111853. _checkCollision(collider: Collider): boolean;
  111854. /**
  111855. * Updates the submesh BoundingInfo
  111856. * @param world defines the world matrix to use to update the bounding info
  111857. * @returns the submesh
  111858. */
  111859. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111860. /**
  111861. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111862. * @param frustumPlanes defines the frustum planes
  111863. * @returns true if the submesh is intersecting with the frustum
  111864. */
  111865. isInFrustum(frustumPlanes: Plane[]): boolean;
  111866. /**
  111867. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111868. * @param frustumPlanes defines the frustum planes
  111869. * @returns true if the submesh is inside the frustum
  111870. */
  111871. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111872. /**
  111873. * Renders the submesh
  111874. * @param enableAlphaMode defines if alpha needs to be used
  111875. * @returns the submesh
  111876. */
  111877. render(enableAlphaMode: boolean): SubMesh;
  111878. /**
  111879. * @hidden
  111880. */
  111881. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111882. /**
  111883. * Checks if the submesh intersects with a ray
  111884. * @param ray defines the ray to test
  111885. * @returns true is the passed ray intersects the submesh bounding box
  111886. */
  111887. canIntersects(ray: Ray): boolean;
  111888. /**
  111889. * Intersects current submesh with a ray
  111890. * @param ray defines the ray to test
  111891. * @param positions defines mesh's positions array
  111892. * @param indices defines mesh's indices array
  111893. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111895. * @returns intersection info or null if no intersection
  111896. */
  111897. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111898. /** @hidden */
  111899. private _intersectLines;
  111900. /** @hidden */
  111901. private _intersectUnIndexedLines;
  111902. /** @hidden */
  111903. private _intersectTriangles;
  111904. /** @hidden */
  111905. private _intersectUnIndexedTriangles;
  111906. /** @hidden */
  111907. _rebuild(): void;
  111908. /**
  111909. * Creates a new submesh from the passed mesh
  111910. * @param newMesh defines the new hosting mesh
  111911. * @param newRenderingMesh defines an optional rendering mesh
  111912. * @returns the new submesh
  111913. */
  111914. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111915. /**
  111916. * Release associated resources
  111917. */
  111918. dispose(): void;
  111919. /**
  111920. * Gets the class name
  111921. * @returns the string "SubMesh".
  111922. */
  111923. getClassName(): string;
  111924. /**
  111925. * Creates a new submesh from indices data
  111926. * @param materialIndex the index of the main mesh material
  111927. * @param startIndex the index where to start the copy in the mesh indices array
  111928. * @param indexCount the number of indices to copy then from the startIndex
  111929. * @param mesh the main mesh to create the submesh from
  111930. * @param renderingMesh the optional rendering mesh
  111931. * @returns a new submesh
  111932. */
  111933. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111934. }
  111935. }
  111936. declare module BABYLON {
  111937. /**
  111938. * Class used to represent data loading progression
  111939. */
  111940. export class SceneLoaderFlags {
  111941. private static _ForceFullSceneLoadingForIncremental;
  111942. private static _ShowLoadingScreen;
  111943. private static _CleanBoneMatrixWeights;
  111944. private static _loggingLevel;
  111945. /**
  111946. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111947. */
  111948. static get ForceFullSceneLoadingForIncremental(): boolean;
  111949. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111950. /**
  111951. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111952. */
  111953. static get ShowLoadingScreen(): boolean;
  111954. static set ShowLoadingScreen(value: boolean);
  111955. /**
  111956. * Defines the current logging level (while loading the scene)
  111957. * @ignorenaming
  111958. */
  111959. static get loggingLevel(): number;
  111960. static set loggingLevel(value: number);
  111961. /**
  111962. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111963. */
  111964. static get CleanBoneMatrixWeights(): boolean;
  111965. static set CleanBoneMatrixWeights(value: boolean);
  111966. }
  111967. }
  111968. declare module BABYLON {
  111969. /**
  111970. * Class used to store geometry data (vertex buffers + index buffer)
  111971. */
  111972. export class Geometry implements IGetSetVerticesData {
  111973. /**
  111974. * Gets or sets the ID of the geometry
  111975. */
  111976. id: string;
  111977. /**
  111978. * Gets or sets the unique ID of the geometry
  111979. */
  111980. uniqueId: number;
  111981. /**
  111982. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111983. */
  111984. delayLoadState: number;
  111985. /**
  111986. * Gets the file containing the data to load when running in delay load state
  111987. */
  111988. delayLoadingFile: Nullable<string>;
  111989. /**
  111990. * Callback called when the geometry is updated
  111991. */
  111992. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111993. private _scene;
  111994. private _engine;
  111995. private _meshes;
  111996. private _totalVertices;
  111997. /** @hidden */
  111998. _indices: IndicesArray;
  111999. /** @hidden */
  112000. _vertexBuffers: {
  112001. [key: string]: VertexBuffer;
  112002. };
  112003. private _isDisposed;
  112004. private _extend;
  112005. private _boundingBias;
  112006. /** @hidden */
  112007. _delayInfo: Array<string>;
  112008. private _indexBuffer;
  112009. private _indexBufferIsUpdatable;
  112010. /** @hidden */
  112011. _boundingInfo: Nullable<BoundingInfo>;
  112012. /** @hidden */
  112013. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  112014. /** @hidden */
  112015. _softwareSkinningFrameId: number;
  112016. private _vertexArrayObjects;
  112017. private _updatable;
  112018. /** @hidden */
  112019. _positions: Nullable<Vector3[]>;
  112020. private _positionsCache;
  112021. /**
  112022. * 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
  112023. */
  112024. get boundingBias(): Vector2;
  112025. /**
  112026. * 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
  112027. */
  112028. set boundingBias(value: Vector2);
  112029. /**
  112030. * Static function used to attach a new empty geometry to a mesh
  112031. * @param mesh defines the mesh to attach the geometry to
  112032. * @returns the new Geometry
  112033. */
  112034. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  112035. /** Get the list of meshes using this geometry */
  112036. get meshes(): Mesh[];
  112037. /**
  112038. * 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
  112039. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  112040. */
  112041. useBoundingInfoFromGeometry: boolean;
  112042. /**
  112043. * Creates a new geometry
  112044. * @param id defines the unique ID
  112045. * @param scene defines the hosting scene
  112046. * @param vertexData defines the VertexData used to get geometry data
  112047. * @param updatable defines if geometry must be updatable (false by default)
  112048. * @param mesh defines the mesh that will be associated with the geometry
  112049. */
  112050. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  112051. /**
  112052. * Gets the current extend of the geometry
  112053. */
  112054. get extend(): {
  112055. minimum: Vector3;
  112056. maximum: Vector3;
  112057. };
  112058. /**
  112059. * Gets the hosting scene
  112060. * @returns the hosting Scene
  112061. */
  112062. getScene(): Scene;
  112063. /**
  112064. * Gets the hosting engine
  112065. * @returns the hosting Engine
  112066. */
  112067. getEngine(): Engine;
  112068. /**
  112069. * Defines if the geometry is ready to use
  112070. * @returns true if the geometry is ready to be used
  112071. */
  112072. isReady(): boolean;
  112073. /**
  112074. * Gets a value indicating that the geometry should not be serialized
  112075. */
  112076. get doNotSerialize(): boolean;
  112077. /** @hidden */
  112078. _rebuild(): void;
  112079. /**
  112080. * Affects all geometry data in one call
  112081. * @param vertexData defines the geometry data
  112082. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  112083. */
  112084. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  112085. /**
  112086. * Set specific vertex data
  112087. * @param kind defines the data kind (Position, normal, etc...)
  112088. * @param data defines the vertex data to use
  112089. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  112090. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  112091. */
  112092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  112093. /**
  112094. * Removes a specific vertex data
  112095. * @param kind defines the data kind (Position, normal, etc...)
  112096. */
  112097. removeVerticesData(kind: string): void;
  112098. /**
  112099. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  112100. * @param buffer defines the vertex buffer to use
  112101. * @param totalVertices defines the total number of vertices for position kind (could be null)
  112102. */
  112103. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  112104. /**
  112105. * Update a specific vertex buffer
  112106. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  112107. * It will do nothing if the buffer is not updatable
  112108. * @param kind defines the data kind (Position, normal, etc...)
  112109. * @param data defines the data to use
  112110. * @param offset defines the offset in the target buffer where to store the data
  112111. * @param useBytes set to true if the offset is in bytes
  112112. */
  112113. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  112114. /**
  112115. * Update a specific vertex buffer
  112116. * This function will create a new buffer if the current one is not updatable
  112117. * @param kind defines the data kind (Position, normal, etc...)
  112118. * @param data defines the data to use
  112119. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  112120. */
  112121. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  112122. private _updateBoundingInfo;
  112123. /** @hidden */
  112124. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  112125. /**
  112126. * Gets total number of vertices
  112127. * @returns the total number of vertices
  112128. */
  112129. getTotalVertices(): number;
  112130. /**
  112131. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  112132. * @param kind defines the data kind (Position, normal, etc...)
  112133. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112135. * @returns a float array containing vertex data
  112136. */
  112137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  112138. /**
  112139. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  112140. * @param kind defines the data kind (Position, normal, etc...)
  112141. * @returns true if the vertex buffer with the specified kind is updatable
  112142. */
  112143. isVertexBufferUpdatable(kind: string): boolean;
  112144. /**
  112145. * Gets a specific vertex buffer
  112146. * @param kind defines the data kind (Position, normal, etc...)
  112147. * @returns a VertexBuffer
  112148. */
  112149. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  112150. /**
  112151. * Returns all vertex buffers
  112152. * @return an object holding all vertex buffers indexed by kind
  112153. */
  112154. getVertexBuffers(): Nullable<{
  112155. [key: string]: VertexBuffer;
  112156. }>;
  112157. /**
  112158. * Gets a boolean indicating if specific vertex buffer is present
  112159. * @param kind defines the data kind (Position, normal, etc...)
  112160. * @returns true if data is present
  112161. */
  112162. isVerticesDataPresent(kind: string): boolean;
  112163. /**
  112164. * Gets a list of all attached data kinds (Position, normal, etc...)
  112165. * @returns a list of string containing all kinds
  112166. */
  112167. getVerticesDataKinds(): string[];
  112168. /**
  112169. * Update index buffer
  112170. * @param indices defines the indices to store in the index buffer
  112171. * @param offset defines the offset in the target buffer where to store the data
  112172. * @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)
  112173. */
  112174. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  112175. /**
  112176. * Creates a new index buffer
  112177. * @param indices defines the indices to store in the index buffer
  112178. * @param totalVertices defines the total number of vertices (could be null)
  112179. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  112180. */
  112181. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  112182. /**
  112183. * Return the total number of indices
  112184. * @returns the total number of indices
  112185. */
  112186. getTotalIndices(): number;
  112187. /**
  112188. * Gets the index buffer array
  112189. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112190. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112191. * @returns the index buffer array
  112192. */
  112193. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  112194. /**
  112195. * Gets the index buffer
  112196. * @return the index buffer
  112197. */
  112198. getIndexBuffer(): Nullable<DataBuffer>;
  112199. /** @hidden */
  112200. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  112201. /**
  112202. * Release the associated resources for a specific mesh
  112203. * @param mesh defines the source mesh
  112204. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  112205. */
  112206. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  112207. /**
  112208. * Apply current geometry to a given mesh
  112209. * @param mesh defines the mesh to apply geometry to
  112210. */
  112211. applyToMesh(mesh: Mesh): void;
  112212. private _updateExtend;
  112213. private _applyToMesh;
  112214. private notifyUpdate;
  112215. /**
  112216. * Load the geometry if it was flagged as delay loaded
  112217. * @param scene defines the hosting scene
  112218. * @param onLoaded defines a callback called when the geometry is loaded
  112219. */
  112220. load(scene: Scene, onLoaded?: () => void): void;
  112221. private _queueLoad;
  112222. /**
  112223. * Invert the geometry to move from a right handed system to a left handed one.
  112224. */
  112225. toLeftHanded(): void;
  112226. /** @hidden */
  112227. _resetPointsArrayCache(): void;
  112228. /** @hidden */
  112229. _generatePointsArray(): boolean;
  112230. /**
  112231. * Gets a value indicating if the geometry is disposed
  112232. * @returns true if the geometry was disposed
  112233. */
  112234. isDisposed(): boolean;
  112235. private _disposeVertexArrayObjects;
  112236. /**
  112237. * Free all associated resources
  112238. */
  112239. dispose(): void;
  112240. /**
  112241. * Clone the current geometry into a new geometry
  112242. * @param id defines the unique ID of the new geometry
  112243. * @returns a new geometry object
  112244. */
  112245. copy(id: string): Geometry;
  112246. /**
  112247. * Serialize the current geometry info (and not the vertices data) into a JSON object
  112248. * @return a JSON representation of the current geometry data (without the vertices data)
  112249. */
  112250. serialize(): any;
  112251. private toNumberArray;
  112252. /**
  112253. * Serialize all vertices data into a JSON oject
  112254. * @returns a JSON representation of the current geometry data
  112255. */
  112256. serializeVerticeData(): any;
  112257. /**
  112258. * Extracts a clone of a mesh geometry
  112259. * @param mesh defines the source mesh
  112260. * @param id defines the unique ID of the new geometry object
  112261. * @returns the new geometry object
  112262. */
  112263. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  112264. /**
  112265. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  112266. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  112267. * Be aware Math.random() could cause collisions, but:
  112268. * "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"
  112269. * @returns a string containing a new GUID
  112270. */
  112271. static RandomId(): string;
  112272. /** @hidden */
  112273. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  112274. private static _CleanMatricesWeights;
  112275. /**
  112276. * Create a new geometry from persisted data (Using .babylon file format)
  112277. * @param parsedVertexData defines the persisted data
  112278. * @param scene defines the hosting scene
  112279. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112280. * @returns the new geometry object
  112281. */
  112282. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112283. }
  112284. }
  112285. declare module BABYLON {
  112286. /**
  112287. * Defines a target to use with MorphTargetManager
  112288. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112289. */
  112290. export class MorphTarget implements IAnimatable {
  112291. /** defines the name of the target */
  112292. name: string;
  112293. /**
  112294. * Gets or sets the list of animations
  112295. */
  112296. animations: Animation[];
  112297. private _scene;
  112298. private _positions;
  112299. private _normals;
  112300. private _tangents;
  112301. private _uvs;
  112302. private _influence;
  112303. private _uniqueId;
  112304. /**
  112305. * Observable raised when the influence changes
  112306. */
  112307. onInfluenceChanged: Observable<boolean>;
  112308. /** @hidden */
  112309. _onDataLayoutChanged: Observable<void>;
  112310. /**
  112311. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112312. */
  112313. get influence(): number;
  112314. set influence(influence: number);
  112315. /**
  112316. * Gets or sets the id of the morph Target
  112317. */
  112318. id: string;
  112319. private _animationPropertiesOverride;
  112320. /**
  112321. * Gets or sets the animation properties override
  112322. */
  112323. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112324. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112325. /**
  112326. * Creates a new MorphTarget
  112327. * @param name defines the name of the target
  112328. * @param influence defines the influence to use
  112329. * @param scene defines the scene the morphtarget belongs to
  112330. */
  112331. constructor(
  112332. /** defines the name of the target */
  112333. name: string, influence?: number, scene?: Nullable<Scene>);
  112334. /**
  112335. * Gets the unique ID of this manager
  112336. */
  112337. get uniqueId(): number;
  112338. /**
  112339. * Gets a boolean defining if the target contains position data
  112340. */
  112341. get hasPositions(): boolean;
  112342. /**
  112343. * Gets a boolean defining if the target contains normal data
  112344. */
  112345. get hasNormals(): boolean;
  112346. /**
  112347. * Gets a boolean defining if the target contains tangent data
  112348. */
  112349. get hasTangents(): boolean;
  112350. /**
  112351. * Gets a boolean defining if the target contains texture coordinates data
  112352. */
  112353. get hasUVs(): boolean;
  112354. /**
  112355. * Affects position data to this target
  112356. * @param data defines the position data to use
  112357. */
  112358. setPositions(data: Nullable<FloatArray>): void;
  112359. /**
  112360. * Gets the position data stored in this target
  112361. * @returns a FloatArray containing the position data (or null if not present)
  112362. */
  112363. getPositions(): Nullable<FloatArray>;
  112364. /**
  112365. * Affects normal data to this target
  112366. * @param data defines the normal data to use
  112367. */
  112368. setNormals(data: Nullable<FloatArray>): void;
  112369. /**
  112370. * Gets the normal data stored in this target
  112371. * @returns a FloatArray containing the normal data (or null if not present)
  112372. */
  112373. getNormals(): Nullable<FloatArray>;
  112374. /**
  112375. * Affects tangent data to this target
  112376. * @param data defines the tangent data to use
  112377. */
  112378. setTangents(data: Nullable<FloatArray>): void;
  112379. /**
  112380. * Gets the tangent data stored in this target
  112381. * @returns a FloatArray containing the tangent data (or null if not present)
  112382. */
  112383. getTangents(): Nullable<FloatArray>;
  112384. /**
  112385. * Affects texture coordinates data to this target
  112386. * @param data defines the texture coordinates data to use
  112387. */
  112388. setUVs(data: Nullable<FloatArray>): void;
  112389. /**
  112390. * Gets the texture coordinates data stored in this target
  112391. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112392. */
  112393. getUVs(): Nullable<FloatArray>;
  112394. /**
  112395. * Clone the current target
  112396. * @returns a new MorphTarget
  112397. */
  112398. clone(): MorphTarget;
  112399. /**
  112400. * Serializes the current target into a Serialization object
  112401. * @returns the serialized object
  112402. */
  112403. serialize(): any;
  112404. /**
  112405. * Returns the string "MorphTarget"
  112406. * @returns "MorphTarget"
  112407. */
  112408. getClassName(): string;
  112409. /**
  112410. * Creates a new target from serialized data
  112411. * @param serializationObject defines the serialized data to use
  112412. * @returns a new MorphTarget
  112413. */
  112414. static Parse(serializationObject: any): MorphTarget;
  112415. /**
  112416. * Creates a MorphTarget from mesh data
  112417. * @param mesh defines the source mesh
  112418. * @param name defines the name to use for the new target
  112419. * @param influence defines the influence to attach to the target
  112420. * @returns a new MorphTarget
  112421. */
  112422. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112423. }
  112424. }
  112425. declare module BABYLON {
  112426. /**
  112427. * This class is used to deform meshes using morphing between different targets
  112428. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112429. */
  112430. export class MorphTargetManager {
  112431. private _targets;
  112432. private _targetInfluenceChangedObservers;
  112433. private _targetDataLayoutChangedObservers;
  112434. private _activeTargets;
  112435. private _scene;
  112436. private _influences;
  112437. private _supportsNormals;
  112438. private _supportsTangents;
  112439. private _supportsUVs;
  112440. private _vertexCount;
  112441. private _uniqueId;
  112442. private _tempInfluences;
  112443. /**
  112444. * Gets or sets a boolean indicating if normals must be morphed
  112445. */
  112446. enableNormalMorphing: boolean;
  112447. /**
  112448. * Gets or sets a boolean indicating if tangents must be morphed
  112449. */
  112450. enableTangentMorphing: boolean;
  112451. /**
  112452. * Gets or sets a boolean indicating if UV must be morphed
  112453. */
  112454. enableUVMorphing: boolean;
  112455. /**
  112456. * Creates a new MorphTargetManager
  112457. * @param scene defines the current scene
  112458. */
  112459. constructor(scene?: Nullable<Scene>);
  112460. /**
  112461. * Gets the unique ID of this manager
  112462. */
  112463. get uniqueId(): number;
  112464. /**
  112465. * Gets the number of vertices handled by this manager
  112466. */
  112467. get vertexCount(): number;
  112468. /**
  112469. * Gets a boolean indicating if this manager supports morphing of normals
  112470. */
  112471. get supportsNormals(): boolean;
  112472. /**
  112473. * Gets a boolean indicating if this manager supports morphing of tangents
  112474. */
  112475. get supportsTangents(): boolean;
  112476. /**
  112477. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112478. */
  112479. get supportsUVs(): boolean;
  112480. /**
  112481. * Gets the number of targets stored in this manager
  112482. */
  112483. get numTargets(): number;
  112484. /**
  112485. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112486. */
  112487. get numInfluencers(): number;
  112488. /**
  112489. * Gets the list of influences (one per target)
  112490. */
  112491. get influences(): Float32Array;
  112492. /**
  112493. * Gets the active target at specified index. An active target is a target with an influence > 0
  112494. * @param index defines the index to check
  112495. * @returns the requested target
  112496. */
  112497. getActiveTarget(index: number): MorphTarget;
  112498. /**
  112499. * Gets the target at specified index
  112500. * @param index defines the index to check
  112501. * @returns the requested target
  112502. */
  112503. getTarget(index: number): MorphTarget;
  112504. /**
  112505. * Add a new target to this manager
  112506. * @param target defines the target to add
  112507. */
  112508. addTarget(target: MorphTarget): void;
  112509. /**
  112510. * Removes a target from the manager
  112511. * @param target defines the target to remove
  112512. */
  112513. removeTarget(target: MorphTarget): void;
  112514. /**
  112515. * Clone the current manager
  112516. * @returns a new MorphTargetManager
  112517. */
  112518. clone(): MorphTargetManager;
  112519. /**
  112520. * Serializes the current manager into a Serialization object
  112521. * @returns the serialized object
  112522. */
  112523. serialize(): any;
  112524. private _syncActiveTargets;
  112525. /**
  112526. * Syncrhonize the targets with all the meshes using this morph target manager
  112527. */
  112528. synchronize(): void;
  112529. /**
  112530. * Creates a new MorphTargetManager from serialized data
  112531. * @param serializationObject defines the serialized data
  112532. * @param scene defines the hosting scene
  112533. * @returns the new MorphTargetManager
  112534. */
  112535. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112536. }
  112537. }
  112538. declare module BABYLON {
  112539. /**
  112540. * Class used to represent a specific level of detail of a mesh
  112541. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112542. */
  112543. export class MeshLODLevel {
  112544. /** Defines the distance where this level should start being displayed */
  112545. distance: number;
  112546. /** Defines the mesh to use to render this level */
  112547. mesh: Nullable<Mesh>;
  112548. /**
  112549. * Creates a new LOD level
  112550. * @param distance defines the distance where this level should star being displayed
  112551. * @param mesh defines the mesh to use to render this level
  112552. */
  112553. constructor(
  112554. /** Defines the distance where this level should start being displayed */
  112555. distance: number,
  112556. /** Defines the mesh to use to render this level */
  112557. mesh: Nullable<Mesh>);
  112558. }
  112559. }
  112560. declare module BABYLON {
  112561. /**
  112562. * Helper class used to generate a canvas to manipulate images
  112563. */
  112564. export class CanvasGenerator {
  112565. /**
  112566. * Create a new canvas (or offscreen canvas depending on the context)
  112567. * @param width defines the expected width
  112568. * @param height defines the expected height
  112569. * @return a new canvas or offscreen canvas
  112570. */
  112571. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112572. }
  112573. }
  112574. declare module BABYLON {
  112575. /**
  112576. * Mesh representing the gorund
  112577. */
  112578. export class GroundMesh extends Mesh {
  112579. /** If octree should be generated */
  112580. generateOctree: boolean;
  112581. private _heightQuads;
  112582. /** @hidden */
  112583. _subdivisionsX: number;
  112584. /** @hidden */
  112585. _subdivisionsY: number;
  112586. /** @hidden */
  112587. _width: number;
  112588. /** @hidden */
  112589. _height: number;
  112590. /** @hidden */
  112591. _minX: number;
  112592. /** @hidden */
  112593. _maxX: number;
  112594. /** @hidden */
  112595. _minZ: number;
  112596. /** @hidden */
  112597. _maxZ: number;
  112598. constructor(name: string, scene: Scene);
  112599. /**
  112600. * "GroundMesh"
  112601. * @returns "GroundMesh"
  112602. */
  112603. getClassName(): string;
  112604. /**
  112605. * The minimum of x and y subdivisions
  112606. */
  112607. get subdivisions(): number;
  112608. /**
  112609. * X subdivisions
  112610. */
  112611. get subdivisionsX(): number;
  112612. /**
  112613. * Y subdivisions
  112614. */
  112615. get subdivisionsY(): number;
  112616. /**
  112617. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112618. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112619. * @param chunksCount the number of subdivisions for x and y
  112620. * @param octreeBlocksSize (Default: 32)
  112621. */
  112622. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112623. /**
  112624. * Returns a height (y) value in the Worl system :
  112625. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112626. * @param x x coordinate
  112627. * @param z z coordinate
  112628. * @returns the ground y position if (x, z) are outside the ground surface.
  112629. */
  112630. getHeightAtCoordinates(x: number, z: number): number;
  112631. /**
  112632. * Returns a normalized vector (Vector3) orthogonal to the ground
  112633. * at the ground coordinates (x, z) expressed in the World system.
  112634. * @param x x coordinate
  112635. * @param z z coordinate
  112636. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112637. */
  112638. getNormalAtCoordinates(x: number, z: number): Vector3;
  112639. /**
  112640. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112641. * at the ground coordinates (x, z) expressed in the World system.
  112642. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112643. * @param x x coordinate
  112644. * @param z z coordinate
  112645. * @param ref vector to store the result
  112646. * @returns the GroundMesh.
  112647. */
  112648. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112649. /**
  112650. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112651. * if the ground has been updated.
  112652. * This can be used in the render loop.
  112653. * @returns the GroundMesh.
  112654. */
  112655. updateCoordinateHeights(): GroundMesh;
  112656. private _getFacetAt;
  112657. private _initHeightQuads;
  112658. private _computeHeightQuads;
  112659. /**
  112660. * Serializes this ground mesh
  112661. * @param serializationObject object to write serialization to
  112662. */
  112663. serialize(serializationObject: any): void;
  112664. /**
  112665. * Parses a serialized ground mesh
  112666. * @param parsedMesh the serialized mesh
  112667. * @param scene the scene to create the ground mesh in
  112668. * @returns the created ground mesh
  112669. */
  112670. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112671. }
  112672. }
  112673. declare module BABYLON {
  112674. /**
  112675. * Interface for Physics-Joint data
  112676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112677. */
  112678. export interface PhysicsJointData {
  112679. /**
  112680. * The main pivot of the joint
  112681. */
  112682. mainPivot?: Vector3;
  112683. /**
  112684. * The connected pivot of the joint
  112685. */
  112686. connectedPivot?: Vector3;
  112687. /**
  112688. * The main axis of the joint
  112689. */
  112690. mainAxis?: Vector3;
  112691. /**
  112692. * The connected axis of the joint
  112693. */
  112694. connectedAxis?: Vector3;
  112695. /**
  112696. * The collision of the joint
  112697. */
  112698. collision?: boolean;
  112699. /**
  112700. * Native Oimo/Cannon/Energy data
  112701. */
  112702. nativeParams?: any;
  112703. }
  112704. /**
  112705. * This is a holder class for the physics joint created by the physics plugin
  112706. * It holds a set of functions to control the underlying joint
  112707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112708. */
  112709. export class PhysicsJoint {
  112710. /**
  112711. * The type of the physics joint
  112712. */
  112713. type: number;
  112714. /**
  112715. * The data for the physics joint
  112716. */
  112717. jointData: PhysicsJointData;
  112718. private _physicsJoint;
  112719. protected _physicsPlugin: IPhysicsEnginePlugin;
  112720. /**
  112721. * Initializes the physics joint
  112722. * @param type The type of the physics joint
  112723. * @param jointData The data for the physics joint
  112724. */
  112725. constructor(
  112726. /**
  112727. * The type of the physics joint
  112728. */
  112729. type: number,
  112730. /**
  112731. * The data for the physics joint
  112732. */
  112733. jointData: PhysicsJointData);
  112734. /**
  112735. * Gets the physics joint
  112736. */
  112737. get physicsJoint(): any;
  112738. /**
  112739. * Sets the physics joint
  112740. */
  112741. set physicsJoint(newJoint: any);
  112742. /**
  112743. * Sets the physics plugin
  112744. */
  112745. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112746. /**
  112747. * Execute a function that is physics-plugin specific.
  112748. * @param {Function} func the function that will be executed.
  112749. * It accepts two parameters: the physics world and the physics joint
  112750. */
  112751. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112752. /**
  112753. * Distance-Joint type
  112754. */
  112755. static DistanceJoint: number;
  112756. /**
  112757. * Hinge-Joint type
  112758. */
  112759. static HingeJoint: number;
  112760. /**
  112761. * Ball-and-Socket joint type
  112762. */
  112763. static BallAndSocketJoint: number;
  112764. /**
  112765. * Wheel-Joint type
  112766. */
  112767. static WheelJoint: number;
  112768. /**
  112769. * Slider-Joint type
  112770. */
  112771. static SliderJoint: number;
  112772. /**
  112773. * Prismatic-Joint type
  112774. */
  112775. static PrismaticJoint: number;
  112776. /**
  112777. * Universal-Joint type
  112778. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112779. */
  112780. static UniversalJoint: number;
  112781. /**
  112782. * Hinge-Joint 2 type
  112783. */
  112784. static Hinge2Joint: number;
  112785. /**
  112786. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112787. */
  112788. static PointToPointJoint: number;
  112789. /**
  112790. * Spring-Joint type
  112791. */
  112792. static SpringJoint: number;
  112793. /**
  112794. * Lock-Joint type
  112795. */
  112796. static LockJoint: number;
  112797. }
  112798. /**
  112799. * A class representing a physics distance joint
  112800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112801. */
  112802. export class DistanceJoint extends PhysicsJoint {
  112803. /**
  112804. *
  112805. * @param jointData The data for the Distance-Joint
  112806. */
  112807. constructor(jointData: DistanceJointData);
  112808. /**
  112809. * Update the predefined distance.
  112810. * @param maxDistance The maximum preferred distance
  112811. * @param minDistance The minimum preferred distance
  112812. */
  112813. updateDistance(maxDistance: number, minDistance?: number): void;
  112814. }
  112815. /**
  112816. * Represents a Motor-Enabled Joint
  112817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112818. */
  112819. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112820. /**
  112821. * Initializes the Motor-Enabled Joint
  112822. * @param type The type of the joint
  112823. * @param jointData The physica joint data for the joint
  112824. */
  112825. constructor(type: number, jointData: PhysicsJointData);
  112826. /**
  112827. * Set the motor values.
  112828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112829. * @param force the force to apply
  112830. * @param maxForce max force for this motor.
  112831. */
  112832. setMotor(force?: number, maxForce?: number): void;
  112833. /**
  112834. * Set the motor's limits.
  112835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112836. * @param upperLimit The upper limit of the motor
  112837. * @param lowerLimit The lower limit of the motor
  112838. */
  112839. setLimit(upperLimit: number, lowerLimit?: number): void;
  112840. }
  112841. /**
  112842. * This class represents a single physics Hinge-Joint
  112843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112844. */
  112845. export class HingeJoint extends MotorEnabledJoint {
  112846. /**
  112847. * Initializes the Hinge-Joint
  112848. * @param jointData The joint data for the Hinge-Joint
  112849. */
  112850. constructor(jointData: PhysicsJointData);
  112851. /**
  112852. * Set the motor values.
  112853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112854. * @param {number} force the force to apply
  112855. * @param {number} maxForce max force for this motor.
  112856. */
  112857. setMotor(force?: number, maxForce?: number): void;
  112858. /**
  112859. * Set the motor's limits.
  112860. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112861. * @param upperLimit The upper limit of the motor
  112862. * @param lowerLimit The lower limit of the motor
  112863. */
  112864. setLimit(upperLimit: number, lowerLimit?: number): void;
  112865. }
  112866. /**
  112867. * This class represents a dual hinge physics joint (same as wheel joint)
  112868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112869. */
  112870. export class Hinge2Joint extends MotorEnabledJoint {
  112871. /**
  112872. * Initializes the Hinge2-Joint
  112873. * @param jointData The joint data for the Hinge2-Joint
  112874. */
  112875. constructor(jointData: PhysicsJointData);
  112876. /**
  112877. * Set the motor values.
  112878. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112879. * @param {number} targetSpeed the speed the motor is to reach
  112880. * @param {number} maxForce max force for this motor.
  112881. * @param {motorIndex} the motor's index, 0 or 1.
  112882. */
  112883. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112884. /**
  112885. * Set the motor limits.
  112886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112887. * @param {number} upperLimit the upper limit
  112888. * @param {number} lowerLimit lower limit
  112889. * @param {motorIndex} the motor's index, 0 or 1.
  112890. */
  112891. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112892. }
  112893. /**
  112894. * Interface for a motor enabled joint
  112895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112896. */
  112897. export interface IMotorEnabledJoint {
  112898. /**
  112899. * Physics joint
  112900. */
  112901. physicsJoint: any;
  112902. /**
  112903. * Sets the motor of the motor-enabled joint
  112904. * @param force The force of the motor
  112905. * @param maxForce The maximum force of the motor
  112906. * @param motorIndex The index of the motor
  112907. */
  112908. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112909. /**
  112910. * Sets the limit of the motor
  112911. * @param upperLimit The upper limit of the motor
  112912. * @param lowerLimit The lower limit of the motor
  112913. * @param motorIndex The index of the motor
  112914. */
  112915. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112916. }
  112917. /**
  112918. * Joint data for a Distance-Joint
  112919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112920. */
  112921. export interface DistanceJointData extends PhysicsJointData {
  112922. /**
  112923. * Max distance the 2 joint objects can be apart
  112924. */
  112925. maxDistance: number;
  112926. }
  112927. /**
  112928. * Joint data from a spring joint
  112929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112930. */
  112931. export interface SpringJointData extends PhysicsJointData {
  112932. /**
  112933. * Length of the spring
  112934. */
  112935. length: number;
  112936. /**
  112937. * Stiffness of the spring
  112938. */
  112939. stiffness: number;
  112940. /**
  112941. * Damping of the spring
  112942. */
  112943. damping: number;
  112944. /** this callback will be called when applying the force to the impostors. */
  112945. forceApplicationCallback: () => void;
  112946. }
  112947. }
  112948. declare module BABYLON {
  112949. /**
  112950. * Holds the data for the raycast result
  112951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112952. */
  112953. export class PhysicsRaycastResult {
  112954. private _hasHit;
  112955. private _hitDistance;
  112956. private _hitNormalWorld;
  112957. private _hitPointWorld;
  112958. private _rayFromWorld;
  112959. private _rayToWorld;
  112960. /**
  112961. * Gets if there was a hit
  112962. */
  112963. get hasHit(): boolean;
  112964. /**
  112965. * Gets the distance from the hit
  112966. */
  112967. get hitDistance(): number;
  112968. /**
  112969. * Gets the hit normal/direction in the world
  112970. */
  112971. get hitNormalWorld(): Vector3;
  112972. /**
  112973. * Gets the hit point in the world
  112974. */
  112975. get hitPointWorld(): Vector3;
  112976. /**
  112977. * Gets the ray "start point" of the ray in the world
  112978. */
  112979. get rayFromWorld(): Vector3;
  112980. /**
  112981. * Gets the ray "end point" of the ray in the world
  112982. */
  112983. get rayToWorld(): Vector3;
  112984. /**
  112985. * Sets the hit data (normal & point in world space)
  112986. * @param hitNormalWorld defines the normal in world space
  112987. * @param hitPointWorld defines the point in world space
  112988. */
  112989. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112990. /**
  112991. * Sets the distance from the start point to the hit point
  112992. * @param distance
  112993. */
  112994. setHitDistance(distance: number): void;
  112995. /**
  112996. * Calculates the distance manually
  112997. */
  112998. calculateHitDistance(): void;
  112999. /**
  113000. * Resets all the values to default
  113001. * @param from The from point on world space
  113002. * @param to The to point on world space
  113003. */
  113004. reset(from?: Vector3, to?: Vector3): void;
  113005. }
  113006. /**
  113007. * Interface for the size containing width and height
  113008. */
  113009. interface IXYZ {
  113010. /**
  113011. * X
  113012. */
  113013. x: number;
  113014. /**
  113015. * Y
  113016. */
  113017. y: number;
  113018. /**
  113019. * Z
  113020. */
  113021. z: number;
  113022. }
  113023. }
  113024. declare module BABYLON {
  113025. /**
  113026. * Interface used to describe a physics joint
  113027. */
  113028. export interface PhysicsImpostorJoint {
  113029. /** Defines the main impostor to which the joint is linked */
  113030. mainImpostor: PhysicsImpostor;
  113031. /** Defines the impostor that is connected to the main impostor using this joint */
  113032. connectedImpostor: PhysicsImpostor;
  113033. /** Defines the joint itself */
  113034. joint: PhysicsJoint;
  113035. }
  113036. /** @hidden */
  113037. export interface IPhysicsEnginePlugin {
  113038. world: any;
  113039. name: string;
  113040. setGravity(gravity: Vector3): void;
  113041. setTimeStep(timeStep: number): void;
  113042. getTimeStep(): number;
  113043. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113044. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113045. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113046. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113047. removePhysicsBody(impostor: PhysicsImpostor): void;
  113048. generateJoint(joint: PhysicsImpostorJoint): void;
  113049. removeJoint(joint: PhysicsImpostorJoint): void;
  113050. isSupported(): boolean;
  113051. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113052. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113053. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113054. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113055. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113056. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113057. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113058. getBodyMass(impostor: PhysicsImpostor): number;
  113059. getBodyFriction(impostor: PhysicsImpostor): number;
  113060. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113061. getBodyRestitution(impostor: PhysicsImpostor): number;
  113062. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113063. getBodyPressure?(impostor: PhysicsImpostor): number;
  113064. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113065. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113066. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113067. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113068. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113069. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113070. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113071. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113072. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113073. sleepBody(impostor: PhysicsImpostor): void;
  113074. wakeUpBody(impostor: PhysicsImpostor): void;
  113075. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113076. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113077. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113078. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113079. getRadius(impostor: PhysicsImpostor): number;
  113080. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113081. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113082. dispose(): void;
  113083. }
  113084. /**
  113085. * Interface used to define a physics engine
  113086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113087. */
  113088. export interface IPhysicsEngine {
  113089. /**
  113090. * Gets the gravity vector used by the simulation
  113091. */
  113092. gravity: Vector3;
  113093. /**
  113094. * Sets the gravity vector used by the simulation
  113095. * @param gravity defines the gravity vector to use
  113096. */
  113097. setGravity(gravity: Vector3): void;
  113098. /**
  113099. * Set the time step of the physics engine.
  113100. * Default is 1/60.
  113101. * To slow it down, enter 1/600 for example.
  113102. * To speed it up, 1/30
  113103. * @param newTimeStep the new timestep to apply to this world.
  113104. */
  113105. setTimeStep(newTimeStep: number): void;
  113106. /**
  113107. * Get the time step of the physics engine.
  113108. * @returns the current time step
  113109. */
  113110. getTimeStep(): number;
  113111. /**
  113112. * Set the sub time step of the physics engine.
  113113. * Default is 0 meaning there is no sub steps
  113114. * To increase physics resolution precision, set a small value (like 1 ms)
  113115. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113116. */
  113117. setSubTimeStep(subTimeStep: number): void;
  113118. /**
  113119. * Get the sub time step of the physics engine.
  113120. * @returns the current sub time step
  113121. */
  113122. getSubTimeStep(): number;
  113123. /**
  113124. * Release all resources
  113125. */
  113126. dispose(): void;
  113127. /**
  113128. * Gets the name of the current physics plugin
  113129. * @returns the name of the plugin
  113130. */
  113131. getPhysicsPluginName(): string;
  113132. /**
  113133. * Adding a new impostor for the impostor tracking.
  113134. * This will be done by the impostor itself.
  113135. * @param impostor the impostor to add
  113136. */
  113137. addImpostor(impostor: PhysicsImpostor): void;
  113138. /**
  113139. * Remove an impostor from the engine.
  113140. * This impostor and its mesh will not longer be updated by the physics engine.
  113141. * @param impostor the impostor to remove
  113142. */
  113143. removeImpostor(impostor: PhysicsImpostor): void;
  113144. /**
  113145. * Add a joint to the physics engine
  113146. * @param mainImpostor defines the main impostor to which the joint is added.
  113147. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113148. * @param joint defines the joint that will connect both impostors.
  113149. */
  113150. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113151. /**
  113152. * Removes a joint from the simulation
  113153. * @param mainImpostor defines the impostor used with the joint
  113154. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113155. * @param joint defines the joint to remove
  113156. */
  113157. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113158. /**
  113159. * Gets the current plugin used to run the simulation
  113160. * @returns current plugin
  113161. */
  113162. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113163. /**
  113164. * Gets the list of physic impostors
  113165. * @returns an array of PhysicsImpostor
  113166. */
  113167. getImpostors(): Array<PhysicsImpostor>;
  113168. /**
  113169. * Gets the impostor for a physics enabled object
  113170. * @param object defines the object impersonated by the impostor
  113171. * @returns the PhysicsImpostor or null if not found
  113172. */
  113173. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113174. /**
  113175. * Gets the impostor for a physics body object
  113176. * @param body defines physics body used by the impostor
  113177. * @returns the PhysicsImpostor or null if not found
  113178. */
  113179. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113180. /**
  113181. * Does a raycast in the physics world
  113182. * @param from when should the ray start?
  113183. * @param to when should the ray end?
  113184. * @returns PhysicsRaycastResult
  113185. */
  113186. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113187. /**
  113188. * Called by the scene. No need to call it.
  113189. * @param delta defines the timespam between frames
  113190. */
  113191. _step(delta: number): void;
  113192. }
  113193. }
  113194. declare module BABYLON {
  113195. /**
  113196. * The interface for the physics imposter parameters
  113197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113198. */
  113199. export interface PhysicsImpostorParameters {
  113200. /**
  113201. * The mass of the physics imposter
  113202. */
  113203. mass: number;
  113204. /**
  113205. * The friction of the physics imposter
  113206. */
  113207. friction?: number;
  113208. /**
  113209. * The coefficient of restitution of the physics imposter
  113210. */
  113211. restitution?: number;
  113212. /**
  113213. * The native options of the physics imposter
  113214. */
  113215. nativeOptions?: any;
  113216. /**
  113217. * Specifies if the parent should be ignored
  113218. */
  113219. ignoreParent?: boolean;
  113220. /**
  113221. * Specifies if bi-directional transformations should be disabled
  113222. */
  113223. disableBidirectionalTransformation?: boolean;
  113224. /**
  113225. * The pressure inside the physics imposter, soft object only
  113226. */
  113227. pressure?: number;
  113228. /**
  113229. * The stiffness the physics imposter, soft object only
  113230. */
  113231. stiffness?: number;
  113232. /**
  113233. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113234. */
  113235. velocityIterations?: number;
  113236. /**
  113237. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113238. */
  113239. positionIterations?: number;
  113240. /**
  113241. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113242. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113243. * Add to fix multiple points
  113244. */
  113245. fixedPoints?: number;
  113246. /**
  113247. * The collision margin around a soft object
  113248. */
  113249. margin?: number;
  113250. /**
  113251. * The collision margin around a soft object
  113252. */
  113253. damping?: number;
  113254. /**
  113255. * The path for a rope based on an extrusion
  113256. */
  113257. path?: any;
  113258. /**
  113259. * The shape of an extrusion used for a rope based on an extrusion
  113260. */
  113261. shape?: any;
  113262. }
  113263. /**
  113264. * Interface for a physics-enabled object
  113265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113266. */
  113267. export interface IPhysicsEnabledObject {
  113268. /**
  113269. * The position of the physics-enabled object
  113270. */
  113271. position: Vector3;
  113272. /**
  113273. * The rotation of the physics-enabled object
  113274. */
  113275. rotationQuaternion: Nullable<Quaternion>;
  113276. /**
  113277. * The scale of the physics-enabled object
  113278. */
  113279. scaling: Vector3;
  113280. /**
  113281. * The rotation of the physics-enabled object
  113282. */
  113283. rotation?: Vector3;
  113284. /**
  113285. * The parent of the physics-enabled object
  113286. */
  113287. parent?: any;
  113288. /**
  113289. * The bounding info of the physics-enabled object
  113290. * @returns The bounding info of the physics-enabled object
  113291. */
  113292. getBoundingInfo(): BoundingInfo;
  113293. /**
  113294. * Computes the world matrix
  113295. * @param force Specifies if the world matrix should be computed by force
  113296. * @returns A world matrix
  113297. */
  113298. computeWorldMatrix(force: boolean): Matrix;
  113299. /**
  113300. * Gets the world matrix
  113301. * @returns A world matrix
  113302. */
  113303. getWorldMatrix?(): Matrix;
  113304. /**
  113305. * Gets the child meshes
  113306. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113307. * @returns An array of abstract meshes
  113308. */
  113309. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113310. /**
  113311. * Gets the vertex data
  113312. * @param kind The type of vertex data
  113313. * @returns A nullable array of numbers, or a float32 array
  113314. */
  113315. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113316. /**
  113317. * Gets the indices from the mesh
  113318. * @returns A nullable array of index arrays
  113319. */
  113320. getIndices?(): Nullable<IndicesArray>;
  113321. /**
  113322. * Gets the scene from the mesh
  113323. * @returns the indices array or null
  113324. */
  113325. getScene?(): Scene;
  113326. /**
  113327. * Gets the absolute position from the mesh
  113328. * @returns the absolute position
  113329. */
  113330. getAbsolutePosition(): Vector3;
  113331. /**
  113332. * Gets the absolute pivot point from the mesh
  113333. * @returns the absolute pivot point
  113334. */
  113335. getAbsolutePivotPoint(): Vector3;
  113336. /**
  113337. * Rotates the mesh
  113338. * @param axis The axis of rotation
  113339. * @param amount The amount of rotation
  113340. * @param space The space of the rotation
  113341. * @returns The rotation transform node
  113342. */
  113343. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113344. /**
  113345. * Translates the mesh
  113346. * @param axis The axis of translation
  113347. * @param distance The distance of translation
  113348. * @param space The space of the translation
  113349. * @returns The transform node
  113350. */
  113351. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113352. /**
  113353. * Sets the absolute position of the mesh
  113354. * @param absolutePosition The absolute position of the mesh
  113355. * @returns The transform node
  113356. */
  113357. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113358. /**
  113359. * Gets the class name of the mesh
  113360. * @returns The class name
  113361. */
  113362. getClassName(): string;
  113363. }
  113364. /**
  113365. * Represents a physics imposter
  113366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113367. */
  113368. export class PhysicsImpostor {
  113369. /**
  113370. * The physics-enabled object used as the physics imposter
  113371. */
  113372. object: IPhysicsEnabledObject;
  113373. /**
  113374. * The type of the physics imposter
  113375. */
  113376. type: number;
  113377. private _options;
  113378. private _scene?;
  113379. /**
  113380. * The default object size of the imposter
  113381. */
  113382. static DEFAULT_OBJECT_SIZE: Vector3;
  113383. /**
  113384. * The identity quaternion of the imposter
  113385. */
  113386. static IDENTITY_QUATERNION: Quaternion;
  113387. /** @hidden */
  113388. _pluginData: any;
  113389. private _physicsEngine;
  113390. private _physicsBody;
  113391. private _bodyUpdateRequired;
  113392. private _onBeforePhysicsStepCallbacks;
  113393. private _onAfterPhysicsStepCallbacks;
  113394. /** @hidden */
  113395. _onPhysicsCollideCallbacks: Array<{
  113396. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113397. otherImpostors: Array<PhysicsImpostor>;
  113398. }>;
  113399. private _deltaPosition;
  113400. private _deltaRotation;
  113401. private _deltaRotationConjugated;
  113402. /** @hidden */
  113403. _isFromLine: boolean;
  113404. private _parent;
  113405. private _isDisposed;
  113406. private static _tmpVecs;
  113407. private static _tmpQuat;
  113408. /**
  113409. * Specifies if the physics imposter is disposed
  113410. */
  113411. get isDisposed(): boolean;
  113412. /**
  113413. * Gets the mass of the physics imposter
  113414. */
  113415. get mass(): number;
  113416. set mass(value: number);
  113417. /**
  113418. * Gets the coefficient of friction
  113419. */
  113420. get friction(): number;
  113421. /**
  113422. * Sets the coefficient of friction
  113423. */
  113424. set friction(value: number);
  113425. /**
  113426. * Gets the coefficient of restitution
  113427. */
  113428. get restitution(): number;
  113429. /**
  113430. * Sets the coefficient of restitution
  113431. */
  113432. set restitution(value: number);
  113433. /**
  113434. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113435. */
  113436. get pressure(): number;
  113437. /**
  113438. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113439. */
  113440. set pressure(value: number);
  113441. /**
  113442. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113443. */
  113444. get stiffness(): number;
  113445. /**
  113446. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113447. */
  113448. set stiffness(value: number);
  113449. /**
  113450. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113451. */
  113452. get velocityIterations(): number;
  113453. /**
  113454. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113455. */
  113456. set velocityIterations(value: number);
  113457. /**
  113458. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113459. */
  113460. get positionIterations(): number;
  113461. /**
  113462. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113463. */
  113464. set positionIterations(value: number);
  113465. /**
  113466. * The unique id of the physics imposter
  113467. * set by the physics engine when adding this impostor to the array
  113468. */
  113469. uniqueId: number;
  113470. /**
  113471. * @hidden
  113472. */
  113473. soft: boolean;
  113474. /**
  113475. * @hidden
  113476. */
  113477. segments: number;
  113478. private _joints;
  113479. /**
  113480. * Initializes the physics imposter
  113481. * @param object The physics-enabled object used as the physics imposter
  113482. * @param type The type of the physics imposter
  113483. * @param _options The options for the physics imposter
  113484. * @param _scene The Babylon scene
  113485. */
  113486. constructor(
  113487. /**
  113488. * The physics-enabled object used as the physics imposter
  113489. */
  113490. object: IPhysicsEnabledObject,
  113491. /**
  113492. * The type of the physics imposter
  113493. */
  113494. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113495. /**
  113496. * This function will completly initialize this impostor.
  113497. * It will create a new body - but only if this mesh has no parent.
  113498. * If it has, this impostor will not be used other than to define the impostor
  113499. * of the child mesh.
  113500. * @hidden
  113501. */
  113502. _init(): void;
  113503. private _getPhysicsParent;
  113504. /**
  113505. * Should a new body be generated.
  113506. * @returns boolean specifying if body initialization is required
  113507. */
  113508. isBodyInitRequired(): boolean;
  113509. /**
  113510. * Sets the updated scaling
  113511. * @param updated Specifies if the scaling is updated
  113512. */
  113513. setScalingUpdated(): void;
  113514. /**
  113515. * Force a regeneration of this or the parent's impostor's body.
  113516. * Use under cautious - This will remove all joints already implemented.
  113517. */
  113518. forceUpdate(): void;
  113519. /**
  113520. * Gets the body that holds this impostor. Either its own, or its parent.
  113521. */
  113522. get physicsBody(): any;
  113523. /**
  113524. * Get the parent of the physics imposter
  113525. * @returns Physics imposter or null
  113526. */
  113527. get parent(): Nullable<PhysicsImpostor>;
  113528. /**
  113529. * Sets the parent of the physics imposter
  113530. */
  113531. set parent(value: Nullable<PhysicsImpostor>);
  113532. /**
  113533. * Set the physics body. Used mainly by the physics engine/plugin
  113534. */
  113535. set physicsBody(physicsBody: any);
  113536. /**
  113537. * Resets the update flags
  113538. */
  113539. resetUpdateFlags(): void;
  113540. /**
  113541. * Gets the object extend size
  113542. * @returns the object extend size
  113543. */
  113544. getObjectExtendSize(): Vector3;
  113545. /**
  113546. * Gets the object center
  113547. * @returns The object center
  113548. */
  113549. getObjectCenter(): Vector3;
  113550. /**
  113551. * Get a specific parameter from the options parameters
  113552. * @param paramName The object parameter name
  113553. * @returns The object parameter
  113554. */
  113555. getParam(paramName: string): any;
  113556. /**
  113557. * Sets a specific parameter in the options given to the physics plugin
  113558. * @param paramName The parameter name
  113559. * @param value The value of the parameter
  113560. */
  113561. setParam(paramName: string, value: number): void;
  113562. /**
  113563. * Specifically change the body's mass option. Won't recreate the physics body object
  113564. * @param mass The mass of the physics imposter
  113565. */
  113566. setMass(mass: number): void;
  113567. /**
  113568. * Gets the linear velocity
  113569. * @returns linear velocity or null
  113570. */
  113571. getLinearVelocity(): Nullable<Vector3>;
  113572. /**
  113573. * Sets the linear velocity
  113574. * @param velocity linear velocity or null
  113575. */
  113576. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113577. /**
  113578. * Gets the angular velocity
  113579. * @returns angular velocity or null
  113580. */
  113581. getAngularVelocity(): Nullable<Vector3>;
  113582. /**
  113583. * Sets the angular velocity
  113584. * @param velocity The velocity or null
  113585. */
  113586. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113587. /**
  113588. * Execute a function with the physics plugin native code
  113589. * Provide a function the will have two variables - the world object and the physics body object
  113590. * @param func The function to execute with the physics plugin native code
  113591. */
  113592. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113593. /**
  113594. * Register a function that will be executed before the physics world is stepping forward
  113595. * @param func The function to execute before the physics world is stepped forward
  113596. */
  113597. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113598. /**
  113599. * Unregister a function that will be executed before the physics world is stepping forward
  113600. * @param func The function to execute before the physics world is stepped forward
  113601. */
  113602. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113603. /**
  113604. * Register a function that will be executed after the physics step
  113605. * @param func The function to execute after physics step
  113606. */
  113607. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113608. /**
  113609. * Unregisters a function that will be executed after the physics step
  113610. * @param func The function to execute after physics step
  113611. */
  113612. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113613. /**
  113614. * register a function that will be executed when this impostor collides against a different body
  113615. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113616. * @param func Callback that is executed on collision
  113617. */
  113618. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113619. /**
  113620. * Unregisters the physics imposter on contact
  113621. * @param collideAgainst The physics object to collide against
  113622. * @param func Callback to execute on collision
  113623. */
  113624. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113625. private _tmpQuat;
  113626. private _tmpQuat2;
  113627. /**
  113628. * Get the parent rotation
  113629. * @returns The parent rotation
  113630. */
  113631. getParentsRotation(): Quaternion;
  113632. /**
  113633. * this function is executed by the physics engine.
  113634. */
  113635. beforeStep: () => void;
  113636. /**
  113637. * this function is executed by the physics engine
  113638. */
  113639. afterStep: () => void;
  113640. /**
  113641. * Legacy collision detection event support
  113642. */
  113643. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113644. /**
  113645. * event and body object due to cannon's event-based architecture.
  113646. */
  113647. onCollide: (e: {
  113648. body: any;
  113649. point: Nullable<Vector3>;
  113650. }) => void;
  113651. /**
  113652. * Apply a force
  113653. * @param force The force to apply
  113654. * @param contactPoint The contact point for the force
  113655. * @returns The physics imposter
  113656. */
  113657. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113658. /**
  113659. * Apply an impulse
  113660. * @param force The impulse force
  113661. * @param contactPoint The contact point for the impulse force
  113662. * @returns The physics imposter
  113663. */
  113664. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113665. /**
  113666. * A help function to create a joint
  113667. * @param otherImpostor A physics imposter used to create a joint
  113668. * @param jointType The type of joint
  113669. * @param jointData The data for the joint
  113670. * @returns The physics imposter
  113671. */
  113672. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113673. /**
  113674. * Add a joint to this impostor with a different impostor
  113675. * @param otherImpostor A physics imposter used to add a joint
  113676. * @param joint The joint to add
  113677. * @returns The physics imposter
  113678. */
  113679. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113680. /**
  113681. * Add an anchor to a cloth impostor
  113682. * @param otherImpostor rigid impostor to anchor to
  113683. * @param width ratio across width from 0 to 1
  113684. * @param height ratio up height from 0 to 1
  113685. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113686. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113687. * @returns impostor the soft imposter
  113688. */
  113689. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113690. /**
  113691. * Add a hook to a rope impostor
  113692. * @param otherImpostor rigid impostor to anchor to
  113693. * @param length ratio across rope from 0 to 1
  113694. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113695. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113696. * @returns impostor the rope imposter
  113697. */
  113698. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113699. /**
  113700. * Will keep this body still, in a sleep mode.
  113701. * @returns the physics imposter
  113702. */
  113703. sleep(): PhysicsImpostor;
  113704. /**
  113705. * Wake the body up.
  113706. * @returns The physics imposter
  113707. */
  113708. wakeUp(): PhysicsImpostor;
  113709. /**
  113710. * Clones the physics imposter
  113711. * @param newObject The physics imposter clones to this physics-enabled object
  113712. * @returns A nullable physics imposter
  113713. */
  113714. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113715. /**
  113716. * Disposes the physics imposter
  113717. */
  113718. dispose(): void;
  113719. /**
  113720. * Sets the delta position
  113721. * @param position The delta position amount
  113722. */
  113723. setDeltaPosition(position: Vector3): void;
  113724. /**
  113725. * Sets the delta rotation
  113726. * @param rotation The delta rotation amount
  113727. */
  113728. setDeltaRotation(rotation: Quaternion): void;
  113729. /**
  113730. * Gets the box size of the physics imposter and stores the result in the input parameter
  113731. * @param result Stores the box size
  113732. * @returns The physics imposter
  113733. */
  113734. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113735. /**
  113736. * Gets the radius of the physics imposter
  113737. * @returns Radius of the physics imposter
  113738. */
  113739. getRadius(): number;
  113740. /**
  113741. * Sync a bone with this impostor
  113742. * @param bone The bone to sync to the impostor.
  113743. * @param boneMesh The mesh that the bone is influencing.
  113744. * @param jointPivot The pivot of the joint / bone in local space.
  113745. * @param distToJoint Optional distance from the impostor to the joint.
  113746. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113747. */
  113748. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113749. /**
  113750. * Sync impostor to a bone
  113751. * @param bone The bone that the impostor will be synced to.
  113752. * @param boneMesh The mesh that the bone is influencing.
  113753. * @param jointPivot The pivot of the joint / bone in local space.
  113754. * @param distToJoint Optional distance from the impostor to the joint.
  113755. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113756. * @param boneAxis Optional vector3 axis the bone is aligned with
  113757. */
  113758. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113759. /**
  113760. * No-Imposter type
  113761. */
  113762. static NoImpostor: number;
  113763. /**
  113764. * Sphere-Imposter type
  113765. */
  113766. static SphereImpostor: number;
  113767. /**
  113768. * Box-Imposter type
  113769. */
  113770. static BoxImpostor: number;
  113771. /**
  113772. * Plane-Imposter type
  113773. */
  113774. static PlaneImpostor: number;
  113775. /**
  113776. * Mesh-imposter type
  113777. */
  113778. static MeshImpostor: number;
  113779. /**
  113780. * Capsule-Impostor type (Ammo.js plugin only)
  113781. */
  113782. static CapsuleImpostor: number;
  113783. /**
  113784. * Cylinder-Imposter type
  113785. */
  113786. static CylinderImpostor: number;
  113787. /**
  113788. * Particle-Imposter type
  113789. */
  113790. static ParticleImpostor: number;
  113791. /**
  113792. * Heightmap-Imposter type
  113793. */
  113794. static HeightmapImpostor: number;
  113795. /**
  113796. * ConvexHull-Impostor type (Ammo.js plugin only)
  113797. */
  113798. static ConvexHullImpostor: number;
  113799. /**
  113800. * Custom-Imposter type (Ammo.js plugin only)
  113801. */
  113802. static CustomImpostor: number;
  113803. /**
  113804. * Rope-Imposter type
  113805. */
  113806. static RopeImpostor: number;
  113807. /**
  113808. * Cloth-Imposter type
  113809. */
  113810. static ClothImpostor: number;
  113811. /**
  113812. * Softbody-Imposter type
  113813. */
  113814. static SoftbodyImpostor: number;
  113815. }
  113816. }
  113817. declare module BABYLON {
  113818. /**
  113819. * @hidden
  113820. **/
  113821. export class _CreationDataStorage {
  113822. closePath?: boolean;
  113823. closeArray?: boolean;
  113824. idx: number[];
  113825. dashSize: number;
  113826. gapSize: number;
  113827. path3D: Path3D;
  113828. pathArray: Vector3[][];
  113829. arc: number;
  113830. radius: number;
  113831. cap: number;
  113832. tessellation: number;
  113833. }
  113834. /**
  113835. * @hidden
  113836. **/
  113837. class _InstanceDataStorage {
  113838. visibleInstances: any;
  113839. batchCache: _InstancesBatch;
  113840. instancesBufferSize: number;
  113841. instancesBuffer: Nullable<Buffer>;
  113842. instancesData: Float32Array;
  113843. overridenInstanceCount: number;
  113844. isFrozen: boolean;
  113845. previousBatch: Nullable<_InstancesBatch>;
  113846. hardwareInstancedRendering: boolean;
  113847. sideOrientation: number;
  113848. manualUpdate: boolean;
  113849. previousRenderId: number;
  113850. }
  113851. /**
  113852. * @hidden
  113853. **/
  113854. export class _InstancesBatch {
  113855. mustReturn: boolean;
  113856. visibleInstances: Nullable<InstancedMesh[]>[];
  113857. renderSelf: boolean[];
  113858. hardwareInstancedRendering: boolean[];
  113859. }
  113860. /**
  113861. * @hidden
  113862. **/
  113863. class _ThinInstanceDataStorage {
  113864. instancesCount: number;
  113865. matrixBuffer: Nullable<Buffer>;
  113866. matrixBufferSize: number;
  113867. matrixData: Nullable<Float32Array>;
  113868. boundingVectors: Array<Vector3>;
  113869. worldMatrices: Nullable<Matrix[]>;
  113870. }
  113871. /**
  113872. * Class used to represent renderable models
  113873. */
  113874. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113875. /**
  113876. * Mesh side orientation : usually the external or front surface
  113877. */
  113878. static readonly FRONTSIDE: number;
  113879. /**
  113880. * Mesh side orientation : usually the internal or back surface
  113881. */
  113882. static readonly BACKSIDE: number;
  113883. /**
  113884. * Mesh side orientation : both internal and external or front and back surfaces
  113885. */
  113886. static readonly DOUBLESIDE: number;
  113887. /**
  113888. * Mesh side orientation : by default, `FRONTSIDE`
  113889. */
  113890. static readonly DEFAULTSIDE: number;
  113891. /**
  113892. * Mesh cap setting : no cap
  113893. */
  113894. static readonly NO_CAP: number;
  113895. /**
  113896. * Mesh cap setting : one cap at the beginning of the mesh
  113897. */
  113898. static readonly CAP_START: number;
  113899. /**
  113900. * Mesh cap setting : one cap at the end of the mesh
  113901. */
  113902. static readonly CAP_END: number;
  113903. /**
  113904. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113905. */
  113906. static readonly CAP_ALL: number;
  113907. /**
  113908. * Mesh pattern setting : no flip or rotate
  113909. */
  113910. static readonly NO_FLIP: number;
  113911. /**
  113912. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113913. */
  113914. static readonly FLIP_TILE: number;
  113915. /**
  113916. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113917. */
  113918. static readonly ROTATE_TILE: number;
  113919. /**
  113920. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113921. */
  113922. static readonly FLIP_ROW: number;
  113923. /**
  113924. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113925. */
  113926. static readonly ROTATE_ROW: number;
  113927. /**
  113928. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113929. */
  113930. static readonly FLIP_N_ROTATE_TILE: number;
  113931. /**
  113932. * Mesh pattern setting : rotate pattern and rotate
  113933. */
  113934. static readonly FLIP_N_ROTATE_ROW: number;
  113935. /**
  113936. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113937. */
  113938. static readonly CENTER: number;
  113939. /**
  113940. * Mesh tile positioning : part tiles on left
  113941. */
  113942. static readonly LEFT: number;
  113943. /**
  113944. * Mesh tile positioning : part tiles on right
  113945. */
  113946. static readonly RIGHT: number;
  113947. /**
  113948. * Mesh tile positioning : part tiles on top
  113949. */
  113950. static readonly TOP: number;
  113951. /**
  113952. * Mesh tile positioning : part tiles on bottom
  113953. */
  113954. static readonly BOTTOM: number;
  113955. /**
  113956. * Gets the default side orientation.
  113957. * @param orientation the orientation to value to attempt to get
  113958. * @returns the default orientation
  113959. * @hidden
  113960. */
  113961. static _GetDefaultSideOrientation(orientation?: number): number;
  113962. private _internalMeshDataInfo;
  113963. get computeBonesUsingShaders(): boolean;
  113964. set computeBonesUsingShaders(value: boolean);
  113965. /**
  113966. * An event triggered before rendering the mesh
  113967. */
  113968. get onBeforeRenderObservable(): Observable<Mesh>;
  113969. /**
  113970. * An event triggered before binding the mesh
  113971. */
  113972. get onBeforeBindObservable(): Observable<Mesh>;
  113973. /**
  113974. * An event triggered after rendering the mesh
  113975. */
  113976. get onAfterRenderObservable(): Observable<Mesh>;
  113977. /**
  113978. * An event triggered before drawing the mesh
  113979. */
  113980. get onBeforeDrawObservable(): Observable<Mesh>;
  113981. private _onBeforeDrawObserver;
  113982. /**
  113983. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113984. */
  113985. set onBeforeDraw(callback: () => void);
  113986. get hasInstances(): boolean;
  113987. get hasThinInstances(): boolean;
  113988. /**
  113989. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113990. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113991. */
  113992. delayLoadState: number;
  113993. /**
  113994. * Gets the list of instances created from this mesh
  113995. * it is not supposed to be modified manually.
  113996. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113997. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113998. */
  113999. instances: InstancedMesh[];
  114000. /**
  114001. * Gets the file containing delay loading data for this mesh
  114002. */
  114003. delayLoadingFile: string;
  114004. /** @hidden */
  114005. _binaryInfo: any;
  114006. /**
  114007. * User defined function used to change how LOD level selection is done
  114008. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114009. */
  114010. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  114011. /**
  114012. * Gets or sets the morph target manager
  114013. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114014. */
  114015. get morphTargetManager(): Nullable<MorphTargetManager>;
  114016. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114017. /** @hidden */
  114018. _creationDataStorage: Nullable<_CreationDataStorage>;
  114019. /** @hidden */
  114020. _geometry: Nullable<Geometry>;
  114021. /** @hidden */
  114022. _delayInfo: Array<string>;
  114023. /** @hidden */
  114024. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114025. /** @hidden */
  114026. _instanceDataStorage: _InstanceDataStorage;
  114027. /** @hidden */
  114028. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114029. private _effectiveMaterial;
  114030. /** @hidden */
  114031. _shouldGenerateFlatShading: boolean;
  114032. /** @hidden */
  114033. _originalBuilderSideOrientation: number;
  114034. /**
  114035. * Use this property to change the original side orientation defined at construction time
  114036. */
  114037. overrideMaterialSideOrientation: Nullable<number>;
  114038. /**
  114039. * Gets the source mesh (the one used to clone this one from)
  114040. */
  114041. get source(): Nullable<Mesh>;
  114042. /**
  114043. * Gets the list of clones of this mesh
  114044. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114045. * Note that useClonedMeshMap=true is the default setting
  114046. */
  114047. get cloneMeshMap(): Nullable<{
  114048. [id: string]: Mesh | undefined;
  114049. }>;
  114050. /**
  114051. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114052. */
  114053. get isUnIndexed(): boolean;
  114054. set isUnIndexed(value: boolean);
  114055. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114056. get worldMatrixInstancedBuffer(): Float32Array;
  114057. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114058. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114059. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114060. /**
  114061. * @constructor
  114062. * @param name The value used by scene.getMeshByName() to do a lookup.
  114063. * @param scene The scene to add this mesh to.
  114064. * @param parent The parent of this mesh, if it has one
  114065. * @param source An optional Mesh from which geometry is shared, cloned.
  114066. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114067. * When false, achieved by calling a clone(), also passing False.
  114068. * This will make creation of children, recursive.
  114069. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114070. */
  114071. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114072. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114073. doNotInstantiate: boolean;
  114074. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114075. /**
  114076. * Gets the class name
  114077. * @returns the string "Mesh".
  114078. */
  114079. getClassName(): string;
  114080. /** @hidden */
  114081. get _isMesh(): boolean;
  114082. /**
  114083. * Returns a description of this mesh
  114084. * @param fullDetails define if full details about this mesh must be used
  114085. * @returns a descriptive string representing this mesh
  114086. */
  114087. toString(fullDetails?: boolean): string;
  114088. /** @hidden */
  114089. _unBindEffect(): void;
  114090. /**
  114091. * Gets a boolean indicating if this mesh has LOD
  114092. */
  114093. get hasLODLevels(): boolean;
  114094. /**
  114095. * Gets the list of MeshLODLevel associated with the current mesh
  114096. * @returns an array of MeshLODLevel
  114097. */
  114098. getLODLevels(): MeshLODLevel[];
  114099. private _sortLODLevels;
  114100. /**
  114101. * Add a mesh as LOD level triggered at the given distance.
  114102. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114103. * @param distance The distance from the center of the object to show this level
  114104. * @param mesh The mesh to be added as LOD level (can be null)
  114105. * @return This mesh (for chaining)
  114106. */
  114107. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114108. /**
  114109. * Returns the LOD level mesh at the passed distance or null if not found.
  114110. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114111. * @param distance The distance from the center of the object to show this level
  114112. * @returns a Mesh or `null`
  114113. */
  114114. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114115. /**
  114116. * Remove a mesh from the LOD array
  114117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114118. * @param mesh defines the mesh to be removed
  114119. * @return This mesh (for chaining)
  114120. */
  114121. removeLODLevel(mesh: Mesh): Mesh;
  114122. /**
  114123. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114124. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114125. * @param camera defines the camera to use to compute distance
  114126. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114127. * @return This mesh (for chaining)
  114128. */
  114129. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114130. /**
  114131. * Gets the mesh internal Geometry object
  114132. */
  114133. get geometry(): Nullable<Geometry>;
  114134. /**
  114135. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114136. * @returns the total number of vertices
  114137. */
  114138. getTotalVertices(): number;
  114139. /**
  114140. * Returns the content of an associated vertex buffer
  114141. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114142. * - VertexBuffer.PositionKind
  114143. * - VertexBuffer.UVKind
  114144. * - VertexBuffer.UV2Kind
  114145. * - VertexBuffer.UV3Kind
  114146. * - VertexBuffer.UV4Kind
  114147. * - VertexBuffer.UV5Kind
  114148. * - VertexBuffer.UV6Kind
  114149. * - VertexBuffer.ColorKind
  114150. * - VertexBuffer.MatricesIndicesKind
  114151. * - VertexBuffer.MatricesIndicesExtraKind
  114152. * - VertexBuffer.MatricesWeightsKind
  114153. * - VertexBuffer.MatricesWeightsExtraKind
  114154. * @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
  114155. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114156. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114157. */
  114158. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114159. /**
  114160. * Returns the mesh VertexBuffer object from the requested `kind`
  114161. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114162. * - VertexBuffer.PositionKind
  114163. * - VertexBuffer.NormalKind
  114164. * - VertexBuffer.UVKind
  114165. * - VertexBuffer.UV2Kind
  114166. * - VertexBuffer.UV3Kind
  114167. * - VertexBuffer.UV4Kind
  114168. * - VertexBuffer.UV5Kind
  114169. * - VertexBuffer.UV6Kind
  114170. * - VertexBuffer.ColorKind
  114171. * - VertexBuffer.MatricesIndicesKind
  114172. * - VertexBuffer.MatricesIndicesExtraKind
  114173. * - VertexBuffer.MatricesWeightsKind
  114174. * - VertexBuffer.MatricesWeightsExtraKind
  114175. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114176. */
  114177. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114178. /**
  114179. * Tests if a specific vertex buffer is associated with this mesh
  114180. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114181. * - VertexBuffer.PositionKind
  114182. * - VertexBuffer.NormalKind
  114183. * - VertexBuffer.UVKind
  114184. * - VertexBuffer.UV2Kind
  114185. * - VertexBuffer.UV3Kind
  114186. * - VertexBuffer.UV4Kind
  114187. * - VertexBuffer.UV5Kind
  114188. * - VertexBuffer.UV6Kind
  114189. * - VertexBuffer.ColorKind
  114190. * - VertexBuffer.MatricesIndicesKind
  114191. * - VertexBuffer.MatricesIndicesExtraKind
  114192. * - VertexBuffer.MatricesWeightsKind
  114193. * - VertexBuffer.MatricesWeightsExtraKind
  114194. * @returns a boolean
  114195. */
  114196. isVerticesDataPresent(kind: string): boolean;
  114197. /**
  114198. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114199. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114200. * - VertexBuffer.PositionKind
  114201. * - VertexBuffer.UVKind
  114202. * - VertexBuffer.UV2Kind
  114203. * - VertexBuffer.UV3Kind
  114204. * - VertexBuffer.UV4Kind
  114205. * - VertexBuffer.UV5Kind
  114206. * - VertexBuffer.UV6Kind
  114207. * - VertexBuffer.ColorKind
  114208. * - VertexBuffer.MatricesIndicesKind
  114209. * - VertexBuffer.MatricesIndicesExtraKind
  114210. * - VertexBuffer.MatricesWeightsKind
  114211. * - VertexBuffer.MatricesWeightsExtraKind
  114212. * @returns a boolean
  114213. */
  114214. isVertexBufferUpdatable(kind: string): boolean;
  114215. /**
  114216. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114218. * - VertexBuffer.PositionKind
  114219. * - VertexBuffer.NormalKind
  114220. * - VertexBuffer.UVKind
  114221. * - VertexBuffer.UV2Kind
  114222. * - VertexBuffer.UV3Kind
  114223. * - VertexBuffer.UV4Kind
  114224. * - VertexBuffer.UV5Kind
  114225. * - VertexBuffer.UV6Kind
  114226. * - VertexBuffer.ColorKind
  114227. * - VertexBuffer.MatricesIndicesKind
  114228. * - VertexBuffer.MatricesIndicesExtraKind
  114229. * - VertexBuffer.MatricesWeightsKind
  114230. * - VertexBuffer.MatricesWeightsExtraKind
  114231. * @returns an array of strings
  114232. */
  114233. getVerticesDataKinds(): string[];
  114234. /**
  114235. * Returns a positive integer : the total number of indices in this mesh geometry.
  114236. * @returns the numner of indices or zero if the mesh has no geometry.
  114237. */
  114238. getTotalIndices(): number;
  114239. /**
  114240. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114241. * @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.
  114242. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114243. * @returns the indices array or an empty array if the mesh has no geometry
  114244. */
  114245. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114246. get isBlocked(): boolean;
  114247. /**
  114248. * Determine if the current mesh is ready to be rendered
  114249. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114250. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114251. * @returns true if all associated assets are ready (material, textures, shaders)
  114252. */
  114253. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114254. /**
  114255. * 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.
  114256. */
  114257. get areNormalsFrozen(): boolean;
  114258. /**
  114259. * 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.
  114260. * @returns the current mesh
  114261. */
  114262. freezeNormals(): Mesh;
  114263. /**
  114264. * 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
  114265. * @returns the current mesh
  114266. */
  114267. unfreezeNormals(): Mesh;
  114268. /**
  114269. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114270. */
  114271. set overridenInstanceCount(count: number);
  114272. /** @hidden */
  114273. _preActivate(): Mesh;
  114274. /** @hidden */
  114275. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114276. /** @hidden */
  114277. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114278. protected _afterComputeWorldMatrix(): void;
  114279. /** @hidden */
  114280. _postActivate(): void;
  114281. /**
  114282. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114283. * This means the mesh underlying bounding box and sphere are recomputed.
  114284. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114285. * @returns the current mesh
  114286. */
  114287. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114288. /** @hidden */
  114289. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114290. /**
  114291. * This function will subdivide the mesh into multiple submeshes
  114292. * @param count defines the expected number of submeshes
  114293. */
  114294. subdivide(count: number): void;
  114295. /**
  114296. * Copy a FloatArray into a specific associated vertex buffer
  114297. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114298. * - VertexBuffer.PositionKind
  114299. * - VertexBuffer.UVKind
  114300. * - VertexBuffer.UV2Kind
  114301. * - VertexBuffer.UV3Kind
  114302. * - VertexBuffer.UV4Kind
  114303. * - VertexBuffer.UV5Kind
  114304. * - VertexBuffer.UV6Kind
  114305. * - VertexBuffer.ColorKind
  114306. * - VertexBuffer.MatricesIndicesKind
  114307. * - VertexBuffer.MatricesIndicesExtraKind
  114308. * - VertexBuffer.MatricesWeightsKind
  114309. * - VertexBuffer.MatricesWeightsExtraKind
  114310. * @param data defines the data source
  114311. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114312. * @param stride defines the data stride size (can be null)
  114313. * @returns the current mesh
  114314. */
  114315. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114316. /**
  114317. * Delete a vertex buffer associated with this mesh
  114318. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114319. * - VertexBuffer.PositionKind
  114320. * - VertexBuffer.UVKind
  114321. * - VertexBuffer.UV2Kind
  114322. * - VertexBuffer.UV3Kind
  114323. * - VertexBuffer.UV4Kind
  114324. * - VertexBuffer.UV5Kind
  114325. * - VertexBuffer.UV6Kind
  114326. * - VertexBuffer.ColorKind
  114327. * - VertexBuffer.MatricesIndicesKind
  114328. * - VertexBuffer.MatricesIndicesExtraKind
  114329. * - VertexBuffer.MatricesWeightsKind
  114330. * - VertexBuffer.MatricesWeightsExtraKind
  114331. */
  114332. removeVerticesData(kind: string): void;
  114333. /**
  114334. * Flags an associated vertex buffer as updatable
  114335. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114336. * - VertexBuffer.PositionKind
  114337. * - VertexBuffer.UVKind
  114338. * - VertexBuffer.UV2Kind
  114339. * - VertexBuffer.UV3Kind
  114340. * - VertexBuffer.UV4Kind
  114341. * - VertexBuffer.UV5Kind
  114342. * - VertexBuffer.UV6Kind
  114343. * - VertexBuffer.ColorKind
  114344. * - VertexBuffer.MatricesIndicesKind
  114345. * - VertexBuffer.MatricesIndicesExtraKind
  114346. * - VertexBuffer.MatricesWeightsKind
  114347. * - VertexBuffer.MatricesWeightsExtraKind
  114348. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114349. */
  114350. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114351. /**
  114352. * Sets the mesh global Vertex Buffer
  114353. * @param buffer defines the buffer to use
  114354. * @returns the current mesh
  114355. */
  114356. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114357. /**
  114358. * Update a specific associated vertex buffer
  114359. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114360. * - VertexBuffer.PositionKind
  114361. * - VertexBuffer.UVKind
  114362. * - VertexBuffer.UV2Kind
  114363. * - VertexBuffer.UV3Kind
  114364. * - VertexBuffer.UV4Kind
  114365. * - VertexBuffer.UV5Kind
  114366. * - VertexBuffer.UV6Kind
  114367. * - VertexBuffer.ColorKind
  114368. * - VertexBuffer.MatricesIndicesKind
  114369. * - VertexBuffer.MatricesIndicesExtraKind
  114370. * - VertexBuffer.MatricesWeightsKind
  114371. * - VertexBuffer.MatricesWeightsExtraKind
  114372. * @param data defines the data source
  114373. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114374. * @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)
  114375. * @returns the current mesh
  114376. */
  114377. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114378. /**
  114379. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114380. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114381. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114382. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114383. * @returns the current mesh
  114384. */
  114385. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114386. /**
  114387. * Creates a un-shared specific occurence of the geometry for the mesh.
  114388. * @returns the current mesh
  114389. */
  114390. makeGeometryUnique(): Mesh;
  114391. /**
  114392. * Set the index buffer of this mesh
  114393. * @param indices defines the source data
  114394. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114395. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114396. * @returns the current mesh
  114397. */
  114398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114399. /**
  114400. * Update the current index buffer
  114401. * @param indices defines the source data
  114402. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114403. * @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)
  114404. * @returns the current mesh
  114405. */
  114406. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114407. /**
  114408. * Invert the geometry to move from a right handed system to a left handed one.
  114409. * @returns the current mesh
  114410. */
  114411. toLeftHanded(): Mesh;
  114412. /** @hidden */
  114413. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114414. /** @hidden */
  114415. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114416. /**
  114417. * Registers for this mesh a javascript function called just before the rendering process
  114418. * @param func defines the function to call before rendering this mesh
  114419. * @returns the current mesh
  114420. */
  114421. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114422. /**
  114423. * Disposes a previously registered javascript function called before the rendering
  114424. * @param func defines the function to remove
  114425. * @returns the current mesh
  114426. */
  114427. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114428. /**
  114429. * Registers for this mesh a javascript function called just after the rendering is complete
  114430. * @param func defines the function to call after rendering this mesh
  114431. * @returns the current mesh
  114432. */
  114433. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114434. /**
  114435. * Disposes a previously registered javascript function called after the rendering.
  114436. * @param func defines the function to remove
  114437. * @returns the current mesh
  114438. */
  114439. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114440. /** @hidden */
  114441. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114442. /** @hidden */
  114443. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114444. /** @hidden */
  114445. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114446. /** @hidden */
  114447. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114448. /** @hidden */
  114449. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114450. /** @hidden */
  114451. _rebuild(): void;
  114452. /** @hidden */
  114453. _freeze(): void;
  114454. /** @hidden */
  114455. _unFreeze(): void;
  114456. /**
  114457. * 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
  114458. * @param subMesh defines the subMesh to render
  114459. * @param enableAlphaMode defines if alpha mode can be changed
  114460. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114461. * @returns the current mesh
  114462. */
  114463. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114464. private _onBeforeDraw;
  114465. /**
  114466. * Renormalize the mesh and patch it up if there are no weights
  114467. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114468. * However in the case of zero weights then we set just a single influence to 1.
  114469. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114470. */
  114471. cleanMatrixWeights(): void;
  114472. private normalizeSkinFourWeights;
  114473. private normalizeSkinWeightsAndExtra;
  114474. /**
  114475. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114476. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114477. * the user know there was an issue with importing the mesh
  114478. * @returns a validation object with skinned, valid and report string
  114479. */
  114480. validateSkinning(): {
  114481. skinned: boolean;
  114482. valid: boolean;
  114483. report: string;
  114484. };
  114485. /** @hidden */
  114486. _checkDelayState(): Mesh;
  114487. private _queueLoad;
  114488. /**
  114489. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114490. * A mesh is in the frustum if its bounding box intersects the frustum
  114491. * @param frustumPlanes defines the frustum to test
  114492. * @returns true if the mesh is in the frustum planes
  114493. */
  114494. isInFrustum(frustumPlanes: Plane[]): boolean;
  114495. /**
  114496. * Sets the mesh material by the material or multiMaterial `id` property
  114497. * @param id is a string identifying the material or the multiMaterial
  114498. * @returns the current mesh
  114499. */
  114500. setMaterialByID(id: string): Mesh;
  114501. /**
  114502. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114503. * @returns an array of IAnimatable
  114504. */
  114505. getAnimatables(): IAnimatable[];
  114506. /**
  114507. * Modifies the mesh geometry according to the passed transformation matrix.
  114508. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114509. * The mesh normals are modified using the same transformation.
  114510. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114511. * @param transform defines the transform matrix to use
  114512. * @see https://doc.babylonjs.com/resources/baking_transformations
  114513. * @returns the current mesh
  114514. */
  114515. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114516. /**
  114517. * Modifies the mesh geometry according to its own current World Matrix.
  114518. * The mesh World Matrix is then reset.
  114519. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114520. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114521. * @see https://doc.babylonjs.com/resources/baking_transformations
  114522. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114523. * @returns the current mesh
  114524. */
  114525. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114526. /** @hidden */
  114527. get _positions(): Nullable<Vector3[]>;
  114528. /** @hidden */
  114529. _resetPointsArrayCache(): Mesh;
  114530. /** @hidden */
  114531. _generatePointsArray(): boolean;
  114532. /**
  114533. * Returns a new Mesh object generated from the current mesh properties.
  114534. * This method must not get confused with createInstance()
  114535. * @param name is a string, the name given to the new mesh
  114536. * @param newParent can be any Node object (default `null`)
  114537. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114538. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114539. * @returns a new mesh
  114540. */
  114541. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114542. /**
  114543. * Releases resources associated with this mesh.
  114544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114546. */
  114547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114548. /** @hidden */
  114549. _disposeInstanceSpecificData(): void;
  114550. /** @hidden */
  114551. _disposeThinInstanceSpecificData(): void;
  114552. /**
  114553. * Modifies the mesh geometry according to a displacement map.
  114554. * 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.
  114555. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114556. * @param url is a string, the URL from the image file is to be downloaded.
  114557. * @param minHeight is the lower limit of the displacement.
  114558. * @param maxHeight is the upper limit of the displacement.
  114559. * @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.
  114560. * @param uvOffset is an optional vector2 used to offset UV.
  114561. * @param uvScale is an optional vector2 used to scale UV.
  114562. * @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.
  114563. * @returns the Mesh.
  114564. */
  114565. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114566. /**
  114567. * Modifies the mesh geometry according to a displacementMap buffer.
  114568. * 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.
  114569. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114570. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114571. * @param heightMapWidth is the width of the buffer image.
  114572. * @param heightMapHeight is the height of the buffer image.
  114573. * @param minHeight is the lower limit of the displacement.
  114574. * @param maxHeight is the upper limit of the displacement.
  114575. * @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.
  114576. * @param uvOffset is an optional vector2 used to offset UV.
  114577. * @param uvScale is an optional vector2 used to scale UV.
  114578. * @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.
  114579. * @returns the Mesh.
  114580. */
  114581. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114582. /**
  114583. * Modify the mesh to get a flat shading rendering.
  114584. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114585. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114586. * @returns current mesh
  114587. */
  114588. convertToFlatShadedMesh(): Mesh;
  114589. /**
  114590. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114591. * In other words, more vertices, no more indices and a single bigger VBO.
  114592. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114593. * @returns current mesh
  114594. */
  114595. convertToUnIndexedMesh(): Mesh;
  114596. /**
  114597. * Inverses facet orientations.
  114598. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114599. * @param flipNormals will also inverts the normals
  114600. * @returns current mesh
  114601. */
  114602. flipFaces(flipNormals?: boolean): Mesh;
  114603. /**
  114604. * Increase the number of facets and hence vertices in a mesh
  114605. * Vertex normals are interpolated from existing vertex normals
  114606. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114607. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114608. */
  114609. increaseVertices(numberPerEdge: number): void;
  114610. /**
  114611. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114612. * This will undo any application of covertToFlatShadedMesh
  114613. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114614. */
  114615. forceSharedVertices(): void;
  114616. /** @hidden */
  114617. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114618. /** @hidden */
  114619. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114620. /**
  114621. * Creates a new InstancedMesh object from the mesh model.
  114622. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114623. * @param name defines the name of the new instance
  114624. * @returns a new InstancedMesh
  114625. */
  114626. createInstance(name: string): InstancedMesh;
  114627. /**
  114628. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114629. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114630. * @returns the current mesh
  114631. */
  114632. synchronizeInstances(): Mesh;
  114633. /**
  114634. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114635. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114636. * This should be used together with the simplification to avoid disappearing triangles.
  114637. * @param successCallback an optional success callback to be called after the optimization finished.
  114638. * @returns the current mesh
  114639. */
  114640. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114641. /**
  114642. * Serialize current mesh
  114643. * @param serializationObject defines the object which will receive the serialization data
  114644. */
  114645. serialize(serializationObject: any): void;
  114646. /** @hidden */
  114647. _syncGeometryWithMorphTargetManager(): void;
  114648. /** @hidden */
  114649. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114650. /**
  114651. * Returns a new Mesh object parsed from the source provided.
  114652. * @param parsedMesh is the source
  114653. * @param scene defines the hosting scene
  114654. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114655. * @returns a new Mesh
  114656. */
  114657. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114658. /**
  114659. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114661. * @param name defines the name of the mesh to create
  114662. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114663. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114664. * @param closePath creates a seam between the first and the last points of each path of the path array
  114665. * @param offset is taken in account only if the `pathArray` is containing a single path
  114666. * @param scene defines the hosting scene
  114667. * @param updatable defines if the mesh must be flagged as updatable
  114668. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114669. * @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)
  114670. * @returns a new Mesh
  114671. */
  114672. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114673. /**
  114674. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114675. * @param name defines the name of the mesh to create
  114676. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114677. * @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
  114678. * @param scene defines the hosting scene
  114679. * @param updatable defines if the mesh must be flagged as updatable
  114680. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114681. * @returns a new Mesh
  114682. */
  114683. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114684. /**
  114685. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114686. * @param name defines the name of the mesh to create
  114687. * @param size sets the size (float) of each box side (default 1)
  114688. * @param scene defines the hosting scene
  114689. * @param updatable defines if the mesh must be flagged as updatable
  114690. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114691. * @returns a new Mesh
  114692. */
  114693. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114694. /**
  114695. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114696. * @param name defines the name of the mesh to create
  114697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114699. * @param scene defines the hosting scene
  114700. * @param updatable defines if the mesh must be flagged as updatable
  114701. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114702. * @returns a new Mesh
  114703. */
  114704. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114705. /**
  114706. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114707. * @param name defines the name of the mesh to create
  114708. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114709. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114710. * @param scene defines the hosting scene
  114711. * @returns a new Mesh
  114712. */
  114713. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114714. /**
  114715. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114716. * @param name defines the name of the mesh to create
  114717. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114718. * @param diameterTop set the top cap diameter (floats, default 1)
  114719. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114720. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114721. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114722. * @param scene defines the hosting scene
  114723. * @param updatable defines if the mesh must be flagged as updatable
  114724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114725. * @returns a new Mesh
  114726. */
  114727. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114728. /**
  114729. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114730. * @param name defines the name of the mesh to create
  114731. * @param diameter sets the diameter size (float) of the torus (default 1)
  114732. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114733. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114734. * @param scene defines the hosting scene
  114735. * @param updatable defines if the mesh must be flagged as updatable
  114736. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114737. * @returns a new Mesh
  114738. */
  114739. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114740. /**
  114741. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114742. * @param name defines the name of the mesh to create
  114743. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114744. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114745. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114746. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114747. * @param p the number of windings on X axis (positive integers, default 2)
  114748. * @param q the number of windings on Y axis (positive integers, default 3)
  114749. * @param scene defines the hosting scene
  114750. * @param updatable defines if the mesh must be flagged as updatable
  114751. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114752. * @returns a new Mesh
  114753. */
  114754. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114755. /**
  114756. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114757. * @param name defines the name of the mesh to create
  114758. * @param points is an array successive Vector3
  114759. * @param scene defines the hosting scene
  114760. * @param updatable defines if the mesh must be flagged as updatable
  114761. * @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).
  114762. * @returns a new Mesh
  114763. */
  114764. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114765. /**
  114766. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114767. * @param name defines the name of the mesh to create
  114768. * @param points is an array successive Vector3
  114769. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114770. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114771. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114772. * @param scene defines the hosting scene
  114773. * @param updatable defines if the mesh must be flagged as updatable
  114774. * @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)
  114775. * @returns a new Mesh
  114776. */
  114777. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114778. /**
  114779. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114781. * 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.
  114782. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114783. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114784. * Remember you can only change the shape positions, not their number when updating a polygon.
  114785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114786. * @param name defines the name of the mesh to create
  114787. * @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
  114788. * @param scene defines the hosting scene
  114789. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114790. * @param updatable defines if the mesh must be flagged as updatable
  114791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114792. * @param earcutInjection can be used to inject your own earcut reference
  114793. * @returns a new Mesh
  114794. */
  114795. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114796. /**
  114797. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114799. * @param name defines the name of the mesh to create
  114800. * @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
  114801. * @param depth defines the height of extrusion
  114802. * @param scene defines the hosting scene
  114803. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114804. * @param updatable defines if the mesh must be flagged as updatable
  114805. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114806. * @param earcutInjection can be used to inject your own earcut reference
  114807. * @returns a new Mesh
  114808. */
  114809. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114810. /**
  114811. * Creates an extruded shape mesh.
  114812. * 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
  114813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114815. * @param name defines the name of the mesh to create
  114816. * @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
  114817. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114818. * @param scale is the value to scale the shape
  114819. * @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
  114820. * @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
  114821. * @param scene defines the hosting scene
  114822. * @param updatable defines if the mesh must be flagged as updatable
  114823. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114824. * @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)
  114825. * @returns a new Mesh
  114826. */
  114827. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114828. /**
  114829. * Creates an custom extruded shape mesh.
  114830. * The custom extrusion is a parametric shape.
  114831. * It has no predefined shape. Its final shape will depend on the input parameters.
  114832. * Please consider using the same method from the MeshBuilder class instead
  114833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114834. * @param name defines the name of the mesh to create
  114835. * @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
  114836. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114837. * @param scaleFunction is a custom Javascript function called on each path point
  114838. * @param rotationFunction is a custom Javascript function called on each path point
  114839. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114840. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114841. * @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
  114842. * @param scene defines the hosting scene
  114843. * @param updatable defines if the mesh must be flagged as updatable
  114844. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114845. * @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)
  114846. * @returns a new Mesh
  114847. */
  114848. 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;
  114849. /**
  114850. * Creates lathe mesh.
  114851. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114852. * Please consider using the same method from the MeshBuilder class instead
  114853. * @param name defines the name of the mesh to create
  114854. * @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
  114855. * @param radius is the radius value of the lathe
  114856. * @param tessellation is the side number of the lathe.
  114857. * @param scene defines the hosting scene
  114858. * @param updatable defines if the mesh must be flagged as updatable
  114859. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114860. * @returns a new Mesh
  114861. */
  114862. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114863. /**
  114864. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114865. * @param name defines the name of the mesh to create
  114866. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114867. * @param scene defines the hosting scene
  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. * @returns a new Mesh
  114871. */
  114872. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114873. /**
  114874. * Creates a ground mesh.
  114875. * Please consider using the same method from the MeshBuilder class instead
  114876. * @param name defines the name of the mesh to create
  114877. * @param width set the width of the ground
  114878. * @param height set the height of the ground
  114879. * @param subdivisions sets the number of subdivisions per side
  114880. * @param scene defines the hosting scene
  114881. * @param updatable defines if the mesh must be flagged as updatable
  114882. * @returns a new Mesh
  114883. */
  114884. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114885. /**
  114886. * Creates a tiled ground mesh.
  114887. * Please consider using the same method from the MeshBuilder class instead
  114888. * @param name defines the name of the mesh to create
  114889. * @param xmin set the ground minimum X coordinate
  114890. * @param zmin set the ground minimum Y coordinate
  114891. * @param xmax set the ground maximum X coordinate
  114892. * @param zmax set the ground maximum Z coordinate
  114893. * @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
  114894. * @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
  114895. * @param scene defines the hosting scene
  114896. * @param updatable defines if the mesh must be flagged as updatable
  114897. * @returns a new Mesh
  114898. */
  114899. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114900. w: number;
  114901. h: number;
  114902. }, precision: {
  114903. w: number;
  114904. h: number;
  114905. }, scene: Scene, updatable?: boolean): Mesh;
  114906. /**
  114907. * Creates a ground mesh from a height map.
  114908. * Please consider using the same method from the MeshBuilder class instead
  114909. * @see https://doc.babylonjs.com/babylon101/height_map
  114910. * @param name defines the name of the mesh to create
  114911. * @param url sets the URL of the height map image resource
  114912. * @param width set the ground width size
  114913. * @param height set the ground height size
  114914. * @param subdivisions sets the number of subdivision per side
  114915. * @param minHeight is the minimum altitude on the ground
  114916. * @param maxHeight is the maximum altitude on the ground
  114917. * @param scene defines the hosting scene
  114918. * @param updatable defines if the mesh must be flagged as updatable
  114919. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114920. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114921. * @returns a new Mesh
  114922. */
  114923. 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;
  114924. /**
  114925. * Creates a tube mesh.
  114926. * The tube is a parametric shape.
  114927. * It has no predefined shape. Its final shape will depend on the input parameters.
  114928. * Please consider using the same method from the MeshBuilder class instead
  114929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114930. * @param name defines the name of the mesh to create
  114931. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114932. * @param radius sets the tube radius size
  114933. * @param tessellation is the number of sides on the tubular surface
  114934. * @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
  114935. * @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
  114936. * @param scene defines the hosting scene
  114937. * @param updatable defines if the mesh must be flagged as updatable
  114938. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114939. * @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)
  114940. * @returns a new Mesh
  114941. */
  114942. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114943. (i: number, distance: number): number;
  114944. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114945. /**
  114946. * Creates a polyhedron mesh.
  114947. * Please consider using the same method from the MeshBuilder class instead.
  114948. * * 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
  114949. * * The parameter `size` (positive float, default 1) sets the polygon size
  114950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114951. * * 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`
  114952. * * 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
  114953. * * 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)`)
  114954. * * 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
  114955. * * 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
  114956. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114959. * @param name defines the name of the mesh to create
  114960. * @param options defines the options used to create the mesh
  114961. * @param scene defines the hosting scene
  114962. * @returns a new Mesh
  114963. */
  114964. static CreatePolyhedron(name: string, options: {
  114965. type?: number;
  114966. size?: number;
  114967. sizeX?: number;
  114968. sizeY?: number;
  114969. sizeZ?: number;
  114970. custom?: any;
  114971. faceUV?: Vector4[];
  114972. faceColors?: Color4[];
  114973. updatable?: boolean;
  114974. sideOrientation?: number;
  114975. }, scene: Scene): Mesh;
  114976. /**
  114977. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114978. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114979. * * 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`)
  114980. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114981. * * 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
  114982. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114985. * @param name defines the name of the mesh
  114986. * @param options defines the options used to create the mesh
  114987. * @param scene defines the hosting scene
  114988. * @returns a new Mesh
  114989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114990. */
  114991. static CreateIcoSphere(name: string, options: {
  114992. radius?: number;
  114993. flat?: boolean;
  114994. subdivisions?: number;
  114995. sideOrientation?: number;
  114996. updatable?: boolean;
  114997. }, scene: Scene): Mesh;
  114998. /**
  114999. * Creates a decal mesh.
  115000. * Please consider using the same method from the MeshBuilder class instead.
  115001. * A decal is a mesh usually applied as a model onto the surface of another mesh
  115002. * @param name defines the name of the mesh
  115003. * @param sourceMesh defines the mesh receiving the decal
  115004. * @param position sets the position of the decal in world coordinates
  115005. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  115006. * @param size sets the decal scaling
  115007. * @param angle sets the angle to rotate the decal
  115008. * @returns a new Mesh
  115009. */
  115010. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  115011. /** Creates a Capsule Mesh
  115012. * @param name defines the name of the mesh.
  115013. * @param options the constructors options used to shape the mesh.
  115014. * @param scene defines the scene the mesh is scoped to.
  115015. * @returns the capsule mesh
  115016. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115017. */
  115018. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115019. /**
  115020. * Prepare internal position array for software CPU skinning
  115021. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115022. */
  115023. setPositionsForCPUSkinning(): Float32Array;
  115024. /**
  115025. * Prepare internal normal array for software CPU skinning
  115026. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115027. */
  115028. setNormalsForCPUSkinning(): Float32Array;
  115029. /**
  115030. * Updates the vertex buffer by applying transformation from the bones
  115031. * @param skeleton defines the skeleton to apply to current mesh
  115032. * @returns the current mesh
  115033. */
  115034. applySkeleton(skeleton: Skeleton): Mesh;
  115035. /**
  115036. * 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
  115037. * @param meshes defines the list of meshes to scan
  115038. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115039. */
  115040. static MinMax(meshes: AbstractMesh[]): {
  115041. min: Vector3;
  115042. max: Vector3;
  115043. };
  115044. /**
  115045. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115046. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115047. * @returns a vector3
  115048. */
  115049. static Center(meshesOrMinMaxVector: {
  115050. min: Vector3;
  115051. max: Vector3;
  115052. } | AbstractMesh[]): Vector3;
  115053. /**
  115054. * Merge the array of meshes into a single mesh for performance reasons.
  115055. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115056. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115057. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115058. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115059. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115060. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115061. * @returns a new mesh
  115062. */
  115063. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115064. /** @hidden */
  115065. addInstance(instance: InstancedMesh): void;
  115066. /** @hidden */
  115067. removeInstance(instance: InstancedMesh): void;
  115068. }
  115069. }
  115070. declare module BABYLON {
  115071. /**
  115072. * The options Interface for creating a Capsule Mesh
  115073. */
  115074. export interface ICreateCapsuleOptions {
  115075. /** The Orientation of the capsule. Default : Vector3.Up() */
  115076. orientation?: Vector3;
  115077. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  115078. subdivisions: number;
  115079. /** Number of cylindrical segments on the capsule. */
  115080. tessellation: number;
  115081. /** Height or Length of the capsule. */
  115082. height: number;
  115083. /** Radius of the capsule. */
  115084. radius: number;
  115085. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  115086. capSubdivisions: number;
  115087. /** Overwrite for the top radius. */
  115088. radiusTop?: number;
  115089. /** Overwrite for the bottom radius. */
  115090. radiusBottom?: number;
  115091. /** Overwrite for the top capSubdivisions. */
  115092. topCapSubdivisions?: number;
  115093. /** Overwrite for the bottom capSubdivisions. */
  115094. bottomCapSubdivisions?: number;
  115095. }
  115096. /**
  115097. * Class containing static functions to help procedurally build meshes
  115098. */
  115099. export class CapsuleBuilder {
  115100. /**
  115101. * Creates a capsule or a pill mesh
  115102. * @param name defines the name of the mesh
  115103. * @param options The constructors options.
  115104. * @param scene The scene the mesh is scoped to.
  115105. * @returns Capsule Mesh
  115106. */
  115107. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  115108. }
  115109. }
  115110. declare module BABYLON {
  115111. /**
  115112. * Define an interface for all classes that will get and set the data on vertices
  115113. */
  115114. export interface IGetSetVerticesData {
  115115. /**
  115116. * Gets a boolean indicating if specific vertex data is present
  115117. * @param kind defines the vertex data kind to use
  115118. * @returns true is data kind is present
  115119. */
  115120. isVerticesDataPresent(kind: string): boolean;
  115121. /**
  115122. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  115123. * @param kind defines the data kind (Position, normal, etc...)
  115124. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115125. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115126. * @returns a float array containing vertex data
  115127. */
  115128. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  115129. /**
  115130. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  115131. * @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.
  115132. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115133. * @returns the indices array or an empty array if the mesh has no geometry
  115134. */
  115135. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  115136. /**
  115137. * Set specific vertex data
  115138. * @param kind defines the data kind (Position, normal, etc...)
  115139. * @param data defines the vertex data to use
  115140. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115141. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115142. */
  115143. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  115144. /**
  115145. * Update a specific associated vertex buffer
  115146. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  115147. * - VertexBuffer.PositionKind
  115148. * - VertexBuffer.UVKind
  115149. * - VertexBuffer.UV2Kind
  115150. * - VertexBuffer.UV3Kind
  115151. * - VertexBuffer.UV4Kind
  115152. * - VertexBuffer.UV5Kind
  115153. * - VertexBuffer.UV6Kind
  115154. * - VertexBuffer.ColorKind
  115155. * - VertexBuffer.MatricesIndicesKind
  115156. * - VertexBuffer.MatricesIndicesExtraKind
  115157. * - VertexBuffer.MatricesWeightsKind
  115158. * - VertexBuffer.MatricesWeightsExtraKind
  115159. * @param data defines the data source
  115160. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  115161. * @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)
  115162. */
  115163. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  115164. /**
  115165. * Creates a new index buffer
  115166. * @param indices defines the indices to store in the index buffer
  115167. * @param totalVertices defines the total number of vertices (could be null)
  115168. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115169. */
  115170. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  115171. }
  115172. /**
  115173. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  115174. */
  115175. export class VertexData {
  115176. /**
  115177. * Mesh side orientation : usually the external or front surface
  115178. */
  115179. static readonly FRONTSIDE: number;
  115180. /**
  115181. * Mesh side orientation : usually the internal or back surface
  115182. */
  115183. static readonly BACKSIDE: number;
  115184. /**
  115185. * Mesh side orientation : both internal and external or front and back surfaces
  115186. */
  115187. static readonly DOUBLESIDE: number;
  115188. /**
  115189. * Mesh side orientation : by default, `FRONTSIDE`
  115190. */
  115191. static readonly DEFAULTSIDE: number;
  115192. /**
  115193. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  115194. */
  115195. positions: Nullable<FloatArray>;
  115196. /**
  115197. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  115198. */
  115199. normals: Nullable<FloatArray>;
  115200. /**
  115201. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  115202. */
  115203. tangents: Nullable<FloatArray>;
  115204. /**
  115205. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115206. */
  115207. uvs: Nullable<FloatArray>;
  115208. /**
  115209. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115210. */
  115211. uvs2: Nullable<FloatArray>;
  115212. /**
  115213. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115214. */
  115215. uvs3: Nullable<FloatArray>;
  115216. /**
  115217. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115218. */
  115219. uvs4: Nullable<FloatArray>;
  115220. /**
  115221. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115222. */
  115223. uvs5: Nullable<FloatArray>;
  115224. /**
  115225. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115226. */
  115227. uvs6: Nullable<FloatArray>;
  115228. /**
  115229. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  115230. */
  115231. colors: Nullable<FloatArray>;
  115232. /**
  115233. * 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).
  115234. */
  115235. matricesIndices: Nullable<FloatArray>;
  115236. /**
  115237. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  115238. */
  115239. matricesWeights: Nullable<FloatArray>;
  115240. /**
  115241. * An array extending the number of possible indices
  115242. */
  115243. matricesIndicesExtra: Nullable<FloatArray>;
  115244. /**
  115245. * An array extending the number of possible weights when the number of indices is extended
  115246. */
  115247. matricesWeightsExtra: Nullable<FloatArray>;
  115248. /**
  115249. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  115250. */
  115251. indices: Nullable<IndicesArray>;
  115252. /**
  115253. * Uses the passed data array to set the set the values for the specified kind of data
  115254. * @param data a linear array of floating numbers
  115255. * @param kind the type of data that is being set, eg positions, colors etc
  115256. */
  115257. set(data: FloatArray, kind: string): void;
  115258. /**
  115259. * Associates the vertexData to the passed Mesh.
  115260. * Sets it as updatable or not (default `false`)
  115261. * @param mesh the mesh the vertexData is applied to
  115262. * @param updatable when used and having the value true allows new data to update the vertexData
  115263. * @returns the VertexData
  115264. */
  115265. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  115266. /**
  115267. * Associates the vertexData to the passed Geometry.
  115268. * Sets it as updatable or not (default `false`)
  115269. * @param geometry the geometry the vertexData is applied to
  115270. * @param updatable when used and having the value true allows new data to update the vertexData
  115271. * @returns VertexData
  115272. */
  115273. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  115274. /**
  115275. * Updates the associated mesh
  115276. * @param mesh the mesh to be updated
  115277. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115278. * @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
  115279. * @returns VertexData
  115280. */
  115281. updateMesh(mesh: Mesh): VertexData;
  115282. /**
  115283. * Updates the associated geometry
  115284. * @param geometry the geometry to be updated
  115285. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115286. * @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
  115287. * @returns VertexData.
  115288. */
  115289. updateGeometry(geometry: Geometry): VertexData;
  115290. private _applyTo;
  115291. private _update;
  115292. /**
  115293. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115294. * @param matrix the transforming matrix
  115295. * @returns the VertexData
  115296. */
  115297. transform(matrix: Matrix): VertexData;
  115298. /**
  115299. * Merges the passed VertexData into the current one
  115300. * @param other the VertexData to be merged into the current one
  115301. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115302. * @returns the modified VertexData
  115303. */
  115304. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115305. private _mergeElement;
  115306. private _validate;
  115307. /**
  115308. * Serializes the VertexData
  115309. * @returns a serialized object
  115310. */
  115311. serialize(): any;
  115312. /**
  115313. * Extracts the vertexData from a mesh
  115314. * @param mesh the mesh from which to extract the VertexData
  115315. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115316. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115317. * @returns the object VertexData associated to the passed mesh
  115318. */
  115319. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115320. /**
  115321. * Extracts the vertexData from the geometry
  115322. * @param geometry the geometry from which to extract the VertexData
  115323. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115324. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115325. * @returns the object VertexData associated to the passed mesh
  115326. */
  115327. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115328. private static _ExtractFrom;
  115329. /**
  115330. * Creates the VertexData for a Ribbon
  115331. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115332. * * pathArray array of paths, each of which an array of successive Vector3
  115333. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115334. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115335. * * 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
  115336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115337. * * 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)
  115338. * * 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)
  115339. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115340. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115341. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115342. * @returns the VertexData of the ribbon
  115343. */
  115344. static CreateRibbon(options: {
  115345. pathArray: Vector3[][];
  115346. closeArray?: boolean;
  115347. closePath?: boolean;
  115348. offset?: number;
  115349. sideOrientation?: number;
  115350. frontUVs?: Vector4;
  115351. backUVs?: Vector4;
  115352. invertUV?: boolean;
  115353. uvs?: Vector2[];
  115354. colors?: Color4[];
  115355. }): VertexData;
  115356. /**
  115357. * Creates the VertexData for a box
  115358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115359. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115360. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115361. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115362. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115363. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115364. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115366. * * 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)
  115367. * * 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)
  115368. * @returns the VertexData of the box
  115369. */
  115370. static CreateBox(options: {
  115371. size?: number;
  115372. width?: number;
  115373. height?: number;
  115374. depth?: number;
  115375. faceUV?: Vector4[];
  115376. faceColors?: Color4[];
  115377. sideOrientation?: number;
  115378. frontUVs?: Vector4;
  115379. backUVs?: Vector4;
  115380. }): VertexData;
  115381. /**
  115382. * Creates the VertexData for a tiled box
  115383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115384. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115385. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115386. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115388. * @returns the VertexData of the box
  115389. */
  115390. static CreateTiledBox(options: {
  115391. pattern?: number;
  115392. width?: number;
  115393. height?: number;
  115394. depth?: number;
  115395. tileSize?: number;
  115396. tileWidth?: number;
  115397. tileHeight?: number;
  115398. alignHorizontal?: number;
  115399. alignVertical?: number;
  115400. faceUV?: Vector4[];
  115401. faceColors?: Color4[];
  115402. sideOrientation?: number;
  115403. }): VertexData;
  115404. /**
  115405. * Creates the VertexData for a tiled plane
  115406. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115407. * * pattern a limited pattern arrangement depending on the number
  115408. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115409. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115410. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115412. * * 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)
  115413. * * 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)
  115414. * @returns the VertexData of the tiled plane
  115415. */
  115416. static CreateTiledPlane(options: {
  115417. pattern?: number;
  115418. tileSize?: number;
  115419. tileWidth?: number;
  115420. tileHeight?: number;
  115421. size?: number;
  115422. width?: number;
  115423. height?: number;
  115424. alignHorizontal?: number;
  115425. alignVertical?: number;
  115426. sideOrientation?: number;
  115427. frontUVs?: Vector4;
  115428. backUVs?: Vector4;
  115429. }): VertexData;
  115430. /**
  115431. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115432. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115433. * * segments sets the number of horizontal strips optional, default 32
  115434. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115435. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115436. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115437. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115438. * * 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
  115439. * * 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
  115440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115441. * * 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)
  115442. * * 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)
  115443. * @returns the VertexData of the ellipsoid
  115444. */
  115445. static CreateSphere(options: {
  115446. segments?: number;
  115447. diameter?: number;
  115448. diameterX?: number;
  115449. diameterY?: number;
  115450. diameterZ?: number;
  115451. arc?: number;
  115452. slice?: number;
  115453. sideOrientation?: number;
  115454. frontUVs?: Vector4;
  115455. backUVs?: Vector4;
  115456. }): VertexData;
  115457. /**
  115458. * Creates the VertexData for a cylinder, cone or prism
  115459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115460. * * height sets the height (y direction) of the cylinder, optional, default 2
  115461. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115462. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115463. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115464. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115465. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115466. * * 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
  115467. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115468. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115469. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115470. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115472. * * 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)
  115473. * * 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)
  115474. * @returns the VertexData of the cylinder, cone or prism
  115475. */
  115476. static CreateCylinder(options: {
  115477. height?: number;
  115478. diameterTop?: number;
  115479. diameterBottom?: number;
  115480. diameter?: number;
  115481. tessellation?: number;
  115482. subdivisions?: number;
  115483. arc?: number;
  115484. faceColors?: Color4[];
  115485. faceUV?: Vector4[];
  115486. hasRings?: boolean;
  115487. enclose?: boolean;
  115488. sideOrientation?: number;
  115489. frontUVs?: Vector4;
  115490. backUVs?: Vector4;
  115491. }): VertexData;
  115492. /**
  115493. * Creates the VertexData for a torus
  115494. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115495. * * diameter the diameter of the torus, optional default 1
  115496. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115497. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115499. * * 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)
  115500. * * 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)
  115501. * @returns the VertexData of the torus
  115502. */
  115503. static CreateTorus(options: {
  115504. diameter?: number;
  115505. thickness?: number;
  115506. tessellation?: number;
  115507. sideOrientation?: number;
  115508. frontUVs?: Vector4;
  115509. backUVs?: Vector4;
  115510. }): VertexData;
  115511. /**
  115512. * Creates the VertexData of the LineSystem
  115513. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115514. * - lines an array of lines, each line being an array of successive Vector3
  115515. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115516. * @returns the VertexData of the LineSystem
  115517. */
  115518. static CreateLineSystem(options: {
  115519. lines: Vector3[][];
  115520. colors?: Nullable<Color4[][]>;
  115521. }): VertexData;
  115522. /**
  115523. * Create the VertexData for a DashedLines
  115524. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115525. * - points an array successive Vector3
  115526. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115527. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115528. * - dashNb the intended total number of dashes, optional, default 200
  115529. * @returns the VertexData for the DashedLines
  115530. */
  115531. static CreateDashedLines(options: {
  115532. points: Vector3[];
  115533. dashSize?: number;
  115534. gapSize?: number;
  115535. dashNb?: number;
  115536. }): VertexData;
  115537. /**
  115538. * Creates the VertexData for a Ground
  115539. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115540. * - width the width (x direction) of the ground, optional, default 1
  115541. * - height the height (z direction) of the ground, optional, default 1
  115542. * - subdivisions the number of subdivisions per side, optional, default 1
  115543. * @returns the VertexData of the Ground
  115544. */
  115545. static CreateGround(options: {
  115546. width?: number;
  115547. height?: number;
  115548. subdivisions?: number;
  115549. subdivisionsX?: number;
  115550. subdivisionsY?: number;
  115551. }): VertexData;
  115552. /**
  115553. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115554. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115555. * * xmin the ground minimum X coordinate, optional, default -1
  115556. * * zmin the ground minimum Z coordinate, optional, default -1
  115557. * * xmax the ground maximum X coordinate, optional, default 1
  115558. * * zmax the ground maximum Z coordinate, optional, default 1
  115559. * * 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}
  115560. * * 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}
  115561. * @returns the VertexData of the TiledGround
  115562. */
  115563. static CreateTiledGround(options: {
  115564. xmin: number;
  115565. zmin: number;
  115566. xmax: number;
  115567. zmax: number;
  115568. subdivisions?: {
  115569. w: number;
  115570. h: number;
  115571. };
  115572. precision?: {
  115573. w: number;
  115574. h: number;
  115575. };
  115576. }): VertexData;
  115577. /**
  115578. * Creates the VertexData of the Ground designed from a heightmap
  115579. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115580. * * width the width (x direction) of the ground
  115581. * * height the height (z direction) of the ground
  115582. * * subdivisions the number of subdivisions per side
  115583. * * minHeight the minimum altitude on the ground, optional, default 0
  115584. * * maxHeight the maximum altitude on the ground, optional default 1
  115585. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115586. * * buffer the array holding the image color data
  115587. * * bufferWidth the width of image
  115588. * * bufferHeight the height of image
  115589. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115590. * @returns the VertexData of the Ground designed from a heightmap
  115591. */
  115592. static CreateGroundFromHeightMap(options: {
  115593. width: number;
  115594. height: number;
  115595. subdivisions: number;
  115596. minHeight: number;
  115597. maxHeight: number;
  115598. colorFilter: Color3;
  115599. buffer: Uint8Array;
  115600. bufferWidth: number;
  115601. bufferHeight: number;
  115602. alphaFilter: number;
  115603. }): VertexData;
  115604. /**
  115605. * Creates the VertexData for a Plane
  115606. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115607. * * size sets the width and height of the plane to the value of size, optional default 1
  115608. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115609. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115611. * * 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)
  115612. * * 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)
  115613. * @returns the VertexData of the box
  115614. */
  115615. static CreatePlane(options: {
  115616. size?: number;
  115617. width?: number;
  115618. height?: number;
  115619. sideOrientation?: number;
  115620. frontUVs?: Vector4;
  115621. backUVs?: Vector4;
  115622. }): VertexData;
  115623. /**
  115624. * Creates the VertexData of the Disc or regular Polygon
  115625. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115626. * * radius the radius of the disc, optional default 0.5
  115627. * * tessellation the number of polygon sides, optional, default 64
  115628. * * 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
  115629. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115630. * * 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)
  115631. * * 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)
  115632. * @returns the VertexData of the box
  115633. */
  115634. static CreateDisc(options: {
  115635. radius?: number;
  115636. tessellation?: number;
  115637. arc?: number;
  115638. sideOrientation?: number;
  115639. frontUVs?: Vector4;
  115640. backUVs?: Vector4;
  115641. }): VertexData;
  115642. /**
  115643. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115644. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115645. * @param polygon a mesh built from polygonTriangulation.build()
  115646. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115647. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115648. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115649. * @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)
  115650. * @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)
  115651. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115652. * @returns the VertexData of the Polygon
  115653. */
  115654. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115655. /**
  115656. * Creates the VertexData of the IcoSphere
  115657. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115658. * * radius the radius of the IcoSphere, optional default 1
  115659. * * radiusX allows stretching in the x direction, optional, default radius
  115660. * * radiusY allows stretching in the y direction, optional, default radius
  115661. * * radiusZ allows stretching in the z direction, optional, default radius
  115662. * * flat when true creates a flat shaded mesh, optional, default true
  115663. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115665. * * 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)
  115666. * * 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)
  115667. * @returns the VertexData of the IcoSphere
  115668. */
  115669. static CreateIcoSphere(options: {
  115670. radius?: number;
  115671. radiusX?: number;
  115672. radiusY?: number;
  115673. radiusZ?: number;
  115674. flat?: boolean;
  115675. subdivisions?: number;
  115676. sideOrientation?: number;
  115677. frontUVs?: Vector4;
  115678. backUVs?: Vector4;
  115679. }): VertexData;
  115680. /**
  115681. * Creates the VertexData for a Polyhedron
  115682. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115683. * * type provided types are:
  115684. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115685. * * 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)
  115686. * * size the size of the IcoSphere, optional default 1
  115687. * * sizeX allows stretching in the x direction, optional, default size
  115688. * * sizeY allows stretching in the y direction, optional, default size
  115689. * * sizeZ allows stretching in the z direction, optional, default size
  115690. * * 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
  115691. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115692. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115693. * * flat when true creates a flat shaded mesh, optional, default true
  115694. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115696. * * 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)
  115697. * * 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)
  115698. * @returns the VertexData of the Polyhedron
  115699. */
  115700. static CreatePolyhedron(options: {
  115701. type?: number;
  115702. size?: number;
  115703. sizeX?: number;
  115704. sizeY?: number;
  115705. sizeZ?: number;
  115706. custom?: any;
  115707. faceUV?: Vector4[];
  115708. faceColors?: Color4[];
  115709. flat?: boolean;
  115710. sideOrientation?: number;
  115711. frontUVs?: Vector4;
  115712. backUVs?: Vector4;
  115713. }): VertexData;
  115714. /**
  115715. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115716. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115717. * @returns the VertexData of the Capsule
  115718. */
  115719. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115720. /**
  115721. * Creates the VertexData for a TorusKnot
  115722. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115723. * * radius the radius of the torus knot, optional, default 2
  115724. * * tube the thickness of the tube, optional, default 0.5
  115725. * * radialSegments the number of sides on each tube segments, optional, default 32
  115726. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115727. * * p the number of windings around the z axis, optional, default 2
  115728. * * q the number of windings around the x axis, optional, default 3
  115729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115730. * * 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)
  115731. * * 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)
  115732. * @returns the VertexData of the Torus Knot
  115733. */
  115734. static CreateTorusKnot(options: {
  115735. radius?: number;
  115736. tube?: number;
  115737. radialSegments?: number;
  115738. tubularSegments?: number;
  115739. p?: number;
  115740. q?: number;
  115741. sideOrientation?: number;
  115742. frontUVs?: Vector4;
  115743. backUVs?: Vector4;
  115744. }): VertexData;
  115745. /**
  115746. * Compute normals for given positions and indices
  115747. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115748. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115749. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115750. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115751. * * facetNormals : optional array of facet normals (vector3)
  115752. * * facetPositions : optional array of facet positions (vector3)
  115753. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115754. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115755. * * bInfo : optional bounding info, required for facetPartitioning computation
  115756. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115757. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115758. * * useRightHandedSystem: optional boolean to for right handed system computation
  115759. * * depthSort : optional boolean to enable the facet depth sort computation
  115760. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115761. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115762. */
  115763. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115764. facetNormals?: any;
  115765. facetPositions?: any;
  115766. facetPartitioning?: any;
  115767. ratio?: number;
  115768. bInfo?: any;
  115769. bbSize?: Vector3;
  115770. subDiv?: any;
  115771. useRightHandedSystem?: boolean;
  115772. depthSort?: boolean;
  115773. distanceTo?: Vector3;
  115774. depthSortedFacets?: any;
  115775. }): void;
  115776. /** @hidden */
  115777. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115778. /**
  115779. * Applies VertexData created from the imported parameters to the geometry
  115780. * @param parsedVertexData the parsed data from an imported file
  115781. * @param geometry the geometry to apply the VertexData to
  115782. */
  115783. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115784. }
  115785. }
  115786. declare module BABYLON {
  115787. /**
  115788. * Class containing static functions to help procedurally build meshes
  115789. */
  115790. export class DiscBuilder {
  115791. /**
  115792. * Creates a plane polygonal mesh. By default, this is a disc
  115793. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115794. * * 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
  115795. * * 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
  115796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115799. * @param name defines the name of the mesh
  115800. * @param options defines the options used to create the mesh
  115801. * @param scene defines the hosting scene
  115802. * @returns the plane polygonal mesh
  115803. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115804. */
  115805. static CreateDisc(name: string, options: {
  115806. radius?: number;
  115807. tessellation?: number;
  115808. arc?: number;
  115809. updatable?: boolean;
  115810. sideOrientation?: number;
  115811. frontUVs?: Vector4;
  115812. backUVs?: Vector4;
  115813. }, scene?: Nullable<Scene>): Mesh;
  115814. }
  115815. }
  115816. declare module BABYLON {
  115817. /**
  115818. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115819. *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.
  115820. * The SPS is also a particle system. It provides some methods to manage the particles.
  115821. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115822. *
  115823. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115824. */
  115825. export class SolidParticleSystem implements IDisposable {
  115826. /**
  115827. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115828. * Example : var p = SPS.particles[i];
  115829. */
  115830. particles: SolidParticle[];
  115831. /**
  115832. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115833. */
  115834. nbParticles: number;
  115835. /**
  115836. * If the particles must ever face the camera (default false). Useful for planar particles.
  115837. */
  115838. billboard: boolean;
  115839. /**
  115840. * Recompute normals when adding a shape
  115841. */
  115842. recomputeNormals: boolean;
  115843. /**
  115844. * This a counter ofr your own usage. It's not set by any SPS functions.
  115845. */
  115846. counter: number;
  115847. /**
  115848. * The SPS name. This name is also given to the underlying mesh.
  115849. */
  115850. name: string;
  115851. /**
  115852. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115853. */
  115854. mesh: Mesh;
  115855. /**
  115856. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115857. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115858. */
  115859. vars: any;
  115860. /**
  115861. * This array is populated when the SPS is set as 'pickable'.
  115862. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115863. * Each element of this array is an object `{idx: int, faceId: int}`.
  115864. * `idx` is the picked particle index in the `SPS.particles` array
  115865. * `faceId` is the picked face index counted within this particle.
  115866. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115867. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115868. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115869. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115870. */
  115871. pickedParticles: {
  115872. idx: number;
  115873. faceId: number;
  115874. }[];
  115875. /**
  115876. * This array is populated when the SPS is set as 'pickable'
  115877. * Each key of this array is a submesh index.
  115878. * Each element of this array is a second array defined like this :
  115879. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115880. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115881. * `idx` is the picked particle index in the `SPS.particles` array
  115882. * `faceId` is the picked face index counted within this particle.
  115883. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115884. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115885. */
  115886. pickedBySubMesh: {
  115887. idx: number;
  115888. faceId: number;
  115889. }[][];
  115890. /**
  115891. * This array is populated when `enableDepthSort` is set to true.
  115892. * Each element of this array is an instance of the class DepthSortedParticle.
  115893. */
  115894. depthSortedParticles: DepthSortedParticle[];
  115895. /**
  115896. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115897. * @hidden
  115898. */
  115899. _bSphereOnly: boolean;
  115900. /**
  115901. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115902. * @hidden
  115903. */
  115904. _bSphereRadiusFactor: number;
  115905. private _scene;
  115906. private _positions;
  115907. private _indices;
  115908. private _normals;
  115909. private _colors;
  115910. private _uvs;
  115911. private _indices32;
  115912. private _positions32;
  115913. private _normals32;
  115914. private _fixedNormal32;
  115915. private _colors32;
  115916. private _uvs32;
  115917. private _index;
  115918. private _updatable;
  115919. private _pickable;
  115920. private _isVisibilityBoxLocked;
  115921. private _alwaysVisible;
  115922. private _depthSort;
  115923. private _expandable;
  115924. private _shapeCounter;
  115925. private _copy;
  115926. private _color;
  115927. private _computeParticleColor;
  115928. private _computeParticleTexture;
  115929. private _computeParticleRotation;
  115930. private _computeParticleVertex;
  115931. private _computeBoundingBox;
  115932. private _depthSortParticles;
  115933. private _camera;
  115934. private _mustUnrotateFixedNormals;
  115935. private _particlesIntersect;
  115936. private _needs32Bits;
  115937. private _isNotBuilt;
  115938. private _lastParticleId;
  115939. private _idxOfId;
  115940. private _multimaterialEnabled;
  115941. private _useModelMaterial;
  115942. private _indicesByMaterial;
  115943. private _materialIndexes;
  115944. private _depthSortFunction;
  115945. private _materialSortFunction;
  115946. private _materials;
  115947. private _multimaterial;
  115948. private _materialIndexesById;
  115949. private _defaultMaterial;
  115950. private _autoUpdateSubMeshes;
  115951. private _tmpVertex;
  115952. /**
  115953. * Creates a SPS (Solid Particle System) object.
  115954. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115955. * @param scene (Scene) is the scene in which the SPS is added.
  115956. * @param options defines the options of the sps e.g.
  115957. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115958. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115959. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115960. * * 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.
  115961. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115962. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115963. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115964. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115965. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115966. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115967. */
  115968. constructor(name: string, scene: Scene, options?: {
  115969. updatable?: boolean;
  115970. isPickable?: boolean;
  115971. enableDepthSort?: boolean;
  115972. particleIntersection?: boolean;
  115973. boundingSphereOnly?: boolean;
  115974. bSphereRadiusFactor?: number;
  115975. expandable?: boolean;
  115976. useModelMaterial?: boolean;
  115977. enableMultiMaterial?: boolean;
  115978. });
  115979. /**
  115980. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115981. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115982. * @returns the created mesh
  115983. */
  115984. buildMesh(): Mesh;
  115985. /**
  115986. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115987. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115988. * Thus the particles generated from `digest()` have their property `position` set yet.
  115989. * @param mesh ( Mesh ) is the mesh to be digested
  115990. * @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
  115991. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115992. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115993. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115994. * @returns the current SPS
  115995. */
  115996. digest(mesh: Mesh, options?: {
  115997. facetNb?: number;
  115998. number?: number;
  115999. delta?: number;
  116000. storage?: [];
  116001. }): SolidParticleSystem;
  116002. /**
  116003. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  116004. * @hidden
  116005. */
  116006. private _unrotateFixedNormals;
  116007. /**
  116008. * Resets the temporary working copy particle
  116009. * @hidden
  116010. */
  116011. private _resetCopy;
  116012. /**
  116013. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  116014. * @param p the current index in the positions array to be updated
  116015. * @param ind the current index in the indices array
  116016. * @param shape a Vector3 array, the shape geometry
  116017. * @param positions the positions array to be updated
  116018. * @param meshInd the shape indices array
  116019. * @param indices the indices array to be updated
  116020. * @param meshUV the shape uv array
  116021. * @param uvs the uv array to be updated
  116022. * @param meshCol the shape color array
  116023. * @param colors the color array to be updated
  116024. * @param meshNor the shape normals array
  116025. * @param normals the normals array to be updated
  116026. * @param idx the particle index
  116027. * @param idxInShape the particle index in its shape
  116028. * @param options the addShape() method passed options
  116029. * @model the particle model
  116030. * @hidden
  116031. */
  116032. private _meshBuilder;
  116033. /**
  116034. * Returns a shape Vector3 array from positions float array
  116035. * @param positions float array
  116036. * @returns a vector3 array
  116037. * @hidden
  116038. */
  116039. private _posToShape;
  116040. /**
  116041. * Returns a shapeUV array from a float uvs (array deep copy)
  116042. * @param uvs as a float array
  116043. * @returns a shapeUV array
  116044. * @hidden
  116045. */
  116046. private _uvsToShapeUV;
  116047. /**
  116048. * Adds a new particle object in the particles array
  116049. * @param idx particle index in particles array
  116050. * @param id particle id
  116051. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  116052. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  116053. * @param model particle ModelShape object
  116054. * @param shapeId model shape identifier
  116055. * @param idxInShape index of the particle in the current model
  116056. * @param bInfo model bounding info object
  116057. * @param storage target storage array, if any
  116058. * @hidden
  116059. */
  116060. private _addParticle;
  116061. /**
  116062. * Adds some particles to the SPS from the model shape. Returns the shape id.
  116063. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  116064. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  116065. * @param nb (positive integer) the number of particles to be created from this model
  116066. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  116067. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  116068. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  116069. * @returns the number of shapes in the system
  116070. */
  116071. addShape(mesh: Mesh, nb: number, options?: {
  116072. positionFunction?: any;
  116073. vertexFunction?: any;
  116074. storage?: [];
  116075. }): number;
  116076. /**
  116077. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  116078. * @hidden
  116079. */
  116080. private _rebuildParticle;
  116081. /**
  116082. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  116083. * @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.
  116084. * @returns the SPS.
  116085. */
  116086. rebuildMesh(reset?: boolean): SolidParticleSystem;
  116087. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  116088. * Returns an array with the removed particles.
  116089. * 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.
  116090. * The SPS can't be empty so at least one particle needs to remain in place.
  116091. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  116092. * @param start index of the first particle to remove
  116093. * @param end index of the last particle to remove (included)
  116094. * @returns an array populated with the removed particles
  116095. */
  116096. removeParticles(start: number, end: number): SolidParticle[];
  116097. /**
  116098. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  116099. * @param solidParticleArray an array populated with Solid Particles objects
  116100. * @returns the SPS
  116101. */
  116102. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  116103. /**
  116104. * Creates a new particle and modifies the SPS mesh geometry :
  116105. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  116106. * - calls _addParticle() to populate the particle array
  116107. * factorized code from addShape() and insertParticlesFromArray()
  116108. * @param idx particle index in the particles array
  116109. * @param i particle index in its shape
  116110. * @param modelShape particle ModelShape object
  116111. * @param shape shape vertex array
  116112. * @param meshInd shape indices array
  116113. * @param meshUV shape uv array
  116114. * @param meshCol shape color array
  116115. * @param meshNor shape normals array
  116116. * @param bbInfo shape bounding info
  116117. * @param storage target particle storage
  116118. * @options addShape() passed options
  116119. * @hidden
  116120. */
  116121. private _insertNewParticle;
  116122. /**
  116123. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  116124. * This method calls `updateParticle()` for each particle of the SPS.
  116125. * For an animated SPS, it is usually called within the render loop.
  116126. * 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.
  116127. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  116128. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  116129. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  116130. * @returns the SPS.
  116131. */
  116132. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  116133. /**
  116134. * Disposes the SPS.
  116135. */
  116136. dispose(): void;
  116137. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  116138. * idx is the particle index in the SPS
  116139. * faceId is the picked face index counted within this particle.
  116140. * Returns null if the pickInfo can't identify a picked particle.
  116141. * @param pickingInfo (PickingInfo object)
  116142. * @returns {idx: number, faceId: number} or null
  116143. */
  116144. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116145. idx: number;
  116146. faceId: number;
  116147. }>;
  116148. /**
  116149. * Returns a SolidParticle object from its identifier : particle.id
  116150. * @param id (integer) the particle Id
  116151. * @returns the searched particle or null if not found in the SPS.
  116152. */
  116153. getParticleById(id: number): Nullable<SolidParticle>;
  116154. /**
  116155. * Returns a new array populated with the particles having the passed shapeId.
  116156. * @param shapeId (integer) the shape identifier
  116157. * @returns a new solid particle array
  116158. */
  116159. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116160. /**
  116161. * Populates the passed array "ref" with the particles having the passed shapeId.
  116162. * @param shapeId the shape identifier
  116163. * @returns the SPS
  116164. * @param ref
  116165. */
  116166. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116167. /**
  116168. * Computes the required SubMeshes according the materials assigned to the particles.
  116169. * @returns the solid particle system.
  116170. * Does nothing if called before the SPS mesh is built.
  116171. */
  116172. computeSubMeshes(): SolidParticleSystem;
  116173. /**
  116174. * Sorts the solid particles by material when MultiMaterial is enabled.
  116175. * Updates the indices32 array.
  116176. * Updates the indicesByMaterial array.
  116177. * Updates the mesh indices array.
  116178. * @returns the SPS
  116179. * @hidden
  116180. */
  116181. private _sortParticlesByMaterial;
  116182. /**
  116183. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116184. * @hidden
  116185. */
  116186. private _setMaterialIndexesById;
  116187. /**
  116188. * Returns an array with unique values of Materials from the passed array
  116189. * @param array the material array to be checked and filtered
  116190. * @hidden
  116191. */
  116192. private _filterUniqueMaterialId;
  116193. /**
  116194. * Sets a new Standard Material as _defaultMaterial if not already set.
  116195. * @hidden
  116196. */
  116197. private _setDefaultMaterial;
  116198. /**
  116199. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116200. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116201. * @returns the SPS.
  116202. */
  116203. refreshVisibleSize(): SolidParticleSystem;
  116204. /**
  116205. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116206. * @param size the size (float) of the visibility box
  116207. * note : this doesn't lock the SPS mesh bounding box.
  116208. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116209. */
  116210. setVisibilityBox(size: number): void;
  116211. /**
  116212. * Gets whether the SPS as always visible or not
  116213. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116214. */
  116215. get isAlwaysVisible(): boolean;
  116216. /**
  116217. * Sets the SPS as always visible or not
  116218. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116219. */
  116220. set isAlwaysVisible(val: boolean);
  116221. /**
  116222. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116223. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116224. */
  116225. set isVisibilityBoxLocked(val: boolean);
  116226. /**
  116227. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116228. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116229. */
  116230. get isVisibilityBoxLocked(): boolean;
  116231. /**
  116232. * Tells to `setParticles()` to compute the particle rotations or not.
  116233. * Default value : true. The SPS is faster when it's set to false.
  116234. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116235. */
  116236. set computeParticleRotation(val: boolean);
  116237. /**
  116238. * Tells to `setParticles()` to compute the particle colors or not.
  116239. * Default value : true. The SPS is faster when it's set to false.
  116240. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116241. */
  116242. set computeParticleColor(val: boolean);
  116243. set computeParticleTexture(val: boolean);
  116244. /**
  116245. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116246. * Default value : false. The SPS is faster when it's set to false.
  116247. * Note : the particle custom vertex positions aren't stored values.
  116248. */
  116249. set computeParticleVertex(val: boolean);
  116250. /**
  116251. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116252. */
  116253. set computeBoundingBox(val: boolean);
  116254. /**
  116255. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116256. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116257. * Default : `true`
  116258. */
  116259. set depthSortParticles(val: boolean);
  116260. /**
  116261. * Gets if `setParticles()` computes the particle rotations or not.
  116262. * Default value : true. The SPS is faster when it's set to false.
  116263. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116264. */
  116265. get computeParticleRotation(): boolean;
  116266. /**
  116267. * Gets if `setParticles()` computes the particle colors or not.
  116268. * Default value : true. The SPS is faster when it's set to false.
  116269. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116270. */
  116271. get computeParticleColor(): boolean;
  116272. /**
  116273. * Gets if `setParticles()` computes the particle textures or not.
  116274. * Default value : true. The SPS is faster when it's set to false.
  116275. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116276. */
  116277. get computeParticleTexture(): boolean;
  116278. /**
  116279. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116280. * Default value : false. The SPS is faster when it's set to false.
  116281. * Note : the particle custom vertex positions aren't stored values.
  116282. */
  116283. get computeParticleVertex(): boolean;
  116284. /**
  116285. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116286. */
  116287. get computeBoundingBox(): boolean;
  116288. /**
  116289. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116290. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116291. * Default : `true`
  116292. */
  116293. get depthSortParticles(): boolean;
  116294. /**
  116295. * Gets if the SPS is created as expandable at construction time.
  116296. * Default : `false`
  116297. */
  116298. get expandable(): boolean;
  116299. /**
  116300. * Gets if the SPS supports the Multi Materials
  116301. */
  116302. get multimaterialEnabled(): boolean;
  116303. /**
  116304. * Gets if the SPS uses the model materials for its own multimaterial.
  116305. */
  116306. get useModelMaterial(): boolean;
  116307. /**
  116308. * The SPS used material array.
  116309. */
  116310. get materials(): Material[];
  116311. /**
  116312. * Sets the SPS MultiMaterial from the passed materials.
  116313. * Note : the passed array is internally copied and not used then by reference.
  116314. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116315. */
  116316. setMultiMaterial(materials: Material[]): void;
  116317. /**
  116318. * The SPS computed multimaterial object
  116319. */
  116320. get multimaterial(): MultiMaterial;
  116321. set multimaterial(mm: MultiMaterial);
  116322. /**
  116323. * If the subMeshes must be updated on the next call to setParticles()
  116324. */
  116325. get autoUpdateSubMeshes(): boolean;
  116326. set autoUpdateSubMeshes(val: boolean);
  116327. /**
  116328. * This function does nothing. It may be overwritten to set all the particle first values.
  116329. * The SPS doesn't call this function, you may have to call it by your own.
  116330. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116331. */
  116332. initParticles(): void;
  116333. /**
  116334. * This function does nothing. It may be overwritten to recycle a particle.
  116335. * The SPS doesn't call this function, you may have to call it by your own.
  116336. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116337. * @param particle The particle to recycle
  116338. * @returns the recycled particle
  116339. */
  116340. recycleParticle(particle: SolidParticle): SolidParticle;
  116341. /**
  116342. * Updates a particle : this function should be overwritten by the user.
  116343. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116344. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116345. * @example : just set a particle position or velocity and recycle conditions
  116346. * @param particle The particle to update
  116347. * @returns the updated particle
  116348. */
  116349. updateParticle(particle: SolidParticle): SolidParticle;
  116350. /**
  116351. * Updates a vertex of a particle : it can be overwritten by the user.
  116352. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116353. * @param particle the current particle
  116354. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116355. * @param pt the index of the current vertex in the particle shape
  116356. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116357. * @example : just set a vertex particle position or color
  116358. * @returns the sps
  116359. */
  116360. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116361. /**
  116362. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116363. * This does nothing and may be overwritten by the user.
  116364. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116365. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116366. * @param update the boolean update value actually passed to setParticles()
  116367. */
  116368. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116369. /**
  116370. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116371. * This will be passed three parameters.
  116372. * This does nothing and may be overwritten by the user.
  116373. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116374. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116375. * @param update the boolean update value actually passed to setParticles()
  116376. */
  116377. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116378. }
  116379. }
  116380. declare module BABYLON {
  116381. /**
  116382. * Represents one particle of a solid particle system.
  116383. */
  116384. export class SolidParticle {
  116385. /**
  116386. * particle global index
  116387. */
  116388. idx: number;
  116389. /**
  116390. * particle identifier
  116391. */
  116392. id: number;
  116393. /**
  116394. * The color of the particle
  116395. */
  116396. color: Nullable<Color4>;
  116397. /**
  116398. * The world space position of the particle.
  116399. */
  116400. position: Vector3;
  116401. /**
  116402. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116403. */
  116404. rotation: Vector3;
  116405. /**
  116406. * The world space rotation quaternion of the particle.
  116407. */
  116408. rotationQuaternion: Nullable<Quaternion>;
  116409. /**
  116410. * The scaling of the particle.
  116411. */
  116412. scaling: Vector3;
  116413. /**
  116414. * The uvs of the particle.
  116415. */
  116416. uvs: Vector4;
  116417. /**
  116418. * The current speed of the particle.
  116419. */
  116420. velocity: Vector3;
  116421. /**
  116422. * The pivot point in the particle local space.
  116423. */
  116424. pivot: Vector3;
  116425. /**
  116426. * Must the particle be translated from its pivot point in its local space ?
  116427. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116428. * Default : false
  116429. */
  116430. translateFromPivot: boolean;
  116431. /**
  116432. * Is the particle active or not ?
  116433. */
  116434. alive: boolean;
  116435. /**
  116436. * Is the particle visible or not ?
  116437. */
  116438. isVisible: boolean;
  116439. /**
  116440. * Index of this particle in the global "positions" array (Internal use)
  116441. * @hidden
  116442. */
  116443. _pos: number;
  116444. /**
  116445. * @hidden Index of this particle in the global "indices" array (Internal use)
  116446. */
  116447. _ind: number;
  116448. /**
  116449. * @hidden ModelShape of this particle (Internal use)
  116450. */
  116451. _model: ModelShape;
  116452. /**
  116453. * ModelShape id of this particle
  116454. */
  116455. shapeId: number;
  116456. /**
  116457. * Index of the particle in its shape id
  116458. */
  116459. idxInShape: number;
  116460. /**
  116461. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116462. */
  116463. _modelBoundingInfo: BoundingInfo;
  116464. /**
  116465. * @hidden Particle BoundingInfo object (Internal use)
  116466. */
  116467. _boundingInfo: BoundingInfo;
  116468. /**
  116469. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116470. */
  116471. _sps: SolidParticleSystem;
  116472. /**
  116473. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116474. */
  116475. _stillInvisible: boolean;
  116476. /**
  116477. * @hidden Last computed particle rotation matrix
  116478. */
  116479. _rotationMatrix: number[];
  116480. /**
  116481. * Parent particle Id, if any.
  116482. * Default null.
  116483. */
  116484. parentId: Nullable<number>;
  116485. /**
  116486. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116487. */
  116488. materialIndex: Nullable<number>;
  116489. /**
  116490. * Custom object or properties.
  116491. */
  116492. props: Nullable<any>;
  116493. /**
  116494. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116495. * The possible values are :
  116496. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116497. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116498. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116499. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116500. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116501. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116502. * */
  116503. cullingStrategy: number;
  116504. /**
  116505. * @hidden Internal global position in the SPS.
  116506. */
  116507. _globalPosition: Vector3;
  116508. /**
  116509. * Creates a Solid Particle object.
  116510. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116511. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116512. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116513. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116514. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116515. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116516. * @param shapeId (integer) is the model shape identifier in the SPS.
  116517. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116518. * @param sps defines the sps it is associated to
  116519. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116520. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116521. */
  116522. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116523. /**
  116524. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116525. * @param target the particle target
  116526. * @returns the current particle
  116527. */
  116528. copyToRef(target: SolidParticle): SolidParticle;
  116529. /**
  116530. * Legacy support, changed scale to scaling
  116531. */
  116532. get scale(): Vector3;
  116533. /**
  116534. * Legacy support, changed scale to scaling
  116535. */
  116536. set scale(scale: Vector3);
  116537. /**
  116538. * Legacy support, changed quaternion to rotationQuaternion
  116539. */
  116540. get quaternion(): Nullable<Quaternion>;
  116541. /**
  116542. * Legacy support, changed quaternion to rotationQuaternion
  116543. */
  116544. set quaternion(q: Nullable<Quaternion>);
  116545. /**
  116546. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116547. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116548. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116549. * @returns true if it intersects
  116550. */
  116551. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116552. /**
  116553. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116554. * A particle is in the frustum if its bounding box intersects the frustum
  116555. * @param frustumPlanes defines the frustum to test
  116556. * @returns true if the particle is in the frustum planes
  116557. */
  116558. isInFrustum(frustumPlanes: Plane[]): boolean;
  116559. /**
  116560. * get the rotation matrix of the particle
  116561. * @hidden
  116562. */
  116563. getRotationMatrix(m: Matrix): void;
  116564. }
  116565. /**
  116566. * Represents the shape of the model used by one particle of a solid particle system.
  116567. * SPS internal tool, don't use it manually.
  116568. */
  116569. export class ModelShape {
  116570. /**
  116571. * The shape id
  116572. * @hidden
  116573. */
  116574. shapeID: number;
  116575. /**
  116576. * flat array of model positions (internal use)
  116577. * @hidden
  116578. */
  116579. _shape: Vector3[];
  116580. /**
  116581. * flat array of model UVs (internal use)
  116582. * @hidden
  116583. */
  116584. _shapeUV: number[];
  116585. /**
  116586. * color array of the model
  116587. * @hidden
  116588. */
  116589. _shapeColors: number[];
  116590. /**
  116591. * indices array of the model
  116592. * @hidden
  116593. */
  116594. _indices: number[];
  116595. /**
  116596. * normals array of the model
  116597. * @hidden
  116598. */
  116599. _normals: number[];
  116600. /**
  116601. * length of the shape in the model indices array (internal use)
  116602. * @hidden
  116603. */
  116604. _indicesLength: number;
  116605. /**
  116606. * Custom position function (internal use)
  116607. * @hidden
  116608. */
  116609. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116610. /**
  116611. * Custom vertex function (internal use)
  116612. * @hidden
  116613. */
  116614. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116615. /**
  116616. * Model material (internal use)
  116617. * @hidden
  116618. */
  116619. _material: Nullable<Material>;
  116620. /**
  116621. * 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.
  116622. * SPS internal tool, don't use it manually.
  116623. * @hidden
  116624. */
  116625. 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>);
  116626. }
  116627. /**
  116628. * Represents a Depth Sorted Particle in the solid particle system.
  116629. * @hidden
  116630. */
  116631. export class DepthSortedParticle {
  116632. /**
  116633. * Particle index
  116634. */
  116635. idx: number;
  116636. /**
  116637. * Index of the particle in the "indices" array
  116638. */
  116639. ind: number;
  116640. /**
  116641. * Length of the particle shape in the "indices" array
  116642. */
  116643. indicesLength: number;
  116644. /**
  116645. * Squared distance from the particle to the camera
  116646. */
  116647. sqDistance: number;
  116648. /**
  116649. * Material index when used with MultiMaterials
  116650. */
  116651. materialIndex: number;
  116652. /**
  116653. * Creates a new sorted particle
  116654. * @param materialIndex
  116655. */
  116656. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116657. }
  116658. /**
  116659. * Represents a solid particle vertex
  116660. */
  116661. export class SolidParticleVertex {
  116662. /**
  116663. * Vertex position
  116664. */
  116665. position: Vector3;
  116666. /**
  116667. * Vertex color
  116668. */
  116669. color: Color4;
  116670. /**
  116671. * Vertex UV
  116672. */
  116673. uv: Vector2;
  116674. /**
  116675. * Creates a new solid particle vertex
  116676. */
  116677. constructor();
  116678. /** Vertex x coordinate */
  116679. get x(): number;
  116680. set x(val: number);
  116681. /** Vertex y coordinate */
  116682. get y(): number;
  116683. set y(val: number);
  116684. /** Vertex z coordinate */
  116685. get z(): number;
  116686. set z(val: number);
  116687. }
  116688. }
  116689. declare module BABYLON {
  116690. /**
  116691. * @hidden
  116692. */
  116693. export class _MeshCollisionData {
  116694. _checkCollisions: boolean;
  116695. _collisionMask: number;
  116696. _collisionGroup: number;
  116697. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116698. _collider: Nullable<Collider>;
  116699. _oldPositionForCollisions: Vector3;
  116700. _diffPositionForCollisions: Vector3;
  116701. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116702. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116703. _collisionResponse: boolean;
  116704. }
  116705. }
  116706. declare module BABYLON {
  116707. /** @hidden */
  116708. class _FacetDataStorage {
  116709. facetPositions: Vector3[];
  116710. facetNormals: Vector3[];
  116711. facetPartitioning: number[][];
  116712. facetNb: number;
  116713. partitioningSubdivisions: number;
  116714. partitioningBBoxRatio: number;
  116715. facetDataEnabled: boolean;
  116716. facetParameters: any;
  116717. bbSize: Vector3;
  116718. subDiv: {
  116719. max: number;
  116720. X: number;
  116721. Y: number;
  116722. Z: number;
  116723. };
  116724. facetDepthSort: boolean;
  116725. facetDepthSortEnabled: boolean;
  116726. depthSortedIndices: IndicesArray;
  116727. depthSortedFacets: {
  116728. ind: number;
  116729. sqDistance: number;
  116730. }[];
  116731. facetDepthSortFunction: (f1: {
  116732. ind: number;
  116733. sqDistance: number;
  116734. }, f2: {
  116735. ind: number;
  116736. sqDistance: number;
  116737. }) => number;
  116738. facetDepthSortFrom: Vector3;
  116739. facetDepthSortOrigin: Vector3;
  116740. invertedMatrix: Matrix;
  116741. }
  116742. /**
  116743. * @hidden
  116744. **/
  116745. class _InternalAbstractMeshDataInfo {
  116746. _hasVertexAlpha: boolean;
  116747. _useVertexColors: boolean;
  116748. _numBoneInfluencers: number;
  116749. _applyFog: boolean;
  116750. _receiveShadows: boolean;
  116751. _facetData: _FacetDataStorage;
  116752. _visibility: number;
  116753. _skeleton: Nullable<Skeleton>;
  116754. _layerMask: number;
  116755. _computeBonesUsingShaders: boolean;
  116756. _isActive: boolean;
  116757. _onlyForInstances: boolean;
  116758. _isActiveIntermediate: boolean;
  116759. _onlyForInstancesIntermediate: boolean;
  116760. _actAsRegularMesh: boolean;
  116761. _currentLOD: Nullable<AbstractMesh>;
  116762. _currentLODIsUpToDate: boolean;
  116763. }
  116764. /**
  116765. * Class used to store all common mesh properties
  116766. */
  116767. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116768. /** No occlusion */
  116769. static OCCLUSION_TYPE_NONE: number;
  116770. /** Occlusion set to optimisitic */
  116771. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116772. /** Occlusion set to strict */
  116773. static OCCLUSION_TYPE_STRICT: number;
  116774. /** Use an accurante occlusion algorithm */
  116775. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116776. /** Use a conservative occlusion algorithm */
  116777. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116778. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116779. * Test order :
  116780. * Is the bounding sphere outside the frustum ?
  116781. * If not, are the bounding box vertices outside the frustum ?
  116782. * It not, then the cullable object is in the frustum.
  116783. */
  116784. static readonly CULLINGSTRATEGY_STANDARD: number;
  116785. /** Culling strategy : Bounding Sphere Only.
  116786. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116787. * It's also less accurate than the standard because some not visible objects can still be selected.
  116788. * Test : is the bounding sphere outside the frustum ?
  116789. * If not, then the cullable object is in the frustum.
  116790. */
  116791. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116792. /** Culling strategy : Optimistic Inclusion.
  116793. * This in an inclusion test first, then the standard exclusion test.
  116794. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116795. * 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.
  116796. * Anyway, it's as accurate as the standard strategy.
  116797. * Test :
  116798. * Is the cullable object bounding sphere center in the frustum ?
  116799. * If not, apply the default culling strategy.
  116800. */
  116801. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116802. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116803. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116804. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116805. * 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.
  116806. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116807. * Test :
  116808. * Is the cullable object bounding sphere center in the frustum ?
  116809. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116810. */
  116811. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116812. /**
  116813. * No billboard
  116814. */
  116815. static get BILLBOARDMODE_NONE(): number;
  116816. /** Billboard on X axis */
  116817. static get BILLBOARDMODE_X(): number;
  116818. /** Billboard on Y axis */
  116819. static get BILLBOARDMODE_Y(): number;
  116820. /** Billboard on Z axis */
  116821. static get BILLBOARDMODE_Z(): number;
  116822. /** Billboard on all axes */
  116823. static get BILLBOARDMODE_ALL(): number;
  116824. /** Billboard on using position instead of orientation */
  116825. static get BILLBOARDMODE_USE_POSITION(): number;
  116826. /** @hidden */
  116827. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116828. /**
  116829. * The culling strategy to use to check whether the mesh must be rendered or not.
  116830. * This value can be changed at any time and will be used on the next render mesh selection.
  116831. * The possible values are :
  116832. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116833. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116834. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116835. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116836. * Please read each static variable documentation to get details about the culling process.
  116837. * */
  116838. cullingStrategy: number;
  116839. /**
  116840. * Gets the number of facets in the mesh
  116841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116842. */
  116843. get facetNb(): number;
  116844. /**
  116845. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116846. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116847. */
  116848. get partitioningSubdivisions(): number;
  116849. set partitioningSubdivisions(nb: number);
  116850. /**
  116851. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116852. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116854. */
  116855. get partitioningBBoxRatio(): number;
  116856. set partitioningBBoxRatio(ratio: number);
  116857. /**
  116858. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116859. * Works only for updatable meshes.
  116860. * Doesn't work with multi-materials
  116861. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116862. */
  116863. get mustDepthSortFacets(): boolean;
  116864. set mustDepthSortFacets(sort: boolean);
  116865. /**
  116866. * The location (Vector3) where the facet depth sort must be computed from.
  116867. * By default, the active camera position.
  116868. * Used only when facet depth sort is enabled
  116869. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116870. */
  116871. get facetDepthSortFrom(): Vector3;
  116872. set facetDepthSortFrom(location: Vector3);
  116873. /**
  116874. * gets a boolean indicating if facetData is enabled
  116875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116876. */
  116877. get isFacetDataEnabled(): boolean;
  116878. /** @hidden */
  116879. _updateNonUniformScalingState(value: boolean): boolean;
  116880. /**
  116881. * An event triggered when this mesh collides with another one
  116882. */
  116883. onCollideObservable: Observable<AbstractMesh>;
  116884. /** Set a function to call when this mesh collides with another one */
  116885. set onCollide(callback: () => void);
  116886. /**
  116887. * An event triggered when the collision's position changes
  116888. */
  116889. onCollisionPositionChangeObservable: Observable<Vector3>;
  116890. /** Set a function to call when the collision's position changes */
  116891. set onCollisionPositionChange(callback: () => void);
  116892. /**
  116893. * An event triggered when material is changed
  116894. */
  116895. onMaterialChangedObservable: Observable<AbstractMesh>;
  116896. /**
  116897. * Gets or sets the orientation for POV movement & rotation
  116898. */
  116899. definedFacingForward: boolean;
  116900. /** @hidden */
  116901. _occlusionQuery: Nullable<WebGLQuery>;
  116902. /** @hidden */
  116903. _renderingGroup: Nullable<RenderingGroup>;
  116904. /**
  116905. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116906. */
  116907. get visibility(): number;
  116908. /**
  116909. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116910. */
  116911. set visibility(value: number);
  116912. /** Gets or sets the alpha index used to sort transparent meshes
  116913. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116914. */
  116915. alphaIndex: number;
  116916. /**
  116917. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116918. */
  116919. isVisible: boolean;
  116920. /**
  116921. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116922. */
  116923. isPickable: boolean;
  116924. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116925. showSubMeshesBoundingBox: boolean;
  116926. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116927. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116928. */
  116929. isBlocker: boolean;
  116930. /**
  116931. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116932. */
  116933. enablePointerMoveEvents: boolean;
  116934. private _renderingGroupId;
  116935. /**
  116936. * Specifies the rendering group id for this mesh (0 by default)
  116937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116938. */
  116939. get renderingGroupId(): number;
  116940. set renderingGroupId(value: number);
  116941. private _material;
  116942. /** Gets or sets current material */
  116943. get material(): Nullable<Material>;
  116944. set material(value: Nullable<Material>);
  116945. /**
  116946. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116947. * @see https://doc.babylonjs.com/babylon101/shadows
  116948. */
  116949. get receiveShadows(): boolean;
  116950. set receiveShadows(value: boolean);
  116951. /** Defines color to use when rendering outline */
  116952. outlineColor: Color3;
  116953. /** Define width to use when rendering outline */
  116954. outlineWidth: number;
  116955. /** Defines color to use when rendering overlay */
  116956. overlayColor: Color3;
  116957. /** Defines alpha to use when rendering overlay */
  116958. overlayAlpha: number;
  116959. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116960. get hasVertexAlpha(): boolean;
  116961. set hasVertexAlpha(value: boolean);
  116962. /** 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) */
  116963. get useVertexColors(): boolean;
  116964. set useVertexColors(value: boolean);
  116965. /**
  116966. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116967. */
  116968. get computeBonesUsingShaders(): boolean;
  116969. set computeBonesUsingShaders(value: boolean);
  116970. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116971. get numBoneInfluencers(): number;
  116972. set numBoneInfluencers(value: number);
  116973. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116974. get applyFog(): boolean;
  116975. set applyFog(value: boolean);
  116976. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116977. useOctreeForRenderingSelection: boolean;
  116978. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116979. useOctreeForPicking: boolean;
  116980. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116981. useOctreeForCollisions: boolean;
  116982. /**
  116983. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116984. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116985. */
  116986. get layerMask(): number;
  116987. set layerMask(value: number);
  116988. /**
  116989. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116990. */
  116991. alwaysSelectAsActiveMesh: boolean;
  116992. /**
  116993. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116994. */
  116995. doNotSyncBoundingInfo: boolean;
  116996. /**
  116997. * Gets or sets the current action manager
  116998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116999. */
  117000. actionManager: Nullable<AbstractActionManager>;
  117001. private _meshCollisionData;
  117002. /**
  117003. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  117004. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117005. */
  117006. ellipsoid: Vector3;
  117007. /**
  117008. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  117009. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117010. */
  117011. ellipsoidOffset: Vector3;
  117012. /**
  117013. * Gets or sets a collision mask used to mask collisions (default is -1).
  117014. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  117015. */
  117016. get collisionMask(): number;
  117017. set collisionMask(mask: number);
  117018. /**
  117019. * Gets or sets a collision response flag (default is true).
  117020. * when collisionResponse is false, events are still triggered but colliding entity has no response
  117021. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  117022. * to respond to the collision.
  117023. */
  117024. get collisionResponse(): boolean;
  117025. set collisionResponse(response: boolean);
  117026. /**
  117027. * Gets or sets the current collision group mask (-1 by default).
  117028. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  117029. */
  117030. get collisionGroup(): number;
  117031. set collisionGroup(mask: number);
  117032. /**
  117033. * Gets or sets current surrounding meshes (null by default).
  117034. *
  117035. * By default collision detection is tested against every mesh in the scene.
  117036. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  117037. * meshes will be tested for the collision.
  117038. *
  117039. * Note: if set to an empty array no collision will happen when this mesh is moved.
  117040. */
  117041. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  117042. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  117043. /**
  117044. * Defines edge width used when edgesRenderer is enabled
  117045. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117046. */
  117047. edgesWidth: number;
  117048. /**
  117049. * Defines edge color used when edgesRenderer is enabled
  117050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117051. */
  117052. edgesColor: Color4;
  117053. /** @hidden */
  117054. _edgesRenderer: Nullable<IEdgesRenderer>;
  117055. /** @hidden */
  117056. _masterMesh: Nullable<AbstractMesh>;
  117057. /** @hidden */
  117058. _boundingInfo: Nullable<BoundingInfo>;
  117059. /** @hidden */
  117060. _renderId: number;
  117061. /**
  117062. * Gets or sets the list of subMeshes
  117063. * @see https://doc.babylonjs.com/how_to/multi_materials
  117064. */
  117065. subMeshes: SubMesh[];
  117066. /** @hidden */
  117067. _intersectionsInProgress: AbstractMesh[];
  117068. /** @hidden */
  117069. _unIndexed: boolean;
  117070. /** @hidden */
  117071. _lightSources: Light[];
  117072. /** Gets the list of lights affecting that mesh */
  117073. get lightSources(): Light[];
  117074. /** @hidden */
  117075. get _positions(): Nullable<Vector3[]>;
  117076. /** @hidden */
  117077. _waitingData: {
  117078. lods: Nullable<any>;
  117079. actions: Nullable<any>;
  117080. freezeWorldMatrix: Nullable<boolean>;
  117081. };
  117082. /** @hidden */
  117083. _bonesTransformMatrices: Nullable<Float32Array>;
  117084. /** @hidden */
  117085. _transformMatrixTexture: Nullable<RawTexture>;
  117086. /**
  117087. * Gets or sets a skeleton to apply skining transformations
  117088. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117089. */
  117090. set skeleton(value: Nullable<Skeleton>);
  117091. get skeleton(): Nullable<Skeleton>;
  117092. /**
  117093. * An event triggered when the mesh is rebuilt.
  117094. */
  117095. onRebuildObservable: Observable<AbstractMesh>;
  117096. /**
  117097. * Creates a new AbstractMesh
  117098. * @param name defines the name of the mesh
  117099. * @param scene defines the hosting scene
  117100. */
  117101. constructor(name: string, scene?: Nullable<Scene>);
  117102. /**
  117103. * Returns the string "AbstractMesh"
  117104. * @returns "AbstractMesh"
  117105. */
  117106. getClassName(): string;
  117107. /**
  117108. * Gets a string representation of the current mesh
  117109. * @param fullDetails defines a boolean indicating if full details must be included
  117110. * @returns a string representation of the current mesh
  117111. */
  117112. toString(fullDetails?: boolean): string;
  117113. /**
  117114. * @hidden
  117115. */
  117116. protected _getEffectiveParent(): Nullable<Node>;
  117117. /** @hidden */
  117118. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117119. /** @hidden */
  117120. _rebuild(): void;
  117121. /** @hidden */
  117122. _resyncLightSources(): void;
  117123. /** @hidden */
  117124. _resyncLightSource(light: Light): void;
  117125. /** @hidden */
  117126. _unBindEffect(): void;
  117127. /** @hidden */
  117128. _removeLightSource(light: Light, dispose: boolean): void;
  117129. private _markSubMeshesAsDirty;
  117130. /** @hidden */
  117131. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  117132. /** @hidden */
  117133. _markSubMeshesAsAttributesDirty(): void;
  117134. /** @hidden */
  117135. _markSubMeshesAsMiscDirty(): void;
  117136. /**
  117137. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  117138. */
  117139. get scaling(): Vector3;
  117140. set scaling(newScaling: Vector3);
  117141. /**
  117142. * Returns true if the mesh is blocked. Implemented by child classes
  117143. */
  117144. get isBlocked(): boolean;
  117145. /**
  117146. * Returns the mesh itself by default. Implemented by child classes
  117147. * @param camera defines the camera to use to pick the right LOD level
  117148. * @returns the currentAbstractMesh
  117149. */
  117150. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117151. /**
  117152. * Returns 0 by default. Implemented by child classes
  117153. * @returns an integer
  117154. */
  117155. getTotalVertices(): number;
  117156. /**
  117157. * Returns a positive integer : the total number of indices in this mesh geometry.
  117158. * @returns the numner of indices or zero if the mesh has no geometry.
  117159. */
  117160. getTotalIndices(): number;
  117161. /**
  117162. * Returns null by default. Implemented by child classes
  117163. * @returns null
  117164. */
  117165. getIndices(): Nullable<IndicesArray>;
  117166. /**
  117167. * Returns the array of the requested vertex data kind. Implemented by child classes
  117168. * @param kind defines the vertex data kind to use
  117169. * @returns null
  117170. */
  117171. getVerticesData(kind: string): Nullable<FloatArray>;
  117172. /**
  117173. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117174. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117175. * Note that a new underlying VertexBuffer object is created each call.
  117176. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117177. * @param kind defines vertex data kind:
  117178. * * VertexBuffer.PositionKind
  117179. * * VertexBuffer.UVKind
  117180. * * VertexBuffer.UV2Kind
  117181. * * VertexBuffer.UV3Kind
  117182. * * VertexBuffer.UV4Kind
  117183. * * VertexBuffer.UV5Kind
  117184. * * VertexBuffer.UV6Kind
  117185. * * VertexBuffer.ColorKind
  117186. * * VertexBuffer.MatricesIndicesKind
  117187. * * VertexBuffer.MatricesIndicesExtraKind
  117188. * * VertexBuffer.MatricesWeightsKind
  117189. * * VertexBuffer.MatricesWeightsExtraKind
  117190. * @param data defines the data source
  117191. * @param updatable defines if the data must be flagged as updatable (or static)
  117192. * @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
  117193. * @returns the current mesh
  117194. */
  117195. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117196. /**
  117197. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117198. * If the mesh has no geometry, it is simply returned as it is.
  117199. * @param kind defines vertex data kind:
  117200. * * VertexBuffer.PositionKind
  117201. * * VertexBuffer.UVKind
  117202. * * VertexBuffer.UV2Kind
  117203. * * VertexBuffer.UV3Kind
  117204. * * VertexBuffer.UV4Kind
  117205. * * VertexBuffer.UV5Kind
  117206. * * VertexBuffer.UV6Kind
  117207. * * VertexBuffer.ColorKind
  117208. * * VertexBuffer.MatricesIndicesKind
  117209. * * VertexBuffer.MatricesIndicesExtraKind
  117210. * * VertexBuffer.MatricesWeightsKind
  117211. * * VertexBuffer.MatricesWeightsExtraKind
  117212. * @param data defines the data source
  117213. * @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
  117214. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117215. * @returns the current mesh
  117216. */
  117217. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117218. /**
  117219. * Sets the mesh indices,
  117220. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117221. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117222. * @param totalVertices Defines the total number of vertices
  117223. * @returns the current mesh
  117224. */
  117225. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117226. /**
  117227. * Gets a boolean indicating if specific vertex data is present
  117228. * @param kind defines the vertex data kind to use
  117229. * @returns true is data kind is present
  117230. */
  117231. isVerticesDataPresent(kind: string): boolean;
  117232. /**
  117233. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117234. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117235. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117236. * @returns a BoundingInfo
  117237. */
  117238. getBoundingInfo(): BoundingInfo;
  117239. /**
  117240. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117241. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117242. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117243. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117244. * @returns the current mesh
  117245. */
  117246. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117247. /**
  117248. * Overwrite the current bounding info
  117249. * @param boundingInfo defines the new bounding info
  117250. * @returns the current mesh
  117251. */
  117252. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117253. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117254. get useBones(): boolean;
  117255. /** @hidden */
  117256. _preActivate(): void;
  117257. /** @hidden */
  117258. _preActivateForIntermediateRendering(renderId: number): void;
  117259. /** @hidden */
  117260. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117261. /** @hidden */
  117262. _postActivate(): void;
  117263. /** @hidden */
  117264. _freeze(): void;
  117265. /** @hidden */
  117266. _unFreeze(): void;
  117267. /**
  117268. * Gets the current world matrix
  117269. * @returns a Matrix
  117270. */
  117271. getWorldMatrix(): Matrix;
  117272. /** @hidden */
  117273. _getWorldMatrixDeterminant(): number;
  117274. /**
  117275. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117276. */
  117277. get isAnInstance(): boolean;
  117278. /**
  117279. * Gets a boolean indicating if this mesh has instances
  117280. */
  117281. get hasInstances(): boolean;
  117282. /**
  117283. * Gets a boolean indicating if this mesh has thin instances
  117284. */
  117285. get hasThinInstances(): boolean;
  117286. /**
  117287. * Perform relative position change from the point of view of behind the front of the mesh.
  117288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117289. * Supports definition of mesh facing forward or backward
  117290. * @param amountRight defines the distance on the right axis
  117291. * @param amountUp defines the distance on the up axis
  117292. * @param amountForward defines the distance on the forward axis
  117293. * @returns the current mesh
  117294. */
  117295. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117296. /**
  117297. * Calculate relative position change from the point of view of behind the front of the mesh.
  117298. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117299. * Supports definition of mesh facing forward or backward
  117300. * @param amountRight defines the distance on the right axis
  117301. * @param amountUp defines the distance on the up axis
  117302. * @param amountForward defines the distance on the forward axis
  117303. * @returns the new displacement vector
  117304. */
  117305. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117306. /**
  117307. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117308. * Supports definition of mesh facing forward or backward
  117309. * @param flipBack defines the flip
  117310. * @param twirlClockwise defines the twirl
  117311. * @param tiltRight defines the tilt
  117312. * @returns the current mesh
  117313. */
  117314. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117315. /**
  117316. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117317. * Supports definition of mesh facing forward or backward.
  117318. * @param flipBack defines the flip
  117319. * @param twirlClockwise defines the twirl
  117320. * @param tiltRight defines the tilt
  117321. * @returns the new rotation vector
  117322. */
  117323. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117324. /**
  117325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117326. * This means the mesh underlying bounding box and sphere are recomputed.
  117327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117328. * @returns the current mesh
  117329. */
  117330. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117331. /** @hidden */
  117332. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117333. /** @hidden */
  117334. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117335. /** @hidden */
  117336. _updateBoundingInfo(): AbstractMesh;
  117337. /** @hidden */
  117338. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117339. /** @hidden */
  117340. protected _afterComputeWorldMatrix(): void;
  117341. /** @hidden */
  117342. get _effectiveMesh(): AbstractMesh;
  117343. /**
  117344. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117345. * A mesh is in the frustum if its bounding box intersects the frustum
  117346. * @param frustumPlanes defines the frustum to test
  117347. * @returns true if the mesh is in the frustum planes
  117348. */
  117349. isInFrustum(frustumPlanes: Plane[]): boolean;
  117350. /**
  117351. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117352. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117353. * @param frustumPlanes defines the frustum to test
  117354. * @returns true if the mesh is completely in the frustum planes
  117355. */
  117356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117357. /**
  117358. * True if the mesh intersects another mesh or a SolidParticle object
  117359. * @param mesh defines a target mesh or SolidParticle to test
  117360. * @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)
  117361. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117362. * @returns true if there is an intersection
  117363. */
  117364. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117365. /**
  117366. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117367. * @param point defines the point to test
  117368. * @returns true if there is an intersection
  117369. */
  117370. intersectsPoint(point: Vector3): boolean;
  117371. /**
  117372. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117373. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117374. */
  117375. get checkCollisions(): boolean;
  117376. set checkCollisions(collisionEnabled: boolean);
  117377. /**
  117378. * Gets Collider object used to compute collisions (not physics)
  117379. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117380. */
  117381. get collider(): Nullable<Collider>;
  117382. /**
  117383. * Move the mesh using collision engine
  117384. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117385. * @param displacement defines the requested displacement vector
  117386. * @returns the current mesh
  117387. */
  117388. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117389. private _onCollisionPositionChange;
  117390. /** @hidden */
  117391. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117392. /** @hidden */
  117393. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117394. /** @hidden */
  117395. _checkCollision(collider: Collider): AbstractMesh;
  117396. /** @hidden */
  117397. _generatePointsArray(): boolean;
  117398. /**
  117399. * Checks if the passed Ray intersects with the mesh
  117400. * @param ray defines the ray to use
  117401. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117403. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117404. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117405. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117406. * @returns the picking info
  117407. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117408. */
  117409. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117410. /**
  117411. * Clones the current mesh
  117412. * @param name defines the mesh name
  117413. * @param newParent defines the new mesh parent
  117414. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117415. * @returns the new mesh
  117416. */
  117417. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117418. /**
  117419. * Disposes all the submeshes of the current meshnp
  117420. * @returns the current mesh
  117421. */
  117422. releaseSubMeshes(): AbstractMesh;
  117423. /**
  117424. * Releases resources associated with this abstract mesh.
  117425. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117426. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117427. */
  117428. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117429. /**
  117430. * Adds the passed mesh as a child to the current mesh
  117431. * @param mesh defines the child mesh
  117432. * @returns the current mesh
  117433. */
  117434. addChild(mesh: AbstractMesh): AbstractMesh;
  117435. /**
  117436. * Removes the passed mesh from the current mesh children list
  117437. * @param mesh defines the child mesh
  117438. * @returns the current mesh
  117439. */
  117440. removeChild(mesh: AbstractMesh): AbstractMesh;
  117441. /** @hidden */
  117442. private _initFacetData;
  117443. /**
  117444. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117445. * This method can be called within the render loop.
  117446. * 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
  117447. * @returns the current mesh
  117448. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117449. */
  117450. updateFacetData(): AbstractMesh;
  117451. /**
  117452. * Returns the facetLocalNormals array.
  117453. * The normals are expressed in the mesh local spac
  117454. * @returns an array of Vector3
  117455. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117456. */
  117457. getFacetLocalNormals(): Vector3[];
  117458. /**
  117459. * Returns the facetLocalPositions array.
  117460. * The facet positions are expressed in the mesh local space
  117461. * @returns an array of Vector3
  117462. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117463. */
  117464. getFacetLocalPositions(): Vector3[];
  117465. /**
  117466. * Returns the facetLocalPartioning array
  117467. * @returns an array of array of numbers
  117468. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117469. */
  117470. getFacetLocalPartitioning(): number[][];
  117471. /**
  117472. * Returns the i-th facet position in the world system.
  117473. * This method allocates a new Vector3 per call
  117474. * @param i defines the facet index
  117475. * @returns a new Vector3
  117476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117477. */
  117478. getFacetPosition(i: number): Vector3;
  117479. /**
  117480. * Sets the reference Vector3 with the i-th facet position in the world system
  117481. * @param i defines the facet index
  117482. * @param ref defines the target vector
  117483. * @returns the current mesh
  117484. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117485. */
  117486. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117487. /**
  117488. * Returns the i-th facet normal in the world system.
  117489. * This method allocates a new Vector3 per call
  117490. * @param i defines the facet index
  117491. * @returns a new Vector3
  117492. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117493. */
  117494. getFacetNormal(i: number): Vector3;
  117495. /**
  117496. * Sets the reference Vector3 with the i-th facet normal in the world system
  117497. * @param i defines the facet index
  117498. * @param ref defines the target vector
  117499. * @returns the current mesh
  117500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117501. */
  117502. getFacetNormalToRef(i: number, ref: Vector3): this;
  117503. /**
  117504. * 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)
  117505. * @param x defines x coordinate
  117506. * @param y defines y coordinate
  117507. * @param z defines z coordinate
  117508. * @returns the array of facet indexes
  117509. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117510. */
  117511. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117512. /**
  117513. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117514. * @param projected sets as the (x,y,z) world projection on the facet
  117515. * @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
  117516. * @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
  117517. * @param x defines x coordinate
  117518. * @param y defines y coordinate
  117519. * @param z defines z coordinate
  117520. * @returns the face index if found (or null instead)
  117521. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117522. */
  117523. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117524. /**
  117525. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117526. * @param projected sets as the (x,y,z) local projection on the facet
  117527. * @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
  117528. * @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
  117529. * @param x defines x coordinate
  117530. * @param y defines y coordinate
  117531. * @param z defines z coordinate
  117532. * @returns the face index if found (or null instead)
  117533. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117534. */
  117535. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117536. /**
  117537. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117538. * @returns the parameters
  117539. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117540. */
  117541. getFacetDataParameters(): any;
  117542. /**
  117543. * Disables the feature FacetData and frees the related memory
  117544. * @returns the current mesh
  117545. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117546. */
  117547. disableFacetData(): AbstractMesh;
  117548. /**
  117549. * Updates the AbstractMesh indices array
  117550. * @param indices defines the data source
  117551. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117552. * @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)
  117553. * @returns the current mesh
  117554. */
  117555. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117556. /**
  117557. * Creates new normals data for the mesh
  117558. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117559. * @returns the current mesh
  117560. */
  117561. createNormals(updatable: boolean): AbstractMesh;
  117562. /**
  117563. * Align the mesh with a normal
  117564. * @param normal defines the normal to use
  117565. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117566. * @returns the current mesh
  117567. */
  117568. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117569. /** @hidden */
  117570. _checkOcclusionQuery(): boolean;
  117571. /**
  117572. * Disables the mesh edge rendering mode
  117573. * @returns the currentAbstractMesh
  117574. */
  117575. disableEdgesRendering(): AbstractMesh;
  117576. /**
  117577. * Enables the edge rendering mode on the mesh.
  117578. * This mode makes the mesh edges visible
  117579. * @param epsilon defines the maximal distance between two angles to detect a face
  117580. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117581. * @param options options to the edge renderer
  117582. * @returns the currentAbstractMesh
  117583. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117584. */
  117585. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117586. /**
  117587. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117588. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117589. */
  117590. getConnectedParticleSystems(): IParticleSystem[];
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /**
  117595. * Interface used to define ActionEvent
  117596. */
  117597. export interface IActionEvent {
  117598. /** The mesh or sprite that triggered the action */
  117599. source: any;
  117600. /** The X mouse cursor position at the time of the event */
  117601. pointerX: number;
  117602. /** The Y mouse cursor position at the time of the event */
  117603. pointerY: number;
  117604. /** The mesh that is currently pointed at (can be null) */
  117605. meshUnderPointer: Nullable<AbstractMesh>;
  117606. /** the original (browser) event that triggered the ActionEvent */
  117607. sourceEvent?: any;
  117608. /** additional data for the event */
  117609. additionalData?: any;
  117610. }
  117611. /**
  117612. * ActionEvent is the event being sent when an action is triggered.
  117613. */
  117614. export class ActionEvent implements IActionEvent {
  117615. /** The mesh or sprite that triggered the action */
  117616. source: any;
  117617. /** The X mouse cursor position at the time of the event */
  117618. pointerX: number;
  117619. /** The Y mouse cursor position at the time of the event */
  117620. pointerY: number;
  117621. /** The mesh that is currently pointed at (can be null) */
  117622. meshUnderPointer: Nullable<AbstractMesh>;
  117623. /** the original (browser) event that triggered the ActionEvent */
  117624. sourceEvent?: any;
  117625. /** additional data for the event */
  117626. additionalData?: any;
  117627. /**
  117628. * Creates a new ActionEvent
  117629. * @param source The mesh or sprite that triggered the action
  117630. * @param pointerX The X mouse cursor position at the time of the event
  117631. * @param pointerY The Y mouse cursor position at the time of the event
  117632. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117633. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117634. * @param additionalData additional data for the event
  117635. */
  117636. constructor(
  117637. /** The mesh or sprite that triggered the action */
  117638. source: any,
  117639. /** The X mouse cursor position at the time of the event */
  117640. pointerX: number,
  117641. /** The Y mouse cursor position at the time of the event */
  117642. pointerY: number,
  117643. /** The mesh that is currently pointed at (can be null) */
  117644. meshUnderPointer: Nullable<AbstractMesh>,
  117645. /** the original (browser) event that triggered the ActionEvent */
  117646. sourceEvent?: any,
  117647. /** additional data for the event */
  117648. additionalData?: any);
  117649. /**
  117650. * Helper function to auto-create an ActionEvent from a source mesh.
  117651. * @param source The source mesh that triggered the event
  117652. * @param evt The original (browser) event
  117653. * @param additionalData additional data for the event
  117654. * @returns the new ActionEvent
  117655. */
  117656. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117657. /**
  117658. * Helper function to auto-create an ActionEvent from a source sprite
  117659. * @param source The source sprite that triggered the event
  117660. * @param scene Scene associated with the sprite
  117661. * @param evt The original (browser) event
  117662. * @param additionalData additional data for the event
  117663. * @returns the new ActionEvent
  117664. */
  117665. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117666. /**
  117667. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117668. * @param scene the scene where the event occurred
  117669. * @param evt The original (browser) event
  117670. * @returns the new ActionEvent
  117671. */
  117672. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117673. /**
  117674. * Helper function to auto-create an ActionEvent from a primitive
  117675. * @param prim defines the target primitive
  117676. * @param pointerPos defines the pointer position
  117677. * @param evt The original (browser) event
  117678. * @param additionalData additional data for the event
  117679. * @returns the new ActionEvent
  117680. */
  117681. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117682. }
  117683. }
  117684. declare module BABYLON {
  117685. /**
  117686. * Abstract class used to decouple action Manager from scene and meshes.
  117687. * Do not instantiate.
  117688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117689. */
  117690. export abstract class AbstractActionManager implements IDisposable {
  117691. /** Gets the list of active triggers */
  117692. static Triggers: {
  117693. [key: string]: number;
  117694. };
  117695. /** Gets the cursor to use when hovering items */
  117696. hoverCursor: string;
  117697. /** Gets the list of actions */
  117698. actions: IAction[];
  117699. /**
  117700. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117701. */
  117702. isRecursive: boolean;
  117703. /**
  117704. * Releases all associated resources
  117705. */
  117706. abstract dispose(): void;
  117707. /**
  117708. * Does this action manager has pointer triggers
  117709. */
  117710. abstract get hasPointerTriggers(): boolean;
  117711. /**
  117712. * Does this action manager has pick triggers
  117713. */
  117714. abstract get hasPickTriggers(): boolean;
  117715. /**
  117716. * Process a specific trigger
  117717. * @param trigger defines the trigger to process
  117718. * @param evt defines the event details to be processed
  117719. */
  117720. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117721. /**
  117722. * Does this action manager handles actions of any of the given triggers
  117723. * @param triggers defines the triggers to be tested
  117724. * @return a boolean indicating whether one (or more) of the triggers is handled
  117725. */
  117726. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117727. /**
  117728. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117729. * speed.
  117730. * @param triggerA defines the trigger to be tested
  117731. * @param triggerB defines the trigger to be tested
  117732. * @return a boolean indicating whether one (or more) of the triggers is handled
  117733. */
  117734. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117735. /**
  117736. * Does this action manager handles actions of a given trigger
  117737. * @param trigger defines the trigger to be tested
  117738. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117739. * @return whether the trigger is handled
  117740. */
  117741. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117742. /**
  117743. * Serialize this manager to a JSON object
  117744. * @param name defines the property name to store this manager
  117745. * @returns a JSON representation of this manager
  117746. */
  117747. abstract serialize(name: string): any;
  117748. /**
  117749. * Registers an action to this action manager
  117750. * @param action defines the action to be registered
  117751. * @return the action amended (prepared) after registration
  117752. */
  117753. abstract registerAction(action: IAction): Nullable<IAction>;
  117754. /**
  117755. * Unregisters an action to this action manager
  117756. * @param action defines the action to be unregistered
  117757. * @return a boolean indicating whether the action has been unregistered
  117758. */
  117759. abstract unregisterAction(action: IAction): Boolean;
  117760. /**
  117761. * Does exist one action manager with at least one trigger
  117762. **/
  117763. static get HasTriggers(): boolean;
  117764. /**
  117765. * Does exist one action manager with at least one pick trigger
  117766. **/
  117767. static get HasPickTriggers(): boolean;
  117768. /**
  117769. * Does exist one action manager that handles actions of a given trigger
  117770. * @param trigger defines the trigger to be tested
  117771. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117772. **/
  117773. static HasSpecificTrigger(trigger: number): boolean;
  117774. }
  117775. }
  117776. declare module BABYLON {
  117777. /**
  117778. * Defines how a node can be built from a string name.
  117779. */
  117780. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117781. /**
  117782. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117783. */
  117784. export class Node implements IBehaviorAware<Node> {
  117785. /** @hidden */
  117786. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117787. private static _NodeConstructors;
  117788. /**
  117789. * Add a new node constructor
  117790. * @param type defines the type name of the node to construct
  117791. * @param constructorFunc defines the constructor function
  117792. */
  117793. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117794. /**
  117795. * Returns a node constructor based on type name
  117796. * @param type defines the type name
  117797. * @param name defines the new node name
  117798. * @param scene defines the hosting scene
  117799. * @param options defines optional options to transmit to constructors
  117800. * @returns the new constructor or null
  117801. */
  117802. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117803. /**
  117804. * Gets or sets the name of the node
  117805. */
  117806. name: string;
  117807. /**
  117808. * Gets or sets the id of the node
  117809. */
  117810. id: string;
  117811. /**
  117812. * Gets or sets the unique id of the node
  117813. */
  117814. uniqueId: number;
  117815. /**
  117816. * Gets or sets a string used to store user defined state for the node
  117817. */
  117818. state: string;
  117819. /**
  117820. * Gets or sets an object used to store user defined information for the node
  117821. */
  117822. metadata: any;
  117823. /**
  117824. * For internal use only. Please do not use.
  117825. */
  117826. reservedDataStore: any;
  117827. /**
  117828. * List of inspectable custom properties (used by the Inspector)
  117829. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117830. */
  117831. inspectableCustomProperties: IInspectable[];
  117832. private _doNotSerialize;
  117833. /**
  117834. * Gets or sets a boolean used to define if the node must be serialized
  117835. */
  117836. get doNotSerialize(): boolean;
  117837. set doNotSerialize(value: boolean);
  117838. /** @hidden */
  117839. _isDisposed: boolean;
  117840. /**
  117841. * Gets a list of Animations associated with the node
  117842. */
  117843. animations: Animation[];
  117844. protected _ranges: {
  117845. [name: string]: Nullable<AnimationRange>;
  117846. };
  117847. /**
  117848. * Callback raised when the node is ready to be used
  117849. */
  117850. onReady: Nullable<(node: Node) => void>;
  117851. private _isEnabled;
  117852. private _isParentEnabled;
  117853. private _isReady;
  117854. /** @hidden */
  117855. _currentRenderId: number;
  117856. private _parentUpdateId;
  117857. /** @hidden */
  117858. _childUpdateId: number;
  117859. /** @hidden */
  117860. _waitingParentId: Nullable<string>;
  117861. /** @hidden */
  117862. _scene: Scene;
  117863. /** @hidden */
  117864. _cache: any;
  117865. private _parentNode;
  117866. private _children;
  117867. /** @hidden */
  117868. _worldMatrix: Matrix;
  117869. /** @hidden */
  117870. _worldMatrixDeterminant: number;
  117871. /** @hidden */
  117872. _worldMatrixDeterminantIsDirty: boolean;
  117873. /** @hidden */
  117874. private _sceneRootNodesIndex;
  117875. /**
  117876. * Gets a boolean indicating if the node has been disposed
  117877. * @returns true if the node was disposed
  117878. */
  117879. isDisposed(): boolean;
  117880. /**
  117881. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117882. * @see https://doc.babylonjs.com/how_to/parenting
  117883. */
  117884. set parent(parent: Nullable<Node>);
  117885. get parent(): Nullable<Node>;
  117886. /** @hidden */
  117887. _addToSceneRootNodes(): void;
  117888. /** @hidden */
  117889. _removeFromSceneRootNodes(): void;
  117890. private _animationPropertiesOverride;
  117891. /**
  117892. * Gets or sets the animation properties override
  117893. */
  117894. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117895. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117896. /**
  117897. * Gets a string identifying the name of the class
  117898. * @returns "Node" string
  117899. */
  117900. getClassName(): string;
  117901. /** @hidden */
  117902. readonly _isNode: boolean;
  117903. /**
  117904. * An event triggered when the mesh is disposed
  117905. */
  117906. onDisposeObservable: Observable<Node>;
  117907. private _onDisposeObserver;
  117908. /**
  117909. * Sets a callback that will be raised when the node will be disposed
  117910. */
  117911. set onDispose(callback: () => void);
  117912. /**
  117913. * Creates a new Node
  117914. * @param name the name and id to be given to this node
  117915. * @param scene the scene this node will be added to
  117916. */
  117917. constructor(name: string, scene?: Nullable<Scene>);
  117918. /**
  117919. * Gets the scene of the node
  117920. * @returns a scene
  117921. */
  117922. getScene(): Scene;
  117923. /**
  117924. * Gets the engine of the node
  117925. * @returns a Engine
  117926. */
  117927. getEngine(): Engine;
  117928. private _behaviors;
  117929. /**
  117930. * Attach a behavior to the node
  117931. * @see https://doc.babylonjs.com/features/behaviour
  117932. * @param behavior defines the behavior to attach
  117933. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117934. * @returns the current Node
  117935. */
  117936. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117937. /**
  117938. * Remove an attached behavior
  117939. * @see https://doc.babylonjs.com/features/behaviour
  117940. * @param behavior defines the behavior to attach
  117941. * @returns the current Node
  117942. */
  117943. removeBehavior(behavior: Behavior<Node>): Node;
  117944. /**
  117945. * Gets the list of attached behaviors
  117946. * @see https://doc.babylonjs.com/features/behaviour
  117947. */
  117948. get behaviors(): Behavior<Node>[];
  117949. /**
  117950. * Gets an attached behavior by name
  117951. * @param name defines the name of the behavior to look for
  117952. * @see https://doc.babylonjs.com/features/behaviour
  117953. * @returns null if behavior was not found else the requested behavior
  117954. */
  117955. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117956. /**
  117957. * Returns the latest update of the World matrix
  117958. * @returns a Matrix
  117959. */
  117960. getWorldMatrix(): Matrix;
  117961. /** @hidden */
  117962. _getWorldMatrixDeterminant(): number;
  117963. /**
  117964. * Returns directly the latest state of the mesh World matrix.
  117965. * A Matrix is returned.
  117966. */
  117967. get worldMatrixFromCache(): Matrix;
  117968. /** @hidden */
  117969. _initCache(): void;
  117970. /** @hidden */
  117971. updateCache(force?: boolean): void;
  117972. /** @hidden */
  117973. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117974. /** @hidden */
  117975. _updateCache(ignoreParentClass?: boolean): void;
  117976. /** @hidden */
  117977. _isSynchronized(): boolean;
  117978. /** @hidden */
  117979. _markSyncedWithParent(): void;
  117980. /** @hidden */
  117981. isSynchronizedWithParent(): boolean;
  117982. /** @hidden */
  117983. isSynchronized(): boolean;
  117984. /**
  117985. * Is this node ready to be used/rendered
  117986. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117987. * @return true if the node is ready
  117988. */
  117989. isReady(completeCheck?: boolean): boolean;
  117990. /**
  117991. * Is this node enabled?
  117992. * 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
  117993. * @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
  117994. * @return whether this node (and its parent) is enabled
  117995. */
  117996. isEnabled(checkAncestors?: boolean): boolean;
  117997. /** @hidden */
  117998. protected _syncParentEnabledState(): void;
  117999. /**
  118000. * Set the enabled state of this node
  118001. * @param value defines the new enabled state
  118002. */
  118003. setEnabled(value: boolean): void;
  118004. /**
  118005. * Is this node a descendant of the given node?
  118006. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  118007. * @param ancestor defines the parent node to inspect
  118008. * @returns a boolean indicating if this node is a descendant of the given node
  118009. */
  118010. isDescendantOf(ancestor: Node): boolean;
  118011. /** @hidden */
  118012. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  118013. /**
  118014. * Will return all nodes that have this node as ascendant
  118015. * @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
  118016. * @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
  118017. * @return all children nodes of all types
  118018. */
  118019. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  118020. /**
  118021. * Get all child-meshes of this node
  118022. * @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)
  118023. * @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
  118024. * @returns an array of AbstractMesh
  118025. */
  118026. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  118027. /**
  118028. * Get all direct children of this node
  118029. * @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
  118030. * @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)
  118031. * @returns an array of Node
  118032. */
  118033. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  118034. /** @hidden */
  118035. _setReady(state: boolean): void;
  118036. /**
  118037. * Get an animation by name
  118038. * @param name defines the name of the animation to look for
  118039. * @returns null if not found else the requested animation
  118040. */
  118041. getAnimationByName(name: string): Nullable<Animation>;
  118042. /**
  118043. * Creates an animation range for this node
  118044. * @param name defines the name of the range
  118045. * @param from defines the starting key
  118046. * @param to defines the end key
  118047. */
  118048. createAnimationRange(name: string, from: number, to: number): void;
  118049. /**
  118050. * Delete a specific animation range
  118051. * @param name defines the name of the range to delete
  118052. * @param deleteFrames defines if animation frames from the range must be deleted as well
  118053. */
  118054. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  118055. /**
  118056. * Get an animation range by name
  118057. * @param name defines the name of the animation range to look for
  118058. * @returns null if not found else the requested animation range
  118059. */
  118060. getAnimationRange(name: string): Nullable<AnimationRange>;
  118061. /**
  118062. * Gets the list of all animation ranges defined on this node
  118063. * @returns an array
  118064. */
  118065. getAnimationRanges(): Nullable<AnimationRange>[];
  118066. /**
  118067. * Will start the animation sequence
  118068. * @param name defines the range frames for animation sequence
  118069. * @param loop defines if the animation should loop (false by default)
  118070. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  118071. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  118072. * @returns the object created for this animation. If range does not exist, it will return null
  118073. */
  118074. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  118075. /**
  118076. * Serialize animation ranges into a JSON compatible object
  118077. * @returns serialization object
  118078. */
  118079. serializeAnimationRanges(): any;
  118080. /**
  118081. * Computes the world matrix of the node
  118082. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  118083. * @returns the world matrix
  118084. */
  118085. computeWorldMatrix(force?: boolean): Matrix;
  118086. /**
  118087. * Releases resources associated with this node.
  118088. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118089. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118090. */
  118091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118092. /**
  118093. * Parse animation range data from a serialization object and store them into a given node
  118094. * @param node defines where to store the animation ranges
  118095. * @param parsedNode defines the serialization object to read data from
  118096. * @param scene defines the hosting scene
  118097. */
  118098. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  118099. /**
  118100. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  118101. * @param includeDescendants Include bounding info from descendants as well (true by default)
  118102. * @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
  118103. * @returns the new bounding vectors
  118104. */
  118105. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  118106. min: Vector3;
  118107. max: Vector3;
  118108. };
  118109. }
  118110. }
  118111. declare module BABYLON {
  118112. /**
  118113. * @hidden
  118114. */
  118115. export class _IAnimationState {
  118116. key: number;
  118117. repeatCount: number;
  118118. workValue?: any;
  118119. loopMode?: number;
  118120. offsetValue?: any;
  118121. highLimitValue?: any;
  118122. }
  118123. /**
  118124. * Class used to store any kind of animation
  118125. */
  118126. export class Animation {
  118127. /**Name of the animation */
  118128. name: string;
  118129. /**Property to animate */
  118130. targetProperty: string;
  118131. /**The frames per second of the animation */
  118132. framePerSecond: number;
  118133. /**The data type of the animation */
  118134. dataType: number;
  118135. /**The loop mode of the animation */
  118136. loopMode?: number | undefined;
  118137. /**Specifies if blending should be enabled */
  118138. enableBlending?: boolean | undefined;
  118139. /**
  118140. * Use matrix interpolation instead of using direct key value when animating matrices
  118141. */
  118142. static AllowMatricesInterpolation: boolean;
  118143. /**
  118144. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118145. */
  118146. static AllowMatrixDecomposeForInterpolation: boolean;
  118147. /** Define the Url to load snippets */
  118148. static SnippetUrl: string;
  118149. /** Snippet ID if the animation was created from the snippet server */
  118150. snippetId: string;
  118151. /**
  118152. * Stores the key frames of the animation
  118153. */
  118154. private _keys;
  118155. /**
  118156. * Stores the easing function of the animation
  118157. */
  118158. private _easingFunction;
  118159. /**
  118160. * @hidden Internal use only
  118161. */
  118162. _runtimeAnimations: RuntimeAnimation[];
  118163. /**
  118164. * The set of event that will be linked to this animation
  118165. */
  118166. private _events;
  118167. /**
  118168. * Stores an array of target property paths
  118169. */
  118170. targetPropertyPath: string[];
  118171. /**
  118172. * Stores the blending speed of the animation
  118173. */
  118174. blendingSpeed: number;
  118175. /**
  118176. * Stores the animation ranges for the animation
  118177. */
  118178. private _ranges;
  118179. /**
  118180. * @hidden Internal use
  118181. */
  118182. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118183. /**
  118184. * Sets up an animation
  118185. * @param property The property to animate
  118186. * @param animationType The animation type to apply
  118187. * @param framePerSecond The frames per second of the animation
  118188. * @param easingFunction The easing function used in the animation
  118189. * @returns The created animation
  118190. */
  118191. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118192. /**
  118193. * Create and start an animation on a node
  118194. * @param name defines the name of the global animation that will be run on all nodes
  118195. * @param node defines the root node where the animation will take place
  118196. * @param targetProperty defines property to animate
  118197. * @param framePerSecond defines the number of frame per second yo use
  118198. * @param totalFrame defines the number of frames in total
  118199. * @param from defines the initial value
  118200. * @param to defines the final value
  118201. * @param loopMode defines which loop mode you want to use (off by default)
  118202. * @param easingFunction defines the easing function to use (linear by default)
  118203. * @param onAnimationEnd defines the callback to call when animation end
  118204. * @returns the animatable created for this animation
  118205. */
  118206. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118207. /**
  118208. * Create and start an animation on a node and its descendants
  118209. * @param name defines the name of the global animation that will be run on all nodes
  118210. * @param node defines the root node where the animation will take place
  118211. * @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
  118212. * @param targetProperty defines property to animate
  118213. * @param framePerSecond defines the number of frame per second to use
  118214. * @param totalFrame defines the number of frames in total
  118215. * @param from defines the initial value
  118216. * @param to defines the final value
  118217. * @param loopMode defines which loop mode you want to use (off by default)
  118218. * @param easingFunction defines the easing function to use (linear by default)
  118219. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118220. * @returns the list of animatables created for all nodes
  118221. * @example https://www.babylonjs-playground.com/#MH0VLI
  118222. */
  118223. 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[]>;
  118224. /**
  118225. * Creates a new animation, merges it with the existing animations and starts it
  118226. * @param name Name of the animation
  118227. * @param node Node which contains the scene that begins the animations
  118228. * @param targetProperty Specifies which property to animate
  118229. * @param framePerSecond The frames per second of the animation
  118230. * @param totalFrame The total number of frames
  118231. * @param from The frame at the beginning of the animation
  118232. * @param to The frame at the end of the animation
  118233. * @param loopMode Specifies the loop mode of the animation
  118234. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118235. * @param onAnimationEnd Callback to run once the animation is complete
  118236. * @returns Nullable animation
  118237. */
  118238. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118239. /**
  118240. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118241. * @param sourceAnimation defines the Animation containing keyframes to convert
  118242. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118243. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118244. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118245. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118246. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118247. */
  118248. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118249. /**
  118250. * Transition property of an host to the target Value
  118251. * @param property The property to transition
  118252. * @param targetValue The target Value of the property
  118253. * @param host The object where the property to animate belongs
  118254. * @param scene Scene used to run the animation
  118255. * @param frameRate Framerate (in frame/s) to use
  118256. * @param transition The transition type we want to use
  118257. * @param duration The duration of the animation, in milliseconds
  118258. * @param onAnimationEnd Callback trigger at the end of the animation
  118259. * @returns Nullable animation
  118260. */
  118261. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118262. /**
  118263. * Return the array of runtime animations currently using this animation
  118264. */
  118265. get runtimeAnimations(): RuntimeAnimation[];
  118266. /**
  118267. * Specifies if any of the runtime animations are currently running
  118268. */
  118269. get hasRunningRuntimeAnimations(): boolean;
  118270. /**
  118271. * Initializes the animation
  118272. * @param name Name of the animation
  118273. * @param targetProperty Property to animate
  118274. * @param framePerSecond The frames per second of the animation
  118275. * @param dataType The data type of the animation
  118276. * @param loopMode The loop mode of the animation
  118277. * @param enableBlending Specifies if blending should be enabled
  118278. */
  118279. constructor(
  118280. /**Name of the animation */
  118281. name: string,
  118282. /**Property to animate */
  118283. targetProperty: string,
  118284. /**The frames per second of the animation */
  118285. framePerSecond: number,
  118286. /**The data type of the animation */
  118287. dataType: number,
  118288. /**The loop mode of the animation */
  118289. loopMode?: number | undefined,
  118290. /**Specifies if blending should be enabled */
  118291. enableBlending?: boolean | undefined);
  118292. /**
  118293. * Converts the animation to a string
  118294. * @param fullDetails support for multiple levels of logging within scene loading
  118295. * @returns String form of the animation
  118296. */
  118297. toString(fullDetails?: boolean): string;
  118298. /**
  118299. * Add an event to this animation
  118300. * @param event Event to add
  118301. */
  118302. addEvent(event: AnimationEvent): void;
  118303. /**
  118304. * Remove all events found at the given frame
  118305. * @param frame The frame to remove events from
  118306. */
  118307. removeEvents(frame: number): void;
  118308. /**
  118309. * Retrieves all the events from the animation
  118310. * @returns Events from the animation
  118311. */
  118312. getEvents(): AnimationEvent[];
  118313. /**
  118314. * Creates an animation range
  118315. * @param name Name of the animation range
  118316. * @param from Starting frame of the animation range
  118317. * @param to Ending frame of the animation
  118318. */
  118319. createRange(name: string, from: number, to: number): void;
  118320. /**
  118321. * Deletes an animation range by name
  118322. * @param name Name of the animation range to delete
  118323. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118324. */
  118325. deleteRange(name: string, deleteFrames?: boolean): void;
  118326. /**
  118327. * Gets the animation range by name, or null if not defined
  118328. * @param name Name of the animation range
  118329. * @returns Nullable animation range
  118330. */
  118331. getRange(name: string): Nullable<AnimationRange>;
  118332. /**
  118333. * Gets the key frames from the animation
  118334. * @returns The key frames of the animation
  118335. */
  118336. getKeys(): Array<IAnimationKey>;
  118337. /**
  118338. * Gets the highest frame rate of the animation
  118339. * @returns Highest frame rate of the animation
  118340. */
  118341. getHighestFrame(): number;
  118342. /**
  118343. * Gets the easing function of the animation
  118344. * @returns Easing function of the animation
  118345. */
  118346. getEasingFunction(): IEasingFunction;
  118347. /**
  118348. * Sets the easing function of the animation
  118349. * @param easingFunction A custom mathematical formula for animation
  118350. */
  118351. setEasingFunction(easingFunction: EasingFunction): void;
  118352. /**
  118353. * Interpolates a scalar linearly
  118354. * @param startValue Start value of the animation curve
  118355. * @param endValue End value of the animation curve
  118356. * @param gradient Scalar amount to interpolate
  118357. * @returns Interpolated scalar value
  118358. */
  118359. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118360. /**
  118361. * Interpolates a scalar cubically
  118362. * @param startValue Start value of the animation curve
  118363. * @param outTangent End tangent of the animation
  118364. * @param endValue End value of the animation curve
  118365. * @param inTangent Start tangent of the animation curve
  118366. * @param gradient Scalar amount to interpolate
  118367. * @returns Interpolated scalar value
  118368. */
  118369. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118370. /**
  118371. * Interpolates a quaternion using a spherical linear interpolation
  118372. * @param startValue Start value of the animation curve
  118373. * @param endValue End value of the animation curve
  118374. * @param gradient Scalar amount to interpolate
  118375. * @returns Interpolated quaternion value
  118376. */
  118377. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118378. /**
  118379. * Interpolates a quaternion cubically
  118380. * @param startValue Start value of the animation curve
  118381. * @param outTangent End tangent of the animation curve
  118382. * @param endValue End value of the animation curve
  118383. * @param inTangent Start tangent of the animation curve
  118384. * @param gradient Scalar amount to interpolate
  118385. * @returns Interpolated quaternion value
  118386. */
  118387. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118388. /**
  118389. * Interpolates a Vector3 linearl
  118390. * @param startValue Start value of the animation curve
  118391. * @param endValue End value of the animation curve
  118392. * @param gradient Scalar amount to interpolate
  118393. * @returns Interpolated scalar value
  118394. */
  118395. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118396. /**
  118397. * Interpolates a Vector3 cubically
  118398. * @param startValue Start value of the animation curve
  118399. * @param outTangent End tangent of the animation
  118400. * @param endValue End value of the animation curve
  118401. * @param inTangent Start tangent of the animation curve
  118402. * @param gradient Scalar amount to interpolate
  118403. * @returns InterpolatedVector3 value
  118404. */
  118405. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118406. /**
  118407. * Interpolates a Vector2 linearly
  118408. * @param startValue Start value of the animation curve
  118409. * @param endValue End value of the animation curve
  118410. * @param gradient Scalar amount to interpolate
  118411. * @returns Interpolated Vector2 value
  118412. */
  118413. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118414. /**
  118415. * Interpolates a Vector2 cubically
  118416. * @param startValue Start value of the animation curve
  118417. * @param outTangent End tangent of the animation
  118418. * @param endValue End value of the animation curve
  118419. * @param inTangent Start tangent of the animation curve
  118420. * @param gradient Scalar amount to interpolate
  118421. * @returns Interpolated Vector2 value
  118422. */
  118423. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118424. /**
  118425. * Interpolates a size linearly
  118426. * @param startValue Start value of the animation curve
  118427. * @param endValue End value of the animation curve
  118428. * @param gradient Scalar amount to interpolate
  118429. * @returns Interpolated Size value
  118430. */
  118431. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118432. /**
  118433. * Interpolates a Color3 linearly
  118434. * @param startValue Start value of the animation curve
  118435. * @param endValue End value of the animation curve
  118436. * @param gradient Scalar amount to interpolate
  118437. * @returns Interpolated Color3 value
  118438. */
  118439. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118440. /**
  118441. * Interpolates a Color4 linearly
  118442. * @param startValue Start value of the animation curve
  118443. * @param endValue End value of the animation curve
  118444. * @param gradient Scalar amount to interpolate
  118445. * @returns Interpolated Color3 value
  118446. */
  118447. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118448. /**
  118449. * @hidden Internal use only
  118450. */
  118451. _getKeyValue(value: any): any;
  118452. /**
  118453. * @hidden Internal use only
  118454. */
  118455. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118456. /**
  118457. * Defines the function to use to interpolate matrices
  118458. * @param startValue defines the start matrix
  118459. * @param endValue defines the end matrix
  118460. * @param gradient defines the gradient between both matrices
  118461. * @param result defines an optional target matrix where to store the interpolation
  118462. * @returns the interpolated matrix
  118463. */
  118464. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118465. /**
  118466. * Makes a copy of the animation
  118467. * @returns Cloned animation
  118468. */
  118469. clone(): Animation;
  118470. /**
  118471. * Sets the key frames of the animation
  118472. * @param values The animation key frames to set
  118473. */
  118474. setKeys(values: Array<IAnimationKey>): void;
  118475. /**
  118476. * Serializes the animation to an object
  118477. * @returns Serialized object
  118478. */
  118479. serialize(): any;
  118480. /**
  118481. * Float animation type
  118482. */
  118483. static readonly ANIMATIONTYPE_FLOAT: number;
  118484. /**
  118485. * Vector3 animation type
  118486. */
  118487. static readonly ANIMATIONTYPE_VECTOR3: number;
  118488. /**
  118489. * Quaternion animation type
  118490. */
  118491. static readonly ANIMATIONTYPE_QUATERNION: number;
  118492. /**
  118493. * Matrix animation type
  118494. */
  118495. static readonly ANIMATIONTYPE_MATRIX: number;
  118496. /**
  118497. * Color3 animation type
  118498. */
  118499. static readonly ANIMATIONTYPE_COLOR3: number;
  118500. /**
  118501. * Color3 animation type
  118502. */
  118503. static readonly ANIMATIONTYPE_COLOR4: number;
  118504. /**
  118505. * Vector2 animation type
  118506. */
  118507. static readonly ANIMATIONTYPE_VECTOR2: number;
  118508. /**
  118509. * Size animation type
  118510. */
  118511. static readonly ANIMATIONTYPE_SIZE: number;
  118512. /**
  118513. * Relative Loop Mode
  118514. */
  118515. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118516. /**
  118517. * Cycle Loop Mode
  118518. */
  118519. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118520. /**
  118521. * Constant Loop Mode
  118522. */
  118523. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118524. /** @hidden */
  118525. static _UniversalLerp(left: any, right: any, amount: number): any;
  118526. /**
  118527. * Parses an animation object and creates an animation
  118528. * @param parsedAnimation Parsed animation object
  118529. * @returns Animation object
  118530. */
  118531. static Parse(parsedAnimation: any): Animation;
  118532. /**
  118533. * Appends the serialized animations from the source animations
  118534. * @param source Source containing the animations
  118535. * @param destination Target to store the animations
  118536. */
  118537. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118538. /**
  118539. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118540. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118541. * @param url defines the url to load from
  118542. * @returns a promise that will resolve to the new animation or an array of animations
  118543. */
  118544. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118545. /**
  118546. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118547. * @param snippetId defines the snippet to load
  118548. * @returns a promise that will resolve to the new animation or a new array of animations
  118549. */
  118550. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118551. }
  118552. }
  118553. declare module BABYLON {
  118554. /**
  118555. * Interface containing an array of animations
  118556. */
  118557. export interface IAnimatable {
  118558. /**
  118559. * Array of animations
  118560. */
  118561. animations: Nullable<Array<Animation>>;
  118562. }
  118563. }
  118564. declare module BABYLON {
  118565. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118566. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118567. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118568. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118569. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118570. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118571. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118572. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118573. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118574. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118575. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118576. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118577. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118578. /**
  118579. * Decorator used to define property that can be serialized as reference to a camera
  118580. * @param sourceName defines the name of the property to decorate
  118581. */
  118582. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118583. /**
  118584. * Class used to help serialization objects
  118585. */
  118586. export class SerializationHelper {
  118587. /** @hidden */
  118588. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118589. /** @hidden */
  118590. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118591. /** @hidden */
  118592. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118593. /** @hidden */
  118594. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118595. /**
  118596. * Appends the serialized animations from the source animations
  118597. * @param source Source containing the animations
  118598. * @param destination Target to store the animations
  118599. */
  118600. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118601. /**
  118602. * Static function used to serialized a specific entity
  118603. * @param entity defines the entity to serialize
  118604. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118605. * @returns a JSON compatible object representing the serialization of the entity
  118606. */
  118607. static Serialize<T>(entity: T, serializationObject?: any): any;
  118608. /**
  118609. * Creates a new entity from a serialization data object
  118610. * @param creationFunction defines a function used to instanciated the new entity
  118611. * @param source defines the source serialization data
  118612. * @param scene defines the hosting scene
  118613. * @param rootUrl defines the root url for resources
  118614. * @returns a new entity
  118615. */
  118616. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118617. /**
  118618. * Clones an object
  118619. * @param creationFunction defines the function used to instanciate the new object
  118620. * @param source defines the source object
  118621. * @returns the cloned object
  118622. */
  118623. static Clone<T>(creationFunction: () => T, source: T): T;
  118624. /**
  118625. * Instanciates a new object based on a source one (some data will be shared between both object)
  118626. * @param creationFunction defines the function used to instanciate the new object
  118627. * @param source defines the source object
  118628. * @returns the new object
  118629. */
  118630. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118631. }
  118632. }
  118633. declare module BABYLON {
  118634. /**
  118635. * This is the base class of all the camera used in the application.
  118636. * @see https://doc.babylonjs.com/features/cameras
  118637. */
  118638. export class Camera extends Node {
  118639. /** @hidden */
  118640. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118641. /**
  118642. * This is the default projection mode used by the cameras.
  118643. * It helps recreating a feeling of perspective and better appreciate depth.
  118644. * This is the best way to simulate real life cameras.
  118645. */
  118646. static readonly PERSPECTIVE_CAMERA: number;
  118647. /**
  118648. * This helps creating camera with an orthographic mode.
  118649. * 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.
  118650. */
  118651. static readonly ORTHOGRAPHIC_CAMERA: number;
  118652. /**
  118653. * This is the default FOV mode for perspective cameras.
  118654. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118655. */
  118656. static readonly FOVMODE_VERTICAL_FIXED: number;
  118657. /**
  118658. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118659. */
  118660. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118661. /**
  118662. * This specifies ther is no need for a camera rig.
  118663. * Basically only one eye is rendered corresponding to the camera.
  118664. */
  118665. static readonly RIG_MODE_NONE: number;
  118666. /**
  118667. * Simulates a camera Rig with one blue eye and one red eye.
  118668. * This can be use with 3d blue and red glasses.
  118669. */
  118670. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118671. /**
  118672. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118673. */
  118674. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118675. /**
  118676. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118677. */
  118678. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118679. /**
  118680. * Defines that both eyes of the camera will be rendered over under each other.
  118681. */
  118682. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118683. /**
  118684. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118685. */
  118686. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118687. /**
  118688. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118689. */
  118690. static readonly RIG_MODE_VR: number;
  118691. /**
  118692. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118693. */
  118694. static readonly RIG_MODE_WEBVR: number;
  118695. /**
  118696. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118697. */
  118698. static readonly RIG_MODE_CUSTOM: number;
  118699. /**
  118700. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118701. */
  118702. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118703. /**
  118704. * Define the input manager associated with the camera.
  118705. */
  118706. inputs: CameraInputsManager<Camera>;
  118707. /** @hidden */
  118708. _position: Vector3;
  118709. /**
  118710. * Define the current local position of the camera in the scene
  118711. */
  118712. get position(): Vector3;
  118713. set position(newPosition: Vector3);
  118714. protected _upVector: Vector3;
  118715. /**
  118716. * The vector the camera should consider as up.
  118717. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118718. */
  118719. set upVector(vec: Vector3);
  118720. get upVector(): Vector3;
  118721. /**
  118722. * Define the current limit on the left side for an orthographic camera
  118723. * In scene unit
  118724. */
  118725. orthoLeft: Nullable<number>;
  118726. /**
  118727. * Define the current limit on the right side for an orthographic camera
  118728. * In scene unit
  118729. */
  118730. orthoRight: Nullable<number>;
  118731. /**
  118732. * Define the current limit on the bottom side for an orthographic camera
  118733. * In scene unit
  118734. */
  118735. orthoBottom: Nullable<number>;
  118736. /**
  118737. * Define the current limit on the top side for an orthographic camera
  118738. * In scene unit
  118739. */
  118740. orthoTop: Nullable<number>;
  118741. /**
  118742. * Field Of View is set in Radians. (default is 0.8)
  118743. */
  118744. fov: number;
  118745. /**
  118746. * Define the minimum distance the camera can see from.
  118747. * This is important to note that the depth buffer are not infinite and the closer it starts
  118748. * the more your scene might encounter depth fighting issue.
  118749. */
  118750. minZ: number;
  118751. /**
  118752. * Define the maximum distance the camera can see to.
  118753. * This is important to note that the depth buffer are not infinite and the further it end
  118754. * the more your scene might encounter depth fighting issue.
  118755. */
  118756. maxZ: number;
  118757. /**
  118758. * Define the default inertia of the camera.
  118759. * This helps giving a smooth feeling to the camera movement.
  118760. */
  118761. inertia: number;
  118762. /**
  118763. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118764. */
  118765. mode: number;
  118766. /**
  118767. * Define whether the camera is intermediate.
  118768. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118769. */
  118770. isIntermediate: boolean;
  118771. /**
  118772. * Define the viewport of the camera.
  118773. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118774. */
  118775. viewport: Viewport;
  118776. /**
  118777. * Restricts the camera to viewing objects with the same layerMask.
  118778. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118779. */
  118780. layerMask: number;
  118781. /**
  118782. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118783. */
  118784. fovMode: number;
  118785. /**
  118786. * Rig mode of the camera.
  118787. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118788. * This is normally controlled byt the camera themselves as internal use.
  118789. */
  118790. cameraRigMode: number;
  118791. /**
  118792. * Defines the distance between both "eyes" in case of a RIG
  118793. */
  118794. interaxialDistance: number;
  118795. /**
  118796. * Defines if stereoscopic rendering is done side by side or over under.
  118797. */
  118798. isStereoscopicSideBySide: boolean;
  118799. /**
  118800. * 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
  118801. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118802. * else in the scene. (Eg. security camera)
  118803. *
  118804. * 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)
  118805. */
  118806. customRenderTargets: RenderTargetTexture[];
  118807. /**
  118808. * When set, the camera will render to this render target instead of the default canvas
  118809. *
  118810. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118811. */
  118812. outputRenderTarget: Nullable<RenderTargetTexture>;
  118813. /**
  118814. * Observable triggered when the camera view matrix has changed.
  118815. */
  118816. onViewMatrixChangedObservable: Observable<Camera>;
  118817. /**
  118818. * Observable triggered when the camera Projection matrix has changed.
  118819. */
  118820. onProjectionMatrixChangedObservable: Observable<Camera>;
  118821. /**
  118822. * Observable triggered when the inputs have been processed.
  118823. */
  118824. onAfterCheckInputsObservable: Observable<Camera>;
  118825. /**
  118826. * Observable triggered when reset has been called and applied to the camera.
  118827. */
  118828. onRestoreStateObservable: Observable<Camera>;
  118829. /**
  118830. * Is this camera a part of a rig system?
  118831. */
  118832. isRigCamera: boolean;
  118833. /**
  118834. * If isRigCamera set to true this will be set with the parent camera.
  118835. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118836. */
  118837. rigParent?: Camera;
  118838. /** @hidden */
  118839. _cameraRigParams: any;
  118840. /** @hidden */
  118841. _rigCameras: Camera[];
  118842. /** @hidden */
  118843. _rigPostProcess: Nullable<PostProcess>;
  118844. protected _webvrViewMatrix: Matrix;
  118845. /** @hidden */
  118846. _skipRendering: boolean;
  118847. /** @hidden */
  118848. _projectionMatrix: Matrix;
  118849. /** @hidden */
  118850. _postProcesses: Nullable<PostProcess>[];
  118851. /** @hidden */
  118852. _activeMeshes: SmartArray<AbstractMesh>;
  118853. protected _globalPosition: Vector3;
  118854. /** @hidden */
  118855. _computedViewMatrix: Matrix;
  118856. private _doNotComputeProjectionMatrix;
  118857. private _transformMatrix;
  118858. private _frustumPlanes;
  118859. private _refreshFrustumPlanes;
  118860. private _storedFov;
  118861. private _stateStored;
  118862. /**
  118863. * Instantiates a new camera object.
  118864. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118865. * @see https://doc.babylonjs.com/features/cameras
  118866. * @param name Defines the name of the camera in the scene
  118867. * @param position Defines the position of the camera
  118868. * @param scene Defines the scene the camera belongs too
  118869. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118870. */
  118871. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118872. /**
  118873. * Store current camera state (fov, position, etc..)
  118874. * @returns the camera
  118875. */
  118876. storeState(): Camera;
  118877. /**
  118878. * Restores the camera state values if it has been stored. You must call storeState() first
  118879. */
  118880. protected _restoreStateValues(): boolean;
  118881. /**
  118882. * Restored camera state. You must call storeState() first.
  118883. * @returns true if restored and false otherwise
  118884. */
  118885. restoreState(): boolean;
  118886. /**
  118887. * Gets the class name of the camera.
  118888. * @returns the class name
  118889. */
  118890. getClassName(): string;
  118891. /** @hidden */
  118892. readonly _isCamera: boolean;
  118893. /**
  118894. * Gets a string representation of the camera useful for debug purpose.
  118895. * @param fullDetails Defines that a more verboe level of logging is required
  118896. * @returns the string representation
  118897. */
  118898. toString(fullDetails?: boolean): string;
  118899. /**
  118900. * Gets the current world space position of the camera.
  118901. */
  118902. get globalPosition(): Vector3;
  118903. /**
  118904. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118905. * @returns the active meshe list
  118906. */
  118907. getActiveMeshes(): SmartArray<AbstractMesh>;
  118908. /**
  118909. * Check whether a mesh is part of the current active mesh list of the camera
  118910. * @param mesh Defines the mesh to check
  118911. * @returns true if active, false otherwise
  118912. */
  118913. isActiveMesh(mesh: Mesh): boolean;
  118914. /**
  118915. * Is this camera ready to be used/rendered
  118916. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118917. * @return true if the camera is ready
  118918. */
  118919. isReady(completeCheck?: boolean): boolean;
  118920. /** @hidden */
  118921. _initCache(): void;
  118922. /** @hidden */
  118923. _updateCache(ignoreParentClass?: boolean): void;
  118924. /** @hidden */
  118925. _isSynchronized(): boolean;
  118926. /** @hidden */
  118927. _isSynchronizedViewMatrix(): boolean;
  118928. /** @hidden */
  118929. _isSynchronizedProjectionMatrix(): boolean;
  118930. /**
  118931. * Attach the input controls to a specific dom element to get the input from.
  118932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118933. */
  118934. attachControl(noPreventDefault?: boolean): void;
  118935. /**
  118936. * Attach the input controls to a specific dom element to get the input from.
  118937. * @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
  118938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118939. * BACK COMPAT SIGNATURE ONLY.
  118940. */
  118941. attachControl(ignored: any, noPreventDefault?: boolean): void;
  118942. /**
  118943. * Detach the current controls from the specified dom element.
  118944. */
  118945. detachControl(): void;
  118946. /**
  118947. * Detach the current controls from the specified dom element.
  118948. * @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
  118949. */
  118950. detachControl(ignored: any): void;
  118951. /**
  118952. * Update the camera state according to the different inputs gathered during the frame.
  118953. */
  118954. update(): void;
  118955. /** @hidden */
  118956. _checkInputs(): void;
  118957. /** @hidden */
  118958. get rigCameras(): Camera[];
  118959. /**
  118960. * Gets the post process used by the rig cameras
  118961. */
  118962. get rigPostProcess(): Nullable<PostProcess>;
  118963. /**
  118964. * Internal, gets the first post proces.
  118965. * @returns the first post process to be run on this camera.
  118966. */
  118967. _getFirstPostProcess(): Nullable<PostProcess>;
  118968. private _cascadePostProcessesToRigCams;
  118969. /**
  118970. * Attach a post process to the camera.
  118971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118972. * @param postProcess The post process to attach to the camera
  118973. * @param insertAt The position of the post process in case several of them are in use in the scene
  118974. * @returns the position the post process has been inserted at
  118975. */
  118976. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  118977. /**
  118978. * Detach a post process to the camera.
  118979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118980. * @param postProcess The post process to detach from the camera
  118981. */
  118982. detachPostProcess(postProcess: PostProcess): void;
  118983. /**
  118984. * Gets the current world matrix of the camera
  118985. */
  118986. getWorldMatrix(): Matrix;
  118987. /** @hidden */
  118988. _getViewMatrix(): Matrix;
  118989. /**
  118990. * Gets the current view matrix of the camera.
  118991. * @param force forces the camera to recompute the matrix without looking at the cached state
  118992. * @returns the view matrix
  118993. */
  118994. getViewMatrix(force?: boolean): Matrix;
  118995. /**
  118996. * Freeze the projection matrix.
  118997. * It will prevent the cache check of the camera projection compute and can speed up perf
  118998. * if no parameter of the camera are meant to change
  118999. * @param projection Defines manually a projection if necessary
  119000. */
  119001. freezeProjectionMatrix(projection?: Matrix): void;
  119002. /**
  119003. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  119004. */
  119005. unfreezeProjectionMatrix(): void;
  119006. /**
  119007. * Gets the current projection matrix of the camera.
  119008. * @param force forces the camera to recompute the matrix without looking at the cached state
  119009. * @returns the projection matrix
  119010. */
  119011. getProjectionMatrix(force?: boolean): Matrix;
  119012. /**
  119013. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  119014. * @returns a Matrix
  119015. */
  119016. getTransformationMatrix(): Matrix;
  119017. private _updateFrustumPlanes;
  119018. /**
  119019. * Checks if a cullable object (mesh...) is in the camera frustum
  119020. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  119021. * @param target The object to check
  119022. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  119023. * @returns true if the object is in frustum otherwise false
  119024. */
  119025. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  119026. /**
  119027. * Checks if a cullable object (mesh...) is in the camera frustum
  119028. * Unlike isInFrustum this cheks the full bounding box
  119029. * @param target The object to check
  119030. * @returns true if the object is in frustum otherwise false
  119031. */
  119032. isCompletelyInFrustum(target: ICullable): boolean;
  119033. /**
  119034. * Gets a ray in the forward direction from the camera.
  119035. * @param length Defines the length of the ray to create
  119036. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119037. * @param origin Defines the start point of the ray which defaults to the camera position
  119038. * @returns the forward ray
  119039. */
  119040. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119041. /**
  119042. * Gets a ray in the forward direction from the camera.
  119043. * @param refRay the ray to (re)use when setting the values
  119044. * @param length Defines the length of the ray to create
  119045. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119046. * @param origin Defines the start point of the ray which defaults to the camera position
  119047. * @returns the forward ray
  119048. */
  119049. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119050. /**
  119051. * Releases resources associated with this node.
  119052. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119053. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119054. */
  119055. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119056. /** @hidden */
  119057. _isLeftCamera: boolean;
  119058. /**
  119059. * Gets the left camera of a rig setup in case of Rigged Camera
  119060. */
  119061. get isLeftCamera(): boolean;
  119062. /** @hidden */
  119063. _isRightCamera: boolean;
  119064. /**
  119065. * Gets the right camera of a rig setup in case of Rigged Camera
  119066. */
  119067. get isRightCamera(): boolean;
  119068. /**
  119069. * Gets the left camera of a rig setup in case of Rigged Camera
  119070. */
  119071. get leftCamera(): Nullable<FreeCamera>;
  119072. /**
  119073. * Gets the right camera of a rig setup in case of Rigged Camera
  119074. */
  119075. get rightCamera(): Nullable<FreeCamera>;
  119076. /**
  119077. * Gets the left camera target of a rig setup in case of Rigged Camera
  119078. * @returns the target position
  119079. */
  119080. getLeftTarget(): Nullable<Vector3>;
  119081. /**
  119082. * Gets the right camera target of a rig setup in case of Rigged Camera
  119083. * @returns the target position
  119084. */
  119085. getRightTarget(): Nullable<Vector3>;
  119086. /**
  119087. * @hidden
  119088. */
  119089. setCameraRigMode(mode: number, rigParams: any): void;
  119090. /** @hidden */
  119091. static _setStereoscopicRigMode(camera: Camera): void;
  119092. /** @hidden */
  119093. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  119094. /** @hidden */
  119095. static _setVRRigMode(camera: Camera, rigParams: any): void;
  119096. /** @hidden */
  119097. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  119098. /** @hidden */
  119099. _getVRProjectionMatrix(): Matrix;
  119100. protected _updateCameraRotationMatrix(): void;
  119101. protected _updateWebVRCameraRotationMatrix(): void;
  119102. /**
  119103. * This function MUST be overwritten by the different WebVR cameras available.
  119104. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119105. * @hidden
  119106. */
  119107. _getWebVRProjectionMatrix(): Matrix;
  119108. /**
  119109. * This function MUST be overwritten by the different WebVR cameras available.
  119110. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119111. * @hidden
  119112. */
  119113. _getWebVRViewMatrix(): Matrix;
  119114. /** @hidden */
  119115. setCameraRigParameter(name: string, value: any): void;
  119116. /**
  119117. * needs to be overridden by children so sub has required properties to be copied
  119118. * @hidden
  119119. */
  119120. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  119121. /**
  119122. * May need to be overridden by children
  119123. * @hidden
  119124. */
  119125. _updateRigCameras(): void;
  119126. /** @hidden */
  119127. _setupInputs(): void;
  119128. /**
  119129. * Serialiaze the camera setup to a json represention
  119130. * @returns the JSON representation
  119131. */
  119132. serialize(): any;
  119133. /**
  119134. * Clones the current camera.
  119135. * @param name The cloned camera name
  119136. * @returns the cloned camera
  119137. */
  119138. clone(name: string): Camera;
  119139. /**
  119140. * Gets the direction of the camera relative to a given local axis.
  119141. * @param localAxis Defines the reference axis to provide a relative direction.
  119142. * @return the direction
  119143. */
  119144. getDirection(localAxis: Vector3): Vector3;
  119145. /**
  119146. * Returns the current camera absolute rotation
  119147. */
  119148. get absoluteRotation(): Quaternion;
  119149. /**
  119150. * Gets the direction of the camera relative to a given local axis into a passed vector.
  119151. * @param localAxis Defines the reference axis to provide a relative direction.
  119152. * @param result Defines the vector to store the result in
  119153. */
  119154. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  119155. /**
  119156. * Gets a camera constructor for a given camera type
  119157. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  119158. * @param name The name of the camera the result will be able to instantiate
  119159. * @param scene The scene the result will construct the camera in
  119160. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  119161. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  119162. * @returns a factory method to construc the camera
  119163. */
  119164. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  119165. /**
  119166. * Compute the world matrix of the camera.
  119167. * @returns the camera world matrix
  119168. */
  119169. computeWorldMatrix(): Matrix;
  119170. /**
  119171. * Parse a JSON and creates the camera from the parsed information
  119172. * @param parsedCamera The JSON to parse
  119173. * @param scene The scene to instantiate the camera in
  119174. * @returns the newly constructed camera
  119175. */
  119176. static Parse(parsedCamera: any, scene: Scene): Camera;
  119177. }
  119178. }
  119179. declare module BABYLON {
  119180. /**
  119181. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119182. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119183. */
  119184. export class PostProcessManager {
  119185. private _scene;
  119186. private _indexBuffer;
  119187. private _vertexBuffers;
  119188. /**
  119189. * Creates a new instance PostProcess
  119190. * @param scene The scene that the post process is associated with.
  119191. */
  119192. constructor(scene: Scene);
  119193. private _prepareBuffers;
  119194. private _buildIndexBuffer;
  119195. /**
  119196. * Rebuilds the vertex buffers of the manager.
  119197. * @hidden
  119198. */
  119199. _rebuild(): void;
  119200. /**
  119201. * Prepares a frame to be run through a post process.
  119202. * @param sourceTexture The input texture to the post procesess. (default: null)
  119203. * @param postProcesses An array of post processes to be run. (default: null)
  119204. * @returns True if the post processes were able to be run.
  119205. * @hidden
  119206. */
  119207. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  119208. /**
  119209. * Manually render a set of post processes to a texture.
  119210. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  119211. * @param postProcesses An array of post processes to be run.
  119212. * @param targetTexture The target texture to render to.
  119213. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119214. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119215. * @param lodLevel defines which lod of the texture to render to
  119216. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  119217. */
  119218. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  119219. /**
  119220. * Finalize the result of the output of the postprocesses.
  119221. * @param doNotPresent If true the result will not be displayed to the screen.
  119222. * @param targetTexture The target texture to render to.
  119223. * @param faceIndex The index of the face to bind the target texture to.
  119224. * @param postProcesses The array of post processes to render.
  119225. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119226. * @hidden
  119227. */
  119228. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  119229. /**
  119230. * Disposes of the post process manager.
  119231. */
  119232. dispose(): void;
  119233. }
  119234. }
  119235. declare module BABYLON {
  119236. /**
  119237. * This Helps creating a texture that will be created from a camera in your scene.
  119238. * It is basically a dynamic texture that could be used to create special effects for instance.
  119239. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  119240. */
  119241. export class RenderTargetTexture extends Texture {
  119242. /**
  119243. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  119244. */
  119245. static readonly REFRESHRATE_RENDER_ONCE: number;
  119246. /**
  119247. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  119248. */
  119249. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  119250. /**
  119251. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  119252. * the central point of your effect and can save a lot of performances.
  119253. */
  119254. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  119255. /**
  119256. * Use this predicate to dynamically define the list of mesh you want to render.
  119257. * If set, the renderList property will be overwritten.
  119258. */
  119259. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  119260. private _renderList;
  119261. /**
  119262. * Use this list to define the list of mesh you want to render.
  119263. */
  119264. get renderList(): Nullable<Array<AbstractMesh>>;
  119265. set renderList(value: Nullable<Array<AbstractMesh>>);
  119266. /**
  119267. * Use this function to overload the renderList array at rendering time.
  119268. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  119269. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  119270. * the cube (if the RTT is a cube, else layerOrFace=0).
  119271. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  119272. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  119273. * hold dummy elements!
  119274. */
  119275. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  119276. private _hookArray;
  119277. /**
  119278. * Define if particles should be rendered in your texture.
  119279. */
  119280. renderParticles: boolean;
  119281. /**
  119282. * Define if sprites should be rendered in your texture.
  119283. */
  119284. renderSprites: boolean;
  119285. /**
  119286. * Define the camera used to render the texture.
  119287. */
  119288. activeCamera: Nullable<Camera>;
  119289. /**
  119290. * Override the mesh isReady function with your own one.
  119291. */
  119292. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119293. /**
  119294. * Override the render function of the texture with your own one.
  119295. */
  119296. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119297. /**
  119298. * Define if camera post processes should be use while rendering the texture.
  119299. */
  119300. useCameraPostProcesses: boolean;
  119301. /**
  119302. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119303. */
  119304. ignoreCameraViewport: boolean;
  119305. private _postProcessManager;
  119306. private _postProcesses;
  119307. private _resizeObserver;
  119308. /**
  119309. * An event triggered when the texture is unbind.
  119310. */
  119311. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119312. /**
  119313. * An event triggered when the texture is unbind.
  119314. */
  119315. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119316. private _onAfterUnbindObserver;
  119317. /**
  119318. * Set a after unbind callback in the texture.
  119319. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119320. */
  119321. set onAfterUnbind(callback: () => void);
  119322. /**
  119323. * An event triggered before rendering the texture
  119324. */
  119325. onBeforeRenderObservable: Observable<number>;
  119326. private _onBeforeRenderObserver;
  119327. /**
  119328. * Set a before render callback in the texture.
  119329. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119330. */
  119331. set onBeforeRender(callback: (faceIndex: number) => void);
  119332. /**
  119333. * An event triggered after rendering the texture
  119334. */
  119335. onAfterRenderObservable: Observable<number>;
  119336. private _onAfterRenderObserver;
  119337. /**
  119338. * Set a after render callback in the texture.
  119339. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119340. */
  119341. set onAfterRender(callback: (faceIndex: number) => void);
  119342. /**
  119343. * An event triggered after the texture clear
  119344. */
  119345. onClearObservable: Observable<Engine>;
  119346. private _onClearObserver;
  119347. /**
  119348. * Set a clear callback in the texture.
  119349. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119350. */
  119351. set onClear(callback: (Engine: Engine) => void);
  119352. /**
  119353. * An event triggered when the texture is resized.
  119354. */
  119355. onResizeObservable: Observable<RenderTargetTexture>;
  119356. /**
  119357. * Define the clear color of the Render Target if it should be different from the scene.
  119358. */
  119359. clearColor: Color4;
  119360. protected _size: number | {
  119361. width: number;
  119362. height: number;
  119363. layers?: number;
  119364. };
  119365. protected _initialSizeParameter: number | {
  119366. width: number;
  119367. height: number;
  119368. } | {
  119369. ratio: number;
  119370. };
  119371. protected _sizeRatio: Nullable<number>;
  119372. /** @hidden */
  119373. _generateMipMaps: boolean;
  119374. protected _renderingManager: RenderingManager;
  119375. /** @hidden */
  119376. _waitingRenderList?: string[];
  119377. protected _doNotChangeAspectRatio: boolean;
  119378. protected _currentRefreshId: number;
  119379. protected _refreshRate: number;
  119380. protected _textureMatrix: Matrix;
  119381. protected _samples: number;
  119382. protected _renderTargetOptions: RenderTargetCreationOptions;
  119383. /**
  119384. * Gets render target creation options that were used.
  119385. */
  119386. get renderTargetOptions(): RenderTargetCreationOptions;
  119387. protected _onRatioRescale(): void;
  119388. /**
  119389. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119390. * It must define where the camera used to render the texture is set
  119391. */
  119392. boundingBoxPosition: Vector3;
  119393. private _boundingBoxSize;
  119394. /**
  119395. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119396. * When defined, the cubemap will switch to local mode
  119397. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119398. * @example https://www.babylonjs-playground.com/#RNASML
  119399. */
  119400. set boundingBoxSize(value: Vector3);
  119401. get boundingBoxSize(): Vector3;
  119402. /**
  119403. * In case the RTT has been created with a depth texture, get the associated
  119404. * depth texture.
  119405. * Otherwise, return null.
  119406. */
  119407. get depthStencilTexture(): Nullable<InternalTexture>;
  119408. /**
  119409. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119410. * or used a shadow, depth texture...
  119411. * @param name The friendly name of the texture
  119412. * @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)
  119413. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119414. * @param generateMipMaps True if mip maps need to be generated after render.
  119415. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119416. * @param type The type of the buffer in the RTT (int, half float, float...)
  119417. * @param isCube True if a cube texture needs to be created
  119418. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119419. * @param generateDepthBuffer True to generate a depth buffer
  119420. * @param generateStencilBuffer True to generate a stencil buffer
  119421. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119422. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119423. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119424. */
  119425. constructor(name: string, size: number | {
  119426. width: number;
  119427. height: number;
  119428. layers?: number;
  119429. } | {
  119430. ratio: number;
  119431. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119432. /**
  119433. * Creates a depth stencil texture.
  119434. * This is only available in WebGL 2 or with the depth texture extension available.
  119435. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119436. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119437. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119438. */
  119439. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119440. private _processSizeParameter;
  119441. /**
  119442. * Define the number of samples to use in case of MSAA.
  119443. * It defaults to one meaning no MSAA has been enabled.
  119444. */
  119445. get samples(): number;
  119446. set samples(value: number);
  119447. /**
  119448. * Resets the refresh counter of the texture and start bak from scratch.
  119449. * Could be useful to regenerate the texture if it is setup to render only once.
  119450. */
  119451. resetRefreshCounter(): void;
  119452. /**
  119453. * Define the refresh rate of the texture or the rendering frequency.
  119454. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119455. */
  119456. get refreshRate(): number;
  119457. set refreshRate(value: number);
  119458. /**
  119459. * Adds a post process to the render target rendering passes.
  119460. * @param postProcess define the post process to add
  119461. */
  119462. addPostProcess(postProcess: PostProcess): void;
  119463. /**
  119464. * Clear all the post processes attached to the render target
  119465. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119466. */
  119467. clearPostProcesses(dispose?: boolean): void;
  119468. /**
  119469. * Remove one of the post process from the list of attached post processes to the texture
  119470. * @param postProcess define the post process to remove from the list
  119471. */
  119472. removePostProcess(postProcess: PostProcess): void;
  119473. /** @hidden */
  119474. _shouldRender(): boolean;
  119475. /**
  119476. * Gets the actual render size of the texture.
  119477. * @returns the width of the render size
  119478. */
  119479. getRenderSize(): number;
  119480. /**
  119481. * Gets the actual render width of the texture.
  119482. * @returns the width of the render size
  119483. */
  119484. getRenderWidth(): number;
  119485. /**
  119486. * Gets the actual render height of the texture.
  119487. * @returns the height of the render size
  119488. */
  119489. getRenderHeight(): number;
  119490. /**
  119491. * Gets the actual number of layers of the texture.
  119492. * @returns the number of layers
  119493. */
  119494. getRenderLayers(): number;
  119495. /**
  119496. * Get if the texture can be rescaled or not.
  119497. */
  119498. get canRescale(): boolean;
  119499. /**
  119500. * Resize the texture using a ratio.
  119501. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119502. */
  119503. scale(ratio: number): void;
  119504. /**
  119505. * Get the texture reflection matrix used to rotate/transform the reflection.
  119506. * @returns the reflection matrix
  119507. */
  119508. getReflectionTextureMatrix(): Matrix;
  119509. /**
  119510. * Resize the texture to a new desired size.
  119511. * Be carrefull as it will recreate all the data in the new texture.
  119512. * @param size Define the new size. It can be:
  119513. * - a number for squared texture,
  119514. * - an object containing { width: number, height: number }
  119515. * - or an object containing a ratio { ratio: number }
  119516. */
  119517. resize(size: number | {
  119518. width: number;
  119519. height: number;
  119520. } | {
  119521. ratio: number;
  119522. }): void;
  119523. private _defaultRenderListPrepared;
  119524. /**
  119525. * Renders all the objects from the render list into the texture.
  119526. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119527. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119528. */
  119529. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119530. private _bestReflectionRenderTargetDimension;
  119531. private _prepareRenderingManager;
  119532. /**
  119533. * @hidden
  119534. * @param faceIndex face index to bind to if this is a cubetexture
  119535. * @param layer defines the index of the texture to bind in the array
  119536. */
  119537. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119538. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119539. private renderToTarget;
  119540. /**
  119541. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119542. * This allowed control for front to back rendering or reversly depending of the special needs.
  119543. *
  119544. * @param renderingGroupId The rendering group id corresponding to its index
  119545. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119546. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119547. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119548. */
  119549. 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;
  119550. /**
  119551. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119552. *
  119553. * @param renderingGroupId The rendering group id corresponding to its index
  119554. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119555. */
  119556. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119557. /**
  119558. * Clones the texture.
  119559. * @returns the cloned texture
  119560. */
  119561. clone(): RenderTargetTexture;
  119562. /**
  119563. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119564. * @returns The JSON representation of the texture
  119565. */
  119566. serialize(): any;
  119567. /**
  119568. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119569. */
  119570. disposeFramebufferObjects(): void;
  119571. /**
  119572. * Dispose the texture and release its associated resources.
  119573. */
  119574. dispose(): void;
  119575. /** @hidden */
  119576. _rebuild(): void;
  119577. /**
  119578. * Clear the info related to rendering groups preventing retention point in material dispose.
  119579. */
  119580. freeRenderingGroups(): void;
  119581. /**
  119582. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119583. * @returns the view count
  119584. */
  119585. getViewCount(): number;
  119586. }
  119587. }
  119588. declare module BABYLON {
  119589. /**
  119590. * Options to be used when creating an effect.
  119591. */
  119592. export interface IEffectCreationOptions {
  119593. /**
  119594. * Atrributes that will be used in the shader.
  119595. */
  119596. attributes: string[];
  119597. /**
  119598. * Uniform varible names that will be set in the shader.
  119599. */
  119600. uniformsNames: string[];
  119601. /**
  119602. * Uniform buffer variable names that will be set in the shader.
  119603. */
  119604. uniformBuffersNames: string[];
  119605. /**
  119606. * Sampler texture variable names that will be set in the shader.
  119607. */
  119608. samplers: string[];
  119609. /**
  119610. * Define statements that will be set in the shader.
  119611. */
  119612. defines: any;
  119613. /**
  119614. * Possible fallbacks for this effect to improve performance when needed.
  119615. */
  119616. fallbacks: Nullable<IEffectFallbacks>;
  119617. /**
  119618. * Callback that will be called when the shader is compiled.
  119619. */
  119620. onCompiled: Nullable<(effect: Effect) => void>;
  119621. /**
  119622. * Callback that will be called if an error occurs during shader compilation.
  119623. */
  119624. onError: Nullable<(effect: Effect, errors: string) => void>;
  119625. /**
  119626. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119627. */
  119628. indexParameters?: any;
  119629. /**
  119630. * Max number of lights that can be used in the shader.
  119631. */
  119632. maxSimultaneousLights?: number;
  119633. /**
  119634. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119635. */
  119636. transformFeedbackVaryings?: Nullable<string[]>;
  119637. /**
  119638. * 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
  119639. */
  119640. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119641. /**
  119642. * Is this effect rendering to several color attachments ?
  119643. */
  119644. multiTarget?: boolean;
  119645. }
  119646. /**
  119647. * Effect containing vertex and fragment shader that can be executed on an object.
  119648. */
  119649. export class Effect implements IDisposable {
  119650. /**
  119651. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119652. */
  119653. static ShadersRepository: string;
  119654. /**
  119655. * Enable logging of the shader code when a compilation error occurs
  119656. */
  119657. static LogShaderCodeOnCompilationError: boolean;
  119658. /**
  119659. * Name of the effect.
  119660. */
  119661. name: any;
  119662. /**
  119663. * String container all the define statements that should be set on the shader.
  119664. */
  119665. defines: string;
  119666. /**
  119667. * Callback that will be called when the shader is compiled.
  119668. */
  119669. onCompiled: Nullable<(effect: Effect) => void>;
  119670. /**
  119671. * Callback that will be called if an error occurs during shader compilation.
  119672. */
  119673. onError: Nullable<(effect: Effect, errors: string) => void>;
  119674. /**
  119675. * Callback that will be called when effect is bound.
  119676. */
  119677. onBind: Nullable<(effect: Effect) => void>;
  119678. /**
  119679. * Unique ID of the effect.
  119680. */
  119681. uniqueId: number;
  119682. /**
  119683. * Observable that will be called when the shader is compiled.
  119684. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119685. */
  119686. onCompileObservable: Observable<Effect>;
  119687. /**
  119688. * Observable that will be called if an error occurs during shader compilation.
  119689. */
  119690. onErrorObservable: Observable<Effect>;
  119691. /** @hidden */
  119692. _onBindObservable: Nullable<Observable<Effect>>;
  119693. /**
  119694. * @hidden
  119695. * Specifies if the effect was previously ready
  119696. */
  119697. _wasPreviouslyReady: boolean;
  119698. /**
  119699. * Observable that will be called when effect is bound.
  119700. */
  119701. get onBindObservable(): Observable<Effect>;
  119702. /** @hidden */
  119703. _bonesComputationForcedToCPU: boolean;
  119704. /** @hidden */
  119705. _multiTarget: boolean;
  119706. private static _uniqueIdSeed;
  119707. private _engine;
  119708. private _uniformBuffersNames;
  119709. private _uniformBuffersNamesList;
  119710. private _uniformsNames;
  119711. private _samplerList;
  119712. private _samplers;
  119713. private _isReady;
  119714. private _compilationError;
  119715. private _allFallbacksProcessed;
  119716. private _attributesNames;
  119717. private _attributes;
  119718. private _attributeLocationByName;
  119719. private _uniforms;
  119720. /**
  119721. * Key for the effect.
  119722. * @hidden
  119723. */
  119724. _key: string;
  119725. private _indexParameters;
  119726. private _fallbacks;
  119727. private _vertexSourceCode;
  119728. private _fragmentSourceCode;
  119729. private _vertexSourceCodeOverride;
  119730. private _fragmentSourceCodeOverride;
  119731. private _transformFeedbackVaryings;
  119732. private _rawVertexSourceCode;
  119733. private _rawFragmentSourceCode;
  119734. /**
  119735. * Compiled shader to webGL program.
  119736. * @hidden
  119737. */
  119738. _pipelineContext: Nullable<IPipelineContext>;
  119739. private _valueCache;
  119740. private static _baseCache;
  119741. /**
  119742. * Instantiates an effect.
  119743. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119744. * @param baseName Name of the effect.
  119745. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119746. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119747. * @param samplers List of sampler variables that will be passed to the shader.
  119748. * @param engine Engine to be used to render the effect
  119749. * @param defines Define statements to be added to the shader.
  119750. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119751. * @param onCompiled Callback that will be called when the shader is compiled.
  119752. * @param onError Callback that will be called if an error occurs during shader compilation.
  119753. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119754. */
  119755. 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);
  119756. private _useFinalCode;
  119757. /**
  119758. * Unique key for this effect
  119759. */
  119760. get key(): string;
  119761. /**
  119762. * If the effect has been compiled and prepared.
  119763. * @returns if the effect is compiled and prepared.
  119764. */
  119765. isReady(): boolean;
  119766. private _isReadyInternal;
  119767. /**
  119768. * The engine the effect was initialized with.
  119769. * @returns the engine.
  119770. */
  119771. getEngine(): Engine;
  119772. /**
  119773. * The pipeline context for this effect
  119774. * @returns the associated pipeline context
  119775. */
  119776. getPipelineContext(): Nullable<IPipelineContext>;
  119777. /**
  119778. * The set of names of attribute variables for the shader.
  119779. * @returns An array of attribute names.
  119780. */
  119781. getAttributesNames(): string[];
  119782. /**
  119783. * Returns the attribute at the given index.
  119784. * @param index The index of the attribute.
  119785. * @returns The location of the attribute.
  119786. */
  119787. getAttributeLocation(index: number): number;
  119788. /**
  119789. * Returns the attribute based on the name of the variable.
  119790. * @param name of the attribute to look up.
  119791. * @returns the attribute location.
  119792. */
  119793. getAttributeLocationByName(name: string): number;
  119794. /**
  119795. * The number of attributes.
  119796. * @returns the numnber of attributes.
  119797. */
  119798. getAttributesCount(): number;
  119799. /**
  119800. * Gets the index of a uniform variable.
  119801. * @param uniformName of the uniform to look up.
  119802. * @returns the index.
  119803. */
  119804. getUniformIndex(uniformName: string): number;
  119805. /**
  119806. * Returns the attribute based on the name of the variable.
  119807. * @param uniformName of the uniform to look up.
  119808. * @returns the location of the uniform.
  119809. */
  119810. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119811. /**
  119812. * Returns an array of sampler variable names
  119813. * @returns The array of sampler variable names.
  119814. */
  119815. getSamplers(): string[];
  119816. /**
  119817. * Returns an array of uniform variable names
  119818. * @returns The array of uniform variable names.
  119819. */
  119820. getUniformNames(): string[];
  119821. /**
  119822. * Returns an array of uniform buffer variable names
  119823. * @returns The array of uniform buffer variable names.
  119824. */
  119825. getUniformBuffersNames(): string[];
  119826. /**
  119827. * Returns the index parameters used to create the effect
  119828. * @returns The index parameters object
  119829. */
  119830. getIndexParameters(): any;
  119831. /**
  119832. * The error from the last compilation.
  119833. * @returns the error string.
  119834. */
  119835. getCompilationError(): string;
  119836. /**
  119837. * Gets a boolean indicating that all fallbacks were used during compilation
  119838. * @returns true if all fallbacks were used
  119839. */
  119840. allFallbacksProcessed(): boolean;
  119841. /**
  119842. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119843. * @param func The callback to be used.
  119844. */
  119845. executeWhenCompiled(func: (effect: Effect) => void): void;
  119846. private _checkIsReady;
  119847. private _loadShader;
  119848. /**
  119849. * Gets the vertex shader source code of this effect
  119850. */
  119851. get vertexSourceCode(): string;
  119852. /**
  119853. * Gets the fragment shader source code of this effect
  119854. */
  119855. get fragmentSourceCode(): string;
  119856. /**
  119857. * Gets the vertex shader source code before it has been processed by the preprocessor
  119858. */
  119859. get rawVertexSourceCode(): string;
  119860. /**
  119861. * Gets the fragment shader source code before it has been processed by the preprocessor
  119862. */
  119863. get rawFragmentSourceCode(): string;
  119864. /**
  119865. * Recompiles the webGL program
  119866. * @param vertexSourceCode The source code for the vertex shader.
  119867. * @param fragmentSourceCode The source code for the fragment shader.
  119868. * @param onCompiled Callback called when completed.
  119869. * @param onError Callback called on error.
  119870. * @hidden
  119871. */
  119872. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119873. /**
  119874. * Prepares the effect
  119875. * @hidden
  119876. */
  119877. _prepareEffect(): void;
  119878. private _getShaderCodeAndErrorLine;
  119879. private _processCompilationErrors;
  119880. /**
  119881. * Checks if the effect is supported. (Must be called after compilation)
  119882. */
  119883. get isSupported(): boolean;
  119884. /**
  119885. * Binds a texture to the engine to be used as output of the shader.
  119886. * @param channel Name of the output variable.
  119887. * @param texture Texture to bind.
  119888. * @hidden
  119889. */
  119890. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119891. /**
  119892. * Sets a texture on the engine to be used in the shader.
  119893. * @param channel Name of the sampler variable.
  119894. * @param texture Texture to set.
  119895. */
  119896. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119897. /**
  119898. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119899. * @param channel Name of the sampler variable.
  119900. * @param texture Texture to set.
  119901. */
  119902. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119903. /**
  119904. * Sets an array of textures on the engine to be used in the shader.
  119905. * @param channel Name of the variable.
  119906. * @param textures Textures to set.
  119907. */
  119908. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119909. /**
  119910. * 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)
  119911. * @param channel Name of the sampler variable.
  119912. * @param postProcess Post process to get the input texture from.
  119913. */
  119914. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119915. /**
  119916. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119917. * 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)
  119918. * @param channel Name of the sampler variable.
  119919. * @param postProcess Post process to get the output texture from.
  119920. */
  119921. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119922. /** @hidden */
  119923. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119924. /** @hidden */
  119925. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119926. /** @hidden */
  119927. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119928. /** @hidden */
  119929. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119930. /**
  119931. * Binds a buffer to a uniform.
  119932. * @param buffer Buffer to bind.
  119933. * @param name Name of the uniform variable to bind to.
  119934. */
  119935. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119936. /**
  119937. * Binds block to a uniform.
  119938. * @param blockName Name of the block to bind.
  119939. * @param index Index to bind.
  119940. */
  119941. bindUniformBlock(blockName: string, index: number): void;
  119942. /**
  119943. * Sets an interger value on a uniform variable.
  119944. * @param uniformName Name of the variable.
  119945. * @param value Value to be set.
  119946. * @returns this effect.
  119947. */
  119948. setInt(uniformName: string, value: number): Effect;
  119949. /**
  119950. * Sets an int array on a uniform variable.
  119951. * @param uniformName Name of the variable.
  119952. * @param array array to be set.
  119953. * @returns this effect.
  119954. */
  119955. setIntArray(uniformName: string, array: Int32Array): Effect;
  119956. /**
  119957. * 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)
  119958. * @param uniformName Name of the variable.
  119959. * @param array array to be set.
  119960. * @returns this effect.
  119961. */
  119962. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119963. /**
  119964. * 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)
  119965. * @param uniformName Name of the variable.
  119966. * @param array array to be set.
  119967. * @returns this effect.
  119968. */
  119969. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119970. /**
  119971. * 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)
  119972. * @param uniformName Name of the variable.
  119973. * @param array array to be set.
  119974. * @returns this effect.
  119975. */
  119976. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119977. /**
  119978. * Sets an float array on a uniform variable.
  119979. * @param uniformName Name of the variable.
  119980. * @param array array to be set.
  119981. * @returns this effect.
  119982. */
  119983. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119984. /**
  119985. * 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)
  119986. * @param uniformName Name of the variable.
  119987. * @param array array to be set.
  119988. * @returns this effect.
  119989. */
  119990. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119991. /**
  119992. * 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)
  119993. * @param uniformName Name of the variable.
  119994. * @param array array to be set.
  119995. * @returns this effect.
  119996. */
  119997. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119998. /**
  119999. * 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)
  120000. * @param uniformName Name of the variable.
  120001. * @param array array to be set.
  120002. * @returns this effect.
  120003. */
  120004. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  120005. /**
  120006. * Sets an array on a uniform variable.
  120007. * @param uniformName Name of the variable.
  120008. * @param array array to be set.
  120009. * @returns this effect.
  120010. */
  120011. setArray(uniformName: string, array: number[]): Effect;
  120012. /**
  120013. * 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)
  120014. * @param uniformName Name of the variable.
  120015. * @param array array to be set.
  120016. * @returns this effect.
  120017. */
  120018. setArray2(uniformName: string, array: number[]): Effect;
  120019. /**
  120020. * 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)
  120021. * @param uniformName Name of the variable.
  120022. * @param array array to be set.
  120023. * @returns this effect.
  120024. */
  120025. setArray3(uniformName: string, array: number[]): Effect;
  120026. /**
  120027. * 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)
  120028. * @param uniformName Name of the variable.
  120029. * @param array array to be set.
  120030. * @returns this effect.
  120031. */
  120032. setArray4(uniformName: string, array: number[]): Effect;
  120033. /**
  120034. * Sets matrices on a uniform variable.
  120035. * @param uniformName Name of the variable.
  120036. * @param matrices matrices to be set.
  120037. * @returns this effect.
  120038. */
  120039. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  120040. /**
  120041. * Sets matrix on a uniform variable.
  120042. * @param uniformName Name of the variable.
  120043. * @param matrix matrix to be set.
  120044. * @returns this effect.
  120045. */
  120046. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  120047. /**
  120048. * 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)
  120049. * @param uniformName Name of the variable.
  120050. * @param matrix matrix to be set.
  120051. * @returns this effect.
  120052. */
  120053. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120054. /**
  120055. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  120056. * @param uniformName Name of the variable.
  120057. * @param matrix matrix to be set.
  120058. * @returns this effect.
  120059. */
  120060. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120061. /**
  120062. * Sets a float on a uniform variable.
  120063. * @param uniformName Name of the variable.
  120064. * @param value value to be set.
  120065. * @returns this effect.
  120066. */
  120067. setFloat(uniformName: string, value: number): Effect;
  120068. /**
  120069. * Sets a boolean on a uniform variable.
  120070. * @param uniformName Name of the variable.
  120071. * @param bool value to be set.
  120072. * @returns this effect.
  120073. */
  120074. setBool(uniformName: string, bool: boolean): Effect;
  120075. /**
  120076. * Sets a Vector2 on a uniform variable.
  120077. * @param uniformName Name of the variable.
  120078. * @param vector2 vector2 to be set.
  120079. * @returns this effect.
  120080. */
  120081. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  120082. /**
  120083. * Sets a float2 on a uniform variable.
  120084. * @param uniformName Name of the variable.
  120085. * @param x First float in float2.
  120086. * @param y Second float in float2.
  120087. * @returns this effect.
  120088. */
  120089. setFloat2(uniformName: string, x: number, y: number): Effect;
  120090. /**
  120091. * Sets a Vector3 on a uniform variable.
  120092. * @param uniformName Name of the variable.
  120093. * @param vector3 Value to be set.
  120094. * @returns this effect.
  120095. */
  120096. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  120097. /**
  120098. * Sets a float3 on a uniform variable.
  120099. * @param uniformName Name of the variable.
  120100. * @param x First float in float3.
  120101. * @param y Second float in float3.
  120102. * @param z Third float in float3.
  120103. * @returns this effect.
  120104. */
  120105. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  120106. /**
  120107. * Sets a Vector4 on a uniform variable.
  120108. * @param uniformName Name of the variable.
  120109. * @param vector4 Value to be set.
  120110. * @returns this effect.
  120111. */
  120112. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  120113. /**
  120114. * Sets a float4 on a uniform variable.
  120115. * @param uniformName Name of the variable.
  120116. * @param x First float in float4.
  120117. * @param y Second float in float4.
  120118. * @param z Third float in float4.
  120119. * @param w Fourth float in float4.
  120120. * @returns this effect.
  120121. */
  120122. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  120123. /**
  120124. * Sets a Color3 on a uniform variable.
  120125. * @param uniformName Name of the variable.
  120126. * @param color3 Value to be set.
  120127. * @returns this effect.
  120128. */
  120129. setColor3(uniformName: string, color3: IColor3Like): Effect;
  120130. /**
  120131. * Sets a Color4 on a uniform variable.
  120132. * @param uniformName Name of the variable.
  120133. * @param color3 Value to be set.
  120134. * @param alpha Alpha value to be set.
  120135. * @returns this effect.
  120136. */
  120137. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  120138. /**
  120139. * Sets a Color4 on a uniform variable
  120140. * @param uniformName defines the name of the variable
  120141. * @param color4 defines the value to be set
  120142. * @returns this effect.
  120143. */
  120144. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  120145. /** Release all associated resources */
  120146. dispose(): void;
  120147. /**
  120148. * This function will add a new shader to the shader store
  120149. * @param name the name of the shader
  120150. * @param pixelShader optional pixel shader content
  120151. * @param vertexShader optional vertex shader content
  120152. */
  120153. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  120154. /**
  120155. * Store of each shader (The can be looked up using effect.key)
  120156. */
  120157. static ShadersStore: {
  120158. [key: string]: string;
  120159. };
  120160. /**
  120161. * Store of each included file for a shader (The can be looked up using effect.key)
  120162. */
  120163. static IncludesShadersStore: {
  120164. [key: string]: string;
  120165. };
  120166. /**
  120167. * Resets the cache of effects.
  120168. */
  120169. static ResetCache(): void;
  120170. }
  120171. }
  120172. declare module BABYLON {
  120173. /**
  120174. * Interface used to describe the capabilities of the engine relatively to the current browser
  120175. */
  120176. export interface EngineCapabilities {
  120177. /** Maximum textures units per fragment shader */
  120178. maxTexturesImageUnits: number;
  120179. /** Maximum texture units per vertex shader */
  120180. maxVertexTextureImageUnits: number;
  120181. /** Maximum textures units in the entire pipeline */
  120182. maxCombinedTexturesImageUnits: number;
  120183. /** Maximum texture size */
  120184. maxTextureSize: number;
  120185. /** Maximum texture samples */
  120186. maxSamples?: number;
  120187. /** Maximum cube texture size */
  120188. maxCubemapTextureSize: number;
  120189. /** Maximum render texture size */
  120190. maxRenderTextureSize: number;
  120191. /** Maximum number of vertex attributes */
  120192. maxVertexAttribs: number;
  120193. /** Maximum number of varyings */
  120194. maxVaryingVectors: number;
  120195. /** Maximum number of uniforms per vertex shader */
  120196. maxVertexUniformVectors: number;
  120197. /** Maximum number of uniforms per fragment shader */
  120198. maxFragmentUniformVectors: number;
  120199. /** Defines if standard derivates (dx/dy) are supported */
  120200. standardDerivatives: boolean;
  120201. /** Defines if s3tc texture compression is supported */
  120202. s3tc?: WEBGL_compressed_texture_s3tc;
  120203. /** Defines if pvrtc texture compression is supported */
  120204. pvrtc: any;
  120205. /** Defines if etc1 texture compression is supported */
  120206. etc1: any;
  120207. /** Defines if etc2 texture compression is supported */
  120208. etc2: any;
  120209. /** Defines if astc texture compression is supported */
  120210. astc: any;
  120211. /** Defines if bptc texture compression is supported */
  120212. bptc: any;
  120213. /** Defines if float textures are supported */
  120214. textureFloat: boolean;
  120215. /** Defines if vertex array objects are supported */
  120216. vertexArrayObject: boolean;
  120217. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  120218. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  120219. /** Gets the maximum level of anisotropy supported */
  120220. maxAnisotropy: number;
  120221. /** Defines if instancing is supported */
  120222. instancedArrays: boolean;
  120223. /** Defines if 32 bits indices are supported */
  120224. uintIndices: boolean;
  120225. /** Defines if high precision shaders are supported */
  120226. highPrecisionShaderSupported: boolean;
  120227. /** Defines if depth reading in the fragment shader is supported */
  120228. fragmentDepthSupported: boolean;
  120229. /** Defines if float texture linear filtering is supported*/
  120230. textureFloatLinearFiltering: boolean;
  120231. /** Defines if rendering to float textures is supported */
  120232. textureFloatRender: boolean;
  120233. /** Defines if half float textures are supported*/
  120234. textureHalfFloat: boolean;
  120235. /** Defines if half float texture linear filtering is supported*/
  120236. textureHalfFloatLinearFiltering: boolean;
  120237. /** Defines if rendering to half float textures is supported */
  120238. textureHalfFloatRender: boolean;
  120239. /** Defines if textureLOD shader command is supported */
  120240. textureLOD: boolean;
  120241. /** Defines if draw buffers extension is supported */
  120242. drawBuffersExtension: boolean;
  120243. /** Defines if depth textures are supported */
  120244. depthTextureExtension: boolean;
  120245. /** Defines if float color buffer are supported */
  120246. colorBufferFloat: boolean;
  120247. /** Gets disjoint timer query extension (null if not supported) */
  120248. timerQuery?: EXT_disjoint_timer_query;
  120249. /** Defines if timestamp can be used with timer query */
  120250. canUseTimestampForTimerQuery: boolean;
  120251. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  120252. multiview?: any;
  120253. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  120254. oculusMultiview?: any;
  120255. /** Function used to let the system compiles shaders in background */
  120256. parallelShaderCompile?: {
  120257. COMPLETION_STATUS_KHR: number;
  120258. };
  120259. /** Max number of texture samples for MSAA */
  120260. maxMSAASamples: number;
  120261. /** Defines if the blend min max extension is supported */
  120262. blendMinMax: boolean;
  120263. }
  120264. }
  120265. declare module BABYLON {
  120266. /**
  120267. * @hidden
  120268. **/
  120269. export class DepthCullingState {
  120270. private _isDepthTestDirty;
  120271. private _isDepthMaskDirty;
  120272. private _isDepthFuncDirty;
  120273. private _isCullFaceDirty;
  120274. private _isCullDirty;
  120275. private _isZOffsetDirty;
  120276. private _isFrontFaceDirty;
  120277. private _depthTest;
  120278. private _depthMask;
  120279. private _depthFunc;
  120280. private _cull;
  120281. private _cullFace;
  120282. private _zOffset;
  120283. private _frontFace;
  120284. /**
  120285. * Initializes the state.
  120286. */
  120287. constructor();
  120288. get isDirty(): boolean;
  120289. get zOffset(): number;
  120290. set zOffset(value: number);
  120291. get cullFace(): Nullable<number>;
  120292. set cullFace(value: Nullable<number>);
  120293. get cull(): Nullable<boolean>;
  120294. set cull(value: Nullable<boolean>);
  120295. get depthFunc(): Nullable<number>;
  120296. set depthFunc(value: Nullable<number>);
  120297. get depthMask(): boolean;
  120298. set depthMask(value: boolean);
  120299. get depthTest(): boolean;
  120300. set depthTest(value: boolean);
  120301. get frontFace(): Nullable<number>;
  120302. set frontFace(value: Nullable<number>);
  120303. reset(): void;
  120304. apply(gl: WebGLRenderingContext): void;
  120305. }
  120306. }
  120307. declare module BABYLON {
  120308. /**
  120309. * @hidden
  120310. **/
  120311. export class StencilState {
  120312. /** 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 */
  120313. static readonly ALWAYS: number;
  120314. /** Passed to stencilOperation to specify that stencil value must be kept */
  120315. static readonly KEEP: number;
  120316. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120317. static readonly REPLACE: number;
  120318. private _isStencilTestDirty;
  120319. private _isStencilMaskDirty;
  120320. private _isStencilFuncDirty;
  120321. private _isStencilOpDirty;
  120322. private _stencilTest;
  120323. private _stencilMask;
  120324. private _stencilFunc;
  120325. private _stencilFuncRef;
  120326. private _stencilFuncMask;
  120327. private _stencilOpStencilFail;
  120328. private _stencilOpDepthFail;
  120329. private _stencilOpStencilDepthPass;
  120330. get isDirty(): boolean;
  120331. get stencilFunc(): number;
  120332. set stencilFunc(value: number);
  120333. get stencilFuncRef(): number;
  120334. set stencilFuncRef(value: number);
  120335. get stencilFuncMask(): number;
  120336. set stencilFuncMask(value: number);
  120337. get stencilOpStencilFail(): number;
  120338. set stencilOpStencilFail(value: number);
  120339. get stencilOpDepthFail(): number;
  120340. set stencilOpDepthFail(value: number);
  120341. get stencilOpStencilDepthPass(): number;
  120342. set stencilOpStencilDepthPass(value: number);
  120343. get stencilMask(): number;
  120344. set stencilMask(value: number);
  120345. get stencilTest(): boolean;
  120346. set stencilTest(value: boolean);
  120347. constructor();
  120348. reset(): void;
  120349. apply(gl: WebGLRenderingContext): void;
  120350. }
  120351. }
  120352. declare module BABYLON {
  120353. /**
  120354. * @hidden
  120355. **/
  120356. export class AlphaState {
  120357. private _isAlphaBlendDirty;
  120358. private _isBlendFunctionParametersDirty;
  120359. private _isBlendEquationParametersDirty;
  120360. private _isBlendConstantsDirty;
  120361. private _alphaBlend;
  120362. private _blendFunctionParameters;
  120363. private _blendEquationParameters;
  120364. private _blendConstants;
  120365. /**
  120366. * Initializes the state.
  120367. */
  120368. constructor();
  120369. get isDirty(): boolean;
  120370. get alphaBlend(): boolean;
  120371. set alphaBlend(value: boolean);
  120372. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120373. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120374. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120375. reset(): void;
  120376. apply(gl: WebGLRenderingContext): void;
  120377. }
  120378. }
  120379. declare module BABYLON {
  120380. /** @hidden */
  120381. export class WebGLShaderProcessor implements IShaderProcessor {
  120382. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120383. }
  120384. }
  120385. declare module BABYLON {
  120386. /** @hidden */
  120387. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120388. attributeProcessor(attribute: string): string;
  120389. varyingProcessor(varying: string, isFragment: boolean): string;
  120390. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120391. }
  120392. }
  120393. declare module BABYLON {
  120394. /**
  120395. * Interface for attribute information associated with buffer instanciation
  120396. */
  120397. export interface InstancingAttributeInfo {
  120398. /**
  120399. * Name of the GLSL attribute
  120400. * if attribute index is not specified, this is used to retrieve the index from the effect
  120401. */
  120402. attributeName: string;
  120403. /**
  120404. * Index/offset of the attribute in the vertex shader
  120405. * if not specified, this will be computes from the name.
  120406. */
  120407. index?: number;
  120408. /**
  120409. * size of the attribute, 1, 2, 3 or 4
  120410. */
  120411. attributeSize: number;
  120412. /**
  120413. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120414. */
  120415. offset: number;
  120416. /**
  120417. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120418. * default to 1
  120419. */
  120420. divisor?: number;
  120421. /**
  120422. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120423. * default is FLOAT
  120424. */
  120425. attributeType?: number;
  120426. /**
  120427. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120428. */
  120429. normalized?: boolean;
  120430. }
  120431. }
  120432. declare module BABYLON {
  120433. interface ThinEngine {
  120434. /**
  120435. * Update a video texture
  120436. * @param texture defines the texture to update
  120437. * @param video defines the video element to use
  120438. * @param invertY defines if data must be stored with Y axis inverted
  120439. */
  120440. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120441. }
  120442. }
  120443. declare module BABYLON {
  120444. interface ThinEngine {
  120445. /**
  120446. * Creates a dynamic texture
  120447. * @param width defines the width of the texture
  120448. * @param height defines the height of the texture
  120449. * @param generateMipMaps defines if the engine should generate the mip levels
  120450. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120451. * @returns the dynamic texture inside an InternalTexture
  120452. */
  120453. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120454. /**
  120455. * Update the content of a dynamic texture
  120456. * @param texture defines the texture to update
  120457. * @param source defines the source containing the data
  120458. * @param invertY defines if data must be stored with Y axis inverted
  120459. * @param premulAlpha defines if alpha is stored as premultiplied
  120460. * @param format defines the format of the data
  120461. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120462. */
  120463. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120464. }
  120465. }
  120466. declare module BABYLON {
  120467. /**
  120468. * Settings for finer control over video usage
  120469. */
  120470. export interface VideoTextureSettings {
  120471. /**
  120472. * Applies `autoplay` to video, if specified
  120473. */
  120474. autoPlay?: boolean;
  120475. /**
  120476. * Applies `muted` to video, if specified
  120477. */
  120478. muted?: boolean;
  120479. /**
  120480. * Applies `loop` to video, if specified
  120481. */
  120482. loop?: boolean;
  120483. /**
  120484. * Automatically updates internal texture from video at every frame in the render loop
  120485. */
  120486. autoUpdateTexture: boolean;
  120487. /**
  120488. * Image src displayed during the video loading or until the user interacts with the video.
  120489. */
  120490. poster?: string;
  120491. }
  120492. /**
  120493. * If you want to display a video in your scene, this is the special texture for that.
  120494. * This special texture works similar to other textures, with the exception of a few parameters.
  120495. * @see https://doc.babylonjs.com/how_to/video_texture
  120496. */
  120497. export class VideoTexture extends Texture {
  120498. /**
  120499. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120500. */
  120501. readonly autoUpdateTexture: boolean;
  120502. /**
  120503. * The video instance used by the texture internally
  120504. */
  120505. readonly video: HTMLVideoElement;
  120506. private _onUserActionRequestedObservable;
  120507. /**
  120508. * Event triggerd when a dom action is required by the user to play the video.
  120509. * This happens due to recent changes in browser policies preventing video to auto start.
  120510. */
  120511. get onUserActionRequestedObservable(): Observable<Texture>;
  120512. private _generateMipMaps;
  120513. private _stillImageCaptured;
  120514. private _displayingPosterTexture;
  120515. private _settings;
  120516. private _createInternalTextureOnEvent;
  120517. private _frameId;
  120518. private _currentSrc;
  120519. /**
  120520. * Creates a video texture.
  120521. * If you want to display a video in your scene, this is the special texture for that.
  120522. * This special texture works similar to other textures, with the exception of a few parameters.
  120523. * @see https://doc.babylonjs.com/how_to/video_texture
  120524. * @param name optional name, will detect from video source, if not defined
  120525. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120526. * @param scene is obviously the current scene.
  120527. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120528. * @param invertY is false by default but can be used to invert video on Y axis
  120529. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120530. * @param settings allows finer control over video usage
  120531. */
  120532. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120533. private _getName;
  120534. private _getVideo;
  120535. private _createInternalTexture;
  120536. private reset;
  120537. /**
  120538. * @hidden Internal method to initiate `update`.
  120539. */
  120540. _rebuild(): void;
  120541. /**
  120542. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120543. */
  120544. update(): void;
  120545. /**
  120546. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120547. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120548. */
  120549. updateTexture(isVisible: boolean): void;
  120550. protected _updateInternalTexture: () => void;
  120551. /**
  120552. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120553. * @param url New url.
  120554. */
  120555. updateURL(url: string): void;
  120556. /**
  120557. * Clones the texture.
  120558. * @returns the cloned texture
  120559. */
  120560. clone(): VideoTexture;
  120561. /**
  120562. * Dispose the texture and release its associated resources.
  120563. */
  120564. dispose(): void;
  120565. /**
  120566. * Creates a video texture straight from a stream.
  120567. * @param scene Define the scene the texture should be created in
  120568. * @param stream Define the stream the texture should be created from
  120569. * @returns The created video texture as a promise
  120570. */
  120571. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120572. /**
  120573. * Creates a video texture straight from your WebCam video feed.
  120574. * @param scene Define the scene the texture should be created in
  120575. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120576. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120577. * @returns The created video texture as a promise
  120578. */
  120579. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120580. minWidth: number;
  120581. maxWidth: number;
  120582. minHeight: number;
  120583. maxHeight: number;
  120584. deviceId: string;
  120585. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120586. /**
  120587. * Creates a video texture straight from your WebCam video feed.
  120588. * @param scene Define the scene the texture should be created in
  120589. * @param onReady Define a callback to triggered once the texture will be ready
  120590. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120591. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120592. */
  120593. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120594. minWidth: number;
  120595. maxWidth: number;
  120596. minHeight: number;
  120597. maxHeight: number;
  120598. deviceId: string;
  120599. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120600. }
  120601. }
  120602. declare module BABYLON {
  120603. /**
  120604. * Defines the interface used by objects working like Scene
  120605. * @hidden
  120606. */
  120607. export interface ISceneLike {
  120608. _addPendingData(data: any): void;
  120609. _removePendingData(data: any): void;
  120610. offlineProvider: IOfflineProvider;
  120611. }
  120612. /**
  120613. * Information about the current host
  120614. */
  120615. export interface HostInformation {
  120616. /**
  120617. * Defines if the current host is a mobile
  120618. */
  120619. isMobile: boolean;
  120620. }
  120621. /** Interface defining initialization parameters for Engine class */
  120622. export interface EngineOptions extends WebGLContextAttributes {
  120623. /**
  120624. * Defines if the engine should no exceed a specified device ratio
  120625. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120626. */
  120627. limitDeviceRatio?: number;
  120628. /**
  120629. * Defines if webvr should be enabled automatically
  120630. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120631. */
  120632. autoEnableWebVR?: boolean;
  120633. /**
  120634. * Defines if webgl2 should be turned off even if supported
  120635. * @see https://doc.babylonjs.com/features/webgl2
  120636. */
  120637. disableWebGL2Support?: boolean;
  120638. /**
  120639. * Defines if webaudio should be initialized as well
  120640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120641. */
  120642. audioEngine?: boolean;
  120643. /**
  120644. * Defines if animations should run using a deterministic lock step
  120645. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120646. */
  120647. deterministicLockstep?: boolean;
  120648. /** Defines the maximum steps to use with deterministic lock step mode */
  120649. lockstepMaxSteps?: number;
  120650. /** Defines the seconds between each deterministic lock step */
  120651. timeStep?: number;
  120652. /**
  120653. * Defines that engine should ignore context lost events
  120654. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120655. */
  120656. doNotHandleContextLost?: boolean;
  120657. /**
  120658. * Defines that engine should ignore modifying touch action attribute and style
  120659. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120660. */
  120661. doNotHandleTouchAction?: boolean;
  120662. /**
  120663. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120664. */
  120665. useHighPrecisionFloats?: boolean;
  120666. /**
  120667. * Make the canvas XR Compatible for XR sessions
  120668. */
  120669. xrCompatible?: boolean;
  120670. /**
  120671. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120672. */
  120673. useHighPrecisionMatrix?: boolean;
  120674. /**
  120675. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120676. */
  120677. failIfMajorPerformanceCaveat?: boolean;
  120678. }
  120679. /**
  120680. * The base engine class (root of all engines)
  120681. */
  120682. export class ThinEngine {
  120683. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120684. static ExceptionList: ({
  120685. key: string;
  120686. capture: string;
  120687. captureConstraint: number;
  120688. targets: string[];
  120689. } | {
  120690. key: string;
  120691. capture: null;
  120692. captureConstraint: null;
  120693. targets: string[];
  120694. })[];
  120695. /** @hidden */
  120696. static _TextureLoaders: IInternalTextureLoader[];
  120697. /**
  120698. * Returns the current npm package of the sdk
  120699. */
  120700. static get NpmPackage(): string;
  120701. /**
  120702. * Returns the current version of the framework
  120703. */
  120704. static get Version(): string;
  120705. /**
  120706. * Returns a string describing the current engine
  120707. */
  120708. get description(): string;
  120709. /**
  120710. * Gets or sets the epsilon value used by collision engine
  120711. */
  120712. static CollisionsEpsilon: number;
  120713. /**
  120714. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120715. */
  120716. static get ShadersRepository(): string;
  120717. static set ShadersRepository(value: string);
  120718. /** @hidden */
  120719. _shaderProcessor: IShaderProcessor;
  120720. /**
  120721. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120722. */
  120723. forcePOTTextures: boolean;
  120724. /**
  120725. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120726. */
  120727. isFullscreen: boolean;
  120728. /**
  120729. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120730. */
  120731. cullBackFaces: boolean;
  120732. /**
  120733. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120734. */
  120735. renderEvenInBackground: boolean;
  120736. /**
  120737. * Gets or sets a boolean indicating that cache can be kept between frames
  120738. */
  120739. preventCacheWipeBetweenFrames: boolean;
  120740. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120741. validateShaderPrograms: boolean;
  120742. /**
  120743. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120744. * This can provide greater z depth for distant objects.
  120745. */
  120746. useReverseDepthBuffer: boolean;
  120747. /**
  120748. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120749. */
  120750. disableUniformBuffers: boolean;
  120751. /** @hidden */
  120752. _uniformBuffers: UniformBuffer[];
  120753. /**
  120754. * Gets a boolean indicating that the engine supports uniform buffers
  120755. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120756. */
  120757. get supportsUniformBuffers(): boolean;
  120758. /** @hidden */
  120759. _gl: WebGLRenderingContext;
  120760. /** @hidden */
  120761. _webGLVersion: number;
  120762. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120763. protected _windowIsBackground: boolean;
  120764. protected _creationOptions: EngineOptions;
  120765. protected _highPrecisionShadersAllowed: boolean;
  120766. /** @hidden */
  120767. get _shouldUseHighPrecisionShader(): boolean;
  120768. /**
  120769. * Gets a boolean indicating that only power of 2 textures are supported
  120770. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120771. */
  120772. get needPOTTextures(): boolean;
  120773. /** @hidden */
  120774. _badOS: boolean;
  120775. /** @hidden */
  120776. _badDesktopOS: boolean;
  120777. private _hardwareScalingLevel;
  120778. /** @hidden */
  120779. _caps: EngineCapabilities;
  120780. private _isStencilEnable;
  120781. private _glVersion;
  120782. private _glRenderer;
  120783. private _glVendor;
  120784. /** @hidden */
  120785. _videoTextureSupported: boolean;
  120786. protected _renderingQueueLaunched: boolean;
  120787. protected _activeRenderLoops: (() => void)[];
  120788. /**
  120789. * Observable signaled when a context lost event is raised
  120790. */
  120791. onContextLostObservable: Observable<ThinEngine>;
  120792. /**
  120793. * Observable signaled when a context restored event is raised
  120794. */
  120795. onContextRestoredObservable: Observable<ThinEngine>;
  120796. private _onContextLost;
  120797. private _onContextRestored;
  120798. protected _contextWasLost: boolean;
  120799. /** @hidden */
  120800. _doNotHandleContextLost: boolean;
  120801. /**
  120802. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120803. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120804. */
  120805. get doNotHandleContextLost(): boolean;
  120806. set doNotHandleContextLost(value: boolean);
  120807. /**
  120808. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120809. */
  120810. disableVertexArrayObjects: boolean;
  120811. /** @hidden */
  120812. protected _colorWrite: boolean;
  120813. /** @hidden */
  120814. protected _colorWriteChanged: boolean;
  120815. /** @hidden */
  120816. protected _depthCullingState: DepthCullingState;
  120817. /** @hidden */
  120818. protected _stencilState: StencilState;
  120819. /** @hidden */
  120820. _alphaState: AlphaState;
  120821. /** @hidden */
  120822. _alphaMode: number;
  120823. /** @hidden */
  120824. _alphaEquation: number;
  120825. /** @hidden */
  120826. _internalTexturesCache: InternalTexture[];
  120827. /** @hidden */
  120828. protected _activeChannel: number;
  120829. private _currentTextureChannel;
  120830. /** @hidden */
  120831. protected _boundTexturesCache: {
  120832. [key: string]: Nullable<InternalTexture>;
  120833. };
  120834. /** @hidden */
  120835. protected _currentEffect: Nullable<Effect>;
  120836. /** @hidden */
  120837. protected _currentProgram: Nullable<WebGLProgram>;
  120838. private _compiledEffects;
  120839. private _vertexAttribArraysEnabled;
  120840. /** @hidden */
  120841. protected _cachedViewport: Nullable<IViewportLike>;
  120842. private _cachedVertexArrayObject;
  120843. /** @hidden */
  120844. protected _cachedVertexBuffers: any;
  120845. /** @hidden */
  120846. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120847. /** @hidden */
  120848. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120849. /** @hidden */
  120850. _currentRenderTarget: Nullable<InternalTexture>;
  120851. private _uintIndicesCurrentlySet;
  120852. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120853. /** @hidden */
  120854. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120855. /** @hidden */
  120856. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120857. private _currentBufferPointers;
  120858. private _currentInstanceLocations;
  120859. private _currentInstanceBuffers;
  120860. private _textureUnits;
  120861. /** @hidden */
  120862. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120863. /** @hidden */
  120864. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120865. /** @hidden */
  120866. _boundRenderFunction: any;
  120867. private _vaoRecordInProgress;
  120868. private _mustWipeVertexAttributes;
  120869. private _emptyTexture;
  120870. private _emptyCubeTexture;
  120871. private _emptyTexture3D;
  120872. private _emptyTexture2DArray;
  120873. /** @hidden */
  120874. _frameHandler: number;
  120875. private _nextFreeTextureSlots;
  120876. private _maxSimultaneousTextures;
  120877. private _activeRequests;
  120878. /** @hidden */
  120879. _transformTextureUrl: Nullable<(url: string) => string>;
  120880. /**
  120881. * Gets information about the current host
  120882. */
  120883. hostInformation: HostInformation;
  120884. protected get _supportsHardwareTextureRescaling(): boolean;
  120885. private _framebufferDimensionsObject;
  120886. /**
  120887. * sets the object from which width and height will be taken from when getting render width and height
  120888. * Will fallback to the gl object
  120889. * @param dimensions the framebuffer width and height that will be used.
  120890. */
  120891. set framebufferDimensionsObject(dimensions: Nullable<{
  120892. framebufferWidth: number;
  120893. framebufferHeight: number;
  120894. }>);
  120895. /**
  120896. * Gets the current viewport
  120897. */
  120898. get currentViewport(): Nullable<IViewportLike>;
  120899. /**
  120900. * Gets the default empty texture
  120901. */
  120902. get emptyTexture(): InternalTexture;
  120903. /**
  120904. * Gets the default empty 3D texture
  120905. */
  120906. get emptyTexture3D(): InternalTexture;
  120907. /**
  120908. * Gets the default empty 2D array texture
  120909. */
  120910. get emptyTexture2DArray(): InternalTexture;
  120911. /**
  120912. * Gets the default empty cube texture
  120913. */
  120914. get emptyCubeTexture(): InternalTexture;
  120915. /**
  120916. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120917. */
  120918. readonly premultipliedAlpha: boolean;
  120919. /**
  120920. * Observable event triggered before each texture is initialized
  120921. */
  120922. onBeforeTextureInitObservable: Observable<Texture>;
  120923. /**
  120924. * Creates a new engine
  120925. * @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
  120926. * @param antialias defines enable antialiasing (default: false)
  120927. * @param options defines further options to be sent to the getContext() function
  120928. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120929. */
  120930. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120931. private _rebuildInternalTextures;
  120932. private _rebuildEffects;
  120933. /**
  120934. * Gets a boolean indicating if all created effects are ready
  120935. * @returns true if all effects are ready
  120936. */
  120937. areAllEffectsReady(): boolean;
  120938. protected _rebuildBuffers(): void;
  120939. protected _initGLContext(): void;
  120940. /**
  120941. * Gets version of the current webGL context
  120942. */
  120943. get webGLVersion(): number;
  120944. /**
  120945. * Gets a string identifying the name of the class
  120946. * @returns "Engine" string
  120947. */
  120948. getClassName(): string;
  120949. /**
  120950. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120951. */
  120952. get isStencilEnable(): boolean;
  120953. /** @hidden */
  120954. _prepareWorkingCanvas(): void;
  120955. /**
  120956. * Reset the texture cache to empty state
  120957. */
  120958. resetTextureCache(): void;
  120959. /**
  120960. * Gets an object containing information about the current webGL context
  120961. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120962. */
  120963. getGlInfo(): {
  120964. vendor: string;
  120965. renderer: string;
  120966. version: string;
  120967. };
  120968. /**
  120969. * Defines the hardware scaling level.
  120970. * By default the hardware scaling level is computed from the window device ratio.
  120971. * 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.
  120972. * @param level defines the level to use
  120973. */
  120974. setHardwareScalingLevel(level: number): void;
  120975. /**
  120976. * Gets the current hardware scaling level.
  120977. * By default the hardware scaling level is computed from the window device ratio.
  120978. * 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.
  120979. * @returns a number indicating the current hardware scaling level
  120980. */
  120981. getHardwareScalingLevel(): number;
  120982. /**
  120983. * Gets the list of loaded textures
  120984. * @returns an array containing all loaded textures
  120985. */
  120986. getLoadedTexturesCache(): InternalTexture[];
  120987. /**
  120988. * Gets the object containing all engine capabilities
  120989. * @returns the EngineCapabilities object
  120990. */
  120991. getCaps(): EngineCapabilities;
  120992. /**
  120993. * stop executing a render loop function and remove it from the execution array
  120994. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120995. */
  120996. stopRenderLoop(renderFunction?: () => void): void;
  120997. /** @hidden */
  120998. _renderLoop(): void;
  120999. /**
  121000. * Gets the HTML canvas attached with the current webGL context
  121001. * @returns a HTML canvas
  121002. */
  121003. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  121004. /**
  121005. * Gets host window
  121006. * @returns the host window object
  121007. */
  121008. getHostWindow(): Nullable<Window>;
  121009. /**
  121010. * Gets the current render width
  121011. * @param useScreen defines if screen size must be used (or the current render target if any)
  121012. * @returns a number defining the current render width
  121013. */
  121014. getRenderWidth(useScreen?: boolean): number;
  121015. /**
  121016. * Gets the current render height
  121017. * @param useScreen defines if screen size must be used (or the current render target if any)
  121018. * @returns a number defining the current render height
  121019. */
  121020. getRenderHeight(useScreen?: boolean): number;
  121021. /**
  121022. * Can be used to override the current requestAnimationFrame requester.
  121023. * @hidden
  121024. */
  121025. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121026. /**
  121027. * Register and execute a render loop. The engine can have more than one render function
  121028. * @param renderFunction defines the function to continuously execute
  121029. */
  121030. runRenderLoop(renderFunction: () => void): void;
  121031. /**
  121032. * Clear the current render buffer or the current render target (if any is set up)
  121033. * @param color defines the color to use
  121034. * @param backBuffer defines if the back buffer must be cleared
  121035. * @param depth defines if the depth buffer must be cleared
  121036. * @param stencil defines if the stencil buffer must be cleared
  121037. */
  121038. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121039. private _viewportCached;
  121040. /** @hidden */
  121041. _viewport(x: number, y: number, width: number, height: number): void;
  121042. /**
  121043. * Set the WebGL's viewport
  121044. * @param viewport defines the viewport element to be used
  121045. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121046. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121047. */
  121048. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121049. /**
  121050. * Begin a new frame
  121051. */
  121052. beginFrame(): void;
  121053. /**
  121054. * Enf the current frame
  121055. */
  121056. endFrame(): void;
  121057. /**
  121058. * Resize the view according to the canvas' size
  121059. */
  121060. resize(): void;
  121061. /**
  121062. * Force a specific size of the canvas
  121063. * @param width defines the new canvas' width
  121064. * @param height defines the new canvas' height
  121065. * @returns true if the size was changed
  121066. */
  121067. setSize(width: number, height: number): boolean;
  121068. /**
  121069. * Binds the frame buffer to the specified texture.
  121070. * @param texture The texture to render to or null for the default canvas
  121071. * @param faceIndex The face of the texture to render to in case of cube texture
  121072. * @param requiredWidth The width of the target to render to
  121073. * @param requiredHeight The height of the target to render to
  121074. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121075. * @param lodLevel defines the lod level to bind to the frame buffer
  121076. * @param layer defines the 2d array index to bind to frame buffer to
  121077. */
  121078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  121079. /** @hidden */
  121080. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121081. /**
  121082. * Unbind the current render target texture from the webGL context
  121083. * @param texture defines the render target texture to unbind
  121084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121086. */
  121087. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121088. /**
  121089. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  121090. */
  121091. flushFramebuffer(): void;
  121092. /**
  121093. * Unbind the current render target and bind the default framebuffer
  121094. */
  121095. restoreDefaultFramebuffer(): void;
  121096. /** @hidden */
  121097. protected _resetVertexBufferBinding(): void;
  121098. /**
  121099. * Creates a vertex buffer
  121100. * @param data the data for the vertex buffer
  121101. * @returns the new WebGL static buffer
  121102. */
  121103. createVertexBuffer(data: DataArray): DataBuffer;
  121104. private _createVertexBuffer;
  121105. /**
  121106. * Creates a dynamic vertex buffer
  121107. * @param data the data for the dynamic vertex buffer
  121108. * @returns the new WebGL dynamic buffer
  121109. */
  121110. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121111. protected _resetIndexBufferBinding(): void;
  121112. /**
  121113. * Creates a new index buffer
  121114. * @param indices defines the content of the index buffer
  121115. * @param updatable defines if the index buffer must be updatable
  121116. * @returns a new webGL buffer
  121117. */
  121118. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  121119. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  121120. /**
  121121. * Bind a webGL buffer to the webGL context
  121122. * @param buffer defines the buffer to bind
  121123. */
  121124. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  121125. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  121126. private bindBuffer;
  121127. /**
  121128. * update the bound buffer with the given data
  121129. * @param data defines the data to update
  121130. */
  121131. updateArrayBuffer(data: Float32Array): void;
  121132. private _vertexAttribPointer;
  121133. /** @hidden */
  121134. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  121135. private _bindVertexBuffersAttributes;
  121136. /**
  121137. * Records a vertex array object
  121138. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121139. * @param vertexBuffers defines the list of vertex buffers to store
  121140. * @param indexBuffer defines the index buffer to store
  121141. * @param effect defines the effect to store
  121142. * @returns the new vertex array object
  121143. */
  121144. recordVertexArrayObject(vertexBuffers: {
  121145. [key: string]: VertexBuffer;
  121146. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121147. /**
  121148. * Bind a specific vertex array object
  121149. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121150. * @param vertexArrayObject defines the vertex array object to bind
  121151. * @param indexBuffer defines the index buffer to bind
  121152. */
  121153. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  121154. /**
  121155. * Bind webGl buffers directly to the webGL context
  121156. * @param vertexBuffer defines the vertex buffer to bind
  121157. * @param indexBuffer defines the index buffer to bind
  121158. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121159. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121160. * @param effect defines the effect associated with the vertex buffer
  121161. */
  121162. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  121163. private _unbindVertexArrayObject;
  121164. /**
  121165. * Bind a list of vertex buffers to the webGL context
  121166. * @param vertexBuffers defines the list of vertex buffers to bind
  121167. * @param indexBuffer defines the index buffer to bind
  121168. * @param effect defines the effect associated with the vertex buffers
  121169. */
  121170. bindBuffers(vertexBuffers: {
  121171. [key: string]: Nullable<VertexBuffer>;
  121172. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  121173. /**
  121174. * Unbind all instance attributes
  121175. */
  121176. unbindInstanceAttributes(): void;
  121177. /**
  121178. * Release and free the memory of a vertex array object
  121179. * @param vao defines the vertex array object to delete
  121180. */
  121181. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  121182. /** @hidden */
  121183. _releaseBuffer(buffer: DataBuffer): boolean;
  121184. protected _deleteBuffer(buffer: DataBuffer): void;
  121185. /**
  121186. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  121187. * @param instancesBuffer defines the webGL buffer to update and bind
  121188. * @param data defines the data to store in the buffer
  121189. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  121190. */
  121191. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  121192. /**
  121193. * Bind the content of a webGL buffer used with instantiation
  121194. * @param instancesBuffer defines the webGL buffer to bind
  121195. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  121196. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  121197. */
  121198. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  121199. /**
  121200. * Disable the instance attribute corresponding to the name in parameter
  121201. * @param name defines the name of the attribute to disable
  121202. */
  121203. disableInstanceAttributeByName(name: string): void;
  121204. /**
  121205. * Disable the instance attribute corresponding to the location in parameter
  121206. * @param attributeLocation defines the attribute location of the attribute to disable
  121207. */
  121208. disableInstanceAttribute(attributeLocation: number): void;
  121209. /**
  121210. * Disable the attribute corresponding to the location in parameter
  121211. * @param attributeLocation defines the attribute location of the attribute to disable
  121212. */
  121213. disableAttributeByIndex(attributeLocation: number): void;
  121214. /**
  121215. * Send a draw order
  121216. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121217. * @param indexStart defines the starting index
  121218. * @param indexCount defines the number of index to draw
  121219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121220. */
  121221. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121222. /**
  121223. * Draw a list of points
  121224. * @param verticesStart defines the index of first vertex to draw
  121225. * @param verticesCount defines the count of vertices to draw
  121226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121227. */
  121228. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121229. /**
  121230. * Draw a list of unindexed primitives
  121231. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121232. * @param verticesStart defines the index of first vertex to draw
  121233. * @param verticesCount defines the count of vertices to draw
  121234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121235. */
  121236. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121237. /**
  121238. * Draw a list of indexed primitives
  121239. * @param fillMode defines the primitive to use
  121240. * @param indexStart defines the starting index
  121241. * @param indexCount defines the number of index to draw
  121242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121243. */
  121244. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121245. /**
  121246. * Draw a list of unindexed primitives
  121247. * @param fillMode defines the primitive to use
  121248. * @param verticesStart defines the index of first vertex to draw
  121249. * @param verticesCount defines the count of vertices to draw
  121250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121251. */
  121252. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121253. private _drawMode;
  121254. /** @hidden */
  121255. protected _reportDrawCall(): void;
  121256. /** @hidden */
  121257. _releaseEffect(effect: Effect): void;
  121258. /** @hidden */
  121259. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121260. /**
  121261. * Create a new effect (used to store vertex/fragment shaders)
  121262. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  121263. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  121264. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  121265. * @param samplers defines an array of string used to represent textures
  121266. * @param defines defines the string containing the defines to use to compile the shaders
  121267. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121268. * @param onCompiled defines a function to call when the effect creation is successful
  121269. * @param onError defines a function to call when the effect creation has failed
  121270. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  121271. * @returns the new Effect
  121272. */
  121273. 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;
  121274. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  121275. private _compileShader;
  121276. private _compileRawShader;
  121277. /** @hidden */
  121278. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121279. /**
  121280. * Directly creates a webGL program
  121281. * @param pipelineContext defines the pipeline context to attach to
  121282. * @param vertexCode defines the vertex shader code to use
  121283. * @param fragmentCode defines the fragment shader code to use
  121284. * @param context defines the webGL context to use (if not set, the current one will be used)
  121285. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121286. * @returns the new webGL program
  121287. */
  121288. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121289. /**
  121290. * Creates a webGL program
  121291. * @param pipelineContext defines the pipeline context to attach to
  121292. * @param vertexCode defines the vertex shader code to use
  121293. * @param fragmentCode defines the fragment shader code to use
  121294. * @param defines defines the string containing the defines to use to compile the shaders
  121295. * @param context defines the webGL context to use (if not set, the current one will be used)
  121296. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121297. * @returns the new webGL program
  121298. */
  121299. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121300. /**
  121301. * Creates a new pipeline context
  121302. * @returns the new pipeline
  121303. */
  121304. createPipelineContext(): IPipelineContext;
  121305. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121306. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121307. /** @hidden */
  121308. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121309. /** @hidden */
  121310. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121311. /** @hidden */
  121312. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121313. /**
  121314. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121315. * @param pipelineContext defines the pipeline context to use
  121316. * @param uniformsNames defines the list of uniform names
  121317. * @returns an array of webGL uniform locations
  121318. */
  121319. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121320. /**
  121321. * Gets the lsit of active attributes for a given webGL program
  121322. * @param pipelineContext defines the pipeline context to use
  121323. * @param attributesNames defines the list of attribute names to get
  121324. * @returns an array of indices indicating the offset of each attribute
  121325. */
  121326. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121327. /**
  121328. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121329. * @param effect defines the effect to activate
  121330. */
  121331. enableEffect(effect: Nullable<Effect>): void;
  121332. /**
  121333. * Set the value of an uniform to a number (int)
  121334. * @param uniform defines the webGL uniform location where to store the value
  121335. * @param value defines the int number to store
  121336. * @returns true if the value was set
  121337. */
  121338. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121339. /**
  121340. * Set the value of an uniform to an array of int32
  121341. * @param uniform defines the webGL uniform location where to store the value
  121342. * @param array defines the array of int32 to store
  121343. * @returns true if the value was set
  121344. */
  121345. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121346. /**
  121347. * Set the value of an uniform to an array of int32 (stored as vec2)
  121348. * @param uniform defines the webGL uniform location where to store the value
  121349. * @param array defines the array of int32 to store
  121350. * @returns true if the value was set
  121351. */
  121352. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121353. /**
  121354. * Set the value of an uniform to an array of int32 (stored as vec3)
  121355. * @param uniform defines the webGL uniform location where to store the value
  121356. * @param array defines the array of int32 to store
  121357. * @returns true if the value was set
  121358. */
  121359. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121360. /**
  121361. * Set the value of an uniform to an array of int32 (stored as vec4)
  121362. * @param uniform defines the webGL uniform location where to store the value
  121363. * @param array defines the array of int32 to store
  121364. * @returns true if the value was set
  121365. */
  121366. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121367. /**
  121368. * Set the value of an uniform to an array of number
  121369. * @param uniform defines the webGL uniform location where to store the value
  121370. * @param array defines the array of number to store
  121371. * @returns true if the value was set
  121372. */
  121373. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121374. /**
  121375. * Set the value of an uniform to an array of number (stored as vec2)
  121376. * @param uniform defines the webGL uniform location where to store the value
  121377. * @param array defines the array of number to store
  121378. * @returns true if the value was set
  121379. */
  121380. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121381. /**
  121382. * Set the value of an uniform to an array of number (stored as vec3)
  121383. * @param uniform defines the webGL uniform location where to store the value
  121384. * @param array defines the array of number to store
  121385. * @returns true if the value was set
  121386. */
  121387. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121388. /**
  121389. * Set the value of an uniform to an array of number (stored as vec4)
  121390. * @param uniform defines the webGL uniform location where to store the value
  121391. * @param array defines the array of number to store
  121392. * @returns true if the value was set
  121393. */
  121394. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121395. /**
  121396. * Set the value of an uniform to an array of float32 (stored as matrices)
  121397. * @param uniform defines the webGL uniform location where to store the value
  121398. * @param matrices defines the array of float32 to store
  121399. * @returns true if the value was set
  121400. */
  121401. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121402. /**
  121403. * Set the value of an uniform to a matrix (3x3)
  121404. * @param uniform defines the webGL uniform location where to store the value
  121405. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121406. * @returns true if the value was set
  121407. */
  121408. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121409. /**
  121410. * Set the value of an uniform to a matrix (2x2)
  121411. * @param uniform defines the webGL uniform location where to store the value
  121412. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121413. * @returns true if the value was set
  121414. */
  121415. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121416. /**
  121417. * Set the value of an uniform to a number (float)
  121418. * @param uniform defines the webGL uniform location where to store the value
  121419. * @param value defines the float number to store
  121420. * @returns true if the value was transfered
  121421. */
  121422. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121423. /**
  121424. * Set the value of an uniform to a vec2
  121425. * @param uniform defines the webGL uniform location where to store the value
  121426. * @param x defines the 1st component of the value
  121427. * @param y defines the 2nd component of the value
  121428. * @returns true if the value was set
  121429. */
  121430. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121431. /**
  121432. * Set the value of an uniform to a vec3
  121433. * @param uniform defines the webGL uniform location where to store the value
  121434. * @param x defines the 1st component of the value
  121435. * @param y defines the 2nd component of the value
  121436. * @param z defines the 3rd component of the value
  121437. * @returns true if the value was set
  121438. */
  121439. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121440. /**
  121441. * Set the value of an uniform to a vec4
  121442. * @param uniform defines the webGL uniform location where to store the value
  121443. * @param x defines the 1st component of the value
  121444. * @param y defines the 2nd component of the value
  121445. * @param z defines the 3rd component of the value
  121446. * @param w defines the 4th component of the value
  121447. * @returns true if the value was set
  121448. */
  121449. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121450. /**
  121451. * Apply all cached states (depth, culling, stencil and alpha)
  121452. */
  121453. applyStates(): void;
  121454. /**
  121455. * Enable or disable color writing
  121456. * @param enable defines the state to set
  121457. */
  121458. setColorWrite(enable: boolean): void;
  121459. /**
  121460. * Gets a boolean indicating if color writing is enabled
  121461. * @returns the current color writing state
  121462. */
  121463. getColorWrite(): boolean;
  121464. /**
  121465. * Gets the depth culling state manager
  121466. */
  121467. get depthCullingState(): DepthCullingState;
  121468. /**
  121469. * Gets the alpha state manager
  121470. */
  121471. get alphaState(): AlphaState;
  121472. /**
  121473. * Gets the stencil state manager
  121474. */
  121475. get stencilState(): StencilState;
  121476. /**
  121477. * Clears the list of texture accessible through engine.
  121478. * This can help preventing texture load conflict due to name collision.
  121479. */
  121480. clearInternalTexturesCache(): void;
  121481. /**
  121482. * Force the entire cache to be cleared
  121483. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121484. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121485. */
  121486. wipeCaches(bruteForce?: boolean): void;
  121487. /** @hidden */
  121488. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121489. min: number;
  121490. mag: number;
  121491. };
  121492. /** @hidden */
  121493. _createTexture(): WebGLTexture;
  121494. /**
  121495. * Usually called from Texture.ts.
  121496. * Passed information to create a WebGLTexture
  121497. * @param url defines a value which contains one of the following:
  121498. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121499. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121500. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121501. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121502. * @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)
  121503. * @param scene needed for loading to the correct scene
  121504. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121505. * @param onLoad optional callback to be called upon successful completion
  121506. * @param onError optional callback to be called upon failure
  121507. * @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
  121508. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121509. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121510. * @param forcedExtension defines the extension to use to pick the right loader
  121511. * @param mimeType defines an optional mime type
  121512. * @param loaderOptions options to be passed to the loader
  121513. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121514. */
  121515. 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;
  121516. /**
  121517. * Loads an image as an HTMLImageElement.
  121518. * @param input url string, ArrayBuffer, or Blob to load
  121519. * @param onLoad callback called when the image successfully loads
  121520. * @param onError callback called when the image fails to load
  121521. * @param offlineProvider offline provider for caching
  121522. * @param mimeType optional mime type
  121523. * @returns the HTMLImageElement of the loaded image
  121524. * @hidden
  121525. */
  121526. 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>;
  121527. /**
  121528. * @hidden
  121529. */
  121530. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121531. private _unpackFlipYCached;
  121532. /**
  121533. * In case you are sharing the context with other applications, it might
  121534. * be interested to not cache the unpack flip y state to ensure a consistent
  121535. * value would be set.
  121536. */
  121537. enableUnpackFlipYCached: boolean;
  121538. /** @hidden */
  121539. _unpackFlipY(value: boolean): void;
  121540. /** @hidden */
  121541. _getUnpackAlignement(): number;
  121542. private _getTextureTarget;
  121543. /**
  121544. * Update the sampling mode of a given texture
  121545. * @param samplingMode defines the required sampling mode
  121546. * @param texture defines the texture to update
  121547. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121548. */
  121549. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121550. /**
  121551. * Update the sampling mode of a given texture
  121552. * @param texture defines the texture to update
  121553. * @param wrapU defines the texture wrap mode of the u coordinates
  121554. * @param wrapV defines the texture wrap mode of the v coordinates
  121555. * @param wrapR defines the texture wrap mode of the r coordinates
  121556. */
  121557. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121558. /** @hidden */
  121559. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121560. width: number;
  121561. height: number;
  121562. layers?: number;
  121563. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121564. /** @hidden */
  121565. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121566. /** @hidden */
  121567. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121568. /**
  121569. * Update a portion of an internal texture
  121570. * @param texture defines the texture to update
  121571. * @param imageData defines the data to store into the texture
  121572. * @param xOffset defines the x coordinates of the update rectangle
  121573. * @param yOffset defines the y coordinates of the update rectangle
  121574. * @param width defines the width of the update rectangle
  121575. * @param height defines the height of the update rectangle
  121576. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121577. * @param lod defines the lod level to update (0 by default)
  121578. */
  121579. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121580. /** @hidden */
  121581. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121582. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121583. private _prepareWebGLTexture;
  121584. /** @hidden */
  121585. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121586. private _getDepthStencilBuffer;
  121587. /** @hidden */
  121588. _releaseFramebufferObjects(texture: InternalTexture): void;
  121589. /** @hidden */
  121590. _releaseTexture(texture: InternalTexture): void;
  121591. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121592. protected _setProgram(program: WebGLProgram): void;
  121593. protected _boundUniforms: {
  121594. [key: number]: WebGLUniformLocation;
  121595. };
  121596. /**
  121597. * Binds an effect to the webGL context
  121598. * @param effect defines the effect to bind
  121599. */
  121600. bindSamplers(effect: Effect): void;
  121601. private _activateCurrentTexture;
  121602. /** @hidden */
  121603. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121604. /** @hidden */
  121605. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121606. /**
  121607. * Unbind all textures from the webGL context
  121608. */
  121609. unbindAllTextures(): void;
  121610. /**
  121611. * Sets a texture to the according uniform.
  121612. * @param channel The texture channel
  121613. * @param uniform The uniform to set
  121614. * @param texture The texture to apply
  121615. */
  121616. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121617. private _bindSamplerUniformToChannel;
  121618. private _getTextureWrapMode;
  121619. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121620. /**
  121621. * Sets an array of texture to the webGL context
  121622. * @param channel defines the channel where the texture array must be set
  121623. * @param uniform defines the associated uniform location
  121624. * @param textures defines the array of textures to bind
  121625. */
  121626. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121627. /** @hidden */
  121628. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121629. private _setTextureParameterFloat;
  121630. private _setTextureParameterInteger;
  121631. /**
  121632. * Unbind all vertex attributes from the webGL context
  121633. */
  121634. unbindAllAttributes(): void;
  121635. /**
  121636. * 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
  121637. */
  121638. releaseEffects(): void;
  121639. /**
  121640. * Dispose and release all associated resources
  121641. */
  121642. dispose(): void;
  121643. /**
  121644. * Attach a new callback raised when context lost event is fired
  121645. * @param callback defines the callback to call
  121646. */
  121647. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121648. /**
  121649. * Attach a new callback raised when context restored event is fired
  121650. * @param callback defines the callback to call
  121651. */
  121652. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121653. /**
  121654. * Get the current error code of the webGL context
  121655. * @returns the error code
  121656. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121657. */
  121658. getError(): number;
  121659. private _canRenderToFloatFramebuffer;
  121660. private _canRenderToHalfFloatFramebuffer;
  121661. private _canRenderToFramebuffer;
  121662. /** @hidden */
  121663. _getWebGLTextureType(type: number): number;
  121664. /** @hidden */
  121665. _getInternalFormat(format: number): number;
  121666. /** @hidden */
  121667. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121668. /** @hidden */
  121669. _getRGBAMultiSampleBufferFormat(type: number): number;
  121670. /** @hidden */
  121671. _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;
  121672. /**
  121673. * Loads a file from a url
  121674. * @param url url to load
  121675. * @param onSuccess callback called when the file successfully loads
  121676. * @param onProgress callback called while file is loading (if the server supports this mode)
  121677. * @param offlineProvider defines the offline provider for caching
  121678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121679. * @param onError callback called when the file fails to load
  121680. * @returns a file request object
  121681. * @hidden
  121682. */
  121683. 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;
  121684. /**
  121685. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121686. * @param x defines the x coordinate of the rectangle where pixels must be read
  121687. * @param y defines the y coordinate of the rectangle where pixels must be read
  121688. * @param width defines the width of the rectangle where pixels must be read
  121689. * @param height defines the height of the rectangle where pixels must be read
  121690. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121691. * @returns a Uint8Array containing RGBA colors
  121692. */
  121693. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121694. private static _IsSupported;
  121695. private static _HasMajorPerformanceCaveat;
  121696. /**
  121697. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121698. */
  121699. static get IsSupported(): boolean;
  121700. /**
  121701. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121702. * @returns true if the engine can be created
  121703. * @ignorenaming
  121704. */
  121705. static isSupported(): boolean;
  121706. /**
  121707. * 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)
  121708. */
  121709. static get HasMajorPerformanceCaveat(): boolean;
  121710. /**
  121711. * Find the next highest power of two.
  121712. * @param x Number to start search from.
  121713. * @return Next highest power of two.
  121714. */
  121715. static CeilingPOT(x: number): number;
  121716. /**
  121717. * Find the next lowest power of two.
  121718. * @param x Number to start search from.
  121719. * @return Next lowest power of two.
  121720. */
  121721. static FloorPOT(x: number): number;
  121722. /**
  121723. * Find the nearest power of two.
  121724. * @param x Number to start search from.
  121725. * @return Next nearest power of two.
  121726. */
  121727. static NearestPOT(x: number): number;
  121728. /**
  121729. * Get the closest exponent of two
  121730. * @param value defines the value to approximate
  121731. * @param max defines the maximum value to return
  121732. * @param mode defines how to define the closest value
  121733. * @returns closest exponent of two of the given value
  121734. */
  121735. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121736. /**
  121737. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121738. * @param func - the function to be called
  121739. * @param requester - the object that will request the next frame. Falls back to window.
  121740. * @returns frame number
  121741. */
  121742. static QueueNewFrame(func: () => void, requester?: any): number;
  121743. /**
  121744. * Gets host document
  121745. * @returns the host document object
  121746. */
  121747. getHostDocument(): Nullable<Document>;
  121748. }
  121749. }
  121750. declare module BABYLON {
  121751. /**
  121752. * Defines the source of the internal texture
  121753. */
  121754. export enum InternalTextureSource {
  121755. /**
  121756. * The source of the texture data is unknown
  121757. */
  121758. Unknown = 0,
  121759. /**
  121760. * Texture data comes from an URL
  121761. */
  121762. Url = 1,
  121763. /**
  121764. * Texture data is only used for temporary storage
  121765. */
  121766. Temp = 2,
  121767. /**
  121768. * Texture data comes from raw data (ArrayBuffer)
  121769. */
  121770. Raw = 3,
  121771. /**
  121772. * Texture content is dynamic (video or dynamic texture)
  121773. */
  121774. Dynamic = 4,
  121775. /**
  121776. * Texture content is generated by rendering to it
  121777. */
  121778. RenderTarget = 5,
  121779. /**
  121780. * Texture content is part of a multi render target process
  121781. */
  121782. MultiRenderTarget = 6,
  121783. /**
  121784. * Texture data comes from a cube data file
  121785. */
  121786. Cube = 7,
  121787. /**
  121788. * Texture data comes from a raw cube data
  121789. */
  121790. CubeRaw = 8,
  121791. /**
  121792. * Texture data come from a prefiltered cube data file
  121793. */
  121794. CubePrefiltered = 9,
  121795. /**
  121796. * Texture content is raw 3D data
  121797. */
  121798. Raw3D = 10,
  121799. /**
  121800. * Texture content is raw 2D array data
  121801. */
  121802. Raw2DArray = 11,
  121803. /**
  121804. * Texture content is a depth texture
  121805. */
  121806. Depth = 12,
  121807. /**
  121808. * Texture data comes from a raw cube data encoded with RGBD
  121809. */
  121810. CubeRawRGBD = 13
  121811. }
  121812. /**
  121813. * Class used to store data associated with WebGL texture data for the engine
  121814. * This class should not be used directly
  121815. */
  121816. export class InternalTexture {
  121817. /** @hidden */
  121818. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121819. /**
  121820. * Defines if the texture is ready
  121821. */
  121822. isReady: boolean;
  121823. /**
  121824. * Defines if the texture is a cube texture
  121825. */
  121826. isCube: boolean;
  121827. /**
  121828. * Defines if the texture contains 3D data
  121829. */
  121830. is3D: boolean;
  121831. /**
  121832. * Defines if the texture contains 2D array data
  121833. */
  121834. is2DArray: boolean;
  121835. /**
  121836. * Defines if the texture contains multiview data
  121837. */
  121838. isMultiview: boolean;
  121839. /**
  121840. * Gets the URL used to load this texture
  121841. */
  121842. url: string;
  121843. /** @hidden */
  121844. _originalUrl: string;
  121845. /**
  121846. * Gets the sampling mode of the texture
  121847. */
  121848. samplingMode: number;
  121849. /**
  121850. * Gets a boolean indicating if the texture needs mipmaps generation
  121851. */
  121852. generateMipMaps: boolean;
  121853. /**
  121854. * Gets the number of samples used by the texture (WebGL2+ only)
  121855. */
  121856. samples: number;
  121857. /**
  121858. * Gets the type of the texture (int, float...)
  121859. */
  121860. type: number;
  121861. /**
  121862. * Gets the format of the texture (RGB, RGBA...)
  121863. */
  121864. format: number;
  121865. /**
  121866. * Observable called when the texture is loaded
  121867. */
  121868. onLoadedObservable: Observable<InternalTexture>;
  121869. /**
  121870. * Gets the width of the texture
  121871. */
  121872. width: number;
  121873. /**
  121874. * Gets the height of the texture
  121875. */
  121876. height: number;
  121877. /**
  121878. * Gets the depth of the texture
  121879. */
  121880. depth: number;
  121881. /**
  121882. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121883. */
  121884. baseWidth: number;
  121885. /**
  121886. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121887. */
  121888. baseHeight: number;
  121889. /**
  121890. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121891. */
  121892. baseDepth: number;
  121893. /**
  121894. * Gets a boolean indicating if the texture is inverted on Y axis
  121895. */
  121896. invertY: boolean;
  121897. /** @hidden */
  121898. _invertVScale: boolean;
  121899. /** @hidden */
  121900. _associatedChannel: number;
  121901. /** @hidden */
  121902. _source: InternalTextureSource;
  121903. /** @hidden */
  121904. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121905. /** @hidden */
  121906. _bufferView: Nullable<ArrayBufferView>;
  121907. /** @hidden */
  121908. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121909. /** @hidden */
  121910. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121911. /** @hidden */
  121912. _size: number;
  121913. /** @hidden */
  121914. _extension: string;
  121915. /** @hidden */
  121916. _files: Nullable<string[]>;
  121917. /** @hidden */
  121918. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121919. /** @hidden */
  121920. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121921. /** @hidden */
  121922. _framebuffer: Nullable<WebGLFramebuffer>;
  121923. /** @hidden */
  121924. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121925. /** @hidden */
  121926. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121927. /** @hidden */
  121928. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121929. /** @hidden */
  121930. _attachments: Nullable<number[]>;
  121931. /** @hidden */
  121932. _textureArray: Nullable<InternalTexture[]>;
  121933. /** @hidden */
  121934. _cachedCoordinatesMode: Nullable<number>;
  121935. /** @hidden */
  121936. _cachedWrapU: Nullable<number>;
  121937. /** @hidden */
  121938. _cachedWrapV: Nullable<number>;
  121939. /** @hidden */
  121940. _cachedWrapR: Nullable<number>;
  121941. /** @hidden */
  121942. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121943. /** @hidden */
  121944. _isDisabled: boolean;
  121945. /** @hidden */
  121946. _compression: Nullable<string>;
  121947. /** @hidden */
  121948. _generateStencilBuffer: boolean;
  121949. /** @hidden */
  121950. _generateDepthBuffer: boolean;
  121951. /** @hidden */
  121952. _comparisonFunction: number;
  121953. /** @hidden */
  121954. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121955. /** @hidden */
  121956. _lodGenerationScale: number;
  121957. /** @hidden */
  121958. _lodGenerationOffset: number;
  121959. /** @hidden */
  121960. _depthStencilTexture: Nullable<InternalTexture>;
  121961. /** @hidden */
  121962. _colorTextureArray: Nullable<WebGLTexture>;
  121963. /** @hidden */
  121964. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121965. /** @hidden */
  121966. _lodTextureHigh: Nullable<BaseTexture>;
  121967. /** @hidden */
  121968. _lodTextureMid: Nullable<BaseTexture>;
  121969. /** @hidden */
  121970. _lodTextureLow: Nullable<BaseTexture>;
  121971. /** @hidden */
  121972. _isRGBD: boolean;
  121973. /** @hidden */
  121974. _linearSpecularLOD: boolean;
  121975. /** @hidden */
  121976. _irradianceTexture: Nullable<BaseTexture>;
  121977. /** @hidden */
  121978. _webGLTexture: Nullable<WebGLTexture>;
  121979. /** @hidden */
  121980. _references: number;
  121981. /** @hidden */
  121982. _gammaSpace: Nullable<boolean>;
  121983. private _engine;
  121984. /**
  121985. * Gets the Engine the texture belongs to.
  121986. * @returns The babylon engine
  121987. */
  121988. getEngine(): ThinEngine;
  121989. /**
  121990. * Gets the data source type of the texture
  121991. */
  121992. get source(): InternalTextureSource;
  121993. /**
  121994. * Creates a new InternalTexture
  121995. * @param engine defines the engine to use
  121996. * @param source defines the type of data that will be used
  121997. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121998. */
  121999. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  122000. /**
  122001. * Increments the number of references (ie. the number of Texture that point to it)
  122002. */
  122003. incrementReferences(): void;
  122004. /**
  122005. * Change the size of the texture (not the size of the content)
  122006. * @param width defines the new width
  122007. * @param height defines the new height
  122008. * @param depth defines the new depth (1 by default)
  122009. */
  122010. updateSize(width: int, height: int, depth?: int): void;
  122011. /** @hidden */
  122012. _rebuild(): void;
  122013. /** @hidden */
  122014. _swapAndDie(target: InternalTexture): void;
  122015. /**
  122016. * Dispose the current allocated resources
  122017. */
  122018. dispose(): void;
  122019. }
  122020. }
  122021. declare module BABYLON {
  122022. /**
  122023. * Interface used to present a loading screen while loading a scene
  122024. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122025. */
  122026. export interface ILoadingScreen {
  122027. /**
  122028. * Function called to display the loading screen
  122029. */
  122030. displayLoadingUI: () => void;
  122031. /**
  122032. * Function called to hide the loading screen
  122033. */
  122034. hideLoadingUI: () => void;
  122035. /**
  122036. * Gets or sets the color to use for the background
  122037. */
  122038. loadingUIBackgroundColor: string;
  122039. /**
  122040. * Gets or sets the text to display while loading
  122041. */
  122042. loadingUIText: string;
  122043. }
  122044. /**
  122045. * Class used for the default loading screen
  122046. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122047. */
  122048. export class DefaultLoadingScreen implements ILoadingScreen {
  122049. private _renderingCanvas;
  122050. private _loadingText;
  122051. private _loadingDivBackgroundColor;
  122052. private _loadingDiv;
  122053. private _loadingTextDiv;
  122054. /** Gets or sets the logo url to use for the default loading screen */
  122055. static DefaultLogoUrl: string;
  122056. /** Gets or sets the spinner url to use for the default loading screen */
  122057. static DefaultSpinnerUrl: string;
  122058. /**
  122059. * Creates a new default loading screen
  122060. * @param _renderingCanvas defines the canvas used to render the scene
  122061. * @param _loadingText defines the default text to display
  122062. * @param _loadingDivBackgroundColor defines the default background color
  122063. */
  122064. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  122065. /**
  122066. * Function called to display the loading screen
  122067. */
  122068. displayLoadingUI(): void;
  122069. /**
  122070. * Function called to hide the loading screen
  122071. */
  122072. hideLoadingUI(): void;
  122073. /**
  122074. * Gets or sets the text to display while loading
  122075. */
  122076. set loadingUIText(text: string);
  122077. get loadingUIText(): string;
  122078. /**
  122079. * Gets or sets the color to use for the background
  122080. */
  122081. get loadingUIBackgroundColor(): string;
  122082. set loadingUIBackgroundColor(color: string);
  122083. private _resizeLoadingUI;
  122084. }
  122085. }
  122086. declare module BABYLON {
  122087. /**
  122088. * Interface for any object that can request an animation frame
  122089. */
  122090. export interface ICustomAnimationFrameRequester {
  122091. /**
  122092. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  122093. */
  122094. renderFunction?: Function;
  122095. /**
  122096. * Called to request the next frame to render to
  122097. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  122098. */
  122099. requestAnimationFrame: Function;
  122100. /**
  122101. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  122102. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  122103. */
  122104. requestID?: number;
  122105. }
  122106. }
  122107. declare module BABYLON {
  122108. /**
  122109. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  122110. */
  122111. export class PerformanceMonitor {
  122112. private _enabled;
  122113. private _rollingFrameTime;
  122114. private _lastFrameTimeMs;
  122115. /**
  122116. * constructor
  122117. * @param frameSampleSize The number of samples required to saturate the sliding window
  122118. */
  122119. constructor(frameSampleSize?: number);
  122120. /**
  122121. * Samples current frame
  122122. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  122123. */
  122124. sampleFrame(timeMs?: number): void;
  122125. /**
  122126. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122127. */
  122128. get averageFrameTime(): number;
  122129. /**
  122130. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122131. */
  122132. get averageFrameTimeVariance(): number;
  122133. /**
  122134. * Returns the frame time of the most recent frame
  122135. */
  122136. get instantaneousFrameTime(): number;
  122137. /**
  122138. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  122139. */
  122140. get averageFPS(): number;
  122141. /**
  122142. * Returns the average framerate in frames per second using the most recent frame time
  122143. */
  122144. get instantaneousFPS(): number;
  122145. /**
  122146. * Returns true if enough samples have been taken to completely fill the sliding window
  122147. */
  122148. get isSaturated(): boolean;
  122149. /**
  122150. * Enables contributions to the sliding window sample set
  122151. */
  122152. enable(): void;
  122153. /**
  122154. * Disables contributions to the sliding window sample set
  122155. * Samples will not be interpolated over the disabled period
  122156. */
  122157. disable(): void;
  122158. /**
  122159. * Returns true if sampling is enabled
  122160. */
  122161. get isEnabled(): boolean;
  122162. /**
  122163. * Resets performance monitor
  122164. */
  122165. reset(): void;
  122166. }
  122167. /**
  122168. * RollingAverage
  122169. *
  122170. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  122171. */
  122172. export class RollingAverage {
  122173. /**
  122174. * Current average
  122175. */
  122176. average: number;
  122177. /**
  122178. * Current variance
  122179. */
  122180. variance: number;
  122181. protected _samples: Array<number>;
  122182. protected _sampleCount: number;
  122183. protected _pos: number;
  122184. protected _m2: number;
  122185. /**
  122186. * constructor
  122187. * @param length The number of samples required to saturate the sliding window
  122188. */
  122189. constructor(length: number);
  122190. /**
  122191. * Adds a sample to the sample set
  122192. * @param v The sample value
  122193. */
  122194. add(v: number): void;
  122195. /**
  122196. * Returns previously added values or null if outside of history or outside the sliding window domain
  122197. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  122198. * @return Value previously recorded with add() or null if outside of range
  122199. */
  122200. history(i: number): number;
  122201. /**
  122202. * Returns true if enough samples have been taken to completely fill the sliding window
  122203. * @return true if sample-set saturated
  122204. */
  122205. isSaturated(): boolean;
  122206. /**
  122207. * Resets the rolling average (equivalent to 0 samples taken so far)
  122208. */
  122209. reset(): void;
  122210. /**
  122211. * Wraps a value around the sample range boundaries
  122212. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  122213. * @return Wrapped position in sample range
  122214. */
  122215. protected _wrapPosition(i: number): number;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * This class is used to track a performance counter which is number based.
  122221. * The user has access to many properties which give statistics of different nature.
  122222. *
  122223. * The implementer can track two kinds of Performance Counter: time and count.
  122224. * 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.
  122225. * 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.
  122226. */
  122227. export class PerfCounter {
  122228. /**
  122229. * Gets or sets a global boolean to turn on and off all the counters
  122230. */
  122231. static Enabled: boolean;
  122232. /**
  122233. * Returns the smallest value ever
  122234. */
  122235. get min(): number;
  122236. /**
  122237. * Returns the biggest value ever
  122238. */
  122239. get max(): number;
  122240. /**
  122241. * Returns the average value since the performance counter is running
  122242. */
  122243. get average(): number;
  122244. /**
  122245. * Returns the average value of the last second the counter was monitored
  122246. */
  122247. get lastSecAverage(): number;
  122248. /**
  122249. * Returns the current value
  122250. */
  122251. get current(): number;
  122252. /**
  122253. * Gets the accumulated total
  122254. */
  122255. get total(): number;
  122256. /**
  122257. * Gets the total value count
  122258. */
  122259. get count(): number;
  122260. /**
  122261. * Creates a new counter
  122262. */
  122263. constructor();
  122264. /**
  122265. * Call this method to start monitoring a new frame.
  122266. * 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.
  122267. */
  122268. fetchNewFrame(): void;
  122269. /**
  122270. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  122271. * @param newCount the count value to add to the monitored count
  122272. * @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.
  122273. */
  122274. addCount(newCount: number, fetchResult: boolean): void;
  122275. /**
  122276. * Start monitoring this performance counter
  122277. */
  122278. beginMonitoring(): void;
  122279. /**
  122280. * Compute the time lapsed since the previous beginMonitoring() call.
  122281. * @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
  122282. */
  122283. endMonitoring(newFrame?: boolean): void;
  122284. private _fetchResult;
  122285. private _startMonitoringTime;
  122286. private _min;
  122287. private _max;
  122288. private _average;
  122289. private _current;
  122290. private _totalValueCount;
  122291. private _totalAccumulated;
  122292. private _lastSecAverage;
  122293. private _lastSecAccumulated;
  122294. private _lastSecTime;
  122295. private _lastSecValueCount;
  122296. }
  122297. }
  122298. declare module BABYLON {
  122299. interface ThinEngine {
  122300. /** @hidden */
  122301. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122302. }
  122303. }
  122304. declare module BABYLON {
  122305. /**
  122306. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122308. */
  122309. export class Analyser {
  122310. /**
  122311. * Gets or sets the smoothing
  122312. * @ignorenaming
  122313. */
  122314. SMOOTHING: number;
  122315. /**
  122316. * Gets or sets the FFT table size
  122317. * @ignorenaming
  122318. */
  122319. FFT_SIZE: number;
  122320. /**
  122321. * Gets or sets the bar graph amplitude
  122322. * @ignorenaming
  122323. */
  122324. BARGRAPHAMPLITUDE: number;
  122325. /**
  122326. * Gets or sets the position of the debug canvas
  122327. * @ignorenaming
  122328. */
  122329. DEBUGCANVASPOS: {
  122330. x: number;
  122331. y: number;
  122332. };
  122333. /**
  122334. * Gets or sets the debug canvas size
  122335. * @ignorenaming
  122336. */
  122337. DEBUGCANVASSIZE: {
  122338. width: number;
  122339. height: number;
  122340. };
  122341. private _byteFreqs;
  122342. private _byteTime;
  122343. private _floatFreqs;
  122344. private _webAudioAnalyser;
  122345. private _debugCanvas;
  122346. private _debugCanvasContext;
  122347. private _scene;
  122348. private _registerFunc;
  122349. private _audioEngine;
  122350. /**
  122351. * Creates a new analyser
  122352. * @param scene defines hosting scene
  122353. */
  122354. constructor(scene: Scene);
  122355. /**
  122356. * Get the number of data values you will have to play with for the visualization
  122357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122358. * @returns a number
  122359. */
  122360. getFrequencyBinCount(): number;
  122361. /**
  122362. * Gets the current frequency data as a byte array
  122363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122364. * @returns a Uint8Array
  122365. */
  122366. getByteFrequencyData(): Uint8Array;
  122367. /**
  122368. * Gets the current waveform as a byte array
  122369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122370. * @returns a Uint8Array
  122371. */
  122372. getByteTimeDomainData(): Uint8Array;
  122373. /**
  122374. * Gets the current frequency data as a float array
  122375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122376. * @returns a Float32Array
  122377. */
  122378. getFloatFrequencyData(): Float32Array;
  122379. /**
  122380. * Renders the debug canvas
  122381. */
  122382. drawDebugCanvas(): void;
  122383. /**
  122384. * Stops rendering the debug canvas and removes it
  122385. */
  122386. stopDebugCanvas(): void;
  122387. /**
  122388. * Connects two audio nodes
  122389. * @param inputAudioNode defines first node to connect
  122390. * @param outputAudioNode defines second node to connect
  122391. */
  122392. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122393. /**
  122394. * Releases all associated resources
  122395. */
  122396. dispose(): void;
  122397. }
  122398. }
  122399. declare module BABYLON {
  122400. /**
  122401. * This represents an audio engine and it is responsible
  122402. * to play, synchronize and analyse sounds throughout the application.
  122403. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122404. */
  122405. export interface IAudioEngine extends IDisposable {
  122406. /**
  122407. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122408. */
  122409. readonly canUseWebAudio: boolean;
  122410. /**
  122411. * Gets the current AudioContext if available.
  122412. */
  122413. readonly audioContext: Nullable<AudioContext>;
  122414. /**
  122415. * The master gain node defines the global audio volume of your audio engine.
  122416. */
  122417. readonly masterGain: GainNode;
  122418. /**
  122419. * Gets whether or not mp3 are supported by your browser.
  122420. */
  122421. readonly isMP3supported: boolean;
  122422. /**
  122423. * Gets whether or not ogg are supported by your browser.
  122424. */
  122425. readonly isOGGsupported: boolean;
  122426. /**
  122427. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122428. * @ignoreNaming
  122429. */
  122430. WarnedWebAudioUnsupported: boolean;
  122431. /**
  122432. * Defines if the audio engine relies on a custom unlocked button.
  122433. * In this case, the embedded button will not be displayed.
  122434. */
  122435. useCustomUnlockedButton: boolean;
  122436. /**
  122437. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122438. */
  122439. readonly unlocked: boolean;
  122440. /**
  122441. * Event raised when audio has been unlocked on the browser.
  122442. */
  122443. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122444. /**
  122445. * Event raised when audio has been locked on the browser.
  122446. */
  122447. onAudioLockedObservable: Observable<IAudioEngine>;
  122448. /**
  122449. * Flags the audio engine in Locked state.
  122450. * This happens due to new browser policies preventing audio to autoplay.
  122451. */
  122452. lock(): void;
  122453. /**
  122454. * Unlocks the audio engine once a user action has been done on the dom.
  122455. * This is helpful to resume play once browser policies have been satisfied.
  122456. */
  122457. unlock(): void;
  122458. /**
  122459. * Gets the global volume sets on the master gain.
  122460. * @returns the global volume if set or -1 otherwise
  122461. */
  122462. getGlobalVolume(): number;
  122463. /**
  122464. * Sets the global volume of your experience (sets on the master gain).
  122465. * @param newVolume Defines the new global volume of the application
  122466. */
  122467. setGlobalVolume(newVolume: number): void;
  122468. /**
  122469. * Connect the audio engine to an audio analyser allowing some amazing
  122470. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122471. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122472. * @param analyser The analyser to connect to the engine
  122473. */
  122474. connectToAnalyser(analyser: Analyser): void;
  122475. }
  122476. }
  122477. declare module BABYLON {
  122478. /**
  122479. * Defines the interface used by display changed events
  122480. */
  122481. export interface IDisplayChangedEventArgs {
  122482. /** Gets the vrDisplay object (if any) */
  122483. vrDisplay: Nullable<any>;
  122484. /** Gets a boolean indicating if webVR is supported */
  122485. vrSupported: boolean;
  122486. }
  122487. /**
  122488. * Defines the interface used by objects containing a viewport (like a camera)
  122489. */
  122490. interface IViewportOwnerLike {
  122491. /**
  122492. * Gets or sets the viewport
  122493. */
  122494. viewport: IViewportLike;
  122495. }
  122496. /**
  122497. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122498. */
  122499. export class Engine extends ThinEngine {
  122500. /** Defines that alpha blending is disabled */
  122501. static readonly ALPHA_DISABLE: number;
  122502. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122503. static readonly ALPHA_ADD: number;
  122504. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122505. static readonly ALPHA_COMBINE: number;
  122506. /** Defines that alpha blending to DEST - SRC * DEST */
  122507. static readonly ALPHA_SUBTRACT: number;
  122508. /** Defines that alpha blending to SRC * DEST */
  122509. static readonly ALPHA_MULTIPLY: number;
  122510. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122511. static readonly ALPHA_MAXIMIZED: number;
  122512. /** Defines that alpha blending to SRC + DEST */
  122513. static readonly ALPHA_ONEONE: number;
  122514. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122515. static readonly ALPHA_PREMULTIPLIED: number;
  122516. /**
  122517. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122518. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122519. */
  122520. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122521. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122522. static readonly ALPHA_INTERPOLATE: number;
  122523. /**
  122524. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122525. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122526. */
  122527. static readonly ALPHA_SCREENMODE: number;
  122528. /** Defines that the ressource is not delayed*/
  122529. static readonly DELAYLOADSTATE_NONE: number;
  122530. /** Defines that the ressource was successfully delay loaded */
  122531. static readonly DELAYLOADSTATE_LOADED: number;
  122532. /** Defines that the ressource is currently delay loading */
  122533. static readonly DELAYLOADSTATE_LOADING: number;
  122534. /** Defines that the ressource is delayed and has not started loading */
  122535. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122536. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122537. static readonly NEVER: number;
  122538. /** 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 */
  122539. static readonly ALWAYS: number;
  122540. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122541. static readonly LESS: number;
  122542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122543. static readonly EQUAL: number;
  122544. /** 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 */
  122545. static readonly LEQUAL: number;
  122546. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122547. static readonly GREATER: number;
  122548. /** 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 */
  122549. static readonly GEQUAL: number;
  122550. /** 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 */
  122551. static readonly NOTEQUAL: number;
  122552. /** Passed to stencilOperation to specify that stencil value must be kept */
  122553. static readonly KEEP: number;
  122554. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122555. static readonly REPLACE: number;
  122556. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122557. static readonly INCR: number;
  122558. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122559. static readonly DECR: number;
  122560. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122561. static readonly INVERT: number;
  122562. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122563. static readonly INCR_WRAP: number;
  122564. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122565. static readonly DECR_WRAP: number;
  122566. /** Texture is not repeating outside of 0..1 UVs */
  122567. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122568. /** Texture is repeating outside of 0..1 UVs */
  122569. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122570. /** Texture is repeating and mirrored */
  122571. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122572. /** ALPHA */
  122573. static readonly TEXTUREFORMAT_ALPHA: number;
  122574. /** LUMINANCE */
  122575. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122576. /** LUMINANCE_ALPHA */
  122577. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122578. /** RGB */
  122579. static readonly TEXTUREFORMAT_RGB: number;
  122580. /** RGBA */
  122581. static readonly TEXTUREFORMAT_RGBA: number;
  122582. /** RED */
  122583. static readonly TEXTUREFORMAT_RED: number;
  122584. /** RED (2nd reference) */
  122585. static readonly TEXTUREFORMAT_R: number;
  122586. /** RG */
  122587. static readonly TEXTUREFORMAT_RG: number;
  122588. /** RED_INTEGER */
  122589. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122590. /** RED_INTEGER (2nd reference) */
  122591. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122592. /** RG_INTEGER */
  122593. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122594. /** RGB_INTEGER */
  122595. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122596. /** RGBA_INTEGER */
  122597. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122598. /** UNSIGNED_BYTE */
  122599. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122600. /** UNSIGNED_BYTE (2nd reference) */
  122601. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122602. /** FLOAT */
  122603. static readonly TEXTURETYPE_FLOAT: number;
  122604. /** HALF_FLOAT */
  122605. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122606. /** BYTE */
  122607. static readonly TEXTURETYPE_BYTE: number;
  122608. /** SHORT */
  122609. static readonly TEXTURETYPE_SHORT: number;
  122610. /** UNSIGNED_SHORT */
  122611. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122612. /** INT */
  122613. static readonly TEXTURETYPE_INT: number;
  122614. /** UNSIGNED_INT */
  122615. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122616. /** UNSIGNED_SHORT_4_4_4_4 */
  122617. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122618. /** UNSIGNED_SHORT_5_5_5_1 */
  122619. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122620. /** UNSIGNED_SHORT_5_6_5 */
  122621. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122622. /** UNSIGNED_INT_2_10_10_10_REV */
  122623. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122624. /** UNSIGNED_INT_24_8 */
  122625. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122626. /** UNSIGNED_INT_10F_11F_11F_REV */
  122627. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122628. /** UNSIGNED_INT_5_9_9_9_REV */
  122629. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122630. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122631. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122632. /** nearest is mag = nearest and min = nearest and mip = linear */
  122633. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122634. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122635. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122636. /** Trilinear is mag = linear and min = linear and mip = linear */
  122637. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122638. /** nearest is mag = nearest and min = nearest and mip = linear */
  122639. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122640. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122641. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122642. /** Trilinear is mag = linear and min = linear and mip = linear */
  122643. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122644. /** mag = nearest and min = nearest and mip = nearest */
  122645. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122646. /** mag = nearest and min = linear and mip = nearest */
  122647. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122648. /** mag = nearest and min = linear and mip = linear */
  122649. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122650. /** mag = nearest and min = linear and mip = none */
  122651. static readonly TEXTURE_NEAREST_LINEAR: number;
  122652. /** mag = nearest and min = nearest and mip = none */
  122653. static readonly TEXTURE_NEAREST_NEAREST: number;
  122654. /** mag = linear and min = nearest and mip = nearest */
  122655. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122656. /** mag = linear and min = nearest and mip = linear */
  122657. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122658. /** mag = linear and min = linear and mip = none */
  122659. static readonly TEXTURE_LINEAR_LINEAR: number;
  122660. /** mag = linear and min = nearest and mip = none */
  122661. static readonly TEXTURE_LINEAR_NEAREST: number;
  122662. /** Explicit coordinates mode */
  122663. static readonly TEXTURE_EXPLICIT_MODE: number;
  122664. /** Spherical coordinates mode */
  122665. static readonly TEXTURE_SPHERICAL_MODE: number;
  122666. /** Planar coordinates mode */
  122667. static readonly TEXTURE_PLANAR_MODE: number;
  122668. /** Cubic coordinates mode */
  122669. static readonly TEXTURE_CUBIC_MODE: number;
  122670. /** Projection coordinates mode */
  122671. static readonly TEXTURE_PROJECTION_MODE: number;
  122672. /** Skybox coordinates mode */
  122673. static readonly TEXTURE_SKYBOX_MODE: number;
  122674. /** Inverse Cubic coordinates mode */
  122675. static readonly TEXTURE_INVCUBIC_MODE: number;
  122676. /** Equirectangular coordinates mode */
  122677. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122678. /** Equirectangular Fixed coordinates mode */
  122679. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122680. /** Equirectangular Fixed Mirrored coordinates mode */
  122681. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122682. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122683. static readonly SCALEMODE_FLOOR: number;
  122684. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122685. static readonly SCALEMODE_NEAREST: number;
  122686. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122687. static readonly SCALEMODE_CEILING: number;
  122688. /**
  122689. * Returns the current npm package of the sdk
  122690. */
  122691. static get NpmPackage(): string;
  122692. /**
  122693. * Returns the current version of the framework
  122694. */
  122695. static get Version(): string;
  122696. /** Gets the list of created engines */
  122697. static get Instances(): Engine[];
  122698. /**
  122699. * Gets the latest created engine
  122700. */
  122701. static get LastCreatedEngine(): Nullable<Engine>;
  122702. /**
  122703. * Gets the latest created scene
  122704. */
  122705. static get LastCreatedScene(): Nullable<Scene>;
  122706. /**
  122707. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122708. * @param flag defines which part of the materials must be marked as dirty
  122709. * @param predicate defines a predicate used to filter which materials should be affected
  122710. */
  122711. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122712. /**
  122713. * Method called to create the default loading screen.
  122714. * This can be overriden in your own app.
  122715. * @param canvas The rendering canvas element
  122716. * @returns The loading screen
  122717. */
  122718. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122719. /**
  122720. * Method called to create the default rescale post process on each engine.
  122721. */
  122722. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122723. /**
  122724. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122725. **/
  122726. enableOfflineSupport: boolean;
  122727. /**
  122728. * 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)
  122729. **/
  122730. disableManifestCheck: boolean;
  122731. /**
  122732. * Gets the list of created scenes
  122733. */
  122734. scenes: Scene[];
  122735. /**
  122736. * Event raised when a new scene is created
  122737. */
  122738. onNewSceneAddedObservable: Observable<Scene>;
  122739. /**
  122740. * Gets the list of created postprocesses
  122741. */
  122742. postProcesses: PostProcess[];
  122743. /**
  122744. * Gets a boolean indicating if the pointer is currently locked
  122745. */
  122746. isPointerLock: boolean;
  122747. /**
  122748. * Observable event triggered each time the rendering canvas is resized
  122749. */
  122750. onResizeObservable: Observable<Engine>;
  122751. /**
  122752. * Observable event triggered each time the canvas loses focus
  122753. */
  122754. onCanvasBlurObservable: Observable<Engine>;
  122755. /**
  122756. * Observable event triggered each time the canvas gains focus
  122757. */
  122758. onCanvasFocusObservable: Observable<Engine>;
  122759. /**
  122760. * Observable event triggered each time the canvas receives pointerout event
  122761. */
  122762. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122763. /**
  122764. * Observable raised when the engine begins a new frame
  122765. */
  122766. onBeginFrameObservable: Observable<Engine>;
  122767. /**
  122768. * If set, will be used to request the next animation frame for the render loop
  122769. */
  122770. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122771. /**
  122772. * Observable raised when the engine ends the current frame
  122773. */
  122774. onEndFrameObservable: Observable<Engine>;
  122775. /**
  122776. * Observable raised when the engine is about to compile a shader
  122777. */
  122778. onBeforeShaderCompilationObservable: Observable<Engine>;
  122779. /**
  122780. * Observable raised when the engine has jsut compiled a shader
  122781. */
  122782. onAfterShaderCompilationObservable: Observable<Engine>;
  122783. /**
  122784. * Gets the audio engine
  122785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122786. * @ignorenaming
  122787. */
  122788. static audioEngine: IAudioEngine;
  122789. /**
  122790. * Default AudioEngine factory responsible of creating the Audio Engine.
  122791. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122792. */
  122793. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122794. /**
  122795. * Default offline support factory responsible of creating a tool used to store data locally.
  122796. * By default, this will create a Database object if the workload has been embedded.
  122797. */
  122798. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122799. private _loadingScreen;
  122800. private _pointerLockRequested;
  122801. private _rescalePostProcess;
  122802. private _deterministicLockstep;
  122803. private _lockstepMaxSteps;
  122804. private _timeStep;
  122805. protected get _supportsHardwareTextureRescaling(): boolean;
  122806. private _fps;
  122807. private _deltaTime;
  122808. /** @hidden */
  122809. _drawCalls: PerfCounter;
  122810. /** 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 */
  122811. canvasTabIndex: number;
  122812. /**
  122813. * Turn this value on if you want to pause FPS computation when in background
  122814. */
  122815. disablePerformanceMonitorInBackground: boolean;
  122816. private _performanceMonitor;
  122817. /**
  122818. * Gets the performance monitor attached to this engine
  122819. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122820. */
  122821. get performanceMonitor(): PerformanceMonitor;
  122822. private _onFocus;
  122823. private _onBlur;
  122824. private _onCanvasPointerOut;
  122825. private _onCanvasBlur;
  122826. private _onCanvasFocus;
  122827. private _onFullscreenChange;
  122828. private _onPointerLockChange;
  122829. /**
  122830. * Gets the HTML element used to attach event listeners
  122831. * @returns a HTML element
  122832. */
  122833. getInputElement(): Nullable<HTMLElement>;
  122834. /**
  122835. * Creates a new engine
  122836. * @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
  122837. * @param antialias defines enable antialiasing (default: false)
  122838. * @param options defines further options to be sent to the getContext() function
  122839. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122840. */
  122841. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122842. /**
  122843. * Gets current aspect ratio
  122844. * @param viewportOwner defines the camera to use to get the aspect ratio
  122845. * @param useScreen defines if screen size must be used (or the current render target if any)
  122846. * @returns a number defining the aspect ratio
  122847. */
  122848. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122849. /**
  122850. * Gets current screen aspect ratio
  122851. * @returns a number defining the aspect ratio
  122852. */
  122853. getScreenAspectRatio(): number;
  122854. /**
  122855. * Gets the client rect of the HTML canvas attached with the current webGL context
  122856. * @returns a client rectanglee
  122857. */
  122858. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122859. /**
  122860. * Gets the client rect of the HTML element used for events
  122861. * @returns a client rectanglee
  122862. */
  122863. getInputElementClientRect(): Nullable<ClientRect>;
  122864. /**
  122865. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122866. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122867. * @returns true if engine is in deterministic lock step mode
  122868. */
  122869. isDeterministicLockStep(): boolean;
  122870. /**
  122871. * Gets the max steps when engine is running in deterministic lock step
  122872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122873. * @returns the max steps
  122874. */
  122875. getLockstepMaxSteps(): number;
  122876. /**
  122877. * Returns the time in ms between steps when using deterministic lock step.
  122878. * @returns time step in (ms)
  122879. */
  122880. getTimeStep(): number;
  122881. /**
  122882. * Force the mipmap generation for the given render target texture
  122883. * @param texture defines the render target texture to use
  122884. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122885. */
  122886. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122887. /** States */
  122888. /**
  122889. * Set various states to the webGL context
  122890. * @param culling defines backface culling state
  122891. * @param zOffset defines the value to apply to zOffset (0 by default)
  122892. * @param force defines if states must be applied even if cache is up to date
  122893. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122894. */
  122895. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122896. /**
  122897. * Set the z offset to apply to current rendering
  122898. * @param value defines the offset to apply
  122899. */
  122900. setZOffset(value: number): void;
  122901. /**
  122902. * Gets the current value of the zOffset
  122903. * @returns the current zOffset state
  122904. */
  122905. getZOffset(): number;
  122906. /**
  122907. * Enable or disable depth buffering
  122908. * @param enable defines the state to set
  122909. */
  122910. setDepthBuffer(enable: boolean): void;
  122911. /**
  122912. * Gets a boolean indicating if depth writing is enabled
  122913. * @returns the current depth writing state
  122914. */
  122915. getDepthWrite(): boolean;
  122916. /**
  122917. * Enable or disable depth writing
  122918. * @param enable defines the state to set
  122919. */
  122920. setDepthWrite(enable: boolean): void;
  122921. /**
  122922. * Gets a boolean indicating if stencil buffer is enabled
  122923. * @returns the current stencil buffer state
  122924. */
  122925. getStencilBuffer(): boolean;
  122926. /**
  122927. * Enable or disable the stencil buffer
  122928. * @param enable defines if the stencil buffer must be enabled or disabled
  122929. */
  122930. setStencilBuffer(enable: boolean): void;
  122931. /**
  122932. * Gets the current stencil mask
  122933. * @returns a number defining the new stencil mask to use
  122934. */
  122935. getStencilMask(): number;
  122936. /**
  122937. * Sets the current stencil mask
  122938. * @param mask defines the new stencil mask to use
  122939. */
  122940. setStencilMask(mask: number): void;
  122941. /**
  122942. * Gets the current stencil function
  122943. * @returns a number defining the stencil function to use
  122944. */
  122945. getStencilFunction(): number;
  122946. /**
  122947. * Gets the current stencil reference value
  122948. * @returns a number defining the stencil reference value to use
  122949. */
  122950. getStencilFunctionReference(): number;
  122951. /**
  122952. * Gets the current stencil mask
  122953. * @returns a number defining the stencil mask to use
  122954. */
  122955. getStencilFunctionMask(): number;
  122956. /**
  122957. * Sets the current stencil function
  122958. * @param stencilFunc defines the new stencil function to use
  122959. */
  122960. setStencilFunction(stencilFunc: number): void;
  122961. /**
  122962. * Sets the current stencil reference
  122963. * @param reference defines the new stencil reference to use
  122964. */
  122965. setStencilFunctionReference(reference: number): void;
  122966. /**
  122967. * Sets the current stencil mask
  122968. * @param mask defines the new stencil mask to use
  122969. */
  122970. setStencilFunctionMask(mask: number): void;
  122971. /**
  122972. * Gets the current stencil operation when stencil fails
  122973. * @returns a number defining stencil operation to use when stencil fails
  122974. */
  122975. getStencilOperationFail(): number;
  122976. /**
  122977. * Gets the current stencil operation when depth fails
  122978. * @returns a number defining stencil operation to use when depth fails
  122979. */
  122980. getStencilOperationDepthFail(): number;
  122981. /**
  122982. * Gets the current stencil operation when stencil passes
  122983. * @returns a number defining stencil operation to use when stencil passes
  122984. */
  122985. getStencilOperationPass(): number;
  122986. /**
  122987. * Sets the stencil operation to use when stencil fails
  122988. * @param operation defines the stencil operation to use when stencil fails
  122989. */
  122990. setStencilOperationFail(operation: number): void;
  122991. /**
  122992. * Sets the stencil operation to use when depth fails
  122993. * @param operation defines the stencil operation to use when depth fails
  122994. */
  122995. setStencilOperationDepthFail(operation: number): void;
  122996. /**
  122997. * Sets the stencil operation to use when stencil passes
  122998. * @param operation defines the stencil operation to use when stencil passes
  122999. */
  123000. setStencilOperationPass(operation: number): void;
  123001. /**
  123002. * Sets a boolean indicating if the dithering state is enabled or disabled
  123003. * @param value defines the dithering state
  123004. */
  123005. setDitheringState(value: boolean): void;
  123006. /**
  123007. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  123008. * @param value defines the rasterizer state
  123009. */
  123010. setRasterizerState(value: boolean): void;
  123011. /**
  123012. * Gets the current depth function
  123013. * @returns a number defining the depth function
  123014. */
  123015. getDepthFunction(): Nullable<number>;
  123016. /**
  123017. * Sets the current depth function
  123018. * @param depthFunc defines the function to use
  123019. */
  123020. setDepthFunction(depthFunc: number): void;
  123021. /**
  123022. * Sets the current depth function to GREATER
  123023. */
  123024. setDepthFunctionToGreater(): void;
  123025. /**
  123026. * Sets the current depth function to GEQUAL
  123027. */
  123028. setDepthFunctionToGreaterOrEqual(): void;
  123029. /**
  123030. * Sets the current depth function to LESS
  123031. */
  123032. setDepthFunctionToLess(): void;
  123033. /**
  123034. * Sets the current depth function to LEQUAL
  123035. */
  123036. setDepthFunctionToLessOrEqual(): void;
  123037. private _cachedStencilBuffer;
  123038. private _cachedStencilFunction;
  123039. private _cachedStencilMask;
  123040. private _cachedStencilOperationPass;
  123041. private _cachedStencilOperationFail;
  123042. private _cachedStencilOperationDepthFail;
  123043. private _cachedStencilReference;
  123044. /**
  123045. * Caches the the state of the stencil buffer
  123046. */
  123047. cacheStencilState(): void;
  123048. /**
  123049. * Restores the state of the stencil buffer
  123050. */
  123051. restoreStencilState(): void;
  123052. /**
  123053. * Directly set the WebGL Viewport
  123054. * @param x defines the x coordinate of the viewport (in screen space)
  123055. * @param y defines the y coordinate of the viewport (in screen space)
  123056. * @param width defines the width of the viewport (in screen space)
  123057. * @param height defines the height of the viewport (in screen space)
  123058. * @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
  123059. */
  123060. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  123061. /**
  123062. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  123063. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123064. * @param y defines the y-coordinate of the corner of the clear rectangle
  123065. * @param width defines the width of the clear rectangle
  123066. * @param height defines the height of the clear rectangle
  123067. * @param clearColor defines the clear color
  123068. */
  123069. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  123070. /**
  123071. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  123072. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123073. * @param y defines the y-coordinate of the corner of the clear rectangle
  123074. * @param width defines the width of the clear rectangle
  123075. * @param height defines the height of the clear rectangle
  123076. */
  123077. enableScissor(x: number, y: number, width: number, height: number): void;
  123078. /**
  123079. * Disable previously set scissor test rectangle
  123080. */
  123081. disableScissor(): void;
  123082. protected _reportDrawCall(): void;
  123083. /**
  123084. * Initializes a webVR display and starts listening to display change events
  123085. * The onVRDisplayChangedObservable will be notified upon these changes
  123086. * @returns The onVRDisplayChangedObservable
  123087. */
  123088. initWebVR(): Observable<IDisplayChangedEventArgs>;
  123089. /** @hidden */
  123090. _prepareVRComponent(): void;
  123091. /** @hidden */
  123092. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  123093. /** @hidden */
  123094. _submitVRFrame(): void;
  123095. /**
  123096. * Call this function to leave webVR mode
  123097. * Will do nothing if webVR is not supported or if there is no webVR device
  123098. * @see https://doc.babylonjs.com/how_to/webvr_camera
  123099. */
  123100. disableVR(): void;
  123101. /**
  123102. * Gets a boolean indicating that the system is in VR mode and is presenting
  123103. * @returns true if VR mode is engaged
  123104. */
  123105. isVRPresenting(): boolean;
  123106. /** @hidden */
  123107. _requestVRFrame(): void;
  123108. /** @hidden */
  123109. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  123110. /**
  123111. * Gets the source code of the vertex shader associated with a specific webGL program
  123112. * @param program defines the program to use
  123113. * @returns a string containing the source code of the vertex shader associated with the program
  123114. */
  123115. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  123116. /**
  123117. * Gets the source code of the fragment shader associated with a specific webGL program
  123118. * @param program defines the program to use
  123119. * @returns a string containing the source code of the fragment shader associated with the program
  123120. */
  123121. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  123122. /**
  123123. * Sets a depth stencil texture from a render target to the according uniform.
  123124. * @param channel The texture channel
  123125. * @param uniform The uniform to set
  123126. * @param texture The render target texture containing the depth stencil texture to apply
  123127. */
  123128. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  123129. /**
  123130. * Sets a texture to the webGL context from a postprocess
  123131. * @param channel defines the channel to use
  123132. * @param postProcess defines the source postprocess
  123133. */
  123134. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  123135. /**
  123136. * Binds the output of the passed in post process to the texture channel specified
  123137. * @param channel The channel the texture should be bound to
  123138. * @param postProcess The post process which's output should be bound
  123139. */
  123140. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  123141. protected _rebuildBuffers(): void;
  123142. /** @hidden */
  123143. _renderFrame(): void;
  123144. _renderLoop(): void;
  123145. /** @hidden */
  123146. _renderViews(): boolean;
  123147. /**
  123148. * Toggle full screen mode
  123149. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123150. */
  123151. switchFullscreen(requestPointerLock: boolean): void;
  123152. /**
  123153. * Enters full screen mode
  123154. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123155. */
  123156. enterFullscreen(requestPointerLock: boolean): void;
  123157. /**
  123158. * Exits full screen mode
  123159. */
  123160. exitFullscreen(): void;
  123161. /**
  123162. * Enters Pointerlock mode
  123163. */
  123164. enterPointerlock(): void;
  123165. /**
  123166. * Exits Pointerlock mode
  123167. */
  123168. exitPointerlock(): void;
  123169. /**
  123170. * Begin a new frame
  123171. */
  123172. beginFrame(): void;
  123173. /**
  123174. * Enf the current frame
  123175. */
  123176. endFrame(): void;
  123177. resize(): void;
  123178. /**
  123179. * Force a specific size of the canvas
  123180. * @param width defines the new canvas' width
  123181. * @param height defines the new canvas' height
  123182. * @returns true if the size was changed
  123183. */
  123184. setSize(width: number, height: number): boolean;
  123185. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  123186. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123187. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123188. _releaseTexture(texture: InternalTexture): void;
  123189. /**
  123190. * @hidden
  123191. * Rescales a texture
  123192. * @param source input texutre
  123193. * @param destination destination texture
  123194. * @param scene scene to use to render the resize
  123195. * @param internalFormat format to use when resizing
  123196. * @param onComplete callback to be called when resize has completed
  123197. */
  123198. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  123199. /**
  123200. * Gets the current framerate
  123201. * @returns a number representing the framerate
  123202. */
  123203. getFps(): number;
  123204. /**
  123205. * Gets the time spent between current and previous frame
  123206. * @returns a number representing the delta time in ms
  123207. */
  123208. getDeltaTime(): number;
  123209. private _measureFps;
  123210. /** @hidden */
  123211. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  123212. /**
  123213. * Updates the sample count of a render target texture
  123214. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123215. * @param texture defines the texture to update
  123216. * @param samples defines the sample count to set
  123217. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123218. */
  123219. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  123220. /**
  123221. * Updates a depth texture Comparison Mode and Function.
  123222. * If the comparison Function is equal to 0, the mode will be set to none.
  123223. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  123224. * @param texture The texture to set the comparison function for
  123225. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  123226. */
  123227. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  123228. /**
  123229. * Creates a webGL buffer to use with instanciation
  123230. * @param capacity defines the size of the buffer
  123231. * @returns the webGL buffer
  123232. */
  123233. createInstancesBuffer(capacity: number): DataBuffer;
  123234. /**
  123235. * Delete a webGL buffer used with instanciation
  123236. * @param buffer defines the webGL buffer to delete
  123237. */
  123238. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  123239. private _clientWaitAsync;
  123240. /** @hidden */
  123241. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  123242. dispose(): void;
  123243. private _disableTouchAction;
  123244. /**
  123245. * Display the loading screen
  123246. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123247. */
  123248. displayLoadingUI(): void;
  123249. /**
  123250. * Hide the loading screen
  123251. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123252. */
  123253. hideLoadingUI(): void;
  123254. /**
  123255. * Gets the current loading screen object
  123256. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123257. */
  123258. get loadingScreen(): ILoadingScreen;
  123259. /**
  123260. * Sets the current loading screen object
  123261. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123262. */
  123263. set loadingScreen(loadingScreen: ILoadingScreen);
  123264. /**
  123265. * Sets the current loading screen text
  123266. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123267. */
  123268. set loadingUIText(text: string);
  123269. /**
  123270. * Sets the current loading screen background color
  123271. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123272. */
  123273. set loadingUIBackgroundColor(color: string);
  123274. /** Pointerlock and fullscreen */
  123275. /**
  123276. * Ask the browser to promote the current element to pointerlock mode
  123277. * @param element defines the DOM element to promote
  123278. */
  123279. static _RequestPointerlock(element: HTMLElement): void;
  123280. /**
  123281. * Asks the browser to exit pointerlock mode
  123282. */
  123283. static _ExitPointerlock(): void;
  123284. /**
  123285. * Ask the browser to promote the current element to fullscreen rendering mode
  123286. * @param element defines the DOM element to promote
  123287. */
  123288. static _RequestFullscreen(element: HTMLElement): void;
  123289. /**
  123290. * Asks the browser to exit fullscreen mode
  123291. */
  123292. static _ExitFullscreen(): void;
  123293. }
  123294. }
  123295. declare module BABYLON {
  123296. /**
  123297. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123298. * during the life time of the application.
  123299. */
  123300. export class EngineStore {
  123301. /** Gets the list of created engines */
  123302. static Instances: Engine[];
  123303. /** @hidden */
  123304. static _LastCreatedScene: Nullable<Scene>;
  123305. /**
  123306. * Gets the latest created engine
  123307. */
  123308. static get LastCreatedEngine(): Nullable<Engine>;
  123309. /**
  123310. * Gets the latest created scene
  123311. */
  123312. static get LastCreatedScene(): Nullable<Scene>;
  123313. /**
  123314. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123315. * @ignorenaming
  123316. */
  123317. static UseFallbackTexture: boolean;
  123318. /**
  123319. * Texture content used if a texture cannot loaded
  123320. * @ignorenaming
  123321. */
  123322. static FallbackTexture: string;
  123323. }
  123324. }
  123325. declare module BABYLON {
  123326. /**
  123327. * Helper class that provides a small promise polyfill
  123328. */
  123329. export class PromisePolyfill {
  123330. /**
  123331. * Static function used to check if the polyfill is required
  123332. * If this is the case then the function will inject the polyfill to window.Promise
  123333. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123334. */
  123335. static Apply(force?: boolean): void;
  123336. }
  123337. }
  123338. declare module BABYLON {
  123339. /**
  123340. * Interface for screenshot methods with describe argument called `size` as object with options
  123341. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123342. */
  123343. export interface IScreenshotSize {
  123344. /**
  123345. * number in pixels for canvas height
  123346. */
  123347. height?: number;
  123348. /**
  123349. * multiplier allowing render at a higher or lower resolution
  123350. * If value is defined then height and width will be ignored and taken from camera
  123351. */
  123352. precision?: number;
  123353. /**
  123354. * number in pixels for canvas width
  123355. */
  123356. width?: number;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. interface IColor4Like {
  123361. r: float;
  123362. g: float;
  123363. b: float;
  123364. a: float;
  123365. }
  123366. /**
  123367. * Class containing a set of static utilities functions
  123368. */
  123369. export class Tools {
  123370. /**
  123371. * Gets or sets the base URL to use to load assets
  123372. */
  123373. static get BaseUrl(): string;
  123374. static set BaseUrl(value: string);
  123375. /**
  123376. * Enable/Disable Custom HTTP Request Headers globally.
  123377. * default = false
  123378. * @see CustomRequestHeaders
  123379. */
  123380. static UseCustomRequestHeaders: boolean;
  123381. /**
  123382. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123383. * i.e. when loading files, where the server/service expects an Authorization header
  123384. */
  123385. static CustomRequestHeaders: {
  123386. [key: string]: string;
  123387. };
  123388. /**
  123389. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123390. */
  123391. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123392. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123393. /**
  123394. * Default behaviour for cors in the application.
  123395. * It can be a string if the expected behavior is identical in the entire app.
  123396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123397. */
  123398. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123399. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123400. /**
  123401. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123402. * @ignorenaming
  123403. */
  123404. static get UseFallbackTexture(): boolean;
  123405. static set UseFallbackTexture(value: boolean);
  123406. /**
  123407. * Use this object to register external classes like custom textures or material
  123408. * to allow the laoders to instantiate them
  123409. */
  123410. static get RegisteredExternalClasses(): {
  123411. [key: string]: Object;
  123412. };
  123413. static set RegisteredExternalClasses(classes: {
  123414. [key: string]: Object;
  123415. });
  123416. /**
  123417. * Texture content used if a texture cannot loaded
  123418. * @ignorenaming
  123419. */
  123420. static get fallbackTexture(): string;
  123421. static set fallbackTexture(value: string);
  123422. /**
  123423. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123424. * @param u defines the coordinate on X axis
  123425. * @param v defines the coordinate on Y axis
  123426. * @param width defines the width of the source data
  123427. * @param height defines the height of the source data
  123428. * @param pixels defines the source byte array
  123429. * @param color defines the output color
  123430. */
  123431. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123432. /**
  123433. * Interpolates between a and b via alpha
  123434. * @param a The lower value (returned when alpha = 0)
  123435. * @param b The upper value (returned when alpha = 1)
  123436. * @param alpha The interpolation-factor
  123437. * @return The mixed value
  123438. */
  123439. static Mix(a: number, b: number, alpha: number): number;
  123440. /**
  123441. * Tries to instantiate a new object from a given class name
  123442. * @param className defines the class name to instantiate
  123443. * @returns the new object or null if the system was not able to do the instantiation
  123444. */
  123445. static Instantiate(className: string): any;
  123446. /**
  123447. * Provides a slice function that will work even on IE
  123448. * @param data defines the array to slice
  123449. * @param start defines the start of the data (optional)
  123450. * @param end defines the end of the data (optional)
  123451. * @returns the new sliced array
  123452. */
  123453. static Slice<T>(data: T, start?: number, end?: number): T;
  123454. /**
  123455. * Provides a slice function that will work even on IE
  123456. * The difference between this and Slice is that this will force-convert to array
  123457. * @param data defines the array to slice
  123458. * @param start defines the start of the data (optional)
  123459. * @param end defines the end of the data (optional)
  123460. * @returns the new sliced array
  123461. */
  123462. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123463. /**
  123464. * Polyfill for setImmediate
  123465. * @param action defines the action to execute after the current execution block
  123466. */
  123467. static SetImmediate(action: () => void): void;
  123468. /**
  123469. * Function indicating if a number is an exponent of 2
  123470. * @param value defines the value to test
  123471. * @returns true if the value is an exponent of 2
  123472. */
  123473. static IsExponentOfTwo(value: number): boolean;
  123474. private static _tmpFloatArray;
  123475. /**
  123476. * Returns the nearest 32-bit single precision float representation of a Number
  123477. * @param value A Number. If the parameter is of a different type, it will get converted
  123478. * to a number or to NaN if it cannot be converted
  123479. * @returns number
  123480. */
  123481. static FloatRound(value: number): number;
  123482. /**
  123483. * Extracts the filename from a path
  123484. * @param path defines the path to use
  123485. * @returns the filename
  123486. */
  123487. static GetFilename(path: string): string;
  123488. /**
  123489. * Extracts the "folder" part of a path (everything before the filename).
  123490. * @param uri The URI to extract the info from
  123491. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123492. * @returns The "folder" part of the path
  123493. */
  123494. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123495. /**
  123496. * Extracts text content from a DOM element hierarchy
  123497. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123498. */
  123499. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123500. /**
  123501. * Convert an angle in radians to degrees
  123502. * @param angle defines the angle to convert
  123503. * @returns the angle in degrees
  123504. */
  123505. static ToDegrees(angle: number): number;
  123506. /**
  123507. * Convert an angle in degrees to radians
  123508. * @param angle defines the angle to convert
  123509. * @returns the angle in radians
  123510. */
  123511. static ToRadians(angle: number): number;
  123512. /**
  123513. * Returns an array if obj is not an array
  123514. * @param obj defines the object to evaluate as an array
  123515. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123516. * @returns either obj directly if obj is an array or a new array containing obj
  123517. */
  123518. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123519. /**
  123520. * Gets the pointer prefix to use
  123521. * @param engine defines the engine we are finding the prefix for
  123522. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123523. */
  123524. static GetPointerPrefix(engine: Engine): string;
  123525. /**
  123526. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123527. * @param url define the url we are trying
  123528. * @param element define the dom element where to configure the cors policy
  123529. */
  123530. static SetCorsBehavior(url: string | string[], element: {
  123531. crossOrigin: string | null;
  123532. }): void;
  123533. /**
  123534. * Removes unwanted characters from an url
  123535. * @param url defines the url to clean
  123536. * @returns the cleaned url
  123537. */
  123538. static CleanUrl(url: string): string;
  123539. /**
  123540. * Gets or sets a function used to pre-process url before using them to load assets
  123541. */
  123542. static get PreprocessUrl(): (url: string) => string;
  123543. static set PreprocessUrl(processor: (url: string) => string);
  123544. /**
  123545. * Loads an image as an HTMLImageElement.
  123546. * @param input url string, ArrayBuffer, or Blob to load
  123547. * @param onLoad callback called when the image successfully loads
  123548. * @param onError callback called when the image fails to load
  123549. * @param offlineProvider offline provider for caching
  123550. * @param mimeType optional mime type
  123551. * @returns the HTMLImageElement of the loaded image
  123552. */
  123553. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123554. /**
  123555. * Loads a file from a url
  123556. * @param url url string, ArrayBuffer, or Blob to load
  123557. * @param onSuccess callback called when the file successfully loads
  123558. * @param onProgress callback called while file is loading (if the server supports this mode)
  123559. * @param offlineProvider defines the offline provider for caching
  123560. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123561. * @param onError callback called when the file fails to load
  123562. * @returns a file request object
  123563. */
  123564. 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;
  123565. /**
  123566. * Loads a file from a url
  123567. * @param url the file url to load
  123568. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123569. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123570. */
  123571. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123572. /**
  123573. * Load a script (identified by an url). When the url returns, the
  123574. * content of this file is added into a new script element, attached to the DOM (body element)
  123575. * @param scriptUrl defines the url of the script to laod
  123576. * @param onSuccess defines the callback called when the script is loaded
  123577. * @param onError defines the callback to call if an error occurs
  123578. * @param scriptId defines the id of the script element
  123579. */
  123580. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123581. /**
  123582. * Load an asynchronous script (identified by an url). When the url returns, the
  123583. * content of this file is added into a new script element, attached to the DOM (body element)
  123584. * @param scriptUrl defines the url of the script to laod
  123585. * @param scriptId defines the id of the script element
  123586. * @returns a promise request object
  123587. */
  123588. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123589. /**
  123590. * Loads a file from a blob
  123591. * @param fileToLoad defines the blob to use
  123592. * @param callback defines the callback to call when data is loaded
  123593. * @param progressCallback defines the callback to call during loading process
  123594. * @returns a file request object
  123595. */
  123596. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123597. /**
  123598. * Reads a file from a File object
  123599. * @param file defines the file to load
  123600. * @param onSuccess defines the callback to call when data is loaded
  123601. * @param onProgress defines the callback to call during loading process
  123602. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123603. * @param onError defines the callback to call when an error occurs
  123604. * @returns a file request object
  123605. */
  123606. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123607. /**
  123608. * Creates a data url from a given string content
  123609. * @param content defines the content to convert
  123610. * @returns the new data url link
  123611. */
  123612. static FileAsURL(content: string): string;
  123613. /**
  123614. * Format the given number to a specific decimal format
  123615. * @param value defines the number to format
  123616. * @param decimals defines the number of decimals to use
  123617. * @returns the formatted string
  123618. */
  123619. static Format(value: number, decimals?: number): string;
  123620. /**
  123621. * Tries to copy an object by duplicating every property
  123622. * @param source defines the source object
  123623. * @param destination defines the target object
  123624. * @param doNotCopyList defines a list of properties to avoid
  123625. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123626. */
  123627. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123628. /**
  123629. * Gets a boolean indicating if the given object has no own property
  123630. * @param obj defines the object to test
  123631. * @returns true if object has no own property
  123632. */
  123633. static IsEmpty(obj: any): boolean;
  123634. /**
  123635. * Function used to register events at window level
  123636. * @param windowElement defines the Window object to use
  123637. * @param events defines the events to register
  123638. */
  123639. static RegisterTopRootEvents(windowElement: Window, events: {
  123640. name: string;
  123641. handler: Nullable<(e: FocusEvent) => any>;
  123642. }[]): void;
  123643. /**
  123644. * Function used to unregister events from window level
  123645. * @param windowElement defines the Window object to use
  123646. * @param events defines the events to unregister
  123647. */
  123648. static UnregisterTopRootEvents(windowElement: Window, events: {
  123649. name: string;
  123650. handler: Nullable<(e: FocusEvent) => any>;
  123651. }[]): void;
  123652. /**
  123653. * @ignore
  123654. */
  123655. static _ScreenshotCanvas: HTMLCanvasElement;
  123656. /**
  123657. * Dumps the current bound framebuffer
  123658. * @param width defines the rendering width
  123659. * @param height defines the rendering height
  123660. * @param engine defines the hosting engine
  123661. * @param successCallback defines the callback triggered once the data are available
  123662. * @param mimeType defines the mime type of the result
  123663. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123664. */
  123665. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123666. /**
  123667. * Converts the canvas data to blob.
  123668. * This acts as a polyfill for browsers not supporting the to blob function.
  123669. * @param canvas Defines the canvas to extract the data from
  123670. * @param successCallback Defines the callback triggered once the data are available
  123671. * @param mimeType Defines the mime type of the result
  123672. */
  123673. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123674. /**
  123675. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123676. * @param successCallback defines the callback triggered once the data are available
  123677. * @param mimeType defines the mime type of the result
  123678. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123679. */
  123680. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123681. /**
  123682. * Downloads a blob in the browser
  123683. * @param blob defines the blob to download
  123684. * @param fileName defines the name of the downloaded file
  123685. */
  123686. static Download(blob: Blob, fileName: string): void;
  123687. /**
  123688. * Will return the right value of the noPreventDefault variable
  123689. * Needed to keep backwards compatibility to the old API.
  123690. *
  123691. * @param args arguments passed to the attachControl function
  123692. * @returns the correct value for noPreventDefault
  123693. */
  123694. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123695. /**
  123696. * Captures a screenshot of the current rendering
  123697. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123698. * @param engine defines the rendering engine
  123699. * @param camera defines the source camera
  123700. * @param size This parameter can be set to a single number or to an object with the
  123701. * following (optional) properties: precision, width, height. If a single number is passed,
  123702. * it will be used for both width and height. If an object is passed, the screenshot size
  123703. * will be derived from the parameters. The precision property is a multiplier allowing
  123704. * rendering at a higher or lower resolution
  123705. * @param successCallback defines the callback receives a single parameter which contains the
  123706. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123707. * src parameter of an <img> to display it
  123708. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123709. * Check your browser for supported MIME types
  123710. */
  123711. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123712. /**
  123713. * Captures a screenshot of the current rendering
  123714. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123715. * @param engine defines the rendering engine
  123716. * @param camera defines the source camera
  123717. * @param size This parameter can be set to a single number or to an object with the
  123718. * following (optional) properties: precision, width, height. If a single number is passed,
  123719. * it will be used for both width and height. If an object is passed, the screenshot size
  123720. * will be derived from the parameters. The precision property is a multiplier allowing
  123721. * rendering at a higher or lower resolution
  123722. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123723. * Check your browser for supported MIME types
  123724. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123725. * to the src parameter of an <img> to display it
  123726. */
  123727. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123728. /**
  123729. * Generates an image screenshot from the specified camera.
  123730. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123731. * @param engine The engine to use for rendering
  123732. * @param camera The camera to use for rendering
  123733. * @param size This parameter can be set to a single number or to an object with the
  123734. * following (optional) properties: precision, width, height. If a single number is passed,
  123735. * it will be used for both width and height. If an object is passed, the screenshot size
  123736. * will be derived from the parameters. The precision property is a multiplier allowing
  123737. * rendering at a higher or lower resolution
  123738. * @param successCallback The callback receives a single parameter which contains the
  123739. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123740. * src parameter of an <img> to display it
  123741. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123742. * Check your browser for supported MIME types
  123743. * @param samples Texture samples (default: 1)
  123744. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123745. * @param fileName A name for for the downloaded file.
  123746. */
  123747. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123748. /**
  123749. * Generates an image screenshot from the specified camera.
  123750. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123751. * @param engine The engine to use for rendering
  123752. * @param camera The camera to use for rendering
  123753. * @param size This parameter can be set to a single number or to an object with the
  123754. * following (optional) properties: precision, width, height. If a single number is passed,
  123755. * it will be used for both width and height. If an object is passed, the screenshot size
  123756. * will be derived from the parameters. The precision property is a multiplier allowing
  123757. * rendering at a higher or lower resolution
  123758. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123759. * Check your browser for supported MIME types
  123760. * @param samples Texture samples (default: 1)
  123761. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123762. * @param fileName A name for for the downloaded file.
  123763. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123764. * to the src parameter of an <img> to display it
  123765. */
  123766. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123767. /**
  123768. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123769. * Be aware Math.random() could cause collisions, but:
  123770. * "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"
  123771. * @returns a pseudo random id
  123772. */
  123773. static RandomId(): string;
  123774. /**
  123775. * Test if the given uri is a base64 string
  123776. * @param uri The uri to test
  123777. * @return True if the uri is a base64 string or false otherwise
  123778. */
  123779. static IsBase64(uri: string): boolean;
  123780. /**
  123781. * Decode the given base64 uri.
  123782. * @param uri The uri to decode
  123783. * @return The decoded base64 data.
  123784. */
  123785. static DecodeBase64(uri: string): ArrayBuffer;
  123786. /**
  123787. * Gets the absolute url.
  123788. * @param url the input url
  123789. * @return the absolute url
  123790. */
  123791. static GetAbsoluteUrl(url: string): string;
  123792. /**
  123793. * No log
  123794. */
  123795. static readonly NoneLogLevel: number;
  123796. /**
  123797. * Only message logs
  123798. */
  123799. static readonly MessageLogLevel: number;
  123800. /**
  123801. * Only warning logs
  123802. */
  123803. static readonly WarningLogLevel: number;
  123804. /**
  123805. * Only error logs
  123806. */
  123807. static readonly ErrorLogLevel: number;
  123808. /**
  123809. * All logs
  123810. */
  123811. static readonly AllLogLevel: number;
  123812. /**
  123813. * Gets a value indicating the number of loading errors
  123814. * @ignorenaming
  123815. */
  123816. static get errorsCount(): number;
  123817. /**
  123818. * Callback called when a new log is added
  123819. */
  123820. static OnNewCacheEntry: (entry: string) => void;
  123821. /**
  123822. * Log a message to the console
  123823. * @param message defines the message to log
  123824. */
  123825. static Log(message: string): void;
  123826. /**
  123827. * Write a warning message to the console
  123828. * @param message defines the message to log
  123829. */
  123830. static Warn(message: string): void;
  123831. /**
  123832. * Write an error message to the console
  123833. * @param message defines the message to log
  123834. */
  123835. static Error(message: string): void;
  123836. /**
  123837. * Gets current log cache (list of logs)
  123838. */
  123839. static get LogCache(): string;
  123840. /**
  123841. * Clears the log cache
  123842. */
  123843. static ClearLogCache(): void;
  123844. /**
  123845. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123846. */
  123847. static set LogLevels(level: number);
  123848. /**
  123849. * Checks if the window object exists
  123850. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123851. */
  123852. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123853. /**
  123854. * No performance log
  123855. */
  123856. static readonly PerformanceNoneLogLevel: number;
  123857. /**
  123858. * Use user marks to log performance
  123859. */
  123860. static readonly PerformanceUserMarkLogLevel: number;
  123861. /**
  123862. * Log performance to the console
  123863. */
  123864. static readonly PerformanceConsoleLogLevel: number;
  123865. private static _performance;
  123866. /**
  123867. * Sets the current performance log level
  123868. */
  123869. static set PerformanceLogLevel(level: number);
  123870. private static _StartPerformanceCounterDisabled;
  123871. private static _EndPerformanceCounterDisabled;
  123872. private static _StartUserMark;
  123873. private static _EndUserMark;
  123874. private static _StartPerformanceConsole;
  123875. private static _EndPerformanceConsole;
  123876. /**
  123877. * Starts a performance counter
  123878. */
  123879. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123880. /**
  123881. * Ends a specific performance coutner
  123882. */
  123883. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123884. /**
  123885. * Gets either window.performance.now() if supported or Date.now() else
  123886. */
  123887. static get Now(): number;
  123888. /**
  123889. * This method will return the name of the class used to create the instance of the given object.
  123890. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123891. * @param object the object to get the class name from
  123892. * @param isType defines if the object is actually a type
  123893. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123894. */
  123895. static GetClassName(object: any, isType?: boolean): string;
  123896. /**
  123897. * Gets the first element of an array satisfying a given predicate
  123898. * @param array defines the array to browse
  123899. * @param predicate defines the predicate to use
  123900. * @returns null if not found or the element
  123901. */
  123902. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123903. /**
  123904. * This method will return the name of the full name of the class, including its owning module (if any).
  123905. * 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).
  123906. * @param object the object to get the class name from
  123907. * @param isType defines if the object is actually a type
  123908. * @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.
  123909. * @ignorenaming
  123910. */
  123911. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123912. /**
  123913. * Returns a promise that resolves after the given amount of time.
  123914. * @param delay Number of milliseconds to delay
  123915. * @returns Promise that resolves after the given amount of time
  123916. */
  123917. static DelayAsync(delay: number): Promise<void>;
  123918. /**
  123919. * Utility function to detect if the current user agent is Safari
  123920. * @returns whether or not the current user agent is safari
  123921. */
  123922. static IsSafari(): boolean;
  123923. }
  123924. /**
  123925. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123926. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123927. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123928. * @param name The name of the class, case should be preserved
  123929. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123930. */
  123931. export function className(name: string, module?: string): (target: Object) => void;
  123932. /**
  123933. * An implementation of a loop for asynchronous functions.
  123934. */
  123935. export class AsyncLoop {
  123936. /**
  123937. * Defines the number of iterations for the loop
  123938. */
  123939. iterations: number;
  123940. /**
  123941. * Defines the current index of the loop.
  123942. */
  123943. index: number;
  123944. private _done;
  123945. private _fn;
  123946. private _successCallback;
  123947. /**
  123948. * Constructor.
  123949. * @param iterations the number of iterations.
  123950. * @param func the function to run each iteration
  123951. * @param successCallback the callback that will be called upon succesful execution
  123952. * @param offset starting offset.
  123953. */
  123954. constructor(
  123955. /**
  123956. * Defines the number of iterations for the loop
  123957. */
  123958. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123959. /**
  123960. * Execute the next iteration. Must be called after the last iteration was finished.
  123961. */
  123962. executeNext(): void;
  123963. /**
  123964. * Break the loop and run the success callback.
  123965. */
  123966. breakLoop(): void;
  123967. /**
  123968. * Create and run an async loop.
  123969. * @param iterations the number of iterations.
  123970. * @param fn the function to run each iteration
  123971. * @param successCallback the callback that will be called upon succesful execution
  123972. * @param offset starting offset.
  123973. * @returns the created async loop object
  123974. */
  123975. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123976. /**
  123977. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123978. * @param iterations total number of iterations
  123979. * @param syncedIterations number of synchronous iterations in each async iteration.
  123980. * @param fn the function to call each iteration.
  123981. * @param callback a success call back that will be called when iterating stops.
  123982. * @param breakFunction a break condition (optional)
  123983. * @param timeout timeout settings for the setTimeout function. default - 0.
  123984. * @returns the created async loop object
  123985. */
  123986. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123987. }
  123988. }
  123989. declare module BABYLON {
  123990. /**
  123991. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123992. * The underlying implementation relies on an associative array to ensure the best performances.
  123993. * The value can be anything including 'null' but except 'undefined'
  123994. */
  123995. export class StringDictionary<T> {
  123996. /**
  123997. * This will clear this dictionary and copy the content from the 'source' one.
  123998. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123999. * @param source the dictionary to take the content from and copy to this dictionary
  124000. */
  124001. copyFrom(source: StringDictionary<T>): void;
  124002. /**
  124003. * Get a value based from its key
  124004. * @param key the given key to get the matching value from
  124005. * @return the value if found, otherwise undefined is returned
  124006. */
  124007. get(key: string): T | undefined;
  124008. /**
  124009. * Get a value from its key or add it if it doesn't exist.
  124010. * This method will ensure you that a given key/data will be present in the dictionary.
  124011. * @param key the given key to get the matching value from
  124012. * @param factory the factory that will create the value if the key is not present in the dictionary.
  124013. * The factory will only be invoked if there's no data for the given key.
  124014. * @return the value corresponding to the key.
  124015. */
  124016. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  124017. /**
  124018. * Get a value from its key if present in the dictionary otherwise add it
  124019. * @param key the key to get the value from
  124020. * @param val if there's no such key/value pair in the dictionary add it with this value
  124021. * @return the value corresponding to the key
  124022. */
  124023. getOrAdd(key: string, val: T): T;
  124024. /**
  124025. * Check if there's a given key in the dictionary
  124026. * @param key the key to check for
  124027. * @return true if the key is present, false otherwise
  124028. */
  124029. contains(key: string): boolean;
  124030. /**
  124031. * Add a new key and its corresponding value
  124032. * @param key the key to add
  124033. * @param value the value corresponding to the key
  124034. * @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
  124035. */
  124036. add(key: string, value: T): boolean;
  124037. /**
  124038. * Update a specific value associated to a key
  124039. * @param key defines the key to use
  124040. * @param value defines the value to store
  124041. * @returns true if the value was updated (or false if the key was not found)
  124042. */
  124043. set(key: string, value: T): boolean;
  124044. /**
  124045. * Get the element of the given key and remove it from the dictionary
  124046. * @param key defines the key to search
  124047. * @returns the value associated with the key or null if not found
  124048. */
  124049. getAndRemove(key: string): Nullable<T>;
  124050. /**
  124051. * Remove a key/value from the dictionary.
  124052. * @param key the key to remove
  124053. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  124054. */
  124055. remove(key: string): boolean;
  124056. /**
  124057. * Clear the whole content of the dictionary
  124058. */
  124059. clear(): void;
  124060. /**
  124061. * Gets the current count
  124062. */
  124063. get count(): number;
  124064. /**
  124065. * Execute a callback on each key/val of the dictionary.
  124066. * Note that you can remove any element in this dictionary in the callback implementation
  124067. * @param callback the callback to execute on a given key/value pair
  124068. */
  124069. forEach(callback: (key: string, val: T) => void): void;
  124070. /**
  124071. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  124072. * If the callback returns null or undefined the method will iterate to the next key/value pair
  124073. * Note that you can remove any element in this dictionary in the callback implementation
  124074. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  124075. * @returns the first item
  124076. */
  124077. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  124078. private _count;
  124079. private _data;
  124080. }
  124081. }
  124082. declare module BABYLON {
  124083. /** @hidden */
  124084. export interface ICollisionCoordinator {
  124085. createCollider(): Collider;
  124086. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124087. init(scene: Scene): void;
  124088. }
  124089. /** @hidden */
  124090. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  124091. private _scene;
  124092. private _scaledPosition;
  124093. private _scaledVelocity;
  124094. private _finalPosition;
  124095. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124096. createCollider(): Collider;
  124097. init(scene: Scene): void;
  124098. private _collideWithWorld;
  124099. }
  124100. }
  124101. declare module BABYLON {
  124102. /**
  124103. * Class used to manage all inputs for the scene.
  124104. */
  124105. export class InputManager {
  124106. /** The distance in pixel that you have to move to prevent some events */
  124107. static DragMovementThreshold: number;
  124108. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  124109. static LongPressDelay: number;
  124110. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  124111. static DoubleClickDelay: number;
  124112. /** If you need to check double click without raising a single click at first click, enable this flag */
  124113. static ExclusiveDoubleClickMode: boolean;
  124114. /** 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. */
  124115. private _alreadyAttached;
  124116. private _alreadyAttachedTo;
  124117. private _wheelEventName;
  124118. private _onPointerMove;
  124119. private _onPointerDown;
  124120. private _onPointerUp;
  124121. private _initClickEvent;
  124122. private _initActionManager;
  124123. private _delayedSimpleClick;
  124124. private _delayedSimpleClickTimeout;
  124125. private _previousDelayedSimpleClickTimeout;
  124126. private _meshPickProceed;
  124127. private _previousButtonPressed;
  124128. private _currentPickResult;
  124129. private _previousPickResult;
  124130. private _totalPointersPressed;
  124131. private _doubleClickOccured;
  124132. private _pointerOverMesh;
  124133. private _pickedDownMesh;
  124134. private _pickedUpMesh;
  124135. private _pointerX;
  124136. private _pointerY;
  124137. private _unTranslatedPointerX;
  124138. private _unTranslatedPointerY;
  124139. private _startingPointerPosition;
  124140. private _previousStartingPointerPosition;
  124141. private _startingPointerTime;
  124142. private _previousStartingPointerTime;
  124143. private _pointerCaptures;
  124144. private _meshUnderPointerId;
  124145. private _onKeyDown;
  124146. private _onKeyUp;
  124147. private _keyboardIsAttached;
  124148. private _onCanvasFocusObserver;
  124149. private _onCanvasBlurObserver;
  124150. private _scene;
  124151. /**
  124152. * Creates a new InputManager
  124153. * @param scene defines the hosting scene
  124154. */
  124155. constructor(scene: Scene);
  124156. /**
  124157. * Gets the mesh that is currently under the pointer
  124158. */
  124159. get meshUnderPointer(): Nullable<AbstractMesh>;
  124160. /**
  124161. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  124162. * @param pointerId the pointer id to use
  124163. * @returns The mesh under this pointer id or null if not found
  124164. */
  124165. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  124166. /**
  124167. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  124168. */
  124169. get unTranslatedPointer(): Vector2;
  124170. /**
  124171. * Gets or sets the current on-screen X position of the pointer
  124172. */
  124173. get pointerX(): number;
  124174. set pointerX(value: number);
  124175. /**
  124176. * Gets or sets the current on-screen Y position of the pointer
  124177. */
  124178. get pointerY(): number;
  124179. set pointerY(value: number);
  124180. private _updatePointerPosition;
  124181. private _processPointerMove;
  124182. private _setRayOnPointerInfo;
  124183. private _checkPrePointerObservable;
  124184. /**
  124185. * Use this method to simulate a pointer move on a mesh
  124186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124187. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124188. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124189. */
  124190. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124191. /**
  124192. * Use this method to simulate a pointer down on a mesh
  124193. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124194. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124195. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124196. */
  124197. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124198. private _processPointerDown;
  124199. /** @hidden */
  124200. _isPointerSwiping(): boolean;
  124201. /**
  124202. * Use this method to simulate a pointer up on a mesh
  124203. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124204. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124205. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124206. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124207. */
  124208. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  124209. private _processPointerUp;
  124210. /**
  124211. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124212. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124213. * @returns true if the pointer was captured
  124214. */
  124215. isPointerCaptured(pointerId?: number): boolean;
  124216. /**
  124217. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124218. * @param attachUp defines if you want to attach events to pointerup
  124219. * @param attachDown defines if you want to attach events to pointerdown
  124220. * @param attachMove defines if you want to attach events to pointermove
  124221. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  124222. */
  124223. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  124224. /**
  124225. * Detaches all event handlers
  124226. */
  124227. detachControl(): void;
  124228. /**
  124229. * Force the value of meshUnderPointer
  124230. * @param mesh defines the mesh to use
  124231. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  124232. */
  124233. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124234. /**
  124235. * Gets the mesh under the pointer
  124236. * @returns a Mesh or null if no mesh is under the pointer
  124237. */
  124238. getPointerOverMesh(): Nullable<AbstractMesh>;
  124239. }
  124240. }
  124241. declare module BABYLON {
  124242. /**
  124243. * This class defines the direct association between an animation and a target
  124244. */
  124245. export class TargetedAnimation {
  124246. /**
  124247. * Animation to perform
  124248. */
  124249. animation: Animation;
  124250. /**
  124251. * Target to animate
  124252. */
  124253. target: any;
  124254. /**
  124255. * Returns the string "TargetedAnimation"
  124256. * @returns "TargetedAnimation"
  124257. */
  124258. getClassName(): string;
  124259. /**
  124260. * Serialize the object
  124261. * @returns the JSON object representing the current entity
  124262. */
  124263. serialize(): any;
  124264. }
  124265. /**
  124266. * Use this class to create coordinated animations on multiple targets
  124267. */
  124268. export class AnimationGroup implements IDisposable {
  124269. /** The name of the animation group */
  124270. name: string;
  124271. private _scene;
  124272. private _targetedAnimations;
  124273. private _animatables;
  124274. private _from;
  124275. private _to;
  124276. private _isStarted;
  124277. private _isPaused;
  124278. private _speedRatio;
  124279. private _loopAnimation;
  124280. private _isAdditive;
  124281. /**
  124282. * Gets or sets the unique id of the node
  124283. */
  124284. uniqueId: number;
  124285. /**
  124286. * This observable will notify when one animation have ended
  124287. */
  124288. onAnimationEndObservable: Observable<TargetedAnimation>;
  124289. /**
  124290. * Observer raised when one animation loops
  124291. */
  124292. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124293. /**
  124294. * Observer raised when all animations have looped
  124295. */
  124296. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124297. /**
  124298. * This observable will notify when all animations have ended.
  124299. */
  124300. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124301. /**
  124302. * This observable will notify when all animations have paused.
  124303. */
  124304. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124305. /**
  124306. * This observable will notify when all animations are playing.
  124307. */
  124308. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124309. /**
  124310. * Gets the first frame
  124311. */
  124312. get from(): number;
  124313. /**
  124314. * Gets the last frame
  124315. */
  124316. get to(): number;
  124317. /**
  124318. * Define if the animations are started
  124319. */
  124320. get isStarted(): boolean;
  124321. /**
  124322. * Gets a value indicating that the current group is playing
  124323. */
  124324. get isPlaying(): boolean;
  124325. /**
  124326. * Gets or sets the speed ratio to use for all animations
  124327. */
  124328. get speedRatio(): number;
  124329. /**
  124330. * Gets or sets the speed ratio to use for all animations
  124331. */
  124332. set speedRatio(value: number);
  124333. /**
  124334. * Gets or sets if all animations should loop or not
  124335. */
  124336. get loopAnimation(): boolean;
  124337. set loopAnimation(value: boolean);
  124338. /**
  124339. * Gets or sets if all animations should be evaluated additively
  124340. */
  124341. get isAdditive(): boolean;
  124342. set isAdditive(value: boolean);
  124343. /**
  124344. * Gets the targeted animations for this animation group
  124345. */
  124346. get targetedAnimations(): Array<TargetedAnimation>;
  124347. /**
  124348. * returning the list of animatables controlled by this animation group.
  124349. */
  124350. get animatables(): Array<Animatable>;
  124351. /**
  124352. * Gets the list of target animations
  124353. */
  124354. get children(): TargetedAnimation[];
  124355. /**
  124356. * Instantiates a new Animation Group.
  124357. * This helps managing several animations at once.
  124358. * @see https://doc.babylonjs.com/how_to/group
  124359. * @param name Defines the name of the group
  124360. * @param scene Defines the scene the group belongs to
  124361. */
  124362. constructor(
  124363. /** The name of the animation group */
  124364. name: string, scene?: Nullable<Scene>);
  124365. /**
  124366. * Add an animation (with its target) in the group
  124367. * @param animation defines the animation we want to add
  124368. * @param target defines the target of the animation
  124369. * @returns the TargetedAnimation object
  124370. */
  124371. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124372. /**
  124373. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124374. * It can add constant keys at begin or end
  124375. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124376. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124377. * @returns the animation group
  124378. */
  124379. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124380. private _animationLoopCount;
  124381. private _animationLoopFlags;
  124382. private _processLoop;
  124383. /**
  124384. * Start all animations on given targets
  124385. * @param loop defines if animations must loop
  124386. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124387. * @param from defines the from key (optional)
  124388. * @param to defines the to key (optional)
  124389. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124390. * @returns the current animation group
  124391. */
  124392. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124393. /**
  124394. * Pause all animations
  124395. * @returns the animation group
  124396. */
  124397. pause(): AnimationGroup;
  124398. /**
  124399. * Play all animations to initial state
  124400. * This function will start() the animations if they were not started or will restart() them if they were paused
  124401. * @param loop defines if animations must loop
  124402. * @returns the animation group
  124403. */
  124404. play(loop?: boolean): AnimationGroup;
  124405. /**
  124406. * Reset all animations to initial state
  124407. * @returns the animation group
  124408. */
  124409. reset(): AnimationGroup;
  124410. /**
  124411. * Restart animations from key 0
  124412. * @returns the animation group
  124413. */
  124414. restart(): AnimationGroup;
  124415. /**
  124416. * Stop all animations
  124417. * @returns the animation group
  124418. */
  124419. stop(): AnimationGroup;
  124420. /**
  124421. * Set animation weight for all animatables
  124422. * @param weight defines the weight to use
  124423. * @return the animationGroup
  124424. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124425. */
  124426. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124427. /**
  124428. * Synchronize and normalize all animatables with a source animatable
  124429. * @param root defines the root animatable to synchronize with
  124430. * @return the animationGroup
  124431. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124432. */
  124433. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124434. /**
  124435. * Goes to a specific frame in this animation group
  124436. * @param frame the frame number to go to
  124437. * @return the animationGroup
  124438. */
  124439. goToFrame(frame: number): AnimationGroup;
  124440. /**
  124441. * Dispose all associated resources
  124442. */
  124443. dispose(): void;
  124444. private _checkAnimationGroupEnded;
  124445. /**
  124446. * Clone the current animation group and returns a copy
  124447. * @param newName defines the name of the new group
  124448. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124449. * @returns the new aniamtion group
  124450. */
  124451. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124452. /**
  124453. * Serializes the animationGroup to an object
  124454. * @returns Serialized object
  124455. */
  124456. serialize(): any;
  124457. /**
  124458. * Returns a new AnimationGroup object parsed from the source provided.
  124459. * @param parsedAnimationGroup defines the source
  124460. * @param scene defines the scene that will receive the animationGroup
  124461. * @returns a new AnimationGroup
  124462. */
  124463. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124464. /**
  124465. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124466. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124467. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124468. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124469. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124470. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124471. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124472. */
  124473. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124474. /**
  124475. * Returns the string "AnimationGroup"
  124476. * @returns "AnimationGroup"
  124477. */
  124478. getClassName(): string;
  124479. /**
  124480. * Creates a detailled string about the object
  124481. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124482. * @returns a string representing the object
  124483. */
  124484. toString(fullDetails?: boolean): string;
  124485. }
  124486. }
  124487. declare module BABYLON {
  124488. /**
  124489. * Define an interface for all classes that will hold resources
  124490. */
  124491. export interface IDisposable {
  124492. /**
  124493. * Releases all held resources
  124494. */
  124495. dispose(): void;
  124496. }
  124497. /** Interface defining initialization parameters for Scene class */
  124498. export interface SceneOptions {
  124499. /**
  124500. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124501. * It will improve performance when the number of geometries becomes important.
  124502. */
  124503. useGeometryUniqueIdsMap?: boolean;
  124504. /**
  124505. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124506. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124507. */
  124508. useMaterialMeshMap?: boolean;
  124509. /**
  124510. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124511. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124512. */
  124513. useClonedMeshMap?: boolean;
  124514. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124515. virtual?: boolean;
  124516. }
  124517. /**
  124518. * Represents a scene to be rendered by the engine.
  124519. * @see https://doc.babylonjs.com/features/scene
  124520. */
  124521. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124522. /** The fog is deactivated */
  124523. static readonly FOGMODE_NONE: number;
  124524. /** The fog density is following an exponential function */
  124525. static readonly FOGMODE_EXP: number;
  124526. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124527. static readonly FOGMODE_EXP2: number;
  124528. /** The fog density is following a linear function. */
  124529. static readonly FOGMODE_LINEAR: number;
  124530. /**
  124531. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124532. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124533. */
  124534. static MinDeltaTime: number;
  124535. /**
  124536. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124537. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124538. */
  124539. static MaxDeltaTime: number;
  124540. /**
  124541. * Factory used to create the default material.
  124542. * @param name The name of the material to create
  124543. * @param scene The scene to create the material for
  124544. * @returns The default material
  124545. */
  124546. static DefaultMaterialFactory(scene: Scene): Material;
  124547. /**
  124548. * Factory used to create the a collision coordinator.
  124549. * @returns The collision coordinator
  124550. */
  124551. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124552. /** @hidden */
  124553. _inputManager: InputManager;
  124554. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124555. cameraToUseForPointers: Nullable<Camera>;
  124556. /** @hidden */
  124557. readonly _isScene: boolean;
  124558. /** @hidden */
  124559. _blockEntityCollection: boolean;
  124560. /**
  124561. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124562. */
  124563. autoClear: boolean;
  124564. /**
  124565. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124566. */
  124567. autoClearDepthAndStencil: boolean;
  124568. /**
  124569. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124570. */
  124571. clearColor: Color4;
  124572. /**
  124573. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124574. */
  124575. ambientColor: Color3;
  124576. /**
  124577. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124578. * It should only be one of the following (if not the default embedded one):
  124579. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124580. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124581. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124582. * The material properties need to be setup according to the type of texture in use.
  124583. */
  124584. environmentBRDFTexture: BaseTexture;
  124585. /**
  124586. * Texture used in all pbr material as the reflection texture.
  124587. * As in the majority of the scene they are the same (exception for multi room and so on),
  124588. * this is easier to reference from here than from all the materials.
  124589. */
  124590. get environmentTexture(): Nullable<BaseTexture>;
  124591. /**
  124592. * Texture used in all pbr material as the reflection texture.
  124593. * As in the majority of the scene they are the same (exception for multi room and so on),
  124594. * this is easier to set here than in all the materials.
  124595. */
  124596. set environmentTexture(value: Nullable<BaseTexture>);
  124597. /** @hidden */
  124598. protected _environmentIntensity: number;
  124599. /**
  124600. * Intensity of the environment in all pbr material.
  124601. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124602. * As in the majority of the scene they are the same (exception for multi room and so on),
  124603. * this is easier to reference from here than from all the materials.
  124604. */
  124605. get environmentIntensity(): number;
  124606. /**
  124607. * Intensity of the environment in all pbr material.
  124608. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124609. * As in the majority of the scene they are the same (exception for multi room and so on),
  124610. * this is easier to set here than in all the materials.
  124611. */
  124612. set environmentIntensity(value: number);
  124613. /** @hidden */
  124614. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124615. /**
  124616. * Default image processing configuration used either in the rendering
  124617. * Forward main pass or through the imageProcessingPostProcess if present.
  124618. * As in the majority of the scene they are the same (exception for multi camera),
  124619. * this is easier to reference from here than from all the materials and post process.
  124620. *
  124621. * No setter as we it is a shared configuration, you can set the values instead.
  124622. */
  124623. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124624. private _forceWireframe;
  124625. /**
  124626. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124627. */
  124628. set forceWireframe(value: boolean);
  124629. get forceWireframe(): boolean;
  124630. private _skipFrustumClipping;
  124631. /**
  124632. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124633. */
  124634. set skipFrustumClipping(value: boolean);
  124635. get skipFrustumClipping(): boolean;
  124636. private _forcePointsCloud;
  124637. /**
  124638. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124639. */
  124640. set forcePointsCloud(value: boolean);
  124641. get forcePointsCloud(): boolean;
  124642. /**
  124643. * Gets or sets the active clipplane 1
  124644. */
  124645. clipPlane: Nullable<Plane>;
  124646. /**
  124647. * Gets or sets the active clipplane 2
  124648. */
  124649. clipPlane2: Nullable<Plane>;
  124650. /**
  124651. * Gets or sets the active clipplane 3
  124652. */
  124653. clipPlane3: Nullable<Plane>;
  124654. /**
  124655. * Gets or sets the active clipplane 4
  124656. */
  124657. clipPlane4: Nullable<Plane>;
  124658. /**
  124659. * Gets or sets the active clipplane 5
  124660. */
  124661. clipPlane5: Nullable<Plane>;
  124662. /**
  124663. * Gets or sets the active clipplane 6
  124664. */
  124665. clipPlane6: Nullable<Plane>;
  124666. /**
  124667. * Gets or sets a boolean indicating if animations are enabled
  124668. */
  124669. animationsEnabled: boolean;
  124670. private _animationPropertiesOverride;
  124671. /**
  124672. * Gets or sets the animation properties override
  124673. */
  124674. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124675. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124676. /**
  124677. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124678. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124679. */
  124680. useConstantAnimationDeltaTime: boolean;
  124681. /**
  124682. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124683. * Please note that it requires to run a ray cast through the scene on every frame
  124684. */
  124685. constantlyUpdateMeshUnderPointer: boolean;
  124686. /**
  124687. * Defines the HTML cursor to use when hovering over interactive elements
  124688. */
  124689. hoverCursor: string;
  124690. /**
  124691. * Defines the HTML default cursor to use (empty by default)
  124692. */
  124693. defaultCursor: string;
  124694. /**
  124695. * Defines whether cursors are handled by the scene.
  124696. */
  124697. doNotHandleCursors: boolean;
  124698. /**
  124699. * This is used to call preventDefault() on pointer down
  124700. * in order to block unwanted artifacts like system double clicks
  124701. */
  124702. preventDefaultOnPointerDown: boolean;
  124703. /**
  124704. * This is used to call preventDefault() on pointer up
  124705. * in order to block unwanted artifacts like system double clicks
  124706. */
  124707. preventDefaultOnPointerUp: boolean;
  124708. /**
  124709. * Gets or sets user defined metadata
  124710. */
  124711. metadata: any;
  124712. /**
  124713. * For internal use only. Please do not use.
  124714. */
  124715. reservedDataStore: any;
  124716. /**
  124717. * Gets the name of the plugin used to load this scene (null by default)
  124718. */
  124719. loadingPluginName: string;
  124720. /**
  124721. * Use this array to add regular expressions used to disable offline support for specific urls
  124722. */
  124723. disableOfflineSupportExceptionRules: RegExp[];
  124724. /**
  124725. * An event triggered when the scene is disposed.
  124726. */
  124727. onDisposeObservable: Observable<Scene>;
  124728. private _onDisposeObserver;
  124729. /** Sets a function to be executed when this scene is disposed. */
  124730. set onDispose(callback: () => void);
  124731. /**
  124732. * An event triggered before rendering the scene (right after animations and physics)
  124733. */
  124734. onBeforeRenderObservable: Observable<Scene>;
  124735. private _onBeforeRenderObserver;
  124736. /** Sets a function to be executed before rendering this scene */
  124737. set beforeRender(callback: Nullable<() => void>);
  124738. /**
  124739. * An event triggered after rendering the scene
  124740. */
  124741. onAfterRenderObservable: Observable<Scene>;
  124742. /**
  124743. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124744. */
  124745. onAfterRenderCameraObservable: Observable<Camera>;
  124746. private _onAfterRenderObserver;
  124747. /** Sets a function to be executed after rendering this scene */
  124748. set afterRender(callback: Nullable<() => void>);
  124749. /**
  124750. * An event triggered before animating the scene
  124751. */
  124752. onBeforeAnimationsObservable: Observable<Scene>;
  124753. /**
  124754. * An event triggered after animations processing
  124755. */
  124756. onAfterAnimationsObservable: Observable<Scene>;
  124757. /**
  124758. * An event triggered before draw calls are ready to be sent
  124759. */
  124760. onBeforeDrawPhaseObservable: Observable<Scene>;
  124761. /**
  124762. * An event triggered after draw calls have been sent
  124763. */
  124764. onAfterDrawPhaseObservable: Observable<Scene>;
  124765. /**
  124766. * An event triggered when the scene is ready
  124767. */
  124768. onReadyObservable: Observable<Scene>;
  124769. /**
  124770. * An event triggered before rendering a camera
  124771. */
  124772. onBeforeCameraRenderObservable: Observable<Camera>;
  124773. private _onBeforeCameraRenderObserver;
  124774. /** Sets a function to be executed before rendering a camera*/
  124775. set beforeCameraRender(callback: () => void);
  124776. /**
  124777. * An event triggered after rendering a camera
  124778. */
  124779. onAfterCameraRenderObservable: Observable<Camera>;
  124780. private _onAfterCameraRenderObserver;
  124781. /** Sets a function to be executed after rendering a camera*/
  124782. set afterCameraRender(callback: () => void);
  124783. /**
  124784. * An event triggered when active meshes evaluation is about to start
  124785. */
  124786. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124787. /**
  124788. * An event triggered when active meshes evaluation is done
  124789. */
  124790. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124791. /**
  124792. * An event triggered when particles rendering is about to start
  124793. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124794. */
  124795. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124796. /**
  124797. * An event triggered when particles rendering is done
  124798. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124799. */
  124800. onAfterParticlesRenderingObservable: Observable<Scene>;
  124801. /**
  124802. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124803. */
  124804. onDataLoadedObservable: Observable<Scene>;
  124805. /**
  124806. * An event triggered when a camera is created
  124807. */
  124808. onNewCameraAddedObservable: Observable<Camera>;
  124809. /**
  124810. * An event triggered when a camera is removed
  124811. */
  124812. onCameraRemovedObservable: Observable<Camera>;
  124813. /**
  124814. * An event triggered when a light is created
  124815. */
  124816. onNewLightAddedObservable: Observable<Light>;
  124817. /**
  124818. * An event triggered when a light is removed
  124819. */
  124820. onLightRemovedObservable: Observable<Light>;
  124821. /**
  124822. * An event triggered when a geometry is created
  124823. */
  124824. onNewGeometryAddedObservable: Observable<Geometry>;
  124825. /**
  124826. * An event triggered when a geometry is removed
  124827. */
  124828. onGeometryRemovedObservable: Observable<Geometry>;
  124829. /**
  124830. * An event triggered when a transform node is created
  124831. */
  124832. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124833. /**
  124834. * An event triggered when a transform node is removed
  124835. */
  124836. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124837. /**
  124838. * An event triggered when a mesh is created
  124839. */
  124840. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124841. /**
  124842. * An event triggered when a mesh is removed
  124843. */
  124844. onMeshRemovedObservable: Observable<AbstractMesh>;
  124845. /**
  124846. * An event triggered when a skeleton is created
  124847. */
  124848. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124849. /**
  124850. * An event triggered when a skeleton is removed
  124851. */
  124852. onSkeletonRemovedObservable: Observable<Skeleton>;
  124853. /**
  124854. * An event triggered when a material is created
  124855. */
  124856. onNewMaterialAddedObservable: Observable<Material>;
  124857. /**
  124858. * An event triggered when a multi material is created
  124859. */
  124860. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124861. /**
  124862. * An event triggered when a material is removed
  124863. */
  124864. onMaterialRemovedObservable: Observable<Material>;
  124865. /**
  124866. * An event triggered when a multi material is removed
  124867. */
  124868. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124869. /**
  124870. * An event triggered when a texture is created
  124871. */
  124872. onNewTextureAddedObservable: Observable<BaseTexture>;
  124873. /**
  124874. * An event triggered when a texture is removed
  124875. */
  124876. onTextureRemovedObservable: Observable<BaseTexture>;
  124877. /**
  124878. * An event triggered when render targets are about to be rendered
  124879. * Can happen multiple times per frame.
  124880. */
  124881. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124882. /**
  124883. * An event triggered when render targets were rendered.
  124884. * Can happen multiple times per frame.
  124885. */
  124886. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124887. /**
  124888. * An event triggered before calculating deterministic simulation step
  124889. */
  124890. onBeforeStepObservable: Observable<Scene>;
  124891. /**
  124892. * An event triggered after calculating deterministic simulation step
  124893. */
  124894. onAfterStepObservable: Observable<Scene>;
  124895. /**
  124896. * An event triggered when the activeCamera property is updated
  124897. */
  124898. onActiveCameraChanged: Observable<Scene>;
  124899. /**
  124900. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124901. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124902. * 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)
  124903. */
  124904. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124905. /**
  124906. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124907. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124908. * 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)
  124909. */
  124910. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124911. /**
  124912. * This Observable will when a mesh has been imported into the scene.
  124913. */
  124914. onMeshImportedObservable: Observable<AbstractMesh>;
  124915. /**
  124916. * This Observable will when an animation file has been imported into the scene.
  124917. */
  124918. onAnimationFileImportedObservable: Observable<Scene>;
  124919. /**
  124920. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124921. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124922. */
  124923. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124924. /** @hidden */
  124925. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124926. /**
  124927. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124928. */
  124929. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124930. /**
  124931. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124932. */
  124933. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124934. /**
  124935. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124936. */
  124937. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124938. /** Callback called when a pointer move is detected */
  124939. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124940. /** Callback called when a pointer down is detected */
  124941. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124942. /** Callback called when a pointer up is detected */
  124943. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124944. /** Callback called when a pointer pick is detected */
  124945. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124946. /**
  124947. * 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).
  124948. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124949. */
  124950. onPrePointerObservable: Observable<PointerInfoPre>;
  124951. /**
  124952. * Observable event triggered each time an input event is received from the rendering canvas
  124953. */
  124954. onPointerObservable: Observable<PointerInfo>;
  124955. /**
  124956. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124957. */
  124958. get unTranslatedPointer(): Vector2;
  124959. /**
  124960. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124961. */
  124962. static get DragMovementThreshold(): number;
  124963. static set DragMovementThreshold(value: number);
  124964. /**
  124965. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124966. */
  124967. static get LongPressDelay(): number;
  124968. static set LongPressDelay(value: number);
  124969. /**
  124970. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124971. */
  124972. static get DoubleClickDelay(): number;
  124973. static set DoubleClickDelay(value: number);
  124974. /** If you need to check double click without raising a single click at first click, enable this flag */
  124975. static get ExclusiveDoubleClickMode(): boolean;
  124976. static set ExclusiveDoubleClickMode(value: boolean);
  124977. /** @hidden */
  124978. _mirroredCameraPosition: Nullable<Vector3>;
  124979. /**
  124980. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124981. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124982. */
  124983. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124984. /**
  124985. * Observable event triggered each time an keyboard event is received from the hosting window
  124986. */
  124987. onKeyboardObservable: Observable<KeyboardInfo>;
  124988. private _useRightHandedSystem;
  124989. /**
  124990. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124991. */
  124992. set useRightHandedSystem(value: boolean);
  124993. get useRightHandedSystem(): boolean;
  124994. private _timeAccumulator;
  124995. private _currentStepId;
  124996. private _currentInternalStep;
  124997. /**
  124998. * Sets the step Id used by deterministic lock step
  124999. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125000. * @param newStepId defines the step Id
  125001. */
  125002. setStepId(newStepId: number): void;
  125003. /**
  125004. * Gets the step Id used by deterministic lock step
  125005. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125006. * @returns the step Id
  125007. */
  125008. getStepId(): number;
  125009. /**
  125010. * Gets the internal step used by deterministic lock step
  125011. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125012. * @returns the internal step
  125013. */
  125014. getInternalStep(): number;
  125015. private _fogEnabled;
  125016. /**
  125017. * Gets or sets a boolean indicating if fog is enabled on this scene
  125018. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125019. * (Default is true)
  125020. */
  125021. set fogEnabled(value: boolean);
  125022. get fogEnabled(): boolean;
  125023. private _fogMode;
  125024. /**
  125025. * Gets or sets the fog mode to use
  125026. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125027. * | mode | value |
  125028. * | --- | --- |
  125029. * | FOGMODE_NONE | 0 |
  125030. * | FOGMODE_EXP | 1 |
  125031. * | FOGMODE_EXP2 | 2 |
  125032. * | FOGMODE_LINEAR | 3 |
  125033. */
  125034. set fogMode(value: number);
  125035. get fogMode(): number;
  125036. /**
  125037. * Gets or sets the fog color to use
  125038. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125039. * (Default is Color3(0.2, 0.2, 0.3))
  125040. */
  125041. fogColor: Color3;
  125042. /**
  125043. * Gets or sets the fog density to use
  125044. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125045. * (Default is 0.1)
  125046. */
  125047. fogDensity: number;
  125048. /**
  125049. * Gets or sets the fog start distance to use
  125050. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125051. * (Default is 0)
  125052. */
  125053. fogStart: number;
  125054. /**
  125055. * Gets or sets the fog end distance to use
  125056. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125057. * (Default is 1000)
  125058. */
  125059. fogEnd: number;
  125060. /**
  125061. * Flag indicating that the frame buffer binding is handled by another component
  125062. */
  125063. prePass: boolean;
  125064. private _shadowsEnabled;
  125065. /**
  125066. * Gets or sets a boolean indicating if shadows are enabled on this scene
  125067. */
  125068. set shadowsEnabled(value: boolean);
  125069. get shadowsEnabled(): boolean;
  125070. private _lightsEnabled;
  125071. /**
  125072. * Gets or sets a boolean indicating if lights are enabled on this scene
  125073. */
  125074. set lightsEnabled(value: boolean);
  125075. get lightsEnabled(): boolean;
  125076. /** All of the active cameras added to this scene. */
  125077. activeCameras: Nullable<Camera[]>;
  125078. /** @hidden */
  125079. _activeCamera: Nullable<Camera>;
  125080. /** Gets or sets the current active camera */
  125081. get activeCamera(): Nullable<Camera>;
  125082. set activeCamera(value: Nullable<Camera>);
  125083. private _defaultMaterial;
  125084. /** The default material used on meshes when no material is affected */
  125085. get defaultMaterial(): Material;
  125086. /** The default material used on meshes when no material is affected */
  125087. set defaultMaterial(value: Material);
  125088. private _texturesEnabled;
  125089. /**
  125090. * Gets or sets a boolean indicating if textures are enabled on this scene
  125091. */
  125092. set texturesEnabled(value: boolean);
  125093. get texturesEnabled(): boolean;
  125094. /**
  125095. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  125096. */
  125097. physicsEnabled: boolean;
  125098. /**
  125099. * Gets or sets a boolean indicating if particles are enabled on this scene
  125100. */
  125101. particlesEnabled: boolean;
  125102. /**
  125103. * Gets or sets a boolean indicating if sprites are enabled on this scene
  125104. */
  125105. spritesEnabled: boolean;
  125106. private _skeletonsEnabled;
  125107. /**
  125108. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  125109. */
  125110. set skeletonsEnabled(value: boolean);
  125111. get skeletonsEnabled(): boolean;
  125112. /**
  125113. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  125114. */
  125115. lensFlaresEnabled: boolean;
  125116. /**
  125117. * Gets or sets a boolean indicating if collisions are enabled on this scene
  125118. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125119. */
  125120. collisionsEnabled: boolean;
  125121. private _collisionCoordinator;
  125122. /** @hidden */
  125123. get collisionCoordinator(): ICollisionCoordinator;
  125124. /**
  125125. * Defines the gravity applied to this scene (used only for collisions)
  125126. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125127. */
  125128. gravity: Vector3;
  125129. /**
  125130. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  125131. */
  125132. postProcessesEnabled: boolean;
  125133. /**
  125134. * Gets the current postprocess manager
  125135. */
  125136. postProcessManager: PostProcessManager;
  125137. /**
  125138. * Gets or sets a boolean indicating if render targets are enabled on this scene
  125139. */
  125140. renderTargetsEnabled: boolean;
  125141. /**
  125142. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  125143. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  125144. */
  125145. dumpNextRenderTargets: boolean;
  125146. /**
  125147. * The list of user defined render targets added to the scene
  125148. */
  125149. customRenderTargets: RenderTargetTexture[];
  125150. /**
  125151. * Defines if texture loading must be delayed
  125152. * If true, textures will only be loaded when they need to be rendered
  125153. */
  125154. useDelayedTextureLoading: boolean;
  125155. /**
  125156. * Gets the list of meshes imported to the scene through SceneLoader
  125157. */
  125158. importedMeshesFiles: String[];
  125159. /**
  125160. * Gets or sets a boolean indicating if probes are enabled on this scene
  125161. */
  125162. probesEnabled: boolean;
  125163. /**
  125164. * Gets or sets the current offline provider to use to store scene data
  125165. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125166. */
  125167. offlineProvider: IOfflineProvider;
  125168. /**
  125169. * Gets or sets the action manager associated with the scene
  125170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125171. */
  125172. actionManager: AbstractActionManager;
  125173. private _meshesForIntersections;
  125174. /**
  125175. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  125176. */
  125177. proceduralTexturesEnabled: boolean;
  125178. private _engine;
  125179. private _totalVertices;
  125180. /** @hidden */
  125181. _activeIndices: PerfCounter;
  125182. /** @hidden */
  125183. _activeParticles: PerfCounter;
  125184. /** @hidden */
  125185. _activeBones: PerfCounter;
  125186. private _animationRatio;
  125187. /** @hidden */
  125188. _animationTimeLast: number;
  125189. /** @hidden */
  125190. _animationTime: number;
  125191. /**
  125192. * Gets or sets a general scale for animation speed
  125193. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  125194. */
  125195. animationTimeScale: number;
  125196. /** @hidden */
  125197. _cachedMaterial: Nullable<Material>;
  125198. /** @hidden */
  125199. _cachedEffect: Nullable<Effect>;
  125200. /** @hidden */
  125201. _cachedVisibility: Nullable<number>;
  125202. private _renderId;
  125203. private _frameId;
  125204. private _executeWhenReadyTimeoutId;
  125205. private _intermediateRendering;
  125206. private _viewUpdateFlag;
  125207. private _projectionUpdateFlag;
  125208. /** @hidden */
  125209. _toBeDisposed: Nullable<IDisposable>[];
  125210. private _activeRequests;
  125211. /** @hidden */
  125212. _pendingData: any[];
  125213. private _isDisposed;
  125214. /**
  125215. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  125216. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  125217. */
  125218. dispatchAllSubMeshesOfActiveMeshes: boolean;
  125219. private _activeMeshes;
  125220. private _processedMaterials;
  125221. private _renderTargets;
  125222. /** @hidden */
  125223. _activeParticleSystems: SmartArray<IParticleSystem>;
  125224. private _activeSkeletons;
  125225. private _softwareSkinnedMeshes;
  125226. private _renderingManager;
  125227. /** @hidden */
  125228. _activeAnimatables: Animatable[];
  125229. private _transformMatrix;
  125230. private _sceneUbo;
  125231. /** @hidden */
  125232. _viewMatrix: Matrix;
  125233. private _projectionMatrix;
  125234. /** @hidden */
  125235. _forcedViewPosition: Nullable<Vector3>;
  125236. /** @hidden */
  125237. _frustumPlanes: Plane[];
  125238. /**
  125239. * Gets the list of frustum planes (built from the active camera)
  125240. */
  125241. get frustumPlanes(): Plane[];
  125242. /**
  125243. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  125244. * This is useful if there are more lights that the maximum simulteanous authorized
  125245. */
  125246. requireLightSorting: boolean;
  125247. /** @hidden */
  125248. readonly useMaterialMeshMap: boolean;
  125249. /** @hidden */
  125250. readonly useClonedMeshMap: boolean;
  125251. private _externalData;
  125252. private _uid;
  125253. /**
  125254. * @hidden
  125255. * Backing store of defined scene components.
  125256. */
  125257. _components: ISceneComponent[];
  125258. /**
  125259. * @hidden
  125260. * Backing store of defined scene components.
  125261. */
  125262. _serializableComponents: ISceneSerializableComponent[];
  125263. /**
  125264. * List of components to register on the next registration step.
  125265. */
  125266. private _transientComponents;
  125267. /**
  125268. * Registers the transient components if needed.
  125269. */
  125270. private _registerTransientComponents;
  125271. /**
  125272. * @hidden
  125273. * Add a component to the scene.
  125274. * Note that the ccomponent could be registered on th next frame if this is called after
  125275. * the register component stage.
  125276. * @param component Defines the component to add to the scene
  125277. */
  125278. _addComponent(component: ISceneComponent): void;
  125279. /**
  125280. * @hidden
  125281. * Gets a component from the scene.
  125282. * @param name defines the name of the component to retrieve
  125283. * @returns the component or null if not present
  125284. */
  125285. _getComponent(name: string): Nullable<ISceneComponent>;
  125286. /**
  125287. * @hidden
  125288. * Defines the actions happening before camera updates.
  125289. */
  125290. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125291. /**
  125292. * @hidden
  125293. * Defines the actions happening before clear the canvas.
  125294. */
  125295. _beforeClearStage: Stage<SimpleStageAction>;
  125296. /**
  125297. * @hidden
  125298. * Defines the actions when collecting render targets for the frame.
  125299. */
  125300. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125301. /**
  125302. * @hidden
  125303. * Defines the actions happening for one camera in the frame.
  125304. */
  125305. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125306. /**
  125307. * @hidden
  125308. * Defines the actions happening during the per mesh ready checks.
  125309. */
  125310. _isReadyForMeshStage: Stage<MeshStageAction>;
  125311. /**
  125312. * @hidden
  125313. * Defines the actions happening before evaluate active mesh checks.
  125314. */
  125315. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125316. /**
  125317. * @hidden
  125318. * Defines the actions happening during the evaluate sub mesh checks.
  125319. */
  125320. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125321. /**
  125322. * @hidden
  125323. * Defines the actions happening during the active mesh stage.
  125324. */
  125325. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125326. /**
  125327. * @hidden
  125328. * Defines the actions happening during the per camera render target step.
  125329. */
  125330. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125331. /**
  125332. * @hidden
  125333. * Defines the actions happening just before the active camera is drawing.
  125334. */
  125335. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125336. /**
  125337. * @hidden
  125338. * Defines the actions happening just before a render target is drawing.
  125339. */
  125340. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125341. /**
  125342. * @hidden
  125343. * Defines the actions happening just before a rendering group is drawing.
  125344. */
  125345. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125346. /**
  125347. * @hidden
  125348. * Defines the actions happening just before a mesh is drawing.
  125349. */
  125350. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125351. /**
  125352. * @hidden
  125353. * Defines the actions happening just after a mesh has been drawn.
  125354. */
  125355. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125356. /**
  125357. * @hidden
  125358. * Defines the actions happening just after a rendering group has been drawn.
  125359. */
  125360. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125361. /**
  125362. * @hidden
  125363. * Defines the actions happening just after the active camera has been drawn.
  125364. */
  125365. _afterCameraDrawStage: Stage<CameraStageAction>;
  125366. /**
  125367. * @hidden
  125368. * Defines the actions happening just after a render target has been drawn.
  125369. */
  125370. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125371. /**
  125372. * @hidden
  125373. * Defines the actions happening just after rendering all cameras and computing intersections.
  125374. */
  125375. _afterRenderStage: Stage<SimpleStageAction>;
  125376. /**
  125377. * @hidden
  125378. * Defines the actions happening when a pointer move event happens.
  125379. */
  125380. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125381. /**
  125382. * @hidden
  125383. * Defines the actions happening when a pointer down event happens.
  125384. */
  125385. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125386. /**
  125387. * @hidden
  125388. * Defines the actions happening when a pointer up event happens.
  125389. */
  125390. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125391. /**
  125392. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125393. */
  125394. private geometriesByUniqueId;
  125395. /**
  125396. * Creates a new Scene
  125397. * @param engine defines the engine to use to render this scene
  125398. * @param options defines the scene options
  125399. */
  125400. constructor(engine: Engine, options?: SceneOptions);
  125401. /**
  125402. * Gets a string identifying the name of the class
  125403. * @returns "Scene" string
  125404. */
  125405. getClassName(): string;
  125406. private _defaultMeshCandidates;
  125407. /**
  125408. * @hidden
  125409. */
  125410. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125411. private _defaultSubMeshCandidates;
  125412. /**
  125413. * @hidden
  125414. */
  125415. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125416. /**
  125417. * Sets the default candidate providers for the scene.
  125418. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125419. * and getCollidingSubMeshCandidates to their default function
  125420. */
  125421. setDefaultCandidateProviders(): void;
  125422. /**
  125423. * Gets the mesh that is currently under the pointer
  125424. */
  125425. get meshUnderPointer(): Nullable<AbstractMesh>;
  125426. /**
  125427. * Gets or sets the current on-screen X position of the pointer
  125428. */
  125429. get pointerX(): number;
  125430. set pointerX(value: number);
  125431. /**
  125432. * Gets or sets the current on-screen Y position of the pointer
  125433. */
  125434. get pointerY(): number;
  125435. set pointerY(value: number);
  125436. /**
  125437. * Gets the cached material (ie. the latest rendered one)
  125438. * @returns the cached material
  125439. */
  125440. getCachedMaterial(): Nullable<Material>;
  125441. /**
  125442. * Gets the cached effect (ie. the latest rendered one)
  125443. * @returns the cached effect
  125444. */
  125445. getCachedEffect(): Nullable<Effect>;
  125446. /**
  125447. * Gets the cached visibility state (ie. the latest rendered one)
  125448. * @returns the cached visibility state
  125449. */
  125450. getCachedVisibility(): Nullable<number>;
  125451. /**
  125452. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125453. * @param material defines the current material
  125454. * @param effect defines the current effect
  125455. * @param visibility defines the current visibility state
  125456. * @returns true if one parameter is not cached
  125457. */
  125458. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125459. /**
  125460. * Gets the engine associated with the scene
  125461. * @returns an Engine
  125462. */
  125463. getEngine(): Engine;
  125464. /**
  125465. * Gets the total number of vertices rendered per frame
  125466. * @returns the total number of vertices rendered per frame
  125467. */
  125468. getTotalVertices(): number;
  125469. /**
  125470. * Gets the performance counter for total vertices
  125471. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125472. */
  125473. get totalVerticesPerfCounter(): PerfCounter;
  125474. /**
  125475. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125476. * @returns the total number of active indices rendered per frame
  125477. */
  125478. getActiveIndices(): number;
  125479. /**
  125480. * Gets the performance counter for active indices
  125481. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125482. */
  125483. get totalActiveIndicesPerfCounter(): PerfCounter;
  125484. /**
  125485. * Gets the total number of active particles rendered per frame
  125486. * @returns the total number of active particles rendered per frame
  125487. */
  125488. getActiveParticles(): number;
  125489. /**
  125490. * Gets the performance counter for active particles
  125491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125492. */
  125493. get activeParticlesPerfCounter(): PerfCounter;
  125494. /**
  125495. * Gets the total number of active bones rendered per frame
  125496. * @returns the total number of active bones rendered per frame
  125497. */
  125498. getActiveBones(): number;
  125499. /**
  125500. * Gets the performance counter for active bones
  125501. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125502. */
  125503. get activeBonesPerfCounter(): PerfCounter;
  125504. /**
  125505. * Gets the array of active meshes
  125506. * @returns an array of AbstractMesh
  125507. */
  125508. getActiveMeshes(): SmartArray<AbstractMesh>;
  125509. /**
  125510. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125511. * @returns a number
  125512. */
  125513. getAnimationRatio(): number;
  125514. /**
  125515. * Gets an unique Id for the current render phase
  125516. * @returns a number
  125517. */
  125518. getRenderId(): number;
  125519. /**
  125520. * Gets an unique Id for the current frame
  125521. * @returns a number
  125522. */
  125523. getFrameId(): number;
  125524. /** Call this function if you want to manually increment the render Id*/
  125525. incrementRenderId(): void;
  125526. private _createUbo;
  125527. /**
  125528. * Use this method to simulate a pointer move on a mesh
  125529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125532. * @returns the current scene
  125533. */
  125534. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125535. /**
  125536. * Use this method to simulate a pointer down on a mesh
  125537. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125538. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125539. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125540. * @returns the current scene
  125541. */
  125542. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125543. /**
  125544. * Use this method to simulate a pointer up on a mesh
  125545. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125546. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125547. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125548. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125549. * @returns the current scene
  125550. */
  125551. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125552. /**
  125553. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125554. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125555. * @returns true if the pointer was captured
  125556. */
  125557. isPointerCaptured(pointerId?: number): boolean;
  125558. /**
  125559. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125560. * @param attachUp defines if you want to attach events to pointerup
  125561. * @param attachDown defines if you want to attach events to pointerdown
  125562. * @param attachMove defines if you want to attach events to pointermove
  125563. */
  125564. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125565. /** Detaches all event handlers*/
  125566. detachControl(): void;
  125567. /**
  125568. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125569. * Delay loaded resources are not taking in account
  125570. * @return true if all required resources are ready
  125571. */
  125572. isReady(): boolean;
  125573. /** Resets all cached information relative to material (including effect and visibility) */
  125574. resetCachedMaterial(): void;
  125575. /**
  125576. * Registers a function to be called before every frame render
  125577. * @param func defines the function to register
  125578. */
  125579. registerBeforeRender(func: () => void): void;
  125580. /**
  125581. * Unregisters a function called before every frame render
  125582. * @param func defines the function to unregister
  125583. */
  125584. unregisterBeforeRender(func: () => void): void;
  125585. /**
  125586. * Registers a function to be called after every frame render
  125587. * @param func defines the function to register
  125588. */
  125589. registerAfterRender(func: () => void): void;
  125590. /**
  125591. * Unregisters a function called after every frame render
  125592. * @param func defines the function to unregister
  125593. */
  125594. unregisterAfterRender(func: () => void): void;
  125595. private _executeOnceBeforeRender;
  125596. /**
  125597. * The provided function will run before render once and will be disposed afterwards.
  125598. * A timeout delay can be provided so that the function will be executed in N ms.
  125599. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125600. * @param func The function to be executed.
  125601. * @param timeout optional delay in ms
  125602. */
  125603. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125604. /** @hidden */
  125605. _addPendingData(data: any): void;
  125606. /** @hidden */
  125607. _removePendingData(data: any): void;
  125608. /**
  125609. * Returns the number of items waiting to be loaded
  125610. * @returns the number of items waiting to be loaded
  125611. */
  125612. getWaitingItemsCount(): number;
  125613. /**
  125614. * Returns a boolean indicating if the scene is still loading data
  125615. */
  125616. get isLoading(): boolean;
  125617. /**
  125618. * Registers a function to be executed when the scene is ready
  125619. * @param {Function} func - the function to be executed
  125620. */
  125621. executeWhenReady(func: () => void): void;
  125622. /**
  125623. * Returns a promise that resolves when the scene is ready
  125624. * @returns A promise that resolves when the scene is ready
  125625. */
  125626. whenReadyAsync(): Promise<void>;
  125627. /** @hidden */
  125628. _checkIsReady(): void;
  125629. /**
  125630. * Gets all animatable attached to the scene
  125631. */
  125632. get animatables(): Animatable[];
  125633. /**
  125634. * Resets the last animation time frame.
  125635. * Useful to override when animations start running when loading a scene for the first time.
  125636. */
  125637. resetLastAnimationTimeFrame(): void;
  125638. /**
  125639. * Gets the current view matrix
  125640. * @returns a Matrix
  125641. */
  125642. getViewMatrix(): Matrix;
  125643. /**
  125644. * Gets the current projection matrix
  125645. * @returns a Matrix
  125646. */
  125647. getProjectionMatrix(): Matrix;
  125648. /**
  125649. * Gets the current transform matrix
  125650. * @returns a Matrix made of View * Projection
  125651. */
  125652. getTransformMatrix(): Matrix;
  125653. /**
  125654. * Sets the current transform matrix
  125655. * @param viewL defines the View matrix to use
  125656. * @param projectionL defines the Projection matrix to use
  125657. * @param viewR defines the right View matrix to use (if provided)
  125658. * @param projectionR defines the right Projection matrix to use (if provided)
  125659. */
  125660. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125661. /**
  125662. * Gets the uniform buffer used to store scene data
  125663. * @returns a UniformBuffer
  125664. */
  125665. getSceneUniformBuffer(): UniformBuffer;
  125666. /**
  125667. * Gets an unique (relatively to the current scene) Id
  125668. * @returns an unique number for the scene
  125669. */
  125670. getUniqueId(): number;
  125671. /**
  125672. * Add a mesh to the list of scene's meshes
  125673. * @param newMesh defines the mesh to add
  125674. * @param recursive if all child meshes should also be added to the scene
  125675. */
  125676. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125677. /**
  125678. * Remove a mesh for the list of scene's meshes
  125679. * @param toRemove defines the mesh to remove
  125680. * @param recursive if all child meshes should also be removed from the scene
  125681. * @returns the index where the mesh was in the mesh list
  125682. */
  125683. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125684. /**
  125685. * Add a transform node to the list of scene's transform nodes
  125686. * @param newTransformNode defines the transform node to add
  125687. */
  125688. addTransformNode(newTransformNode: TransformNode): void;
  125689. /**
  125690. * Remove a transform node for the list of scene's transform nodes
  125691. * @param toRemove defines the transform node to remove
  125692. * @returns the index where the transform node was in the transform node list
  125693. */
  125694. removeTransformNode(toRemove: TransformNode): number;
  125695. /**
  125696. * Remove a skeleton for the list of scene's skeletons
  125697. * @param toRemove defines the skeleton to remove
  125698. * @returns the index where the skeleton was in the skeleton list
  125699. */
  125700. removeSkeleton(toRemove: Skeleton): number;
  125701. /**
  125702. * Remove a morph target for the list of scene's morph targets
  125703. * @param toRemove defines the morph target to remove
  125704. * @returns the index where the morph target was in the morph target list
  125705. */
  125706. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125707. /**
  125708. * Remove a light for the list of scene's lights
  125709. * @param toRemove defines the light to remove
  125710. * @returns the index where the light was in the light list
  125711. */
  125712. removeLight(toRemove: Light): number;
  125713. /**
  125714. * Remove a camera for the list of scene's cameras
  125715. * @param toRemove defines the camera to remove
  125716. * @returns the index where the camera was in the camera list
  125717. */
  125718. removeCamera(toRemove: Camera): number;
  125719. /**
  125720. * Remove a particle system for the list of scene's particle systems
  125721. * @param toRemove defines the particle system to remove
  125722. * @returns the index where the particle system was in the particle system list
  125723. */
  125724. removeParticleSystem(toRemove: IParticleSystem): number;
  125725. /**
  125726. * Remove a animation for the list of scene's animations
  125727. * @param toRemove defines the animation to remove
  125728. * @returns the index where the animation was in the animation list
  125729. */
  125730. removeAnimation(toRemove: Animation): number;
  125731. /**
  125732. * Will stop the animation of the given target
  125733. * @param target - the target
  125734. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125735. * @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)
  125736. */
  125737. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125738. /**
  125739. * Removes the given animation group from this scene.
  125740. * @param toRemove The animation group to remove
  125741. * @returns The index of the removed animation group
  125742. */
  125743. removeAnimationGroup(toRemove: AnimationGroup): number;
  125744. /**
  125745. * Removes the given multi-material from this scene.
  125746. * @param toRemove The multi-material to remove
  125747. * @returns The index of the removed multi-material
  125748. */
  125749. removeMultiMaterial(toRemove: MultiMaterial): number;
  125750. /**
  125751. * Removes the given material from this scene.
  125752. * @param toRemove The material to remove
  125753. * @returns The index of the removed material
  125754. */
  125755. removeMaterial(toRemove: Material): number;
  125756. /**
  125757. * Removes the given action manager from this scene.
  125758. * @param toRemove The action manager to remove
  125759. * @returns The index of the removed action manager
  125760. */
  125761. removeActionManager(toRemove: AbstractActionManager): number;
  125762. /**
  125763. * Removes the given texture from this scene.
  125764. * @param toRemove The texture to remove
  125765. * @returns The index of the removed texture
  125766. */
  125767. removeTexture(toRemove: BaseTexture): number;
  125768. /**
  125769. * Adds the given light to this scene
  125770. * @param newLight The light to add
  125771. */
  125772. addLight(newLight: Light): void;
  125773. /**
  125774. * Sorts the list list based on light priorities
  125775. */
  125776. sortLightsByPriority(): void;
  125777. /**
  125778. * Adds the given camera to this scene
  125779. * @param newCamera The camera to add
  125780. */
  125781. addCamera(newCamera: Camera): void;
  125782. /**
  125783. * Adds the given skeleton to this scene
  125784. * @param newSkeleton The skeleton to add
  125785. */
  125786. addSkeleton(newSkeleton: Skeleton): void;
  125787. /**
  125788. * Adds the given particle system to this scene
  125789. * @param newParticleSystem The particle system to add
  125790. */
  125791. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125792. /**
  125793. * Adds the given animation to this scene
  125794. * @param newAnimation The animation to add
  125795. */
  125796. addAnimation(newAnimation: Animation): void;
  125797. /**
  125798. * Adds the given animation group to this scene.
  125799. * @param newAnimationGroup The animation group to add
  125800. */
  125801. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125802. /**
  125803. * Adds the given multi-material to this scene
  125804. * @param newMultiMaterial The multi-material to add
  125805. */
  125806. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125807. /**
  125808. * Adds the given material to this scene
  125809. * @param newMaterial The material to add
  125810. */
  125811. addMaterial(newMaterial: Material): void;
  125812. /**
  125813. * Adds the given morph target to this scene
  125814. * @param newMorphTargetManager The morph target to add
  125815. */
  125816. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125817. /**
  125818. * Adds the given geometry to this scene
  125819. * @param newGeometry The geometry to add
  125820. */
  125821. addGeometry(newGeometry: Geometry): void;
  125822. /**
  125823. * Adds the given action manager to this scene
  125824. * @param newActionManager The action manager to add
  125825. */
  125826. addActionManager(newActionManager: AbstractActionManager): void;
  125827. /**
  125828. * Adds the given texture to this scene.
  125829. * @param newTexture The texture to add
  125830. */
  125831. addTexture(newTexture: BaseTexture): void;
  125832. /**
  125833. * Switch active camera
  125834. * @param newCamera defines the new active camera
  125835. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125836. */
  125837. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125838. /**
  125839. * sets the active camera of the scene using its ID
  125840. * @param id defines the camera's ID
  125841. * @return the new active camera or null if none found.
  125842. */
  125843. setActiveCameraByID(id: string): Nullable<Camera>;
  125844. /**
  125845. * sets the active camera of the scene using its name
  125846. * @param name defines the camera's name
  125847. * @returns the new active camera or null if none found.
  125848. */
  125849. setActiveCameraByName(name: string): Nullable<Camera>;
  125850. /**
  125851. * get an animation group using its name
  125852. * @param name defines the material's name
  125853. * @return the animation group or null if none found.
  125854. */
  125855. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125856. /**
  125857. * Get a material using its unique id
  125858. * @param uniqueId defines the material's unique id
  125859. * @return the material or null if none found.
  125860. */
  125861. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125862. /**
  125863. * get a material using its id
  125864. * @param id defines the material's ID
  125865. * @return the material or null if none found.
  125866. */
  125867. getMaterialByID(id: string): Nullable<Material>;
  125868. /**
  125869. * Gets a the last added material using a given id
  125870. * @param id defines the material's ID
  125871. * @return the last material with the given id or null if none found.
  125872. */
  125873. getLastMaterialByID(id: string): Nullable<Material>;
  125874. /**
  125875. * Gets a material using its name
  125876. * @param name defines the material's name
  125877. * @return the material or null if none found.
  125878. */
  125879. getMaterialByName(name: string): Nullable<Material>;
  125880. /**
  125881. * Get a texture using its unique id
  125882. * @param uniqueId defines the texture's unique id
  125883. * @return the texture or null if none found.
  125884. */
  125885. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125886. /**
  125887. * Gets a camera using its id
  125888. * @param id defines the id to look for
  125889. * @returns the camera or null if not found
  125890. */
  125891. getCameraByID(id: string): Nullable<Camera>;
  125892. /**
  125893. * Gets a camera using its unique id
  125894. * @param uniqueId defines the unique id to look for
  125895. * @returns the camera or null if not found
  125896. */
  125897. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125898. /**
  125899. * Gets a camera using its name
  125900. * @param name defines the camera's name
  125901. * @return the camera or null if none found.
  125902. */
  125903. getCameraByName(name: string): Nullable<Camera>;
  125904. /**
  125905. * Gets a bone using its id
  125906. * @param id defines the bone's id
  125907. * @return the bone or null if not found
  125908. */
  125909. getBoneByID(id: string): Nullable<Bone>;
  125910. /**
  125911. * Gets a bone using its id
  125912. * @param name defines the bone's name
  125913. * @return the bone or null if not found
  125914. */
  125915. getBoneByName(name: string): Nullable<Bone>;
  125916. /**
  125917. * Gets a light node using its name
  125918. * @param name defines the the light's name
  125919. * @return the light or null if none found.
  125920. */
  125921. getLightByName(name: string): Nullable<Light>;
  125922. /**
  125923. * Gets a light node using its id
  125924. * @param id defines the light's id
  125925. * @return the light or null if none found.
  125926. */
  125927. getLightByID(id: string): Nullable<Light>;
  125928. /**
  125929. * Gets a light node using its scene-generated unique ID
  125930. * @param uniqueId defines the light's unique id
  125931. * @return the light or null if none found.
  125932. */
  125933. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125934. /**
  125935. * Gets a particle system by id
  125936. * @param id defines the particle system id
  125937. * @return the corresponding system or null if none found
  125938. */
  125939. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125940. /**
  125941. * Gets a geometry using its ID
  125942. * @param id defines the geometry's id
  125943. * @return the geometry or null if none found.
  125944. */
  125945. getGeometryByID(id: string): Nullable<Geometry>;
  125946. private _getGeometryByUniqueID;
  125947. /**
  125948. * Add a new geometry to this scene
  125949. * @param geometry defines the geometry to be added to the scene.
  125950. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125951. * @return a boolean defining if the geometry was added or not
  125952. */
  125953. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125954. /**
  125955. * Removes an existing geometry
  125956. * @param geometry defines the geometry to be removed from the scene
  125957. * @return a boolean defining if the geometry was removed or not
  125958. */
  125959. removeGeometry(geometry: Geometry): boolean;
  125960. /**
  125961. * Gets the list of geometries attached to the scene
  125962. * @returns an array of Geometry
  125963. */
  125964. getGeometries(): Geometry[];
  125965. /**
  125966. * Gets the first added mesh found of a given ID
  125967. * @param id defines the id to search for
  125968. * @return the mesh found or null if not found at all
  125969. */
  125970. getMeshByID(id: string): Nullable<AbstractMesh>;
  125971. /**
  125972. * Gets a list of meshes using their id
  125973. * @param id defines the id to search for
  125974. * @returns a list of meshes
  125975. */
  125976. getMeshesByID(id: string): Array<AbstractMesh>;
  125977. /**
  125978. * Gets the first added transform node found of a given ID
  125979. * @param id defines the id to search for
  125980. * @return the found transform node or null if not found at all.
  125981. */
  125982. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125983. /**
  125984. * Gets a transform node with its auto-generated unique id
  125985. * @param uniqueId efines the unique id to search for
  125986. * @return the found transform node or null if not found at all.
  125987. */
  125988. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125989. /**
  125990. * Gets a list of transform nodes using their id
  125991. * @param id defines the id to search for
  125992. * @returns a list of transform nodes
  125993. */
  125994. getTransformNodesByID(id: string): Array<TransformNode>;
  125995. /**
  125996. * Gets a mesh with its auto-generated unique id
  125997. * @param uniqueId defines the unique id to search for
  125998. * @return the found mesh or null if not found at all.
  125999. */
  126000. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  126001. /**
  126002. * Gets a the last added mesh using a given id
  126003. * @param id defines the id to search for
  126004. * @return the found mesh or null if not found at all.
  126005. */
  126006. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  126007. /**
  126008. * Gets a the last added node (Mesh, Camera, Light) using a given id
  126009. * @param id defines the id to search for
  126010. * @return the found node or null if not found at all
  126011. */
  126012. getLastEntryByID(id: string): Nullable<Node>;
  126013. /**
  126014. * Gets a node (Mesh, Camera, Light) using a given id
  126015. * @param id defines the id to search for
  126016. * @return the found node or null if not found at all
  126017. */
  126018. getNodeByID(id: string): Nullable<Node>;
  126019. /**
  126020. * Gets a node (Mesh, Camera, Light) using a given name
  126021. * @param name defines the name to search for
  126022. * @return the found node or null if not found at all.
  126023. */
  126024. getNodeByName(name: string): Nullable<Node>;
  126025. /**
  126026. * Gets a mesh using a given name
  126027. * @param name defines the name to search for
  126028. * @return the found mesh or null if not found at all.
  126029. */
  126030. getMeshByName(name: string): Nullable<AbstractMesh>;
  126031. /**
  126032. * Gets a transform node using a given name
  126033. * @param name defines the name to search for
  126034. * @return the found transform node or null if not found at all.
  126035. */
  126036. getTransformNodeByName(name: string): Nullable<TransformNode>;
  126037. /**
  126038. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  126039. * @param id defines the id to search for
  126040. * @return the found skeleton or null if not found at all.
  126041. */
  126042. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  126043. /**
  126044. * Gets a skeleton using a given auto generated unique id
  126045. * @param uniqueId defines the unique id to search for
  126046. * @return the found skeleton or null if not found at all.
  126047. */
  126048. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  126049. /**
  126050. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  126051. * @param id defines the id to search for
  126052. * @return the found skeleton or null if not found at all.
  126053. */
  126054. getSkeletonById(id: string): Nullable<Skeleton>;
  126055. /**
  126056. * Gets a skeleton using a given name
  126057. * @param name defines the name to search for
  126058. * @return the found skeleton or null if not found at all.
  126059. */
  126060. getSkeletonByName(name: string): Nullable<Skeleton>;
  126061. /**
  126062. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  126063. * @param id defines the id to search for
  126064. * @return the found morph target manager or null if not found at all.
  126065. */
  126066. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  126067. /**
  126068. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  126069. * @param id defines the id to search for
  126070. * @return the found morph target or null if not found at all.
  126071. */
  126072. getMorphTargetById(id: string): Nullable<MorphTarget>;
  126073. /**
  126074. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  126075. * @param name defines the name to search for
  126076. * @return the found morph target or null if not found at all.
  126077. */
  126078. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  126079. /**
  126080. * Gets a post process using a given name (if many are found, this function will pick the first one)
  126081. * @param name defines the name to search for
  126082. * @return the found post process or null if not found at all.
  126083. */
  126084. getPostProcessByName(name: string): Nullable<PostProcess>;
  126085. /**
  126086. * Gets a boolean indicating if the given mesh is active
  126087. * @param mesh defines the mesh to look for
  126088. * @returns true if the mesh is in the active list
  126089. */
  126090. isActiveMesh(mesh: AbstractMesh): boolean;
  126091. /**
  126092. * Return a unique id as a string which can serve as an identifier for the scene
  126093. */
  126094. get uid(): string;
  126095. /**
  126096. * Add an externaly attached data from its key.
  126097. * This method call will fail and return false, if such key already exists.
  126098. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  126099. * @param key the unique key that identifies the data
  126100. * @param data the data object to associate to the key for this Engine instance
  126101. * @return true if no such key were already present and the data was added successfully, false otherwise
  126102. */
  126103. addExternalData<T>(key: string, data: T): boolean;
  126104. /**
  126105. * Get an externaly attached data from its key
  126106. * @param key the unique key that identifies the data
  126107. * @return the associated data, if present (can be null), or undefined if not present
  126108. */
  126109. getExternalData<T>(key: string): Nullable<T>;
  126110. /**
  126111. * Get an externaly attached data from its key, create it using a factory if it's not already present
  126112. * @param key the unique key that identifies the data
  126113. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  126114. * @return the associated data, can be null if the factory returned null.
  126115. */
  126116. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  126117. /**
  126118. * Remove an externaly attached data from the Engine instance
  126119. * @param key the unique key that identifies the data
  126120. * @return true if the data was successfully removed, false if it doesn't exist
  126121. */
  126122. removeExternalData(key: string): boolean;
  126123. private _evaluateSubMesh;
  126124. /**
  126125. * Clear the processed materials smart array preventing retention point in material dispose.
  126126. */
  126127. freeProcessedMaterials(): void;
  126128. private _preventFreeActiveMeshesAndRenderingGroups;
  126129. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  126130. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  126131. * when disposing several meshes in a row or a hierarchy of meshes.
  126132. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  126133. */
  126134. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  126135. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  126136. /**
  126137. * Clear the active meshes smart array preventing retention point in mesh dispose.
  126138. */
  126139. freeActiveMeshes(): void;
  126140. /**
  126141. * Clear the info related to rendering groups preventing retention points during dispose.
  126142. */
  126143. freeRenderingGroups(): void;
  126144. /** @hidden */
  126145. _isInIntermediateRendering(): boolean;
  126146. /**
  126147. * Lambda returning the list of potentially active meshes.
  126148. */
  126149. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  126150. /**
  126151. * Lambda returning the list of potentially active sub meshes.
  126152. */
  126153. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  126154. /**
  126155. * Lambda returning the list of potentially intersecting sub meshes.
  126156. */
  126157. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  126158. /**
  126159. * Lambda returning the list of potentially colliding sub meshes.
  126160. */
  126161. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  126162. /** @hidden */
  126163. _activeMeshesFrozen: boolean;
  126164. private _skipEvaluateActiveMeshesCompletely;
  126165. /**
  126166. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  126167. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  126168. * @param onSuccess optional success callback
  126169. * @param onError optional error callback
  126170. * @returns the current scene
  126171. */
  126172. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  126173. /**
  126174. * Use this function to restart evaluating active meshes on every frame
  126175. * @returns the current scene
  126176. */
  126177. unfreezeActiveMeshes(): Scene;
  126178. private _evaluateActiveMeshes;
  126179. private _activeMesh;
  126180. /**
  126181. * Update the transform matrix to update from the current active camera
  126182. * @param force defines a boolean used to force the update even if cache is up to date
  126183. */
  126184. updateTransformMatrix(force?: boolean): void;
  126185. private _bindFrameBuffer;
  126186. /** @hidden */
  126187. _allowPostProcessClearColor: boolean;
  126188. /** @hidden */
  126189. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  126190. private _processSubCameras;
  126191. private _checkIntersections;
  126192. /** @hidden */
  126193. _advancePhysicsEngineStep(step: number): void;
  126194. /**
  126195. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  126196. */
  126197. getDeterministicFrameTime: () => number;
  126198. /** @hidden */
  126199. _animate(): void;
  126200. /** Execute all animations (for a frame) */
  126201. animate(): void;
  126202. /**
  126203. * Render the scene
  126204. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  126205. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  126206. */
  126207. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  126208. /**
  126209. * Freeze all materials
  126210. * A frozen material will not be updatable but should be faster to render
  126211. */
  126212. freezeMaterials(): void;
  126213. /**
  126214. * Unfreeze all materials
  126215. * A frozen material will not be updatable but should be faster to render
  126216. */
  126217. unfreezeMaterials(): void;
  126218. /**
  126219. * Releases all held ressources
  126220. */
  126221. dispose(): void;
  126222. /**
  126223. * Gets if the scene is already disposed
  126224. */
  126225. get isDisposed(): boolean;
  126226. /**
  126227. * Call this function to reduce memory footprint of the scene.
  126228. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  126229. */
  126230. clearCachedVertexData(): void;
  126231. /**
  126232. * This function will remove the local cached buffer data from texture.
  126233. * It will save memory but will prevent the texture from being rebuilt
  126234. */
  126235. cleanCachedTextureBuffer(): void;
  126236. /**
  126237. * Get the world extend vectors with an optional filter
  126238. *
  126239. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  126240. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  126241. */
  126242. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  126243. min: Vector3;
  126244. max: Vector3;
  126245. };
  126246. /**
  126247. * Creates a ray that can be used to pick in the scene
  126248. * @param x defines the x coordinate of the origin (on-screen)
  126249. * @param y defines the y coordinate of the origin (on-screen)
  126250. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126251. * @param camera defines the camera to use for the picking
  126252. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126253. * @returns a Ray
  126254. */
  126255. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  126256. /**
  126257. * Creates a ray that can be used to pick in the scene
  126258. * @param x defines the x coordinate of the origin (on-screen)
  126259. * @param y defines the y coordinate of the origin (on-screen)
  126260. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126261. * @param result defines the ray where to store the picking ray
  126262. * @param camera defines the camera to use for the picking
  126263. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126264. * @returns the current scene
  126265. */
  126266. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  126267. /**
  126268. * Creates a ray that can be used to pick in the scene
  126269. * @param x defines the x coordinate of the origin (on-screen)
  126270. * @param y defines the y coordinate of the origin (on-screen)
  126271. * @param camera defines the camera to use for the picking
  126272. * @returns a Ray
  126273. */
  126274. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  126275. /**
  126276. * Creates a ray that can be used to pick in the scene
  126277. * @param x defines the x coordinate of the origin (on-screen)
  126278. * @param y defines the y coordinate of the origin (on-screen)
  126279. * @param result defines the ray where to store the picking ray
  126280. * @param camera defines the camera to use for the picking
  126281. * @returns the current scene
  126282. */
  126283. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126284. /** Launch a ray to try to pick a mesh in the scene
  126285. * @param x position on screen
  126286. * @param y position on screen
  126287. * @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
  126288. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126289. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126290. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126291. * @returns a PickingInfo
  126292. */
  126293. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126294. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126295. * @param x position on screen
  126296. * @param y position on screen
  126297. * @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
  126298. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126299. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126300. * @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)
  126301. */
  126302. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126303. /** Use the given ray to pick a mesh in the scene
  126304. * @param ray The ray to use to pick meshes
  126305. * @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
  126306. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126308. * @returns a PickingInfo
  126309. */
  126310. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126311. /**
  126312. * Launch a ray to try to pick a mesh in the scene
  126313. * @param x X position on screen
  126314. * @param y Y position on screen
  126315. * @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
  126316. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126317. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126318. * @returns an array of PickingInfo
  126319. */
  126320. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126321. /**
  126322. * Launch a ray to try to pick a mesh in the scene
  126323. * @param ray Ray to use
  126324. * @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
  126325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126326. * @returns an array of PickingInfo
  126327. */
  126328. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126329. /**
  126330. * Force the value of meshUnderPointer
  126331. * @param mesh defines the mesh to use
  126332. * @param pointerId optional pointer id when using more than one pointer
  126333. */
  126334. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126335. /**
  126336. * Gets the mesh under the pointer
  126337. * @returns a Mesh or null if no mesh is under the pointer
  126338. */
  126339. getPointerOverMesh(): Nullable<AbstractMesh>;
  126340. /** @hidden */
  126341. _rebuildGeometries(): void;
  126342. /** @hidden */
  126343. _rebuildTextures(): void;
  126344. private _getByTags;
  126345. /**
  126346. * Get a list of meshes by tags
  126347. * @param tagsQuery defines the tags query to use
  126348. * @param forEach defines a predicate used to filter results
  126349. * @returns an array of Mesh
  126350. */
  126351. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126352. /**
  126353. * Get a list of cameras by tags
  126354. * @param tagsQuery defines the tags query to use
  126355. * @param forEach defines a predicate used to filter results
  126356. * @returns an array of Camera
  126357. */
  126358. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126359. /**
  126360. * Get a list of lights by tags
  126361. * @param tagsQuery defines the tags query to use
  126362. * @param forEach defines a predicate used to filter results
  126363. * @returns an array of Light
  126364. */
  126365. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126366. /**
  126367. * Get a list of materials by tags
  126368. * @param tagsQuery defines the tags query to use
  126369. * @param forEach defines a predicate used to filter results
  126370. * @returns an array of Material
  126371. */
  126372. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126373. /**
  126374. * Get a list of transform nodes by tags
  126375. * @param tagsQuery defines the tags query to use
  126376. * @param forEach defines a predicate used to filter results
  126377. * @returns an array of TransformNode
  126378. */
  126379. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126380. /**
  126381. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126382. * This allowed control for front to back rendering or reversly depending of the special needs.
  126383. *
  126384. * @param renderingGroupId The rendering group id corresponding to its index
  126385. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126386. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126387. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126388. */
  126389. 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;
  126390. /**
  126391. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126392. *
  126393. * @param renderingGroupId The rendering group id corresponding to its index
  126394. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126395. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126396. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126397. */
  126398. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126399. /**
  126400. * Gets the current auto clear configuration for one rendering group of the rendering
  126401. * manager.
  126402. * @param index the rendering group index to get the information for
  126403. * @returns The auto clear setup for the requested rendering group
  126404. */
  126405. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126406. private _blockMaterialDirtyMechanism;
  126407. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126408. get blockMaterialDirtyMechanism(): boolean;
  126409. set blockMaterialDirtyMechanism(value: boolean);
  126410. /**
  126411. * Will flag all materials as dirty to trigger new shader compilation
  126412. * @param flag defines the flag used to specify which material part must be marked as dirty
  126413. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126414. */
  126415. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126416. /** @hidden */
  126417. _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;
  126418. /** @hidden */
  126419. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126420. /** @hidden */
  126421. _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;
  126422. /** @hidden */
  126423. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126424. /** @hidden */
  126425. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126426. /** @hidden */
  126427. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126428. }
  126429. }
  126430. declare module BABYLON {
  126431. /**
  126432. * Set of assets to keep when moving a scene into an asset container.
  126433. */
  126434. export class KeepAssets extends AbstractScene {
  126435. }
  126436. /**
  126437. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126438. */
  126439. export class InstantiatedEntries {
  126440. /**
  126441. * List of new root nodes (eg. nodes with no parent)
  126442. */
  126443. rootNodes: TransformNode[];
  126444. /**
  126445. * List of new skeletons
  126446. */
  126447. skeletons: Skeleton[];
  126448. /**
  126449. * List of new animation groups
  126450. */
  126451. animationGroups: AnimationGroup[];
  126452. }
  126453. /**
  126454. * Container with a set of assets that can be added or removed from a scene.
  126455. */
  126456. export class AssetContainer extends AbstractScene {
  126457. private _wasAddedToScene;
  126458. /**
  126459. * The scene the AssetContainer belongs to.
  126460. */
  126461. scene: Scene;
  126462. /**
  126463. * Instantiates an AssetContainer.
  126464. * @param scene The scene the AssetContainer belongs to.
  126465. */
  126466. constructor(scene: Scene);
  126467. /**
  126468. * Instantiate or clone all meshes and add the new ones to the scene.
  126469. * Skeletons and animation groups will all be cloned
  126470. * @param nameFunction defines an optional function used to get new names for clones
  126471. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126472. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126473. */
  126474. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126475. /**
  126476. * Adds all the assets from the container to the scene.
  126477. */
  126478. addAllToScene(): void;
  126479. /**
  126480. * Removes all the assets in the container from the scene
  126481. */
  126482. removeAllFromScene(): void;
  126483. /**
  126484. * Disposes all the assets in the container
  126485. */
  126486. dispose(): void;
  126487. private _moveAssets;
  126488. /**
  126489. * Removes all the assets contained in the scene and adds them to the container.
  126490. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126491. */
  126492. moveAllFromScene(keepAssets?: KeepAssets): void;
  126493. /**
  126494. * 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.
  126495. * @returns the root mesh
  126496. */
  126497. createRootMesh(): Mesh;
  126498. /**
  126499. * Merge animations (direct and animation groups) from this asset container into a scene
  126500. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126501. * @param animatables set of animatables to retarget to a node from the scene
  126502. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126503. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126504. */
  126505. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126506. }
  126507. }
  126508. declare module BABYLON {
  126509. /**
  126510. * Defines how the parser contract is defined.
  126511. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126512. */
  126513. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126514. /**
  126515. * Defines how the individual parser contract is defined.
  126516. * These parser can parse an individual asset
  126517. */
  126518. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126519. /**
  126520. * Base class of the scene acting as a container for the different elements composing a scene.
  126521. * This class is dynamically extended by the different components of the scene increasing
  126522. * flexibility and reducing coupling
  126523. */
  126524. export abstract class AbstractScene {
  126525. /**
  126526. * Stores the list of available parsers in the application.
  126527. */
  126528. private static _BabylonFileParsers;
  126529. /**
  126530. * Stores the list of available individual parsers in the application.
  126531. */
  126532. private static _IndividualBabylonFileParsers;
  126533. /**
  126534. * Adds a parser in the list of available ones
  126535. * @param name Defines the name of the parser
  126536. * @param parser Defines the parser to add
  126537. */
  126538. static AddParser(name: string, parser: BabylonFileParser): void;
  126539. /**
  126540. * Gets a general parser from the list of avaialble ones
  126541. * @param name Defines the name of the parser
  126542. * @returns the requested parser or null
  126543. */
  126544. static GetParser(name: string): Nullable<BabylonFileParser>;
  126545. /**
  126546. * Adds n individual parser in the list of available ones
  126547. * @param name Defines the name of the parser
  126548. * @param parser Defines the parser to add
  126549. */
  126550. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126551. /**
  126552. * Gets an individual parser from the list of avaialble ones
  126553. * @param name Defines the name of the parser
  126554. * @returns the requested parser or null
  126555. */
  126556. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126557. /**
  126558. * Parser json data and populate both a scene and its associated container object
  126559. * @param jsonData Defines the data to parse
  126560. * @param scene Defines the scene to parse the data for
  126561. * @param container Defines the container attached to the parsing sequence
  126562. * @param rootUrl Defines the root url of the data
  126563. */
  126564. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126565. /**
  126566. * Gets the list of root nodes (ie. nodes with no parent)
  126567. */
  126568. rootNodes: Node[];
  126569. /** All of the cameras added to this scene
  126570. * @see https://doc.babylonjs.com/babylon101/cameras
  126571. */
  126572. cameras: Camera[];
  126573. /**
  126574. * All of the lights added to this scene
  126575. * @see https://doc.babylonjs.com/babylon101/lights
  126576. */
  126577. lights: Light[];
  126578. /**
  126579. * All of the (abstract) meshes added to this scene
  126580. */
  126581. meshes: AbstractMesh[];
  126582. /**
  126583. * The list of skeletons added to the scene
  126584. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126585. */
  126586. skeletons: Skeleton[];
  126587. /**
  126588. * All of the particle systems added to this scene
  126589. * @see https://doc.babylonjs.com/babylon101/particles
  126590. */
  126591. particleSystems: IParticleSystem[];
  126592. /**
  126593. * Gets a list of Animations associated with the scene
  126594. */
  126595. animations: Animation[];
  126596. /**
  126597. * All of the animation groups added to this scene
  126598. * @see https://doc.babylonjs.com/how_to/group
  126599. */
  126600. animationGroups: AnimationGroup[];
  126601. /**
  126602. * All of the multi-materials added to this scene
  126603. * @see https://doc.babylonjs.com/how_to/multi_materials
  126604. */
  126605. multiMaterials: MultiMaterial[];
  126606. /**
  126607. * All of the materials added to this scene
  126608. * In the context of a Scene, it is not supposed to be modified manually.
  126609. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126610. * Note also that the order of the Material within the array is not significant and might change.
  126611. * @see https://doc.babylonjs.com/babylon101/materials
  126612. */
  126613. materials: Material[];
  126614. /**
  126615. * The list of morph target managers added to the scene
  126616. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126617. */
  126618. morphTargetManagers: MorphTargetManager[];
  126619. /**
  126620. * The list of geometries used in the scene.
  126621. */
  126622. geometries: Geometry[];
  126623. /**
  126624. * All of the tranform nodes added to this scene
  126625. * In the context of a Scene, it is not supposed to be modified manually.
  126626. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126627. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126628. * @see https://doc.babylonjs.com/how_to/transformnode
  126629. */
  126630. transformNodes: TransformNode[];
  126631. /**
  126632. * ActionManagers available on the scene.
  126633. */
  126634. actionManagers: AbstractActionManager[];
  126635. /**
  126636. * Textures to keep.
  126637. */
  126638. textures: BaseTexture[];
  126639. /** @hidden */
  126640. protected _environmentTexture: Nullable<BaseTexture>;
  126641. /**
  126642. * Texture used in all pbr material as the reflection texture.
  126643. * As in the majority of the scene they are the same (exception for multi room and so on),
  126644. * this is easier to reference from here than from all the materials.
  126645. */
  126646. get environmentTexture(): Nullable<BaseTexture>;
  126647. set environmentTexture(value: Nullable<BaseTexture>);
  126648. /**
  126649. * The list of postprocesses added to the scene
  126650. */
  126651. postProcesses: PostProcess[];
  126652. /**
  126653. * @returns all meshes, lights, cameras, transformNodes and bones
  126654. */
  126655. getNodes(): Array<Node>;
  126656. }
  126657. }
  126658. declare module BABYLON {
  126659. /**
  126660. * Interface used to define options for Sound class
  126661. */
  126662. export interface ISoundOptions {
  126663. /**
  126664. * Does the sound autoplay once loaded.
  126665. */
  126666. autoplay?: boolean;
  126667. /**
  126668. * Does the sound loop after it finishes playing once.
  126669. */
  126670. loop?: boolean;
  126671. /**
  126672. * Sound's volume
  126673. */
  126674. volume?: number;
  126675. /**
  126676. * Is it a spatial sound?
  126677. */
  126678. spatialSound?: boolean;
  126679. /**
  126680. * Maximum distance to hear that sound
  126681. */
  126682. maxDistance?: number;
  126683. /**
  126684. * Uses user defined attenuation function
  126685. */
  126686. useCustomAttenuation?: boolean;
  126687. /**
  126688. * Define the roll off factor of spatial sounds.
  126689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126690. */
  126691. rolloffFactor?: number;
  126692. /**
  126693. * Define the reference distance the sound should be heard perfectly.
  126694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126695. */
  126696. refDistance?: number;
  126697. /**
  126698. * Define the distance attenuation model the sound will follow.
  126699. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126700. */
  126701. distanceModel?: string;
  126702. /**
  126703. * Defines the playback speed (1 by default)
  126704. */
  126705. playbackRate?: number;
  126706. /**
  126707. * Defines if the sound is from a streaming source
  126708. */
  126709. streaming?: boolean;
  126710. /**
  126711. * Defines an optional length (in seconds) inside the sound file
  126712. */
  126713. length?: number;
  126714. /**
  126715. * Defines an optional offset (in seconds) inside the sound file
  126716. */
  126717. offset?: number;
  126718. /**
  126719. * If true, URLs will not be required to state the audio file codec to use.
  126720. */
  126721. skipCodecCheck?: boolean;
  126722. }
  126723. }
  126724. declare module BABYLON {
  126725. /**
  126726. * Defines a sound that can be played in the application.
  126727. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126729. */
  126730. export class Sound {
  126731. /**
  126732. * The name of the sound in the scene.
  126733. */
  126734. name: string;
  126735. /**
  126736. * Does the sound autoplay once loaded.
  126737. */
  126738. autoplay: boolean;
  126739. /**
  126740. * Does the sound loop after it finishes playing once.
  126741. */
  126742. loop: boolean;
  126743. /**
  126744. * Does the sound use a custom attenuation curve to simulate the falloff
  126745. * happening when the source gets further away from the camera.
  126746. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126747. */
  126748. useCustomAttenuation: boolean;
  126749. /**
  126750. * The sound track id this sound belongs to.
  126751. */
  126752. soundTrackId: number;
  126753. /**
  126754. * Is this sound currently played.
  126755. */
  126756. isPlaying: boolean;
  126757. /**
  126758. * Is this sound currently paused.
  126759. */
  126760. isPaused: boolean;
  126761. /**
  126762. * Does this sound enables spatial sound.
  126763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126764. */
  126765. spatialSound: boolean;
  126766. /**
  126767. * Define the reference distance the sound should be heard perfectly.
  126768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126769. */
  126770. refDistance: number;
  126771. /**
  126772. * Define the roll off factor of spatial sounds.
  126773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126774. */
  126775. rolloffFactor: number;
  126776. /**
  126777. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126779. */
  126780. maxDistance: number;
  126781. /**
  126782. * Define the distance attenuation model the sound will follow.
  126783. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126784. */
  126785. distanceModel: string;
  126786. /**
  126787. * @hidden
  126788. * Back Compat
  126789. **/
  126790. onended: () => any;
  126791. /**
  126792. * Gets or sets an object used to store user defined information for the sound.
  126793. */
  126794. metadata: any;
  126795. /**
  126796. * Observable event when the current playing sound finishes.
  126797. */
  126798. onEndedObservable: Observable<Sound>;
  126799. /**
  126800. * Gets the current time for the sound.
  126801. */
  126802. get currentTime(): number;
  126803. private _panningModel;
  126804. private _playbackRate;
  126805. private _streaming;
  126806. private _startTime;
  126807. private _startOffset;
  126808. private _position;
  126809. /** @hidden */
  126810. _positionInEmitterSpace: boolean;
  126811. private _localDirection;
  126812. private _volume;
  126813. private _isReadyToPlay;
  126814. private _isDirectional;
  126815. private _readyToPlayCallback;
  126816. private _audioBuffer;
  126817. private _soundSource;
  126818. private _streamingSource;
  126819. private _soundPanner;
  126820. private _soundGain;
  126821. private _inputAudioNode;
  126822. private _outputAudioNode;
  126823. private _coneInnerAngle;
  126824. private _coneOuterAngle;
  126825. private _coneOuterGain;
  126826. private _scene;
  126827. private _connectedTransformNode;
  126828. private _customAttenuationFunction;
  126829. private _registerFunc;
  126830. private _isOutputConnected;
  126831. private _htmlAudioElement;
  126832. private _urlType;
  126833. private _length?;
  126834. private _offset?;
  126835. /** @hidden */
  126836. static _SceneComponentInitialization: (scene: Scene) => void;
  126837. /**
  126838. * Create a sound and attach it to a scene
  126839. * @param name Name of your sound
  126840. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126841. * @param scene defines the scene the sound belongs to
  126842. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126843. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126844. */
  126845. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126846. /**
  126847. * Release the sound and its associated resources
  126848. */
  126849. dispose(): void;
  126850. /**
  126851. * Gets if the sounds is ready to be played or not.
  126852. * @returns true if ready, otherwise false
  126853. */
  126854. isReady(): boolean;
  126855. private _soundLoaded;
  126856. /**
  126857. * Sets the data of the sound from an audiobuffer
  126858. * @param audioBuffer The audioBuffer containing the data
  126859. */
  126860. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126861. /**
  126862. * Updates the current sounds options such as maxdistance, loop...
  126863. * @param options A JSON object containing values named as the object properties
  126864. */
  126865. updateOptions(options: ISoundOptions): void;
  126866. private _createSpatialParameters;
  126867. private _updateSpatialParameters;
  126868. /**
  126869. * Switch the panning model to HRTF:
  126870. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126871. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126872. */
  126873. switchPanningModelToHRTF(): void;
  126874. /**
  126875. * Switch the panning model to Equal Power:
  126876. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126877. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126878. */
  126879. switchPanningModelToEqualPower(): void;
  126880. private _switchPanningModel;
  126881. /**
  126882. * Connect this sound to a sound track audio node like gain...
  126883. * @param soundTrackAudioNode the sound track audio node to connect to
  126884. */
  126885. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126886. /**
  126887. * Transform this sound into a directional source
  126888. * @param coneInnerAngle Size of the inner cone in degree
  126889. * @param coneOuterAngle Size of the outer cone in degree
  126890. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126891. */
  126892. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126893. /**
  126894. * Gets or sets the inner angle for the directional cone.
  126895. */
  126896. get directionalConeInnerAngle(): number;
  126897. /**
  126898. * Gets or sets the inner angle for the directional cone.
  126899. */
  126900. set directionalConeInnerAngle(value: number);
  126901. /**
  126902. * Gets or sets the outer angle for the directional cone.
  126903. */
  126904. get directionalConeOuterAngle(): number;
  126905. /**
  126906. * Gets or sets the outer angle for the directional cone.
  126907. */
  126908. set directionalConeOuterAngle(value: number);
  126909. /**
  126910. * Sets the position of the emitter if spatial sound is enabled
  126911. * @param newPosition Defines the new posisiton
  126912. */
  126913. setPosition(newPosition: Vector3): void;
  126914. /**
  126915. * Sets the local direction of the emitter if spatial sound is enabled
  126916. * @param newLocalDirection Defines the new local direction
  126917. */
  126918. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126919. private _updateDirection;
  126920. /** @hidden */
  126921. updateDistanceFromListener(): void;
  126922. /**
  126923. * Sets a new custom attenuation function for the sound.
  126924. * @param callback Defines the function used for the attenuation
  126925. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126926. */
  126927. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126928. /**
  126929. * Play the sound
  126930. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126931. * @param offset (optional) Start the sound at a specific time in seconds
  126932. * @param length (optional) Sound duration (in seconds)
  126933. */
  126934. play(time?: number, offset?: number, length?: number): void;
  126935. private _onended;
  126936. /**
  126937. * Stop the sound
  126938. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126939. */
  126940. stop(time?: number): void;
  126941. /**
  126942. * Put the sound in pause
  126943. */
  126944. pause(): void;
  126945. /**
  126946. * Sets a dedicated volume for this sounds
  126947. * @param newVolume Define the new volume of the sound
  126948. * @param time Define time for gradual change to new volume
  126949. */
  126950. setVolume(newVolume: number, time?: number): void;
  126951. /**
  126952. * Set the sound play back rate
  126953. * @param newPlaybackRate Define the playback rate the sound should be played at
  126954. */
  126955. setPlaybackRate(newPlaybackRate: number): void;
  126956. /**
  126957. * Gets the volume of the sound.
  126958. * @returns the volume of the sound
  126959. */
  126960. getVolume(): number;
  126961. /**
  126962. * Attach the sound to a dedicated mesh
  126963. * @param transformNode The transform node to connect the sound with
  126964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126965. */
  126966. attachToMesh(transformNode: TransformNode): void;
  126967. /**
  126968. * Detach the sound from the previously attached mesh
  126969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126970. */
  126971. detachFromMesh(): void;
  126972. private _onRegisterAfterWorldMatrixUpdate;
  126973. /**
  126974. * Clone the current sound in the scene.
  126975. * @returns the new sound clone
  126976. */
  126977. clone(): Nullable<Sound>;
  126978. /**
  126979. * Gets the current underlying audio buffer containing the data
  126980. * @returns the audio buffer
  126981. */
  126982. getAudioBuffer(): Nullable<AudioBuffer>;
  126983. /**
  126984. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126985. * @returns the source node
  126986. */
  126987. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126988. /**
  126989. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126990. * @returns the gain node
  126991. */
  126992. getSoundGain(): Nullable<GainNode>;
  126993. /**
  126994. * Serializes the Sound in a JSON representation
  126995. * @returns the JSON representation of the sound
  126996. */
  126997. serialize(): any;
  126998. /**
  126999. * Parse a JSON representation of a sound to innstantiate in a given scene
  127000. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  127001. * @param scene Define the scene the new parsed sound should be created in
  127002. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  127003. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  127004. * @returns the newly parsed sound
  127005. */
  127006. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  127007. }
  127008. }
  127009. declare module BABYLON {
  127010. /**
  127011. * This defines an action helpful to play a defined sound on a triggered action.
  127012. */
  127013. export class PlaySoundAction extends Action {
  127014. private _sound;
  127015. /**
  127016. * Instantiate the action
  127017. * @param triggerOptions defines the trigger options
  127018. * @param sound defines the sound to play
  127019. * @param condition defines the trigger related conditions
  127020. */
  127021. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  127022. /** @hidden */
  127023. _prepare(): void;
  127024. /**
  127025. * Execute the action and play the sound.
  127026. */
  127027. execute(): void;
  127028. /**
  127029. * Serializes the actions and its related information.
  127030. * @param parent defines the object to serialize in
  127031. * @returns the serialized object
  127032. */
  127033. serialize(parent: any): any;
  127034. }
  127035. /**
  127036. * This defines an action helpful to stop a defined sound on a triggered action.
  127037. */
  127038. export class StopSoundAction extends Action {
  127039. private _sound;
  127040. /**
  127041. * Instantiate the action
  127042. * @param triggerOptions defines the trigger options
  127043. * @param sound defines the sound to stop
  127044. * @param condition defines the trigger related conditions
  127045. */
  127046. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  127047. /** @hidden */
  127048. _prepare(): void;
  127049. /**
  127050. * Execute the action and stop the sound.
  127051. */
  127052. execute(): void;
  127053. /**
  127054. * Serializes the actions and its related information.
  127055. * @param parent defines the object to serialize in
  127056. * @returns the serialized object
  127057. */
  127058. serialize(parent: any): any;
  127059. }
  127060. }
  127061. declare module BABYLON {
  127062. /**
  127063. * This defines an action responsible to change the value of a property
  127064. * by interpolating between its current value and the newly set one once triggered.
  127065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  127066. */
  127067. export class InterpolateValueAction extends Action {
  127068. /**
  127069. * Defines the path of the property where the value should be interpolated
  127070. */
  127071. propertyPath: string;
  127072. /**
  127073. * Defines the target value at the end of the interpolation.
  127074. */
  127075. value: any;
  127076. /**
  127077. * Defines the time it will take for the property to interpolate to the value.
  127078. */
  127079. duration: number;
  127080. /**
  127081. * Defines if the other scene animations should be stopped when the action has been triggered
  127082. */
  127083. stopOtherAnimations?: boolean;
  127084. /**
  127085. * Defines a callback raised once the interpolation animation has been done.
  127086. */
  127087. onInterpolationDone?: () => void;
  127088. /**
  127089. * Observable triggered once the interpolation animation has been done.
  127090. */
  127091. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  127092. private _target;
  127093. private _effectiveTarget;
  127094. private _property;
  127095. /**
  127096. * Instantiate the action
  127097. * @param triggerOptions defines the trigger options
  127098. * @param target defines the object containing the value to interpolate
  127099. * @param propertyPath defines the path to the property in the target object
  127100. * @param value defines the target value at the end of the interpolation
  127101. * @param duration deines the time it will take for the property to interpolate to the value.
  127102. * @param condition defines the trigger related conditions
  127103. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  127104. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  127105. */
  127106. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  127107. /** @hidden */
  127108. _prepare(): void;
  127109. /**
  127110. * Execute the action starts the value interpolation.
  127111. */
  127112. execute(): void;
  127113. /**
  127114. * Serializes the actions and its related information.
  127115. * @param parent defines the object to serialize in
  127116. * @returns the serialized object
  127117. */
  127118. serialize(parent: any): any;
  127119. }
  127120. }
  127121. declare module BABYLON {
  127122. /**
  127123. * This represents the default audio engine used in babylon.
  127124. * It is responsible to play, synchronize and analyse sounds throughout the application.
  127125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127126. */
  127127. export class AudioEngine implements IAudioEngine {
  127128. private _audioContext;
  127129. private _audioContextInitialized;
  127130. private _muteButton;
  127131. private _hostElement;
  127132. /**
  127133. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  127134. */
  127135. canUseWebAudio: boolean;
  127136. /**
  127137. * The master gain node defines the global audio volume of your audio engine.
  127138. */
  127139. masterGain: GainNode;
  127140. /**
  127141. * Defines if Babylon should emit a warning if WebAudio is not supported.
  127142. * @ignoreNaming
  127143. */
  127144. WarnedWebAudioUnsupported: boolean;
  127145. /**
  127146. * Gets whether or not mp3 are supported by your browser.
  127147. */
  127148. isMP3supported: boolean;
  127149. /**
  127150. * Gets whether or not ogg are supported by your browser.
  127151. */
  127152. isOGGsupported: boolean;
  127153. /**
  127154. * Gets whether audio has been unlocked on the device.
  127155. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  127156. * a user interaction has happened.
  127157. */
  127158. unlocked: boolean;
  127159. /**
  127160. * Defines if the audio engine relies on a custom unlocked button.
  127161. * In this case, the embedded button will not be displayed.
  127162. */
  127163. useCustomUnlockedButton: boolean;
  127164. /**
  127165. * Event raised when audio has been unlocked on the browser.
  127166. */
  127167. onAudioUnlockedObservable: Observable<IAudioEngine>;
  127168. /**
  127169. * Event raised when audio has been locked on the browser.
  127170. */
  127171. onAudioLockedObservable: Observable<IAudioEngine>;
  127172. /**
  127173. * Gets the current AudioContext if available.
  127174. */
  127175. get audioContext(): Nullable<AudioContext>;
  127176. private _connectedAnalyser;
  127177. /**
  127178. * Instantiates a new audio engine.
  127179. *
  127180. * There should be only one per page as some browsers restrict the number
  127181. * of audio contexts you can create.
  127182. * @param hostElement defines the host element where to display the mute icon if necessary
  127183. */
  127184. constructor(hostElement?: Nullable<HTMLElement>);
  127185. /**
  127186. * Flags the audio engine in Locked state.
  127187. * This happens due to new browser policies preventing audio to autoplay.
  127188. */
  127189. lock(): void;
  127190. /**
  127191. * Unlocks the audio engine once a user action has been done on the dom.
  127192. * This is helpful to resume play once browser policies have been satisfied.
  127193. */
  127194. unlock(): void;
  127195. private _resumeAudioContext;
  127196. private _initializeAudioContext;
  127197. private _tryToRun;
  127198. private _triggerRunningState;
  127199. private _triggerSuspendedState;
  127200. private _displayMuteButton;
  127201. private _moveButtonToTopLeft;
  127202. private _onResize;
  127203. private _hideMuteButton;
  127204. /**
  127205. * Destroy and release the resources associated with the audio ccontext.
  127206. */
  127207. dispose(): void;
  127208. /**
  127209. * Gets the global volume sets on the master gain.
  127210. * @returns the global volume if set or -1 otherwise
  127211. */
  127212. getGlobalVolume(): number;
  127213. /**
  127214. * Sets the global volume of your experience (sets on the master gain).
  127215. * @param newVolume Defines the new global volume of the application
  127216. */
  127217. setGlobalVolume(newVolume: number): void;
  127218. /**
  127219. * Connect the audio engine to an audio analyser allowing some amazing
  127220. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127221. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127222. * @param analyser The analyser to connect to the engine
  127223. */
  127224. connectToAnalyser(analyser: Analyser): void;
  127225. }
  127226. }
  127227. declare module BABYLON {
  127228. /**
  127229. * Options allowed during the creation of a sound track.
  127230. */
  127231. export interface ISoundTrackOptions {
  127232. /**
  127233. * The volume the sound track should take during creation
  127234. */
  127235. volume?: number;
  127236. /**
  127237. * Define if the sound track is the main sound track of the scene
  127238. */
  127239. mainTrack?: boolean;
  127240. }
  127241. /**
  127242. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  127243. * It will be also used in a future release to apply effects on a specific track.
  127244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127245. */
  127246. export class SoundTrack {
  127247. /**
  127248. * The unique identifier of the sound track in the scene.
  127249. */
  127250. id: number;
  127251. /**
  127252. * The list of sounds included in the sound track.
  127253. */
  127254. soundCollection: Array<Sound>;
  127255. private _outputAudioNode;
  127256. private _scene;
  127257. private _connectedAnalyser;
  127258. private _options;
  127259. private _isInitialized;
  127260. /**
  127261. * Creates a new sound track.
  127262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127263. * @param scene Define the scene the sound track belongs to
  127264. * @param options
  127265. */
  127266. constructor(scene: Scene, options?: ISoundTrackOptions);
  127267. private _initializeSoundTrackAudioGraph;
  127268. /**
  127269. * Release the sound track and its associated resources
  127270. */
  127271. dispose(): void;
  127272. /**
  127273. * Adds a sound to this sound track
  127274. * @param sound define the cound to add
  127275. * @ignoreNaming
  127276. */
  127277. addSound(sound: Sound): void;
  127278. /**
  127279. * Removes a sound to this sound track
  127280. * @param sound define the cound to remove
  127281. * @ignoreNaming
  127282. */
  127283. removeSound(sound: Sound): void;
  127284. /**
  127285. * Set a global volume for the full sound track.
  127286. * @param newVolume Define the new volume of the sound track
  127287. */
  127288. setVolume(newVolume: number): void;
  127289. /**
  127290. * Switch the panning model to HRTF:
  127291. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127292. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127293. */
  127294. switchPanningModelToHRTF(): void;
  127295. /**
  127296. * Switch the panning model to Equal Power:
  127297. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127298. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127299. */
  127300. switchPanningModelToEqualPower(): void;
  127301. /**
  127302. * Connect the sound track to an audio analyser allowing some amazing
  127303. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127304. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127305. * @param analyser The analyser to connect to the engine
  127306. */
  127307. connectToAnalyser(analyser: Analyser): void;
  127308. }
  127309. }
  127310. declare module BABYLON {
  127311. interface AbstractScene {
  127312. /**
  127313. * The list of sounds used in the scene.
  127314. */
  127315. sounds: Nullable<Array<Sound>>;
  127316. }
  127317. interface Scene {
  127318. /**
  127319. * @hidden
  127320. * Backing field
  127321. */
  127322. _mainSoundTrack: SoundTrack;
  127323. /**
  127324. * The main sound track played by the scene.
  127325. * It cotains your primary collection of sounds.
  127326. */
  127327. mainSoundTrack: SoundTrack;
  127328. /**
  127329. * The list of sound tracks added to the scene
  127330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127331. */
  127332. soundTracks: Nullable<Array<SoundTrack>>;
  127333. /**
  127334. * Gets a sound using a given name
  127335. * @param name defines the name to search for
  127336. * @return the found sound or null if not found at all.
  127337. */
  127338. getSoundByName(name: string): Nullable<Sound>;
  127339. /**
  127340. * Gets or sets if audio support is enabled
  127341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127342. */
  127343. audioEnabled: boolean;
  127344. /**
  127345. * Gets or sets if audio will be output to headphones
  127346. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127347. */
  127348. headphone: boolean;
  127349. /**
  127350. * Gets or sets custom audio listener position provider
  127351. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127352. */
  127353. audioListenerPositionProvider: Nullable<() => Vector3>;
  127354. /**
  127355. * Gets or sets a refresh rate when using 3D audio positioning
  127356. */
  127357. audioPositioningRefreshRate: number;
  127358. }
  127359. /**
  127360. * Defines the sound scene component responsible to manage any sounds
  127361. * in a given scene.
  127362. */
  127363. export class AudioSceneComponent implements ISceneSerializableComponent {
  127364. private static _CameraDirectionLH;
  127365. private static _CameraDirectionRH;
  127366. /**
  127367. * The component name helpfull to identify the component in the list of scene components.
  127368. */
  127369. readonly name: string;
  127370. /**
  127371. * The scene the component belongs to.
  127372. */
  127373. scene: Scene;
  127374. private _audioEnabled;
  127375. /**
  127376. * Gets whether audio is enabled or not.
  127377. * Please use related enable/disable method to switch state.
  127378. */
  127379. get audioEnabled(): boolean;
  127380. private _headphone;
  127381. /**
  127382. * Gets whether audio is outputing to headphone or not.
  127383. * Please use the according Switch methods to change output.
  127384. */
  127385. get headphone(): boolean;
  127386. /**
  127387. * Gets or sets a refresh rate when using 3D audio positioning
  127388. */
  127389. audioPositioningRefreshRate: number;
  127390. private _audioListenerPositionProvider;
  127391. /**
  127392. * Gets the current audio listener position provider
  127393. */
  127394. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127395. /**
  127396. * Sets a custom listener position for all sounds in the scene
  127397. * By default, this is the position of the first active camera
  127398. */
  127399. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127400. /**
  127401. * Creates a new instance of the component for the given scene
  127402. * @param scene Defines the scene to register the component in
  127403. */
  127404. constructor(scene: Scene);
  127405. /**
  127406. * Registers the component in a given scene
  127407. */
  127408. register(): void;
  127409. /**
  127410. * Rebuilds the elements related to this component in case of
  127411. * context lost for instance.
  127412. */
  127413. rebuild(): void;
  127414. /**
  127415. * Serializes the component data to the specified json object
  127416. * @param serializationObject The object to serialize to
  127417. */
  127418. serialize(serializationObject: any): void;
  127419. /**
  127420. * Adds all the elements from the container to the scene
  127421. * @param container the container holding the elements
  127422. */
  127423. addFromContainer(container: AbstractScene): void;
  127424. /**
  127425. * Removes all the elements in the container from the scene
  127426. * @param container contains the elements to remove
  127427. * @param dispose if the removed element should be disposed (default: false)
  127428. */
  127429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127430. /**
  127431. * Disposes the component and the associated ressources.
  127432. */
  127433. dispose(): void;
  127434. /**
  127435. * Disables audio in the associated scene.
  127436. */
  127437. disableAudio(): void;
  127438. /**
  127439. * Enables audio in the associated scene.
  127440. */
  127441. enableAudio(): void;
  127442. /**
  127443. * Switch audio to headphone output.
  127444. */
  127445. switchAudioModeForHeadphones(): void;
  127446. /**
  127447. * Switch audio to normal speakers.
  127448. */
  127449. switchAudioModeForNormalSpeakers(): void;
  127450. private _cachedCameraDirection;
  127451. private _cachedCameraPosition;
  127452. private _lastCheck;
  127453. private _afterRender;
  127454. }
  127455. }
  127456. declare module BABYLON {
  127457. /**
  127458. * Wraps one or more Sound objects and selects one with random weight for playback.
  127459. */
  127460. export class WeightedSound {
  127461. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127462. loop: boolean;
  127463. private _coneInnerAngle;
  127464. private _coneOuterAngle;
  127465. private _volume;
  127466. /** A Sound is currently playing. */
  127467. isPlaying: boolean;
  127468. /** A Sound is currently paused. */
  127469. isPaused: boolean;
  127470. private _sounds;
  127471. private _weights;
  127472. private _currentIndex?;
  127473. /**
  127474. * Creates a new WeightedSound from the list of sounds given.
  127475. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127476. * @param sounds Array of Sounds that will be selected from.
  127477. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127478. */
  127479. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127480. /**
  127481. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127482. */
  127483. get directionalConeInnerAngle(): number;
  127484. /**
  127485. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127486. */
  127487. set directionalConeInnerAngle(value: number);
  127488. /**
  127489. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127490. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127491. */
  127492. get directionalConeOuterAngle(): number;
  127493. /**
  127494. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127495. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127496. */
  127497. set directionalConeOuterAngle(value: number);
  127498. /**
  127499. * Playback volume.
  127500. */
  127501. get volume(): number;
  127502. /**
  127503. * Playback volume.
  127504. */
  127505. set volume(value: number);
  127506. private _onended;
  127507. /**
  127508. * Suspend playback
  127509. */
  127510. pause(): void;
  127511. /**
  127512. * Stop playback
  127513. */
  127514. stop(): void;
  127515. /**
  127516. * Start playback.
  127517. * @param startOffset Position the clip head at a specific time in seconds.
  127518. */
  127519. play(startOffset?: number): void;
  127520. }
  127521. }
  127522. declare module BABYLON {
  127523. /**
  127524. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127525. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127526. */
  127527. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127528. /**
  127529. * Gets the name of the behavior.
  127530. */
  127531. get name(): string;
  127532. /**
  127533. * The easing function used by animations
  127534. */
  127535. static EasingFunction: BackEase;
  127536. /**
  127537. * The easing mode used by animations
  127538. */
  127539. static EasingMode: number;
  127540. /**
  127541. * The duration of the animation, in milliseconds
  127542. */
  127543. transitionDuration: number;
  127544. /**
  127545. * Length of the distance animated by the transition when lower radius is reached
  127546. */
  127547. lowerRadiusTransitionRange: number;
  127548. /**
  127549. * Length of the distance animated by the transition when upper radius is reached
  127550. */
  127551. upperRadiusTransitionRange: number;
  127552. private _autoTransitionRange;
  127553. /**
  127554. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127555. */
  127556. get autoTransitionRange(): boolean;
  127557. /**
  127558. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127559. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127560. */
  127561. set autoTransitionRange(value: boolean);
  127562. private _attachedCamera;
  127563. private _onAfterCheckInputsObserver;
  127564. private _onMeshTargetChangedObserver;
  127565. /**
  127566. * Initializes the behavior.
  127567. */
  127568. init(): void;
  127569. /**
  127570. * Attaches the behavior to its arc rotate camera.
  127571. * @param camera Defines the camera to attach the behavior to
  127572. */
  127573. attach(camera: ArcRotateCamera): void;
  127574. /**
  127575. * Detaches the behavior from its current arc rotate camera.
  127576. */
  127577. detach(): void;
  127578. private _radiusIsAnimating;
  127579. private _radiusBounceTransition;
  127580. private _animatables;
  127581. private _cachedWheelPrecision;
  127582. /**
  127583. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127584. * @param radiusLimit The limit to check against.
  127585. * @return Bool to indicate if at limit.
  127586. */
  127587. private _isRadiusAtLimit;
  127588. /**
  127589. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127590. * @param radiusDelta The delta by which to animate to. Can be negative.
  127591. */
  127592. private _applyBoundRadiusAnimation;
  127593. /**
  127594. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127595. */
  127596. protected _clearAnimationLocks(): void;
  127597. /**
  127598. * Stops and removes all animations that have been applied to the camera
  127599. */
  127600. stopAllAnimations(): void;
  127601. }
  127602. }
  127603. declare module BABYLON {
  127604. /**
  127605. * 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.
  127606. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127607. */
  127608. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127609. /**
  127610. * Gets the name of the behavior.
  127611. */
  127612. get name(): string;
  127613. private _mode;
  127614. private _radiusScale;
  127615. private _positionScale;
  127616. private _defaultElevation;
  127617. private _elevationReturnTime;
  127618. private _elevationReturnWaitTime;
  127619. private _zoomStopsAnimation;
  127620. private _framingTime;
  127621. /**
  127622. * The easing function used by animations
  127623. */
  127624. static EasingFunction: ExponentialEase;
  127625. /**
  127626. * The easing mode used by animations
  127627. */
  127628. static EasingMode: number;
  127629. /**
  127630. * Sets the current mode used by the behavior
  127631. */
  127632. set mode(mode: number);
  127633. /**
  127634. * Gets current mode used by the behavior.
  127635. */
  127636. get mode(): number;
  127637. /**
  127638. * Sets the scale applied to the radius (1 by default)
  127639. */
  127640. set radiusScale(radius: number);
  127641. /**
  127642. * Gets the scale applied to the radius
  127643. */
  127644. get radiusScale(): number;
  127645. /**
  127646. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127647. */
  127648. set positionScale(scale: number);
  127649. /**
  127650. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127651. */
  127652. get positionScale(): number;
  127653. /**
  127654. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127655. * behaviour is triggered, in radians.
  127656. */
  127657. set defaultElevation(elevation: number);
  127658. /**
  127659. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127660. * behaviour is triggered, in radians.
  127661. */
  127662. get defaultElevation(): number;
  127663. /**
  127664. * Sets the time (in milliseconds) taken to return to the default beta position.
  127665. * Negative value indicates camera should not return to default.
  127666. */
  127667. set elevationReturnTime(speed: number);
  127668. /**
  127669. * Gets the time (in milliseconds) taken to return to the default beta position.
  127670. * Negative value indicates camera should not return to default.
  127671. */
  127672. get elevationReturnTime(): number;
  127673. /**
  127674. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127675. */
  127676. set elevationReturnWaitTime(time: number);
  127677. /**
  127678. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127679. */
  127680. get elevationReturnWaitTime(): number;
  127681. /**
  127682. * Sets the flag that indicates if user zooming should stop animation.
  127683. */
  127684. set zoomStopsAnimation(flag: boolean);
  127685. /**
  127686. * Gets the flag that indicates if user zooming should stop animation.
  127687. */
  127688. get zoomStopsAnimation(): boolean;
  127689. /**
  127690. * Sets the transition time when framing the mesh, in milliseconds
  127691. */
  127692. set framingTime(time: number);
  127693. /**
  127694. * Gets the transition time when framing the mesh, in milliseconds
  127695. */
  127696. get framingTime(): number;
  127697. /**
  127698. * Define if the behavior should automatically change the configured
  127699. * camera limits and sensibilities.
  127700. */
  127701. autoCorrectCameraLimitsAndSensibility: boolean;
  127702. private _onPrePointerObservableObserver;
  127703. private _onAfterCheckInputsObserver;
  127704. private _onMeshTargetChangedObserver;
  127705. private _attachedCamera;
  127706. private _isPointerDown;
  127707. private _lastInteractionTime;
  127708. /**
  127709. * Initializes the behavior.
  127710. */
  127711. init(): void;
  127712. /**
  127713. * Attaches the behavior to its arc rotate camera.
  127714. * @param camera Defines the camera to attach the behavior to
  127715. */
  127716. attach(camera: ArcRotateCamera): void;
  127717. /**
  127718. * Detaches the behavior from its current arc rotate camera.
  127719. */
  127720. detach(): void;
  127721. private _animatables;
  127722. private _betaIsAnimating;
  127723. private _betaTransition;
  127724. private _radiusTransition;
  127725. private _vectorTransition;
  127726. /**
  127727. * Targets the given mesh and updates zoom level accordingly.
  127728. * @param mesh The mesh to target.
  127729. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127730. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127731. */
  127732. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127733. /**
  127734. * Targets the given mesh with its children and updates zoom level accordingly.
  127735. * @param mesh The mesh to target.
  127736. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127737. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127738. */
  127739. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127740. /**
  127741. * Targets the given meshes with their children and updates zoom level accordingly.
  127742. * @param meshes The mesh to target.
  127743. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127744. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127745. */
  127746. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127747. /**
  127748. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127749. * @param minimumWorld Determines the smaller position of the bounding box extend
  127750. * @param maximumWorld Determines the bigger position of the bounding box extend
  127751. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127752. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127753. */
  127754. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127755. /**
  127756. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127757. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127758. * frustum width.
  127759. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127760. * to fully enclose the mesh in the viewing frustum.
  127761. */
  127762. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127763. /**
  127764. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127765. * is automatically returned to its default position (expected to be above ground plane).
  127766. */
  127767. private _maintainCameraAboveGround;
  127768. /**
  127769. * Returns the frustum slope based on the canvas ratio and camera FOV
  127770. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127771. */
  127772. private _getFrustumSlope;
  127773. /**
  127774. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127775. */
  127776. private _clearAnimationLocks;
  127777. /**
  127778. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127779. */
  127780. private _applyUserInteraction;
  127781. /**
  127782. * Stops and removes all animations that have been applied to the camera
  127783. */
  127784. stopAllAnimations(): void;
  127785. /**
  127786. * Gets a value indicating if the user is moving the camera
  127787. */
  127788. get isUserIsMoving(): boolean;
  127789. /**
  127790. * The camera can move all the way towards the mesh.
  127791. */
  127792. static IgnoreBoundsSizeMode: number;
  127793. /**
  127794. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127795. */
  127796. static FitFrustumSidesMode: number;
  127797. }
  127798. }
  127799. declare module BABYLON {
  127800. /**
  127801. * Base class for Camera Pointer Inputs.
  127802. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127803. * for example usage.
  127804. */
  127805. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127806. /**
  127807. * Defines the camera the input is attached to.
  127808. */
  127809. abstract camera: Camera;
  127810. /**
  127811. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127812. */
  127813. protected _altKey: boolean;
  127814. protected _ctrlKey: boolean;
  127815. protected _metaKey: boolean;
  127816. protected _shiftKey: boolean;
  127817. /**
  127818. * Which mouse buttons were pressed at time of last mouse event.
  127819. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127820. */
  127821. protected _buttonsPressed: number;
  127822. /**
  127823. * Defines the buttons associated with the input to handle camera move.
  127824. */
  127825. buttons: number[];
  127826. /**
  127827. * Attach the input controls to a specific dom element to get the input from.
  127828. * @param element Defines the element the controls should be listened from
  127829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127830. */
  127831. attachControl(noPreventDefault?: boolean): void;
  127832. /**
  127833. * Detach the current controls from the specified dom element.
  127834. */
  127835. detachControl(): void;
  127836. /**
  127837. * Gets the class name of the current input.
  127838. * @returns the class name
  127839. */
  127840. getClassName(): string;
  127841. /**
  127842. * Get the friendly name associated with the input class.
  127843. * @returns the input friendly name
  127844. */
  127845. getSimpleName(): string;
  127846. /**
  127847. * Called on pointer POINTERDOUBLETAP event.
  127848. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127849. */
  127850. protected onDoubleTap(type: string): void;
  127851. /**
  127852. * Called on pointer POINTERMOVE event if only a single touch is active.
  127853. * Override this method to provide functionality.
  127854. */
  127855. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127856. /**
  127857. * Called on pointer POINTERMOVE event if multiple touches are active.
  127858. * Override this method to provide functionality.
  127859. */
  127860. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127861. /**
  127862. * Called on JS contextmenu event.
  127863. * Override this method to provide functionality.
  127864. */
  127865. protected onContextMenu(evt: PointerEvent): void;
  127866. /**
  127867. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127868. * press.
  127869. * Override this method to provide functionality.
  127870. */
  127871. protected onButtonDown(evt: PointerEvent): void;
  127872. /**
  127873. * Called each time a new POINTERUP event occurs. Ie, for each button
  127874. * release.
  127875. * Override this method to provide functionality.
  127876. */
  127877. protected onButtonUp(evt: PointerEvent): void;
  127878. /**
  127879. * Called when window becomes inactive.
  127880. * Override this method to provide functionality.
  127881. */
  127882. protected onLostFocus(): void;
  127883. private _pointerInput;
  127884. private _observer;
  127885. private _onLostFocus;
  127886. private pointA;
  127887. private pointB;
  127888. }
  127889. }
  127890. declare module BABYLON {
  127891. /**
  127892. * Manage the pointers inputs to control an arc rotate camera.
  127893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127894. */
  127895. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127896. /**
  127897. * Defines the camera the input is attached to.
  127898. */
  127899. camera: ArcRotateCamera;
  127900. /**
  127901. * Gets the class name of the current input.
  127902. * @returns the class name
  127903. */
  127904. getClassName(): string;
  127905. /**
  127906. * Defines the buttons associated with the input to handle camera move.
  127907. */
  127908. buttons: number[];
  127909. /**
  127910. * Defines the pointer angular sensibility along the X axis or how fast is
  127911. * the camera rotating.
  127912. */
  127913. angularSensibilityX: number;
  127914. /**
  127915. * Defines the pointer angular sensibility along the Y axis or how fast is
  127916. * the camera rotating.
  127917. */
  127918. angularSensibilityY: number;
  127919. /**
  127920. * Defines the pointer pinch precision or how fast is the camera zooming.
  127921. */
  127922. pinchPrecision: number;
  127923. /**
  127924. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127925. * from 0.
  127926. * It defines the percentage of current camera.radius to use as delta when
  127927. * pinch zoom is used.
  127928. */
  127929. pinchDeltaPercentage: number;
  127930. /**
  127931. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127932. * that any object in the plane at the camera's target point will scale
  127933. * perfectly with finger motion.
  127934. * Overrides pinchDeltaPercentage and pinchPrecision.
  127935. */
  127936. useNaturalPinchZoom: boolean;
  127937. /**
  127938. * Defines the pointer panning sensibility or how fast is the camera moving.
  127939. */
  127940. panningSensibility: number;
  127941. /**
  127942. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127943. */
  127944. multiTouchPanning: boolean;
  127945. /**
  127946. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127947. * zoom (pinch) through multitouch.
  127948. */
  127949. multiTouchPanAndZoom: boolean;
  127950. /**
  127951. * Revers pinch action direction.
  127952. */
  127953. pinchInwards: boolean;
  127954. private _isPanClick;
  127955. private _twoFingerActivityCount;
  127956. private _isPinching;
  127957. /**
  127958. * Called on pointer POINTERMOVE event if only a single touch is active.
  127959. */
  127960. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127961. /**
  127962. * Called on pointer POINTERDOUBLETAP event.
  127963. */
  127964. protected onDoubleTap(type: string): void;
  127965. /**
  127966. * Called on pointer POINTERMOVE event if multiple touches are active.
  127967. */
  127968. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127969. /**
  127970. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127971. * press.
  127972. */
  127973. protected onButtonDown(evt: PointerEvent): void;
  127974. /**
  127975. * Called each time a new POINTERUP event occurs. Ie, for each button
  127976. * release.
  127977. */
  127978. protected onButtonUp(evt: PointerEvent): void;
  127979. /**
  127980. * Called when window becomes inactive.
  127981. */
  127982. protected onLostFocus(): void;
  127983. }
  127984. }
  127985. declare module BABYLON {
  127986. /**
  127987. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127988. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127989. */
  127990. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127991. /**
  127992. * Defines the camera the input is attached to.
  127993. */
  127994. camera: ArcRotateCamera;
  127995. /**
  127996. * Defines the list of key codes associated with the up action (increase alpha)
  127997. */
  127998. keysUp: number[];
  127999. /**
  128000. * Defines the list of key codes associated with the down action (decrease alpha)
  128001. */
  128002. keysDown: number[];
  128003. /**
  128004. * Defines the list of key codes associated with the left action (increase beta)
  128005. */
  128006. keysLeft: number[];
  128007. /**
  128008. * Defines the list of key codes associated with the right action (decrease beta)
  128009. */
  128010. keysRight: number[];
  128011. /**
  128012. * Defines the list of key codes associated with the reset action.
  128013. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  128014. */
  128015. keysReset: number[];
  128016. /**
  128017. * Defines the panning sensibility of the inputs.
  128018. * (How fast is the camera panning)
  128019. */
  128020. panningSensibility: number;
  128021. /**
  128022. * Defines the zooming sensibility of the inputs.
  128023. * (How fast is the camera zooming)
  128024. */
  128025. zoomingSensibility: number;
  128026. /**
  128027. * Defines whether maintaining the alt key down switch the movement mode from
  128028. * orientation to zoom.
  128029. */
  128030. useAltToZoom: boolean;
  128031. /**
  128032. * Rotation speed of the camera
  128033. */
  128034. angularSpeed: number;
  128035. private _keys;
  128036. private _ctrlPressed;
  128037. private _altPressed;
  128038. private _onCanvasBlurObserver;
  128039. private _onKeyboardObserver;
  128040. private _engine;
  128041. private _scene;
  128042. /**
  128043. * Attach the input controls to a specific dom element to get the input from.
  128044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128045. */
  128046. attachControl(noPreventDefault?: boolean): void;
  128047. /**
  128048. * Detach the current controls from the specified dom element.
  128049. */
  128050. detachControl(): void;
  128051. /**
  128052. * Update the current camera state depending on the inputs that have been used this frame.
  128053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128054. */
  128055. checkInputs(): void;
  128056. /**
  128057. * Gets the class name of the current intput.
  128058. * @returns the class name
  128059. */
  128060. getClassName(): string;
  128061. /**
  128062. * Get the friendly name associated with the input class.
  128063. * @returns the input friendly name
  128064. */
  128065. getSimpleName(): string;
  128066. }
  128067. }
  128068. declare module BABYLON {
  128069. /**
  128070. * Manage the mouse wheel inputs to control an arc rotate camera.
  128071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128072. */
  128073. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  128074. /**
  128075. * Defines the camera the input is attached to.
  128076. */
  128077. camera: ArcRotateCamera;
  128078. /**
  128079. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128080. */
  128081. wheelPrecision: number;
  128082. /**
  128083. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128084. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128085. */
  128086. wheelDeltaPercentage: number;
  128087. private _wheel;
  128088. private _observer;
  128089. private computeDeltaFromMouseWheelLegacyEvent;
  128090. /**
  128091. * Attach the input controls to a specific dom element to get the input from.
  128092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128093. */
  128094. attachControl(noPreventDefault?: boolean): void;
  128095. /**
  128096. * Detach the current controls from the specified dom element.
  128097. */
  128098. detachControl(): void;
  128099. /**
  128100. * Gets the class name of the current intput.
  128101. * @returns the class name
  128102. */
  128103. getClassName(): string;
  128104. /**
  128105. * Get the friendly name associated with the input class.
  128106. * @returns the input friendly name
  128107. */
  128108. getSimpleName(): string;
  128109. }
  128110. }
  128111. declare module BABYLON {
  128112. /**
  128113. * Default Inputs manager for the ArcRotateCamera.
  128114. * It groups all the default supported inputs for ease of use.
  128115. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128116. */
  128117. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  128118. /**
  128119. * Instantiates a new ArcRotateCameraInputsManager.
  128120. * @param camera Defines the camera the inputs belong to
  128121. */
  128122. constructor(camera: ArcRotateCamera);
  128123. /**
  128124. * Add mouse wheel input support to the input manager.
  128125. * @returns the current input manager
  128126. */
  128127. addMouseWheel(): ArcRotateCameraInputsManager;
  128128. /**
  128129. * Add pointers input support to the input manager.
  128130. * @returns the current input manager
  128131. */
  128132. addPointers(): ArcRotateCameraInputsManager;
  128133. /**
  128134. * Add keyboard input support to the input manager.
  128135. * @returns the current input manager
  128136. */
  128137. addKeyboard(): ArcRotateCameraInputsManager;
  128138. }
  128139. }
  128140. declare module BABYLON {
  128141. /**
  128142. * This represents an orbital type of camera.
  128143. *
  128144. * 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.
  128145. * 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.
  128146. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  128147. */
  128148. export class ArcRotateCamera extends TargetCamera {
  128149. /**
  128150. * Defines the rotation angle of the camera along the longitudinal axis.
  128151. */
  128152. alpha: number;
  128153. /**
  128154. * Defines the rotation angle of the camera along the latitudinal axis.
  128155. */
  128156. beta: number;
  128157. /**
  128158. * Defines the radius of the camera from it s target point.
  128159. */
  128160. radius: number;
  128161. protected _target: Vector3;
  128162. protected _targetHost: Nullable<AbstractMesh>;
  128163. /**
  128164. * Defines the target point of the camera.
  128165. * The camera looks towards it form the radius distance.
  128166. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  128167. */
  128168. get target(): Vector3;
  128169. set target(value: Vector3);
  128170. /**
  128171. * Define the current local position of the camera in the scene
  128172. */
  128173. get position(): Vector3;
  128174. set position(newPosition: Vector3);
  128175. protected _upToYMatrix: Matrix;
  128176. protected _YToUpMatrix: Matrix;
  128177. /**
  128178. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  128179. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  128180. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  128181. */
  128182. set upVector(vec: Vector3);
  128183. get upVector(): Vector3;
  128184. /**
  128185. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  128186. */
  128187. setMatUp(): void;
  128188. /**
  128189. * Current inertia value on the longitudinal axis.
  128190. * The bigger this number the longer it will take for the camera to stop.
  128191. */
  128192. inertialAlphaOffset: number;
  128193. /**
  128194. * Current inertia value on the latitudinal axis.
  128195. * The bigger this number the longer it will take for the camera to stop.
  128196. */
  128197. inertialBetaOffset: number;
  128198. /**
  128199. * Current inertia value on the radius axis.
  128200. * The bigger this number the longer it will take for the camera to stop.
  128201. */
  128202. inertialRadiusOffset: number;
  128203. /**
  128204. * Minimum allowed angle on the longitudinal axis.
  128205. * This can help limiting how the Camera is able to move in the scene.
  128206. */
  128207. lowerAlphaLimit: Nullable<number>;
  128208. /**
  128209. * Maximum allowed angle on the longitudinal axis.
  128210. * This can help limiting how the Camera is able to move in the scene.
  128211. */
  128212. upperAlphaLimit: Nullable<number>;
  128213. /**
  128214. * Minimum allowed angle on the latitudinal axis.
  128215. * This can help limiting how the Camera is able to move in the scene.
  128216. */
  128217. lowerBetaLimit: number;
  128218. /**
  128219. * Maximum allowed angle on the latitudinal axis.
  128220. * This can help limiting how the Camera is able to move in the scene.
  128221. */
  128222. upperBetaLimit: number;
  128223. /**
  128224. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  128225. * This can help limiting how the Camera is able to move in the scene.
  128226. */
  128227. lowerRadiusLimit: Nullable<number>;
  128228. /**
  128229. * Maximum allowed distance of the camera to the target (The camera can not get further).
  128230. * This can help limiting how the Camera is able to move in the scene.
  128231. */
  128232. upperRadiusLimit: Nullable<number>;
  128233. /**
  128234. * Defines the current inertia value used during panning of the camera along the X axis.
  128235. */
  128236. inertialPanningX: number;
  128237. /**
  128238. * Defines the current inertia value used during panning of the camera along the Y axis.
  128239. */
  128240. inertialPanningY: number;
  128241. /**
  128242. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  128243. * Basically if your fingers moves away from more than this distance you will be considered
  128244. * in pinch mode.
  128245. */
  128246. pinchToPanMaxDistance: number;
  128247. /**
  128248. * Defines the maximum distance the camera can pan.
  128249. * This could help keeping the cammera always in your scene.
  128250. */
  128251. panningDistanceLimit: Nullable<number>;
  128252. /**
  128253. * Defines the target of the camera before paning.
  128254. */
  128255. panningOriginTarget: Vector3;
  128256. /**
  128257. * Defines the value of the inertia used during panning.
  128258. * 0 would mean stop inertia and one would mean no decelleration at all.
  128259. */
  128260. panningInertia: number;
  128261. /**
  128262. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  128263. */
  128264. get angularSensibilityX(): number;
  128265. set angularSensibilityX(value: number);
  128266. /**
  128267. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  128268. */
  128269. get angularSensibilityY(): number;
  128270. set angularSensibilityY(value: number);
  128271. /**
  128272. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  128273. */
  128274. get pinchPrecision(): number;
  128275. set pinchPrecision(value: number);
  128276. /**
  128277. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  128278. * It will be used instead of pinchDeltaPrecision if different from 0.
  128279. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128280. */
  128281. get pinchDeltaPercentage(): number;
  128282. set pinchDeltaPercentage(value: number);
  128283. /**
  128284. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128285. * and pinch delta percentage.
  128286. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128287. * that any object in the plane at the camera's target point will scale
  128288. * perfectly with finger motion.
  128289. */
  128290. get useNaturalPinchZoom(): boolean;
  128291. set useNaturalPinchZoom(value: boolean);
  128292. /**
  128293. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128294. */
  128295. get panningSensibility(): number;
  128296. set panningSensibility(value: number);
  128297. /**
  128298. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128299. */
  128300. get keysUp(): number[];
  128301. set keysUp(value: number[]);
  128302. /**
  128303. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128304. */
  128305. get keysDown(): number[];
  128306. set keysDown(value: number[]);
  128307. /**
  128308. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128309. */
  128310. get keysLeft(): number[];
  128311. set keysLeft(value: number[]);
  128312. /**
  128313. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128314. */
  128315. get keysRight(): number[];
  128316. set keysRight(value: number[]);
  128317. /**
  128318. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128319. */
  128320. get wheelPrecision(): number;
  128321. set wheelPrecision(value: number);
  128322. /**
  128323. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128324. * It will be used instead of pinchDeltaPrecision if different from 0.
  128325. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128326. */
  128327. get wheelDeltaPercentage(): number;
  128328. set wheelDeltaPercentage(value: number);
  128329. /**
  128330. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128331. */
  128332. zoomOnFactor: number;
  128333. /**
  128334. * Defines a screen offset for the camera position.
  128335. */
  128336. targetScreenOffset: Vector2;
  128337. /**
  128338. * Allows the camera to be completely reversed.
  128339. * If false the camera can not arrive upside down.
  128340. */
  128341. allowUpsideDown: boolean;
  128342. /**
  128343. * Define if double tap/click is used to restore the previously saved state of the camera.
  128344. */
  128345. useInputToRestoreState: boolean;
  128346. /** @hidden */
  128347. _viewMatrix: Matrix;
  128348. /** @hidden */
  128349. _useCtrlForPanning: boolean;
  128350. /** @hidden */
  128351. _panningMouseButton: number;
  128352. /**
  128353. * Defines the input associated to the camera.
  128354. */
  128355. inputs: ArcRotateCameraInputsManager;
  128356. /** @hidden */
  128357. _reset: () => void;
  128358. /**
  128359. * Defines the allowed panning axis.
  128360. */
  128361. panningAxis: Vector3;
  128362. protected _localDirection: Vector3;
  128363. protected _transformedDirection: Vector3;
  128364. private _bouncingBehavior;
  128365. /**
  128366. * Gets the bouncing behavior of the camera if it has been enabled.
  128367. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128368. */
  128369. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128370. /**
  128371. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128372. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128373. */
  128374. get useBouncingBehavior(): boolean;
  128375. set useBouncingBehavior(value: boolean);
  128376. private _framingBehavior;
  128377. /**
  128378. * Gets the framing behavior of the camera if it has been enabled.
  128379. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128380. */
  128381. get framingBehavior(): Nullable<FramingBehavior>;
  128382. /**
  128383. * Defines if the framing behavior of the camera is enabled on the camera.
  128384. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128385. */
  128386. get useFramingBehavior(): boolean;
  128387. set useFramingBehavior(value: boolean);
  128388. private _autoRotationBehavior;
  128389. /**
  128390. * Gets the auto rotation behavior of the camera if it has been enabled.
  128391. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128392. */
  128393. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128394. /**
  128395. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128396. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128397. */
  128398. get useAutoRotationBehavior(): boolean;
  128399. set useAutoRotationBehavior(value: boolean);
  128400. /**
  128401. * Observable triggered when the mesh target has been changed on the camera.
  128402. */
  128403. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128404. /**
  128405. * Event raised when the camera is colliding with a mesh.
  128406. */
  128407. onCollide: (collidedMesh: AbstractMesh) => void;
  128408. /**
  128409. * Defines whether the camera should check collision with the objects oh the scene.
  128410. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128411. */
  128412. checkCollisions: boolean;
  128413. /**
  128414. * Defines the collision radius of the camera.
  128415. * This simulates a sphere around the camera.
  128416. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128417. */
  128418. collisionRadius: Vector3;
  128419. protected _collider: Collider;
  128420. protected _previousPosition: Vector3;
  128421. protected _collisionVelocity: Vector3;
  128422. protected _newPosition: Vector3;
  128423. protected _previousAlpha: number;
  128424. protected _previousBeta: number;
  128425. protected _previousRadius: number;
  128426. protected _collisionTriggered: boolean;
  128427. protected _targetBoundingCenter: Nullable<Vector3>;
  128428. private _computationVector;
  128429. /**
  128430. * Instantiates a new ArcRotateCamera in a given scene
  128431. * @param name Defines the name of the camera
  128432. * @param alpha Defines the camera rotation along the logitudinal axis
  128433. * @param beta Defines the camera rotation along the latitudinal axis
  128434. * @param radius Defines the camera distance from its target
  128435. * @param target Defines the camera target
  128436. * @param scene Defines the scene the camera belongs to
  128437. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128438. */
  128439. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128440. /** @hidden */
  128441. _initCache(): void;
  128442. /** @hidden */
  128443. _updateCache(ignoreParentClass?: boolean): void;
  128444. protected _getTargetPosition(): Vector3;
  128445. private _storedAlpha;
  128446. private _storedBeta;
  128447. private _storedRadius;
  128448. private _storedTarget;
  128449. private _storedTargetScreenOffset;
  128450. /**
  128451. * Stores the current state of the camera (alpha, beta, radius and target)
  128452. * @returns the camera itself
  128453. */
  128454. storeState(): Camera;
  128455. /**
  128456. * @hidden
  128457. * Restored camera state. You must call storeState() first
  128458. */
  128459. _restoreStateValues(): boolean;
  128460. /** @hidden */
  128461. _isSynchronizedViewMatrix(): boolean;
  128462. /**
  128463. * Attach the input controls to a specific dom element to get the input from.
  128464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128465. */
  128466. attachControl(noPreventDefault?: boolean): void;
  128467. /**
  128468. * Attach the input controls to a specific dom element to get the input from.
  128469. * @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
  128470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128471. */
  128472. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128473. /**
  128474. * Attached controls to the current camera.
  128475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128476. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128477. */
  128478. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128479. /**
  128480. * Attached controls to the current camera.
  128481. * @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
  128482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128483. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128484. */
  128485. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128486. /**
  128487. * Attached controls to the current camera.
  128488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128489. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128490. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128491. */
  128492. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128493. /**
  128494. * Detach the current controls from the specified dom element.
  128495. */
  128496. detachControl(): void;
  128497. /**
  128498. * Detach the current controls from the specified dom element.
  128499. * @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
  128500. */
  128501. detachControl(ignored: any): void;
  128502. /** @hidden */
  128503. _checkInputs(): void;
  128504. protected _checkLimits(): void;
  128505. /**
  128506. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128507. */
  128508. rebuildAnglesAndRadius(): void;
  128509. /**
  128510. * Use a position to define the current camera related information like alpha, beta and radius
  128511. * @param position Defines the position to set the camera at
  128512. */
  128513. setPosition(position: Vector3): void;
  128514. /**
  128515. * Defines the target the camera should look at.
  128516. * This will automatically adapt alpha beta and radius to fit within the new target.
  128517. * @param target Defines the new target as a Vector or a mesh
  128518. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128519. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128520. */
  128521. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128522. /** @hidden */
  128523. _getViewMatrix(): Matrix;
  128524. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128525. /**
  128526. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128527. * @param meshes Defines the mesh to zoom on
  128528. * @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)
  128529. */
  128530. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128531. /**
  128532. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128533. * The target will be changed but the radius
  128534. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128535. * @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)
  128536. */
  128537. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128538. min: Vector3;
  128539. max: Vector3;
  128540. distance: number;
  128541. }, doNotUpdateMaxZ?: boolean): void;
  128542. /**
  128543. * @override
  128544. * Override Camera.createRigCamera
  128545. */
  128546. createRigCamera(name: string, cameraIndex: number): Camera;
  128547. /**
  128548. * @hidden
  128549. * @override
  128550. * Override Camera._updateRigCameras
  128551. */
  128552. _updateRigCameras(): void;
  128553. /**
  128554. * Destroy the camera and release the current resources hold by it.
  128555. */
  128556. dispose(): void;
  128557. /**
  128558. * Gets the current object class name.
  128559. * @return the class name
  128560. */
  128561. getClassName(): string;
  128562. }
  128563. }
  128564. declare module BABYLON {
  128565. /**
  128566. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128567. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128568. */
  128569. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128570. /**
  128571. * Gets the name of the behavior.
  128572. */
  128573. get name(): string;
  128574. private _zoomStopsAnimation;
  128575. private _idleRotationSpeed;
  128576. private _idleRotationWaitTime;
  128577. private _idleRotationSpinupTime;
  128578. /**
  128579. * Sets the flag that indicates if user zooming should stop animation.
  128580. */
  128581. set zoomStopsAnimation(flag: boolean);
  128582. /**
  128583. * Gets the flag that indicates if user zooming should stop animation.
  128584. */
  128585. get zoomStopsAnimation(): boolean;
  128586. /**
  128587. * Sets the default speed at which the camera rotates around the model.
  128588. */
  128589. set idleRotationSpeed(speed: number);
  128590. /**
  128591. * Gets the default speed at which the camera rotates around the model.
  128592. */
  128593. get idleRotationSpeed(): number;
  128594. /**
  128595. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128596. */
  128597. set idleRotationWaitTime(time: number);
  128598. /**
  128599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128600. */
  128601. get idleRotationWaitTime(): number;
  128602. /**
  128603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128604. */
  128605. set idleRotationSpinupTime(time: number);
  128606. /**
  128607. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128608. */
  128609. get idleRotationSpinupTime(): number;
  128610. /**
  128611. * Gets a value indicating if the camera is currently rotating because of this behavior
  128612. */
  128613. get rotationInProgress(): boolean;
  128614. private _onPrePointerObservableObserver;
  128615. private _onAfterCheckInputsObserver;
  128616. private _attachedCamera;
  128617. private _isPointerDown;
  128618. private _lastFrameTime;
  128619. private _lastInteractionTime;
  128620. private _cameraRotationSpeed;
  128621. /**
  128622. * Initializes the behavior.
  128623. */
  128624. init(): void;
  128625. /**
  128626. * Attaches the behavior to its arc rotate camera.
  128627. * @param camera Defines the camera to attach the behavior to
  128628. */
  128629. attach(camera: ArcRotateCamera): void;
  128630. /**
  128631. * Detaches the behavior from its current arc rotate camera.
  128632. */
  128633. detach(): void;
  128634. /**
  128635. * Returns true if user is scrolling.
  128636. * @return true if user is scrolling.
  128637. */
  128638. private _userIsZooming;
  128639. private _lastFrameRadius;
  128640. private _shouldAnimationStopForInteraction;
  128641. /**
  128642. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128643. */
  128644. private _applyUserInteraction;
  128645. private _userIsMoving;
  128646. }
  128647. }
  128648. declare module BABYLON {
  128649. /**
  128650. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128651. */
  128652. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128653. private ui;
  128654. /**
  128655. * The name of the behavior
  128656. */
  128657. name: string;
  128658. /**
  128659. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128660. */
  128661. distanceAwayFromFace: number;
  128662. /**
  128663. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128664. */
  128665. distanceAwayFromBottomOfFace: number;
  128666. private _faceVectors;
  128667. private _target;
  128668. private _scene;
  128669. private _onRenderObserver;
  128670. private _tmpMatrix;
  128671. private _tmpVector;
  128672. /**
  128673. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128674. * @param ui The transform node that should be attched to the mesh
  128675. */
  128676. constructor(ui: TransformNode);
  128677. /**
  128678. * Initializes the behavior
  128679. */
  128680. init(): void;
  128681. private _closestFace;
  128682. private _zeroVector;
  128683. private _lookAtTmpMatrix;
  128684. private _lookAtToRef;
  128685. /**
  128686. * Attaches the AttachToBoxBehavior to the passed in mesh
  128687. * @param target The mesh that the specified node will be attached to
  128688. */
  128689. attach(target: Mesh): void;
  128690. /**
  128691. * Detaches the behavior from the mesh
  128692. */
  128693. detach(): void;
  128694. }
  128695. }
  128696. declare module BABYLON {
  128697. /**
  128698. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128699. */
  128700. export class FadeInOutBehavior implements Behavior<Mesh> {
  128701. /**
  128702. * Time in milliseconds to delay before fading in (Default: 0)
  128703. */
  128704. delay: number;
  128705. /**
  128706. * Time in milliseconds for the mesh to fade in (Default: 300)
  128707. */
  128708. fadeInTime: number;
  128709. private _millisecondsPerFrame;
  128710. private _hovered;
  128711. private _hoverValue;
  128712. private _ownerNode;
  128713. /**
  128714. * Instatiates the FadeInOutBehavior
  128715. */
  128716. constructor();
  128717. /**
  128718. * The name of the behavior
  128719. */
  128720. get name(): string;
  128721. /**
  128722. * Initializes the behavior
  128723. */
  128724. init(): void;
  128725. /**
  128726. * Attaches the fade behavior on the passed in mesh
  128727. * @param ownerNode The mesh that will be faded in/out once attached
  128728. */
  128729. attach(ownerNode: Mesh): void;
  128730. /**
  128731. * Detaches the behavior from the mesh
  128732. */
  128733. detach(): void;
  128734. /**
  128735. * Triggers the mesh to begin fading in or out
  128736. * @param value if the object should fade in or out (true to fade in)
  128737. */
  128738. fadeIn(value: boolean): void;
  128739. private _update;
  128740. private _setAllVisibility;
  128741. }
  128742. }
  128743. declare module BABYLON {
  128744. /**
  128745. * Class containing a set of static utilities functions for managing Pivots
  128746. * @hidden
  128747. */
  128748. export class PivotTools {
  128749. private static _PivotCached;
  128750. private static _OldPivotPoint;
  128751. private static _PivotTranslation;
  128752. private static _PivotTmpVector;
  128753. private static _PivotPostMultiplyPivotMatrix;
  128754. /** @hidden */
  128755. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128756. /** @hidden */
  128757. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * Class containing static functions to help procedurally build meshes
  128763. */
  128764. export class PlaneBuilder {
  128765. /**
  128766. * Creates a plane mesh
  128767. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128768. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128769. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128773. * @param name defines the name of the mesh
  128774. * @param options defines the options used to create the mesh
  128775. * @param scene defines the hosting scene
  128776. * @returns the plane mesh
  128777. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128778. */
  128779. static CreatePlane(name: string, options: {
  128780. size?: number;
  128781. width?: number;
  128782. height?: number;
  128783. sideOrientation?: number;
  128784. frontUVs?: Vector4;
  128785. backUVs?: Vector4;
  128786. updatable?: boolean;
  128787. sourcePlane?: Plane;
  128788. }, scene?: Nullable<Scene>): Mesh;
  128789. }
  128790. }
  128791. declare module BABYLON {
  128792. /**
  128793. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128794. */
  128795. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128796. private static _AnyMouseID;
  128797. /**
  128798. * Abstract mesh the behavior is set on
  128799. */
  128800. attachedNode: AbstractMesh;
  128801. private _dragPlane;
  128802. private _scene;
  128803. private _pointerObserver;
  128804. private _beforeRenderObserver;
  128805. private static _planeScene;
  128806. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128807. /**
  128808. * 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)
  128809. */
  128810. maxDragAngle: number;
  128811. /**
  128812. * @hidden
  128813. */
  128814. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128815. /**
  128816. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128817. */
  128818. currentDraggingPointerID: number;
  128819. /**
  128820. * The last position where the pointer hit the drag plane in world space
  128821. */
  128822. lastDragPosition: Vector3;
  128823. /**
  128824. * If the behavior is currently in a dragging state
  128825. */
  128826. dragging: boolean;
  128827. /**
  128828. * 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)
  128829. */
  128830. dragDeltaRatio: number;
  128831. /**
  128832. * If the drag plane orientation should be updated during the dragging (Default: true)
  128833. */
  128834. updateDragPlane: boolean;
  128835. private _debugMode;
  128836. private _moving;
  128837. /**
  128838. * Fires each time the attached mesh is dragged with the pointer
  128839. * * delta between last drag position and current drag position in world space
  128840. * * dragDistance along the drag axis
  128841. * * dragPlaneNormal normal of the current drag plane used during the drag
  128842. * * dragPlanePoint in world space where the drag intersects the drag plane
  128843. */
  128844. onDragObservable: Observable<{
  128845. delta: Vector3;
  128846. dragPlanePoint: Vector3;
  128847. dragPlaneNormal: Vector3;
  128848. dragDistance: number;
  128849. pointerId: number;
  128850. }>;
  128851. /**
  128852. * Fires each time a drag begins (eg. mouse down on mesh)
  128853. */
  128854. onDragStartObservable: Observable<{
  128855. dragPlanePoint: Vector3;
  128856. pointerId: number;
  128857. }>;
  128858. /**
  128859. * Fires each time a drag ends (eg. mouse release after drag)
  128860. */
  128861. onDragEndObservable: Observable<{
  128862. dragPlanePoint: Vector3;
  128863. pointerId: number;
  128864. }>;
  128865. /**
  128866. * If the attached mesh should be moved when dragged
  128867. */
  128868. moveAttached: boolean;
  128869. /**
  128870. * If the drag behavior will react to drag events (Default: true)
  128871. */
  128872. enabled: boolean;
  128873. /**
  128874. * If pointer events should start and release the drag (Default: true)
  128875. */
  128876. startAndReleaseDragOnPointerEvents: boolean;
  128877. /**
  128878. * If camera controls should be detached during the drag
  128879. */
  128880. detachCameraControls: boolean;
  128881. /**
  128882. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128883. */
  128884. useObjectOrientationForDragging: boolean;
  128885. private _options;
  128886. /**
  128887. * Gets the options used by the behavior
  128888. */
  128889. get options(): {
  128890. dragAxis?: Vector3;
  128891. dragPlaneNormal?: Vector3;
  128892. };
  128893. /**
  128894. * Sets the options used by the behavior
  128895. */
  128896. set options(options: {
  128897. dragAxis?: Vector3;
  128898. dragPlaneNormal?: Vector3;
  128899. });
  128900. /**
  128901. * Creates a pointer drag behavior that can be attached to a mesh
  128902. * @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)
  128903. */
  128904. constructor(options?: {
  128905. dragAxis?: Vector3;
  128906. dragPlaneNormal?: Vector3;
  128907. });
  128908. /**
  128909. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128910. */
  128911. validateDrag: (targetPosition: Vector3) => boolean;
  128912. /**
  128913. * The name of the behavior
  128914. */
  128915. get name(): string;
  128916. /**
  128917. * Initializes the behavior
  128918. */
  128919. init(): void;
  128920. private _tmpVector;
  128921. private _alternatePickedPoint;
  128922. private _worldDragAxis;
  128923. private _targetPosition;
  128924. private _attachedToElement;
  128925. /**
  128926. * Attaches the drag behavior the passed in mesh
  128927. * @param ownerNode The mesh that will be dragged around once attached
  128928. * @param predicate Predicate to use for pick filtering
  128929. */
  128930. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128931. /**
  128932. * Force relase the drag action by code.
  128933. */
  128934. releaseDrag(): void;
  128935. private _startDragRay;
  128936. private _lastPointerRay;
  128937. /**
  128938. * Simulates the start of a pointer drag event on the behavior
  128939. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128940. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128941. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128942. */
  128943. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128944. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128945. private _dragDelta;
  128946. protected _moveDrag(ray: Ray): void;
  128947. private _pickWithRayOnDragPlane;
  128948. private _pointA;
  128949. private _pointC;
  128950. private _localAxis;
  128951. private _lookAt;
  128952. private _updateDragPlanePosition;
  128953. /**
  128954. * Detaches the behavior from the mesh
  128955. */
  128956. detach(): void;
  128957. }
  128958. }
  128959. declare module BABYLON {
  128960. /**
  128961. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128962. */
  128963. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128964. private _dragBehaviorA;
  128965. private _dragBehaviorB;
  128966. private _startDistance;
  128967. private _initialScale;
  128968. private _targetScale;
  128969. private _ownerNode;
  128970. private _sceneRenderObserver;
  128971. /**
  128972. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128973. */
  128974. constructor();
  128975. /**
  128976. * The name of the behavior
  128977. */
  128978. get name(): string;
  128979. /**
  128980. * Initializes the behavior
  128981. */
  128982. init(): void;
  128983. private _getCurrentDistance;
  128984. /**
  128985. * Attaches the scale behavior the passed in mesh
  128986. * @param ownerNode The mesh that will be scaled around once attached
  128987. */
  128988. attach(ownerNode: Mesh): void;
  128989. /**
  128990. * Detaches the behavior from the mesh
  128991. */
  128992. detach(): void;
  128993. }
  128994. }
  128995. declare module BABYLON {
  128996. /**
  128997. * 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
  128998. */
  128999. export class SixDofDragBehavior implements Behavior<Mesh> {
  129000. private static _virtualScene;
  129001. private _ownerNode;
  129002. private _sceneRenderObserver;
  129003. private _scene;
  129004. private _targetPosition;
  129005. private _virtualOriginMesh;
  129006. private _virtualDragMesh;
  129007. private _pointerObserver;
  129008. private _moving;
  129009. private _startingOrientation;
  129010. private _attachedToElement;
  129011. /**
  129012. * 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)
  129013. */
  129014. private zDragFactor;
  129015. /**
  129016. * If the object should rotate to face the drag origin
  129017. */
  129018. rotateDraggedObject: boolean;
  129019. /**
  129020. * If the behavior is currently in a dragging state
  129021. */
  129022. dragging: boolean;
  129023. /**
  129024. * 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)
  129025. */
  129026. dragDeltaRatio: number;
  129027. /**
  129028. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  129029. */
  129030. currentDraggingPointerID: number;
  129031. /**
  129032. * If camera controls should be detached during the drag
  129033. */
  129034. detachCameraControls: boolean;
  129035. /**
  129036. * Fires each time a drag starts
  129037. */
  129038. onDragStartObservable: Observable<{}>;
  129039. /**
  129040. * Fires each time a drag happens
  129041. */
  129042. onDragObservable: Observable<void>;
  129043. /**
  129044. * Fires each time a drag ends (eg. mouse release after drag)
  129045. */
  129046. onDragEndObservable: Observable<{}>;
  129047. /**
  129048. * 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
  129049. */
  129050. constructor();
  129051. /**
  129052. * The name of the behavior
  129053. */
  129054. get name(): string;
  129055. /**
  129056. * Initializes the behavior
  129057. */
  129058. init(): void;
  129059. /**
  129060. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  129061. */
  129062. private get _pointerCamera();
  129063. /**
  129064. * Attaches the scale behavior the passed in mesh
  129065. * @param ownerNode The mesh that will be scaled around once attached
  129066. */
  129067. attach(ownerNode: Mesh): void;
  129068. /**
  129069. * Detaches the behavior from the mesh
  129070. */
  129071. detach(): void;
  129072. }
  129073. }
  129074. declare module BABYLON {
  129075. /**
  129076. * Class used to apply inverse kinematics to bones
  129077. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  129078. */
  129079. export class BoneIKController {
  129080. private static _tmpVecs;
  129081. private static _tmpQuat;
  129082. private static _tmpMats;
  129083. /**
  129084. * Gets or sets the target mesh
  129085. */
  129086. targetMesh: AbstractMesh;
  129087. /** Gets or sets the mesh used as pole */
  129088. poleTargetMesh: AbstractMesh;
  129089. /**
  129090. * Gets or sets the bone used as pole
  129091. */
  129092. poleTargetBone: Nullable<Bone>;
  129093. /**
  129094. * Gets or sets the target position
  129095. */
  129096. targetPosition: Vector3;
  129097. /**
  129098. * Gets or sets the pole target position
  129099. */
  129100. poleTargetPosition: Vector3;
  129101. /**
  129102. * Gets or sets the pole target local offset
  129103. */
  129104. poleTargetLocalOffset: Vector3;
  129105. /**
  129106. * Gets or sets the pole angle
  129107. */
  129108. poleAngle: number;
  129109. /**
  129110. * Gets or sets the mesh associated with the controller
  129111. */
  129112. mesh: AbstractMesh;
  129113. /**
  129114. * 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)
  129115. */
  129116. slerpAmount: number;
  129117. private _bone1Quat;
  129118. private _bone1Mat;
  129119. private _bone2Ang;
  129120. private _bone1;
  129121. private _bone2;
  129122. private _bone1Length;
  129123. private _bone2Length;
  129124. private _maxAngle;
  129125. private _maxReach;
  129126. private _rightHandedSystem;
  129127. private _bendAxis;
  129128. private _slerping;
  129129. private _adjustRoll;
  129130. /**
  129131. * Gets or sets maximum allowed angle
  129132. */
  129133. get maxAngle(): number;
  129134. set maxAngle(value: number);
  129135. /**
  129136. * Creates a new BoneIKController
  129137. * @param mesh defines the mesh to control
  129138. * @param bone defines the bone to control
  129139. * @param options defines options to set up the controller
  129140. */
  129141. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  129142. targetMesh?: AbstractMesh;
  129143. poleTargetMesh?: AbstractMesh;
  129144. poleTargetBone?: Bone;
  129145. poleTargetLocalOffset?: Vector3;
  129146. poleAngle?: number;
  129147. bendAxis?: Vector3;
  129148. maxAngle?: number;
  129149. slerpAmount?: number;
  129150. });
  129151. private _setMaxAngle;
  129152. /**
  129153. * Force the controller to update the bones
  129154. */
  129155. update(): void;
  129156. }
  129157. }
  129158. declare module BABYLON {
  129159. /**
  129160. * Class used to make a bone look toward a point in space
  129161. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  129162. */
  129163. export class BoneLookController {
  129164. private static _tmpVecs;
  129165. private static _tmpQuat;
  129166. private static _tmpMats;
  129167. /**
  129168. * The target Vector3 that the bone will look at
  129169. */
  129170. target: Vector3;
  129171. /**
  129172. * The mesh that the bone is attached to
  129173. */
  129174. mesh: AbstractMesh;
  129175. /**
  129176. * The bone that will be looking to the target
  129177. */
  129178. bone: Bone;
  129179. /**
  129180. * The up axis of the coordinate system that is used when the bone is rotated
  129181. */
  129182. upAxis: Vector3;
  129183. /**
  129184. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  129185. */
  129186. upAxisSpace: Space;
  129187. /**
  129188. * Used to make an adjustment to the yaw of the bone
  129189. */
  129190. adjustYaw: number;
  129191. /**
  129192. * Used to make an adjustment to the pitch of the bone
  129193. */
  129194. adjustPitch: number;
  129195. /**
  129196. * Used to make an adjustment to the roll of the bone
  129197. */
  129198. adjustRoll: number;
  129199. /**
  129200. * 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)
  129201. */
  129202. slerpAmount: number;
  129203. private _minYaw;
  129204. private _maxYaw;
  129205. private _minPitch;
  129206. private _maxPitch;
  129207. private _minYawSin;
  129208. private _minYawCos;
  129209. private _maxYawSin;
  129210. private _maxYawCos;
  129211. private _midYawConstraint;
  129212. private _minPitchTan;
  129213. private _maxPitchTan;
  129214. private _boneQuat;
  129215. private _slerping;
  129216. private _transformYawPitch;
  129217. private _transformYawPitchInv;
  129218. private _firstFrameSkipped;
  129219. private _yawRange;
  129220. private _fowardAxis;
  129221. /**
  129222. * Gets or sets the minimum yaw angle that the bone can look to
  129223. */
  129224. get minYaw(): number;
  129225. set minYaw(value: number);
  129226. /**
  129227. * Gets or sets the maximum yaw angle that the bone can look to
  129228. */
  129229. get maxYaw(): number;
  129230. set maxYaw(value: number);
  129231. /**
  129232. * Gets or sets the minimum pitch angle that the bone can look to
  129233. */
  129234. get minPitch(): number;
  129235. set minPitch(value: number);
  129236. /**
  129237. * Gets or sets the maximum pitch angle that the bone can look to
  129238. */
  129239. get maxPitch(): number;
  129240. set maxPitch(value: number);
  129241. /**
  129242. * Create a BoneLookController
  129243. * @param mesh the mesh that the bone belongs to
  129244. * @param bone the bone that will be looking to the target
  129245. * @param target the target Vector3 to look at
  129246. * @param options optional settings:
  129247. * * maxYaw: the maximum angle the bone will yaw to
  129248. * * minYaw: the minimum angle the bone will yaw to
  129249. * * maxPitch: the maximum angle the bone will pitch to
  129250. * * minPitch: the minimum angle the bone will yaw to
  129251. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  129252. * * upAxis: the up axis of the coordinate system
  129253. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  129254. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  129255. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  129256. * * adjustYaw: used to make an adjustment to the yaw of the bone
  129257. * * adjustPitch: used to make an adjustment to the pitch of the bone
  129258. * * adjustRoll: used to make an adjustment to the roll of the bone
  129259. **/
  129260. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  129261. maxYaw?: number;
  129262. minYaw?: number;
  129263. maxPitch?: number;
  129264. minPitch?: number;
  129265. slerpAmount?: number;
  129266. upAxis?: Vector3;
  129267. upAxisSpace?: Space;
  129268. yawAxis?: Vector3;
  129269. pitchAxis?: Vector3;
  129270. adjustYaw?: number;
  129271. adjustPitch?: number;
  129272. adjustRoll?: number;
  129273. });
  129274. /**
  129275. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  129276. */
  129277. update(): void;
  129278. private _getAngleDiff;
  129279. private _getAngleBetween;
  129280. private _isAngleBetween;
  129281. }
  129282. }
  129283. declare module BABYLON {
  129284. /**
  129285. * Manage the gamepad inputs to control an arc rotate camera.
  129286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129287. */
  129288. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129289. /**
  129290. * Defines the camera the input is attached to.
  129291. */
  129292. camera: ArcRotateCamera;
  129293. /**
  129294. * Defines the gamepad the input is gathering event from.
  129295. */
  129296. gamepad: Nullable<Gamepad>;
  129297. /**
  129298. * Defines the gamepad rotation sensiblity.
  129299. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129300. */
  129301. gamepadRotationSensibility: number;
  129302. /**
  129303. * Defines the gamepad move sensiblity.
  129304. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129305. */
  129306. gamepadMoveSensibility: number;
  129307. private _yAxisScale;
  129308. /**
  129309. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129310. */
  129311. get invertYAxis(): boolean;
  129312. set invertYAxis(value: boolean);
  129313. private _onGamepadConnectedObserver;
  129314. private _onGamepadDisconnectedObserver;
  129315. /**
  129316. * Attach the input controls to a specific dom element to get the input from.
  129317. */
  129318. attachControl(): void;
  129319. /**
  129320. * Detach the current controls from the specified dom element.
  129321. */
  129322. detachControl(): void;
  129323. /**
  129324. * Update the current camera state depending on the inputs that have been used this frame.
  129325. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129326. */
  129327. checkInputs(): void;
  129328. /**
  129329. * Gets the class name of the current intput.
  129330. * @returns the class name
  129331. */
  129332. getClassName(): string;
  129333. /**
  129334. * Get the friendly name associated with the input class.
  129335. * @returns the input friendly name
  129336. */
  129337. getSimpleName(): string;
  129338. }
  129339. }
  129340. declare module BABYLON {
  129341. interface ArcRotateCameraInputsManager {
  129342. /**
  129343. * Add orientation input support to the input manager.
  129344. * @returns the current input manager
  129345. */
  129346. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129347. }
  129348. /**
  129349. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129351. */
  129352. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129353. /**
  129354. * Defines the camera the input is attached to.
  129355. */
  129356. camera: ArcRotateCamera;
  129357. /**
  129358. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129359. */
  129360. alphaCorrection: number;
  129361. /**
  129362. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129363. */
  129364. gammaCorrection: number;
  129365. private _alpha;
  129366. private _gamma;
  129367. private _dirty;
  129368. private _deviceOrientationHandler;
  129369. /**
  129370. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129371. */
  129372. constructor();
  129373. /**
  129374. * Attach the input controls to a specific dom element to get the input from.
  129375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129376. */
  129377. attachControl(noPreventDefault?: boolean): void;
  129378. /** @hidden */
  129379. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129380. /**
  129381. * Update the current camera state depending on the inputs that have been used this frame.
  129382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129383. */
  129384. checkInputs(): void;
  129385. /**
  129386. * Detach the current controls from the specified dom element.
  129387. */
  129388. detachControl(): void;
  129389. /**
  129390. * Gets the class name of the current intput.
  129391. * @returns the class name
  129392. */
  129393. getClassName(): string;
  129394. /**
  129395. * Get the friendly name associated with the input class.
  129396. * @returns the input friendly name
  129397. */
  129398. getSimpleName(): string;
  129399. }
  129400. }
  129401. declare module BABYLON {
  129402. /**
  129403. * Listen to mouse events to control the camera.
  129404. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129405. */
  129406. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129407. /**
  129408. * Defines the camera the input is attached to.
  129409. */
  129410. camera: FlyCamera;
  129411. /**
  129412. * Defines if touch is enabled. (Default is true.)
  129413. */
  129414. touchEnabled: boolean;
  129415. /**
  129416. * Defines the buttons associated with the input to handle camera rotation.
  129417. */
  129418. buttons: number[];
  129419. /**
  129420. * Assign buttons for Yaw control.
  129421. */
  129422. buttonsYaw: number[];
  129423. /**
  129424. * Assign buttons for Pitch control.
  129425. */
  129426. buttonsPitch: number[];
  129427. /**
  129428. * Assign buttons for Roll control.
  129429. */
  129430. buttonsRoll: number[];
  129431. /**
  129432. * Detect if any button is being pressed while mouse is moved.
  129433. * -1 = Mouse locked.
  129434. * 0 = Left button.
  129435. * 1 = Middle Button.
  129436. * 2 = Right Button.
  129437. */
  129438. activeButton: number;
  129439. /**
  129440. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129441. * Higher values reduce its sensitivity.
  129442. */
  129443. angularSensibility: number;
  129444. private _observer;
  129445. private _rollObserver;
  129446. private previousPosition;
  129447. private noPreventDefault;
  129448. private element;
  129449. /**
  129450. * Listen to mouse events to control the camera.
  129451. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129453. */
  129454. constructor(touchEnabled?: boolean);
  129455. /**
  129456. * Attach the mouse control to the HTML DOM element.
  129457. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129458. */
  129459. attachControl(noPreventDefault?: boolean): void;
  129460. /**
  129461. * Detach the current controls from the specified dom element.
  129462. */
  129463. detachControl(): void;
  129464. /**
  129465. * Gets the class name of the current input.
  129466. * @returns the class name.
  129467. */
  129468. getClassName(): string;
  129469. /**
  129470. * Get the friendly name associated with the input class.
  129471. * @returns the input's friendly name.
  129472. */
  129473. getSimpleName(): string;
  129474. private _pointerInput;
  129475. private _onMouseMove;
  129476. /**
  129477. * Rotate camera by mouse offset.
  129478. */
  129479. private rotateCamera;
  129480. }
  129481. }
  129482. declare module BABYLON {
  129483. /**
  129484. * Default Inputs manager for the FlyCamera.
  129485. * It groups all the default supported inputs for ease of use.
  129486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129487. */
  129488. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129489. /**
  129490. * Instantiates a new FlyCameraInputsManager.
  129491. * @param camera Defines the camera the inputs belong to.
  129492. */
  129493. constructor(camera: FlyCamera);
  129494. /**
  129495. * Add keyboard input support to the input manager.
  129496. * @returns the new FlyCameraKeyboardMoveInput().
  129497. */
  129498. addKeyboard(): FlyCameraInputsManager;
  129499. /**
  129500. * Add mouse input support to the input manager.
  129501. * @param touchEnabled Enable touch screen support.
  129502. * @returns the new FlyCameraMouseInput().
  129503. */
  129504. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129505. }
  129506. }
  129507. declare module BABYLON {
  129508. /**
  129509. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129510. * such as in a 3D Space Shooter or a Flight Simulator.
  129511. */
  129512. export class FlyCamera extends TargetCamera {
  129513. /**
  129514. * Define the collision ellipsoid of the camera.
  129515. * This is helpful for simulating a camera body, like a player's body.
  129516. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129517. */
  129518. ellipsoid: Vector3;
  129519. /**
  129520. * Define an offset for the position of the ellipsoid around the camera.
  129521. * This can be helpful if the camera is attached away from the player's body center,
  129522. * such as at its head.
  129523. */
  129524. ellipsoidOffset: Vector3;
  129525. /**
  129526. * Enable or disable collisions of the camera with the rest of the scene objects.
  129527. */
  129528. checkCollisions: boolean;
  129529. /**
  129530. * Enable or disable gravity on the camera.
  129531. */
  129532. applyGravity: boolean;
  129533. /**
  129534. * Define the current direction the camera is moving to.
  129535. */
  129536. cameraDirection: Vector3;
  129537. /**
  129538. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129539. * This overrides and empties cameraRotation.
  129540. */
  129541. rotationQuaternion: Quaternion;
  129542. /**
  129543. * Track Roll to maintain the wanted Rolling when looking around.
  129544. */
  129545. _trackRoll: number;
  129546. /**
  129547. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129548. */
  129549. rollCorrect: number;
  129550. /**
  129551. * Mimic a banked turn, Rolling the camera when Yawing.
  129552. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129553. */
  129554. bankedTurn: boolean;
  129555. /**
  129556. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129557. */
  129558. bankedTurnLimit: number;
  129559. /**
  129560. * Value of 0 disables the banked Roll.
  129561. * Value of 1 is equal to the Yaw angle in radians.
  129562. */
  129563. bankedTurnMultiplier: number;
  129564. /**
  129565. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129566. */
  129567. inputs: FlyCameraInputsManager;
  129568. /**
  129569. * Gets the input sensibility for mouse input.
  129570. * Higher values reduce sensitivity.
  129571. */
  129572. get angularSensibility(): number;
  129573. /**
  129574. * Sets the input sensibility for a mouse input.
  129575. * Higher values reduce sensitivity.
  129576. */
  129577. set angularSensibility(value: number);
  129578. /**
  129579. * Get the keys for camera movement forward.
  129580. */
  129581. get keysForward(): number[];
  129582. /**
  129583. * Set the keys for camera movement forward.
  129584. */
  129585. set keysForward(value: number[]);
  129586. /**
  129587. * Get the keys for camera movement backward.
  129588. */
  129589. get keysBackward(): number[];
  129590. set keysBackward(value: number[]);
  129591. /**
  129592. * Get the keys for camera movement up.
  129593. */
  129594. get keysUp(): number[];
  129595. /**
  129596. * Set the keys for camera movement up.
  129597. */
  129598. set keysUp(value: number[]);
  129599. /**
  129600. * Get the keys for camera movement down.
  129601. */
  129602. get keysDown(): number[];
  129603. /**
  129604. * Set the keys for camera movement down.
  129605. */
  129606. set keysDown(value: number[]);
  129607. /**
  129608. * Get the keys for camera movement left.
  129609. */
  129610. get keysLeft(): number[];
  129611. /**
  129612. * Set the keys for camera movement left.
  129613. */
  129614. set keysLeft(value: number[]);
  129615. /**
  129616. * Set the keys for camera movement right.
  129617. */
  129618. get keysRight(): number[];
  129619. /**
  129620. * Set the keys for camera movement right.
  129621. */
  129622. set keysRight(value: number[]);
  129623. /**
  129624. * Event raised when the camera collides with a mesh in the scene.
  129625. */
  129626. onCollide: (collidedMesh: AbstractMesh) => void;
  129627. private _collider;
  129628. private _needMoveForGravity;
  129629. private _oldPosition;
  129630. private _diffPosition;
  129631. private _newPosition;
  129632. /** @hidden */
  129633. _localDirection: Vector3;
  129634. /** @hidden */
  129635. _transformedDirection: Vector3;
  129636. /**
  129637. * Instantiates a FlyCamera.
  129638. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129639. * such as in a 3D Space Shooter or a Flight Simulator.
  129640. * @param name Define the name of the camera in the scene.
  129641. * @param position Define the starting position of the camera in the scene.
  129642. * @param scene Define the scene the camera belongs to.
  129643. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129644. */
  129645. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129646. /**
  129647. * Attach the input controls to a specific dom element to get the input from.
  129648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129649. */
  129650. attachControl(noPreventDefault?: boolean): void;
  129651. /**
  129652. * Detach a control from the HTML DOM element.
  129653. * The camera will stop reacting to that input.
  129654. */
  129655. detachControl(): void;
  129656. private _collisionMask;
  129657. /**
  129658. * Get the mask that the camera ignores in collision events.
  129659. */
  129660. get collisionMask(): number;
  129661. /**
  129662. * Set the mask that the camera ignores in collision events.
  129663. */
  129664. set collisionMask(mask: number);
  129665. /** @hidden */
  129666. _collideWithWorld(displacement: Vector3): void;
  129667. /** @hidden */
  129668. private _onCollisionPositionChange;
  129669. /** @hidden */
  129670. _checkInputs(): void;
  129671. /** @hidden */
  129672. _decideIfNeedsToMove(): boolean;
  129673. /** @hidden */
  129674. _updatePosition(): void;
  129675. /**
  129676. * Restore the Roll to its target value at the rate specified.
  129677. * @param rate - Higher means slower restoring.
  129678. * @hidden
  129679. */
  129680. restoreRoll(rate: number): void;
  129681. /**
  129682. * Destroy the camera and release the current resources held by it.
  129683. */
  129684. dispose(): void;
  129685. /**
  129686. * Get the current object class name.
  129687. * @returns the class name.
  129688. */
  129689. getClassName(): string;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /**
  129694. * Listen to keyboard events to control the camera.
  129695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129696. */
  129697. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129698. /**
  129699. * Defines the camera the input is attached to.
  129700. */
  129701. camera: FlyCamera;
  129702. /**
  129703. * The list of keyboard keys used to control the forward move of the camera.
  129704. */
  129705. keysForward: number[];
  129706. /**
  129707. * The list of keyboard keys used to control the backward move of the camera.
  129708. */
  129709. keysBackward: number[];
  129710. /**
  129711. * The list of keyboard keys used to control the forward move of the camera.
  129712. */
  129713. keysUp: number[];
  129714. /**
  129715. * The list of keyboard keys used to control the backward move of the camera.
  129716. */
  129717. keysDown: number[];
  129718. /**
  129719. * The list of keyboard keys used to control the right strafe move of the camera.
  129720. */
  129721. keysRight: number[];
  129722. /**
  129723. * The list of keyboard keys used to control the left strafe move of the camera.
  129724. */
  129725. keysLeft: number[];
  129726. private _keys;
  129727. private _onCanvasBlurObserver;
  129728. private _onKeyboardObserver;
  129729. private _engine;
  129730. private _scene;
  129731. /**
  129732. * Attach the input controls to a specific dom element to get the input from.
  129733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129734. */
  129735. attachControl(noPreventDefault?: boolean): void;
  129736. /**
  129737. * Detach the current controls from the specified dom element.
  129738. */
  129739. detachControl(): void;
  129740. /**
  129741. * Gets the class name of the current intput.
  129742. * @returns the class name
  129743. */
  129744. getClassName(): string;
  129745. /** @hidden */
  129746. _onLostFocus(e: FocusEvent): void;
  129747. /**
  129748. * Get the friendly name associated with the input class.
  129749. * @returns the input friendly name
  129750. */
  129751. getSimpleName(): string;
  129752. /**
  129753. * Update the current camera state depending on the inputs that have been used this frame.
  129754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129755. */
  129756. checkInputs(): void;
  129757. }
  129758. }
  129759. declare module BABYLON {
  129760. /**
  129761. * Manage the mouse wheel inputs to control a follow camera.
  129762. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129763. */
  129764. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129765. /**
  129766. * Defines the camera the input is attached to.
  129767. */
  129768. camera: FollowCamera;
  129769. /**
  129770. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129771. */
  129772. axisControlRadius: boolean;
  129773. /**
  129774. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129775. */
  129776. axisControlHeight: boolean;
  129777. /**
  129778. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129779. */
  129780. axisControlRotation: boolean;
  129781. /**
  129782. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129783. * relation to mouseWheel events.
  129784. */
  129785. wheelPrecision: number;
  129786. /**
  129787. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129788. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129789. */
  129790. wheelDeltaPercentage: number;
  129791. private _wheel;
  129792. private _observer;
  129793. /**
  129794. * Attach the input controls to a specific dom element to get the input from.
  129795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129796. */
  129797. attachControl(noPreventDefault?: boolean): void;
  129798. /**
  129799. * Detach the current controls from the specified dom element.
  129800. */
  129801. detachControl(): void;
  129802. /**
  129803. * Gets the class name of the current intput.
  129804. * @returns the class name
  129805. */
  129806. getClassName(): string;
  129807. /**
  129808. * Get the friendly name associated with the input class.
  129809. * @returns the input friendly name
  129810. */
  129811. getSimpleName(): string;
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /**
  129816. * Manage the pointers inputs to control an follow camera.
  129817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129818. */
  129819. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129820. /**
  129821. * Defines the camera the input is attached to.
  129822. */
  129823. camera: FollowCamera;
  129824. /**
  129825. * Gets the class name of the current input.
  129826. * @returns the class name
  129827. */
  129828. getClassName(): string;
  129829. /**
  129830. * Defines the pointer angular sensibility along the X axis or how fast is
  129831. * the camera rotating.
  129832. * A negative number will reverse the axis direction.
  129833. */
  129834. angularSensibilityX: number;
  129835. /**
  129836. * Defines the pointer angular sensibility along the Y axis or how fast is
  129837. * the camera rotating.
  129838. * A negative number will reverse the axis direction.
  129839. */
  129840. angularSensibilityY: number;
  129841. /**
  129842. * Defines the pointer pinch precision or how fast is the camera zooming.
  129843. * A negative number will reverse the axis direction.
  129844. */
  129845. pinchPrecision: number;
  129846. /**
  129847. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129848. * from 0.
  129849. * It defines the percentage of current camera.radius to use as delta when
  129850. * pinch zoom is used.
  129851. */
  129852. pinchDeltaPercentage: number;
  129853. /**
  129854. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129855. */
  129856. axisXControlRadius: boolean;
  129857. /**
  129858. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129859. */
  129860. axisXControlHeight: boolean;
  129861. /**
  129862. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129863. */
  129864. axisXControlRotation: boolean;
  129865. /**
  129866. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129867. */
  129868. axisYControlRadius: boolean;
  129869. /**
  129870. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129871. */
  129872. axisYControlHeight: boolean;
  129873. /**
  129874. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129875. */
  129876. axisYControlRotation: boolean;
  129877. /**
  129878. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129879. */
  129880. axisPinchControlRadius: boolean;
  129881. /**
  129882. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129883. */
  129884. axisPinchControlHeight: boolean;
  129885. /**
  129886. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129887. */
  129888. axisPinchControlRotation: boolean;
  129889. /**
  129890. * Log error messages if basic misconfiguration has occurred.
  129891. */
  129892. warningEnable: boolean;
  129893. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129894. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129895. private _warningCounter;
  129896. private _warning;
  129897. }
  129898. }
  129899. declare module BABYLON {
  129900. /**
  129901. * Default Inputs manager for the FollowCamera.
  129902. * It groups all the default supported inputs for ease of use.
  129903. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129904. */
  129905. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129906. /**
  129907. * Instantiates a new FollowCameraInputsManager.
  129908. * @param camera Defines the camera the inputs belong to
  129909. */
  129910. constructor(camera: FollowCamera);
  129911. /**
  129912. * Add keyboard input support to the input manager.
  129913. * @returns the current input manager
  129914. */
  129915. addKeyboard(): FollowCameraInputsManager;
  129916. /**
  129917. * Add mouse wheel input support to the input manager.
  129918. * @returns the current input manager
  129919. */
  129920. addMouseWheel(): FollowCameraInputsManager;
  129921. /**
  129922. * Add pointers input support to the input manager.
  129923. * @returns the current input manager
  129924. */
  129925. addPointers(): FollowCameraInputsManager;
  129926. /**
  129927. * Add orientation input support to the input manager.
  129928. * @returns the current input manager
  129929. */
  129930. addVRDeviceOrientation(): FollowCameraInputsManager;
  129931. }
  129932. }
  129933. declare module BABYLON {
  129934. /**
  129935. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129936. * an arc rotate version arcFollowCamera are available.
  129937. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129938. */
  129939. export class FollowCamera extends TargetCamera {
  129940. /**
  129941. * Distance the follow camera should follow an object at
  129942. */
  129943. radius: number;
  129944. /**
  129945. * Minimum allowed distance of the camera to the axis of rotation
  129946. * (The camera can not get closer).
  129947. * This can help limiting how the Camera is able to move in the scene.
  129948. */
  129949. lowerRadiusLimit: Nullable<number>;
  129950. /**
  129951. * Maximum allowed distance of the camera to the axis of rotation
  129952. * (The camera can not get further).
  129953. * This can help limiting how the Camera is able to move in the scene.
  129954. */
  129955. upperRadiusLimit: Nullable<number>;
  129956. /**
  129957. * Define a rotation offset between the camera and the object it follows
  129958. */
  129959. rotationOffset: number;
  129960. /**
  129961. * Minimum allowed angle to camera position relative to target object.
  129962. * This can help limiting how the Camera is able to move in the scene.
  129963. */
  129964. lowerRotationOffsetLimit: Nullable<number>;
  129965. /**
  129966. * Maximum allowed angle to camera position relative to target object.
  129967. * This can help limiting how the Camera is able to move in the scene.
  129968. */
  129969. upperRotationOffsetLimit: Nullable<number>;
  129970. /**
  129971. * Define a height offset between the camera and the object it follows.
  129972. * It can help following an object from the top (like a car chaing a plane)
  129973. */
  129974. heightOffset: number;
  129975. /**
  129976. * Minimum allowed height of camera position relative to target object.
  129977. * This can help limiting how the Camera is able to move in the scene.
  129978. */
  129979. lowerHeightOffsetLimit: Nullable<number>;
  129980. /**
  129981. * Maximum allowed height of camera position relative to target object.
  129982. * This can help limiting how the Camera is able to move in the scene.
  129983. */
  129984. upperHeightOffsetLimit: Nullable<number>;
  129985. /**
  129986. * Define how fast the camera can accelerate to follow it s target.
  129987. */
  129988. cameraAcceleration: number;
  129989. /**
  129990. * Define the speed limit of the camera following an object.
  129991. */
  129992. maxCameraSpeed: number;
  129993. /**
  129994. * Define the target of the camera.
  129995. */
  129996. lockedTarget: Nullable<AbstractMesh>;
  129997. /**
  129998. * Defines the input associated with the camera.
  129999. */
  130000. inputs: FollowCameraInputsManager;
  130001. /**
  130002. * Instantiates the follow camera.
  130003. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130004. * @param name Define the name of the camera in the scene
  130005. * @param position Define the position of the camera
  130006. * @param scene Define the scene the camera belong to
  130007. * @param lockedTarget Define the target of the camera
  130008. */
  130009. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  130010. private _follow;
  130011. /**
  130012. * Attach the input controls to a specific dom element to get the input from.
  130013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130014. */
  130015. attachControl(noPreventDefault?: boolean): void;
  130016. /**
  130017. * Detach the current controls from the specified dom element.
  130018. */
  130019. detachControl(): void;
  130020. /** @hidden */
  130021. _checkInputs(): void;
  130022. private _checkLimits;
  130023. /**
  130024. * Gets the camera class name.
  130025. * @returns the class name
  130026. */
  130027. getClassName(): string;
  130028. }
  130029. /**
  130030. * Arc Rotate version of the follow camera.
  130031. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  130032. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130033. */
  130034. export class ArcFollowCamera extends TargetCamera {
  130035. /** The longitudinal angle of the camera */
  130036. alpha: number;
  130037. /** The latitudinal angle of the camera */
  130038. beta: number;
  130039. /** The radius of the camera from its target */
  130040. radius: number;
  130041. private _cartesianCoordinates;
  130042. /** Define the camera target (the mesh it should follow) */
  130043. private _meshTarget;
  130044. /**
  130045. * Instantiates a new ArcFollowCamera
  130046. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130047. * @param name Define the name of the camera
  130048. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  130049. * @param beta Define the rotation angle of the camera around the elevation axis
  130050. * @param radius Define the radius of the camera from its target point
  130051. * @param target Define the target of the camera
  130052. * @param scene Define the scene the camera belongs to
  130053. */
  130054. constructor(name: string,
  130055. /** The longitudinal angle of the camera */
  130056. alpha: number,
  130057. /** The latitudinal angle of the camera */
  130058. beta: number,
  130059. /** The radius of the camera from its target */
  130060. radius: number,
  130061. /** Define the camera target (the mesh it should follow) */
  130062. target: Nullable<AbstractMesh>, scene: Scene);
  130063. private _follow;
  130064. /** @hidden */
  130065. _checkInputs(): void;
  130066. /**
  130067. * Returns the class name of the object.
  130068. * It is mostly used internally for serialization purposes.
  130069. */
  130070. getClassName(): string;
  130071. }
  130072. }
  130073. declare module BABYLON {
  130074. /**
  130075. * Manage the keyboard inputs to control the movement of a follow camera.
  130076. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130077. */
  130078. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  130079. /**
  130080. * Defines the camera the input is attached to.
  130081. */
  130082. camera: FollowCamera;
  130083. /**
  130084. * Defines the list of key codes associated with the up action (increase heightOffset)
  130085. */
  130086. keysHeightOffsetIncr: number[];
  130087. /**
  130088. * Defines the list of key codes associated with the down action (decrease heightOffset)
  130089. */
  130090. keysHeightOffsetDecr: number[];
  130091. /**
  130092. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  130093. */
  130094. keysHeightOffsetModifierAlt: boolean;
  130095. /**
  130096. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  130097. */
  130098. keysHeightOffsetModifierCtrl: boolean;
  130099. /**
  130100. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  130101. */
  130102. keysHeightOffsetModifierShift: boolean;
  130103. /**
  130104. * Defines the list of key codes associated with the left action (increase rotationOffset)
  130105. */
  130106. keysRotationOffsetIncr: number[];
  130107. /**
  130108. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  130109. */
  130110. keysRotationOffsetDecr: number[];
  130111. /**
  130112. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  130113. */
  130114. keysRotationOffsetModifierAlt: boolean;
  130115. /**
  130116. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  130117. */
  130118. keysRotationOffsetModifierCtrl: boolean;
  130119. /**
  130120. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  130121. */
  130122. keysRotationOffsetModifierShift: boolean;
  130123. /**
  130124. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  130125. */
  130126. keysRadiusIncr: number[];
  130127. /**
  130128. * Defines the list of key codes associated with the zoom-out action (increase radius)
  130129. */
  130130. keysRadiusDecr: number[];
  130131. /**
  130132. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  130133. */
  130134. keysRadiusModifierAlt: boolean;
  130135. /**
  130136. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  130137. */
  130138. keysRadiusModifierCtrl: boolean;
  130139. /**
  130140. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  130141. */
  130142. keysRadiusModifierShift: boolean;
  130143. /**
  130144. * Defines the rate of change of heightOffset.
  130145. */
  130146. heightSensibility: number;
  130147. /**
  130148. * Defines the rate of change of rotationOffset.
  130149. */
  130150. rotationSensibility: number;
  130151. /**
  130152. * Defines the rate of change of radius.
  130153. */
  130154. radiusSensibility: number;
  130155. private _keys;
  130156. private _ctrlPressed;
  130157. private _altPressed;
  130158. private _shiftPressed;
  130159. private _onCanvasBlurObserver;
  130160. private _onKeyboardObserver;
  130161. private _engine;
  130162. private _scene;
  130163. /**
  130164. * Attach the input controls to a specific dom element to get the input from.
  130165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130166. */
  130167. attachControl(noPreventDefault?: boolean): void;
  130168. /**
  130169. * Detach the current controls from the specified dom element.
  130170. */
  130171. detachControl(): void;
  130172. /**
  130173. * Update the current camera state depending on the inputs that have been used this frame.
  130174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130175. */
  130176. checkInputs(): void;
  130177. /**
  130178. * Gets the class name of the current input.
  130179. * @returns the class name
  130180. */
  130181. getClassName(): string;
  130182. /**
  130183. * Get the friendly name associated with the input class.
  130184. * @returns the input friendly name
  130185. */
  130186. getSimpleName(): string;
  130187. /**
  130188. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130189. * allow modification of the heightOffset value.
  130190. */
  130191. private _modifierHeightOffset;
  130192. /**
  130193. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130194. * allow modification of the rotationOffset value.
  130195. */
  130196. private _modifierRotationOffset;
  130197. /**
  130198. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130199. * allow modification of the radius value.
  130200. */
  130201. private _modifierRadius;
  130202. }
  130203. }
  130204. declare module BABYLON {
  130205. interface FreeCameraInputsManager {
  130206. /**
  130207. * @hidden
  130208. */
  130209. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  130210. /**
  130211. * Add orientation input support to the input manager.
  130212. * @returns the current input manager
  130213. */
  130214. addDeviceOrientation(): FreeCameraInputsManager;
  130215. }
  130216. /**
  130217. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  130218. * Screen rotation is taken into account.
  130219. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130220. */
  130221. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  130222. private _camera;
  130223. private _screenOrientationAngle;
  130224. private _constantTranform;
  130225. private _screenQuaternion;
  130226. private _alpha;
  130227. private _beta;
  130228. private _gamma;
  130229. /**
  130230. * Can be used to detect if a device orientation sensor is available on a device
  130231. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  130232. * @returns a promise that will resolve on orientation change
  130233. */
  130234. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  130235. /**
  130236. * @hidden
  130237. */
  130238. _onDeviceOrientationChangedObservable: Observable<void>;
  130239. /**
  130240. * Instantiates a new input
  130241. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130242. */
  130243. constructor();
  130244. /**
  130245. * Define the camera controlled by the input.
  130246. */
  130247. get camera(): FreeCamera;
  130248. set camera(camera: FreeCamera);
  130249. /**
  130250. * Attach the input controls to a specific dom element to get the input from.
  130251. */
  130252. attachControl(): void;
  130253. private _orientationChanged;
  130254. private _deviceOrientation;
  130255. /**
  130256. * Detach the current controls from the specified dom element.
  130257. */
  130258. detachControl(): void;
  130259. /**
  130260. * Update the current camera state depending on the inputs that have been used this frame.
  130261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130262. */
  130263. checkInputs(): void;
  130264. /**
  130265. * Gets the class name of the current intput.
  130266. * @returns the class name
  130267. */
  130268. getClassName(): string;
  130269. /**
  130270. * Get the friendly name associated with the input class.
  130271. * @returns the input friendly name
  130272. */
  130273. getSimpleName(): string;
  130274. }
  130275. }
  130276. declare module BABYLON {
  130277. /**
  130278. * Manage the gamepad inputs to control a free camera.
  130279. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130280. */
  130281. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  130282. /**
  130283. * Define the camera the input is attached to.
  130284. */
  130285. camera: FreeCamera;
  130286. /**
  130287. * Define the Gamepad controlling the input
  130288. */
  130289. gamepad: Nullable<Gamepad>;
  130290. /**
  130291. * Defines the gamepad rotation sensiblity.
  130292. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130293. */
  130294. gamepadAngularSensibility: number;
  130295. /**
  130296. * Defines the gamepad move sensiblity.
  130297. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130298. */
  130299. gamepadMoveSensibility: number;
  130300. private _yAxisScale;
  130301. /**
  130302. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130303. */
  130304. get invertYAxis(): boolean;
  130305. set invertYAxis(value: boolean);
  130306. private _onGamepadConnectedObserver;
  130307. private _onGamepadDisconnectedObserver;
  130308. private _cameraTransform;
  130309. private _deltaTransform;
  130310. private _vector3;
  130311. private _vector2;
  130312. /**
  130313. * Attach the input controls to a specific dom element to get the input from.
  130314. */
  130315. attachControl(): void;
  130316. /**
  130317. * Detach the current controls from the specified dom element.
  130318. */
  130319. detachControl(): void;
  130320. /**
  130321. * Update the current camera state depending on the inputs that have been used this frame.
  130322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130323. */
  130324. checkInputs(): void;
  130325. /**
  130326. * Gets the class name of the current intput.
  130327. * @returns the class name
  130328. */
  130329. getClassName(): string;
  130330. /**
  130331. * Get the friendly name associated with the input class.
  130332. * @returns the input friendly name
  130333. */
  130334. getSimpleName(): string;
  130335. }
  130336. }
  130337. declare module BABYLON {
  130338. /**
  130339. * Defines the potential axis of a Joystick
  130340. */
  130341. export enum JoystickAxis {
  130342. /** X axis */
  130343. X = 0,
  130344. /** Y axis */
  130345. Y = 1,
  130346. /** Z axis */
  130347. Z = 2
  130348. }
  130349. /**
  130350. * Represents the different customization options available
  130351. * for VirtualJoystick
  130352. */
  130353. interface VirtualJoystickCustomizations {
  130354. /**
  130355. * Size of the joystick's puck
  130356. */
  130357. puckSize: number;
  130358. /**
  130359. * Size of the joystick's container
  130360. */
  130361. containerSize: number;
  130362. /**
  130363. * Color of the joystick && puck
  130364. */
  130365. color: string;
  130366. /**
  130367. * Image URL for the joystick's puck
  130368. */
  130369. puckImage?: string;
  130370. /**
  130371. * Image URL for the joystick's container
  130372. */
  130373. containerImage?: string;
  130374. /**
  130375. * Defines the unmoving position of the joystick container
  130376. */
  130377. position?: {
  130378. x: number;
  130379. y: number;
  130380. };
  130381. /**
  130382. * Defines whether or not the joystick container is always visible
  130383. */
  130384. alwaysVisible: boolean;
  130385. /**
  130386. * Defines whether or not to limit the movement of the puck to the joystick's container
  130387. */
  130388. limitToContainer: boolean;
  130389. }
  130390. /**
  130391. * Class used to define virtual joystick (used in touch mode)
  130392. */
  130393. export class VirtualJoystick {
  130394. /**
  130395. * Gets or sets a boolean indicating that left and right values must be inverted
  130396. */
  130397. reverseLeftRight: boolean;
  130398. /**
  130399. * Gets or sets a boolean indicating that up and down values must be inverted
  130400. */
  130401. reverseUpDown: boolean;
  130402. /**
  130403. * Gets the offset value for the position (ie. the change of the position value)
  130404. */
  130405. deltaPosition: Vector3;
  130406. /**
  130407. * Gets a boolean indicating if the virtual joystick was pressed
  130408. */
  130409. pressed: boolean;
  130410. /**
  130411. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130412. */
  130413. static Canvas: Nullable<HTMLCanvasElement>;
  130414. /**
  130415. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130416. */
  130417. limitToContainer: boolean;
  130418. private static _globalJoystickIndex;
  130419. private static _alwaysVisibleSticks;
  130420. private static vjCanvasContext;
  130421. private static vjCanvasWidth;
  130422. private static vjCanvasHeight;
  130423. private static halfWidth;
  130424. private static _GetDefaultOptions;
  130425. private _action;
  130426. private _axisTargetedByLeftAndRight;
  130427. private _axisTargetedByUpAndDown;
  130428. private _joystickSensibility;
  130429. private _inversedSensibility;
  130430. private _joystickPointerID;
  130431. private _joystickColor;
  130432. private _joystickPointerPos;
  130433. private _joystickPreviousPointerPos;
  130434. private _joystickPointerStartPos;
  130435. private _deltaJoystickVector;
  130436. private _leftJoystick;
  130437. private _touches;
  130438. private _joystickPosition;
  130439. private _alwaysVisible;
  130440. private _puckImage;
  130441. private _containerImage;
  130442. private _joystickPuckSize;
  130443. private _joystickContainerSize;
  130444. private _clearPuckSize;
  130445. private _clearContainerSize;
  130446. private _clearPuckSizeOffset;
  130447. private _clearContainerSizeOffset;
  130448. private _onPointerDownHandlerRef;
  130449. private _onPointerMoveHandlerRef;
  130450. private _onPointerUpHandlerRef;
  130451. private _onResize;
  130452. /**
  130453. * Creates a new virtual joystick
  130454. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130455. * @param customizations Defines the options we want to customize the VirtualJoystick
  130456. */
  130457. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130458. /**
  130459. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130460. * @param newJoystickSensibility defines the new sensibility
  130461. */
  130462. setJoystickSensibility(newJoystickSensibility: number): void;
  130463. private _onPointerDown;
  130464. private _onPointerMove;
  130465. private _onPointerUp;
  130466. /**
  130467. * Change the color of the virtual joystick
  130468. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130469. */
  130470. setJoystickColor(newColor: string): void;
  130471. /**
  130472. * Size of the joystick's container
  130473. */
  130474. set containerSize(newSize: number);
  130475. get containerSize(): number;
  130476. /**
  130477. * Size of the joystick's puck
  130478. */
  130479. set puckSize(newSize: number);
  130480. get puckSize(): number;
  130481. /**
  130482. * Clears the set position of the joystick
  130483. */
  130484. clearPosition(): void;
  130485. /**
  130486. * Defines whether or not the joystick container is always visible
  130487. */
  130488. set alwaysVisible(value: boolean);
  130489. get alwaysVisible(): boolean;
  130490. /**
  130491. * Sets the constant position of the Joystick container
  130492. * @param x X axis coordinate
  130493. * @param y Y axis coordinate
  130494. */
  130495. setPosition(x: number, y: number): void;
  130496. /**
  130497. * Defines a callback to call when the joystick is touched
  130498. * @param action defines the callback
  130499. */
  130500. setActionOnTouch(action: () => any): void;
  130501. /**
  130502. * Defines which axis you'd like to control for left & right
  130503. * @param axis defines the axis to use
  130504. */
  130505. setAxisForLeftRight(axis: JoystickAxis): void;
  130506. /**
  130507. * Defines which axis you'd like to control for up & down
  130508. * @param axis defines the axis to use
  130509. */
  130510. setAxisForUpDown(axis: JoystickAxis): void;
  130511. /**
  130512. * Clears the canvas from the previous puck / container draw
  130513. */
  130514. private _clearPreviousDraw;
  130515. /**
  130516. * Loads `urlPath` to be used for the container's image
  130517. * @param urlPath defines the urlPath of an image to use
  130518. */
  130519. setContainerImage(urlPath: string): void;
  130520. /**
  130521. * Loads `urlPath` to be used for the puck's image
  130522. * @param urlPath defines the urlPath of an image to use
  130523. */
  130524. setPuckImage(urlPath: string): void;
  130525. /**
  130526. * Draws the Virtual Joystick's container
  130527. */
  130528. private _drawContainer;
  130529. /**
  130530. * Draws the Virtual Joystick's puck
  130531. */
  130532. private _drawPuck;
  130533. private _drawVirtualJoystick;
  130534. /**
  130535. * Release internal HTML canvas
  130536. */
  130537. releaseCanvas(): void;
  130538. }
  130539. }
  130540. declare module BABYLON {
  130541. interface FreeCameraInputsManager {
  130542. /**
  130543. * Add virtual joystick input support to the input manager.
  130544. * @returns the current input manager
  130545. */
  130546. addVirtualJoystick(): FreeCameraInputsManager;
  130547. }
  130548. /**
  130549. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130551. */
  130552. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130553. /**
  130554. * Defines the camera the input is attached to.
  130555. */
  130556. camera: FreeCamera;
  130557. private _leftjoystick;
  130558. private _rightjoystick;
  130559. /**
  130560. * Gets the left stick of the virtual joystick.
  130561. * @returns The virtual Joystick
  130562. */
  130563. getLeftJoystick(): VirtualJoystick;
  130564. /**
  130565. * Gets the right stick of the virtual joystick.
  130566. * @returns The virtual Joystick
  130567. */
  130568. getRightJoystick(): VirtualJoystick;
  130569. /**
  130570. * Update the current camera state depending on the inputs that have been used this frame.
  130571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130572. */
  130573. checkInputs(): void;
  130574. /**
  130575. * Attach the input controls to a specific dom element to get the input from.
  130576. */
  130577. attachControl(): void;
  130578. /**
  130579. * Detach the current controls from the specified dom element.
  130580. */
  130581. detachControl(): void;
  130582. /**
  130583. * Gets the class name of the current intput.
  130584. * @returns the class name
  130585. */
  130586. getClassName(): string;
  130587. /**
  130588. * Get the friendly name associated with the input class.
  130589. * @returns the input friendly name
  130590. */
  130591. getSimpleName(): string;
  130592. }
  130593. }
  130594. declare module BABYLON {
  130595. /**
  130596. * This represents a FPS type of camera controlled by touch.
  130597. * This is like a universal camera minus the Gamepad controls.
  130598. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130599. */
  130600. export class TouchCamera extends FreeCamera {
  130601. /**
  130602. * Defines the touch sensibility for rotation.
  130603. * The higher the faster.
  130604. */
  130605. get touchAngularSensibility(): number;
  130606. set touchAngularSensibility(value: number);
  130607. /**
  130608. * Defines the touch sensibility for move.
  130609. * The higher the faster.
  130610. */
  130611. get touchMoveSensibility(): number;
  130612. set touchMoveSensibility(value: number);
  130613. /**
  130614. * Instantiates a new touch camera.
  130615. * This represents a FPS type of camera controlled by touch.
  130616. * This is like a universal camera minus the Gamepad controls.
  130617. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130618. * @param name Define the name of the camera in the scene
  130619. * @param position Define the start position of the camera in the scene
  130620. * @param scene Define the scene the camera belongs to
  130621. */
  130622. constructor(name: string, position: Vector3, scene: Scene);
  130623. /**
  130624. * Gets the current object class name.
  130625. * @return the class name
  130626. */
  130627. getClassName(): string;
  130628. /** @hidden */
  130629. _setupInputs(): void;
  130630. }
  130631. }
  130632. declare module BABYLON {
  130633. /**
  130634. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130635. * being tilted forward or back and left or right.
  130636. */
  130637. export class DeviceOrientationCamera extends FreeCamera {
  130638. private _initialQuaternion;
  130639. private _quaternionCache;
  130640. private _tmpDragQuaternion;
  130641. private _disablePointerInputWhenUsingDeviceOrientation;
  130642. /**
  130643. * Creates a new device orientation camera
  130644. * @param name The name of the camera
  130645. * @param position The start position camera
  130646. * @param scene The scene the camera belongs to
  130647. */
  130648. constructor(name: string, position: Vector3, scene: Scene);
  130649. /**
  130650. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130651. */
  130652. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130653. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130654. private _dragFactor;
  130655. /**
  130656. * Enabled turning on the y axis when the orientation sensor is active
  130657. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130658. */
  130659. enableHorizontalDragging(dragFactor?: number): void;
  130660. /**
  130661. * Gets the current instance class name ("DeviceOrientationCamera").
  130662. * This helps avoiding instanceof at run time.
  130663. * @returns the class name
  130664. */
  130665. getClassName(): string;
  130666. /**
  130667. * @hidden
  130668. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130669. */
  130670. _checkInputs(): void;
  130671. /**
  130672. * Reset the camera to its default orientation on the specified axis only.
  130673. * @param axis The axis to reset
  130674. */
  130675. resetToCurrentRotation(axis?: Axis): void;
  130676. }
  130677. }
  130678. declare module BABYLON {
  130679. /**
  130680. * Defines supported buttons for XBox360 compatible gamepads
  130681. */
  130682. export enum Xbox360Button {
  130683. /** A */
  130684. A = 0,
  130685. /** B */
  130686. B = 1,
  130687. /** X */
  130688. X = 2,
  130689. /** Y */
  130690. Y = 3,
  130691. /** Left button */
  130692. LB = 4,
  130693. /** Right button */
  130694. RB = 5,
  130695. /** Back */
  130696. Back = 8,
  130697. /** Start */
  130698. Start = 9,
  130699. /** Left stick */
  130700. LeftStick = 10,
  130701. /** Right stick */
  130702. RightStick = 11
  130703. }
  130704. /** Defines values for XBox360 DPad */
  130705. export enum Xbox360Dpad {
  130706. /** Up */
  130707. Up = 12,
  130708. /** Down */
  130709. Down = 13,
  130710. /** Left */
  130711. Left = 14,
  130712. /** Right */
  130713. Right = 15
  130714. }
  130715. /**
  130716. * Defines a XBox360 gamepad
  130717. */
  130718. export class Xbox360Pad extends Gamepad {
  130719. private _leftTrigger;
  130720. private _rightTrigger;
  130721. private _onlefttriggerchanged;
  130722. private _onrighttriggerchanged;
  130723. private _onbuttondown;
  130724. private _onbuttonup;
  130725. private _ondpaddown;
  130726. private _ondpadup;
  130727. /** Observable raised when a button is pressed */
  130728. onButtonDownObservable: Observable<Xbox360Button>;
  130729. /** Observable raised when a button is released */
  130730. onButtonUpObservable: Observable<Xbox360Button>;
  130731. /** Observable raised when a pad is pressed */
  130732. onPadDownObservable: Observable<Xbox360Dpad>;
  130733. /** Observable raised when a pad is released */
  130734. onPadUpObservable: Observable<Xbox360Dpad>;
  130735. private _buttonA;
  130736. private _buttonB;
  130737. private _buttonX;
  130738. private _buttonY;
  130739. private _buttonBack;
  130740. private _buttonStart;
  130741. private _buttonLB;
  130742. private _buttonRB;
  130743. private _buttonLeftStick;
  130744. private _buttonRightStick;
  130745. private _dPadUp;
  130746. private _dPadDown;
  130747. private _dPadLeft;
  130748. private _dPadRight;
  130749. private _isXboxOnePad;
  130750. /**
  130751. * Creates a new XBox360 gamepad object
  130752. * @param id defines the id of this gamepad
  130753. * @param index defines its index
  130754. * @param gamepad defines the internal HTML gamepad object
  130755. * @param xboxOne defines if it is a XBox One gamepad
  130756. */
  130757. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130758. /**
  130759. * Defines the callback to call when left trigger is pressed
  130760. * @param callback defines the callback to use
  130761. */
  130762. onlefttriggerchanged(callback: (value: number) => void): void;
  130763. /**
  130764. * Defines the callback to call when right trigger is pressed
  130765. * @param callback defines the callback to use
  130766. */
  130767. onrighttriggerchanged(callback: (value: number) => void): void;
  130768. /**
  130769. * Gets the left trigger value
  130770. */
  130771. get leftTrigger(): number;
  130772. /**
  130773. * Sets the left trigger value
  130774. */
  130775. set leftTrigger(newValue: number);
  130776. /**
  130777. * Gets the right trigger value
  130778. */
  130779. get rightTrigger(): number;
  130780. /**
  130781. * Sets the right trigger value
  130782. */
  130783. set rightTrigger(newValue: number);
  130784. /**
  130785. * Defines the callback to call when a button is pressed
  130786. * @param callback defines the callback to use
  130787. */
  130788. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130789. /**
  130790. * Defines the callback to call when a button is released
  130791. * @param callback defines the callback to use
  130792. */
  130793. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130794. /**
  130795. * Defines the callback to call when a pad is pressed
  130796. * @param callback defines the callback to use
  130797. */
  130798. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130799. /**
  130800. * Defines the callback to call when a pad is released
  130801. * @param callback defines the callback to use
  130802. */
  130803. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130804. private _setButtonValue;
  130805. private _setDPadValue;
  130806. /**
  130807. * Gets the value of the `A` button
  130808. */
  130809. get buttonA(): number;
  130810. /**
  130811. * Sets the value of the `A` button
  130812. */
  130813. set buttonA(value: number);
  130814. /**
  130815. * Gets the value of the `B` button
  130816. */
  130817. get buttonB(): number;
  130818. /**
  130819. * Sets the value of the `B` button
  130820. */
  130821. set buttonB(value: number);
  130822. /**
  130823. * Gets the value of the `X` button
  130824. */
  130825. get buttonX(): number;
  130826. /**
  130827. * Sets the value of the `X` button
  130828. */
  130829. set buttonX(value: number);
  130830. /**
  130831. * Gets the value of the `Y` button
  130832. */
  130833. get buttonY(): number;
  130834. /**
  130835. * Sets the value of the `Y` button
  130836. */
  130837. set buttonY(value: number);
  130838. /**
  130839. * Gets the value of the `Start` button
  130840. */
  130841. get buttonStart(): number;
  130842. /**
  130843. * Sets the value of the `Start` button
  130844. */
  130845. set buttonStart(value: number);
  130846. /**
  130847. * Gets the value of the `Back` button
  130848. */
  130849. get buttonBack(): number;
  130850. /**
  130851. * Sets the value of the `Back` button
  130852. */
  130853. set buttonBack(value: number);
  130854. /**
  130855. * Gets the value of the `Left` button
  130856. */
  130857. get buttonLB(): number;
  130858. /**
  130859. * Sets the value of the `Left` button
  130860. */
  130861. set buttonLB(value: number);
  130862. /**
  130863. * Gets the value of the `Right` button
  130864. */
  130865. get buttonRB(): number;
  130866. /**
  130867. * Sets the value of the `Right` button
  130868. */
  130869. set buttonRB(value: number);
  130870. /**
  130871. * Gets the value of the Left joystick
  130872. */
  130873. get buttonLeftStick(): number;
  130874. /**
  130875. * Sets the value of the Left joystick
  130876. */
  130877. set buttonLeftStick(value: number);
  130878. /**
  130879. * Gets the value of the Right joystick
  130880. */
  130881. get buttonRightStick(): number;
  130882. /**
  130883. * Sets the value of the Right joystick
  130884. */
  130885. set buttonRightStick(value: number);
  130886. /**
  130887. * Gets the value of D-pad up
  130888. */
  130889. get dPadUp(): number;
  130890. /**
  130891. * Sets the value of D-pad up
  130892. */
  130893. set dPadUp(value: number);
  130894. /**
  130895. * Gets the value of D-pad down
  130896. */
  130897. get dPadDown(): number;
  130898. /**
  130899. * Sets the value of D-pad down
  130900. */
  130901. set dPadDown(value: number);
  130902. /**
  130903. * Gets the value of D-pad left
  130904. */
  130905. get dPadLeft(): number;
  130906. /**
  130907. * Sets the value of D-pad left
  130908. */
  130909. set dPadLeft(value: number);
  130910. /**
  130911. * Gets the value of D-pad right
  130912. */
  130913. get dPadRight(): number;
  130914. /**
  130915. * Sets the value of D-pad right
  130916. */
  130917. set dPadRight(value: number);
  130918. /**
  130919. * Force the gamepad to synchronize with device values
  130920. */
  130921. update(): void;
  130922. /**
  130923. * Disposes the gamepad
  130924. */
  130925. dispose(): void;
  130926. }
  130927. }
  130928. declare module BABYLON {
  130929. /**
  130930. * Defines supported buttons for DualShock compatible gamepads
  130931. */
  130932. export enum DualShockButton {
  130933. /** Cross */
  130934. Cross = 0,
  130935. /** Circle */
  130936. Circle = 1,
  130937. /** Square */
  130938. Square = 2,
  130939. /** Triangle */
  130940. Triangle = 3,
  130941. /** L1 */
  130942. L1 = 4,
  130943. /** R1 */
  130944. R1 = 5,
  130945. /** Share */
  130946. Share = 8,
  130947. /** Options */
  130948. Options = 9,
  130949. /** Left stick */
  130950. LeftStick = 10,
  130951. /** Right stick */
  130952. RightStick = 11
  130953. }
  130954. /** Defines values for DualShock DPad */
  130955. export enum DualShockDpad {
  130956. /** Up */
  130957. Up = 12,
  130958. /** Down */
  130959. Down = 13,
  130960. /** Left */
  130961. Left = 14,
  130962. /** Right */
  130963. Right = 15
  130964. }
  130965. /**
  130966. * Defines a DualShock gamepad
  130967. */
  130968. export class DualShockPad extends Gamepad {
  130969. private _leftTrigger;
  130970. private _rightTrigger;
  130971. private _onlefttriggerchanged;
  130972. private _onrighttriggerchanged;
  130973. private _onbuttondown;
  130974. private _onbuttonup;
  130975. private _ondpaddown;
  130976. private _ondpadup;
  130977. /** Observable raised when a button is pressed */
  130978. onButtonDownObservable: Observable<DualShockButton>;
  130979. /** Observable raised when a button is released */
  130980. onButtonUpObservable: Observable<DualShockButton>;
  130981. /** Observable raised when a pad is pressed */
  130982. onPadDownObservable: Observable<DualShockDpad>;
  130983. /** Observable raised when a pad is released */
  130984. onPadUpObservable: Observable<DualShockDpad>;
  130985. private _buttonCross;
  130986. private _buttonCircle;
  130987. private _buttonSquare;
  130988. private _buttonTriangle;
  130989. private _buttonShare;
  130990. private _buttonOptions;
  130991. private _buttonL1;
  130992. private _buttonR1;
  130993. private _buttonLeftStick;
  130994. private _buttonRightStick;
  130995. private _dPadUp;
  130996. private _dPadDown;
  130997. private _dPadLeft;
  130998. private _dPadRight;
  130999. /**
  131000. * Creates a new DualShock gamepad object
  131001. * @param id defines the id of this gamepad
  131002. * @param index defines its index
  131003. * @param gamepad defines the internal HTML gamepad object
  131004. */
  131005. constructor(id: string, index: number, gamepad: any);
  131006. /**
  131007. * Defines the callback to call when left trigger is pressed
  131008. * @param callback defines the callback to use
  131009. */
  131010. onlefttriggerchanged(callback: (value: number) => void): void;
  131011. /**
  131012. * Defines the callback to call when right trigger is pressed
  131013. * @param callback defines the callback to use
  131014. */
  131015. onrighttriggerchanged(callback: (value: number) => void): void;
  131016. /**
  131017. * Gets the left trigger value
  131018. */
  131019. get leftTrigger(): number;
  131020. /**
  131021. * Sets the left trigger value
  131022. */
  131023. set leftTrigger(newValue: number);
  131024. /**
  131025. * Gets the right trigger value
  131026. */
  131027. get rightTrigger(): number;
  131028. /**
  131029. * Sets the right trigger value
  131030. */
  131031. set rightTrigger(newValue: number);
  131032. /**
  131033. * Defines the callback to call when a button is pressed
  131034. * @param callback defines the callback to use
  131035. */
  131036. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  131037. /**
  131038. * Defines the callback to call when a button is released
  131039. * @param callback defines the callback to use
  131040. */
  131041. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  131042. /**
  131043. * Defines the callback to call when a pad is pressed
  131044. * @param callback defines the callback to use
  131045. */
  131046. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  131047. /**
  131048. * Defines the callback to call when a pad is released
  131049. * @param callback defines the callback to use
  131050. */
  131051. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  131052. private _setButtonValue;
  131053. private _setDPadValue;
  131054. /**
  131055. * Gets the value of the `Cross` button
  131056. */
  131057. get buttonCross(): number;
  131058. /**
  131059. * Sets the value of the `Cross` button
  131060. */
  131061. set buttonCross(value: number);
  131062. /**
  131063. * Gets the value of the `Circle` button
  131064. */
  131065. get buttonCircle(): number;
  131066. /**
  131067. * Sets the value of the `Circle` button
  131068. */
  131069. set buttonCircle(value: number);
  131070. /**
  131071. * Gets the value of the `Square` button
  131072. */
  131073. get buttonSquare(): number;
  131074. /**
  131075. * Sets the value of the `Square` button
  131076. */
  131077. set buttonSquare(value: number);
  131078. /**
  131079. * Gets the value of the `Triangle` button
  131080. */
  131081. get buttonTriangle(): number;
  131082. /**
  131083. * Sets the value of the `Triangle` button
  131084. */
  131085. set buttonTriangle(value: number);
  131086. /**
  131087. * Gets the value of the `Options` button
  131088. */
  131089. get buttonOptions(): number;
  131090. /**
  131091. * Sets the value of the `Options` button
  131092. */
  131093. set buttonOptions(value: number);
  131094. /**
  131095. * Gets the value of the `Share` button
  131096. */
  131097. get buttonShare(): number;
  131098. /**
  131099. * Sets the value of the `Share` button
  131100. */
  131101. set buttonShare(value: number);
  131102. /**
  131103. * Gets the value of the `L1` button
  131104. */
  131105. get buttonL1(): number;
  131106. /**
  131107. * Sets the value of the `L1` button
  131108. */
  131109. set buttonL1(value: number);
  131110. /**
  131111. * Gets the value of the `R1` button
  131112. */
  131113. get buttonR1(): number;
  131114. /**
  131115. * Sets the value of the `R1` button
  131116. */
  131117. set buttonR1(value: number);
  131118. /**
  131119. * Gets the value of the Left joystick
  131120. */
  131121. get buttonLeftStick(): number;
  131122. /**
  131123. * Sets the value of the Left joystick
  131124. */
  131125. set buttonLeftStick(value: number);
  131126. /**
  131127. * Gets the value of the Right joystick
  131128. */
  131129. get buttonRightStick(): number;
  131130. /**
  131131. * Sets the value of the Right joystick
  131132. */
  131133. set buttonRightStick(value: number);
  131134. /**
  131135. * Gets the value of D-pad up
  131136. */
  131137. get dPadUp(): number;
  131138. /**
  131139. * Sets the value of D-pad up
  131140. */
  131141. set dPadUp(value: number);
  131142. /**
  131143. * Gets the value of D-pad down
  131144. */
  131145. get dPadDown(): number;
  131146. /**
  131147. * Sets the value of D-pad down
  131148. */
  131149. set dPadDown(value: number);
  131150. /**
  131151. * Gets the value of D-pad left
  131152. */
  131153. get dPadLeft(): number;
  131154. /**
  131155. * Sets the value of D-pad left
  131156. */
  131157. set dPadLeft(value: number);
  131158. /**
  131159. * Gets the value of D-pad right
  131160. */
  131161. get dPadRight(): number;
  131162. /**
  131163. * Sets the value of D-pad right
  131164. */
  131165. set dPadRight(value: number);
  131166. /**
  131167. * Force the gamepad to synchronize with device values
  131168. */
  131169. update(): void;
  131170. /**
  131171. * Disposes the gamepad
  131172. */
  131173. dispose(): void;
  131174. }
  131175. }
  131176. declare module BABYLON {
  131177. /**
  131178. * Manager for handling gamepads
  131179. */
  131180. export class GamepadManager {
  131181. private _scene?;
  131182. private _babylonGamepads;
  131183. private _oneGamepadConnected;
  131184. /** @hidden */
  131185. _isMonitoring: boolean;
  131186. private _gamepadEventSupported;
  131187. private _gamepadSupport?;
  131188. /**
  131189. * observable to be triggered when the gamepad controller has been connected
  131190. */
  131191. onGamepadConnectedObservable: Observable<Gamepad>;
  131192. /**
  131193. * observable to be triggered when the gamepad controller has been disconnected
  131194. */
  131195. onGamepadDisconnectedObservable: Observable<Gamepad>;
  131196. private _onGamepadConnectedEvent;
  131197. private _onGamepadDisconnectedEvent;
  131198. /**
  131199. * Initializes the gamepad manager
  131200. * @param _scene BabylonJS scene
  131201. */
  131202. constructor(_scene?: Scene | undefined);
  131203. /**
  131204. * The gamepads in the game pad manager
  131205. */
  131206. get gamepads(): Gamepad[];
  131207. /**
  131208. * Get the gamepad controllers based on type
  131209. * @param type The type of gamepad controller
  131210. * @returns Nullable gamepad
  131211. */
  131212. getGamepadByType(type?: number): Nullable<Gamepad>;
  131213. /**
  131214. * Disposes the gamepad manager
  131215. */
  131216. dispose(): void;
  131217. private _addNewGamepad;
  131218. private _startMonitoringGamepads;
  131219. private _stopMonitoringGamepads;
  131220. /** @hidden */
  131221. _checkGamepadsStatus(): void;
  131222. private _updateGamepadObjects;
  131223. }
  131224. }
  131225. declare module BABYLON {
  131226. interface Scene {
  131227. /** @hidden */
  131228. _gamepadManager: Nullable<GamepadManager>;
  131229. /**
  131230. * Gets the gamepad manager associated with the scene
  131231. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  131232. */
  131233. gamepadManager: GamepadManager;
  131234. }
  131235. /**
  131236. * Interface representing a free camera inputs manager
  131237. */
  131238. interface FreeCameraInputsManager {
  131239. /**
  131240. * Adds gamepad input support to the FreeCameraInputsManager.
  131241. * @returns the FreeCameraInputsManager
  131242. */
  131243. addGamepad(): FreeCameraInputsManager;
  131244. }
  131245. /**
  131246. * Interface representing an arc rotate camera inputs manager
  131247. */
  131248. interface ArcRotateCameraInputsManager {
  131249. /**
  131250. * Adds gamepad input support to the ArcRotateCamera InputManager.
  131251. * @returns the camera inputs manager
  131252. */
  131253. addGamepad(): ArcRotateCameraInputsManager;
  131254. }
  131255. /**
  131256. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  131257. */
  131258. export class GamepadSystemSceneComponent implements ISceneComponent {
  131259. /**
  131260. * The component name helpfull to identify the component in the list of scene components.
  131261. */
  131262. readonly name: string;
  131263. /**
  131264. * The scene the component belongs to.
  131265. */
  131266. scene: Scene;
  131267. /**
  131268. * Creates a new instance of the component for the given scene
  131269. * @param scene Defines the scene to register the component in
  131270. */
  131271. constructor(scene: Scene);
  131272. /**
  131273. * Registers the component in a given scene
  131274. */
  131275. register(): void;
  131276. /**
  131277. * Rebuilds the elements related to this component in case of
  131278. * context lost for instance.
  131279. */
  131280. rebuild(): void;
  131281. /**
  131282. * Disposes the component and the associated ressources
  131283. */
  131284. dispose(): void;
  131285. private _beforeCameraUpdate;
  131286. }
  131287. }
  131288. declare module BABYLON {
  131289. /**
  131290. * 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,
  131291. * which still works and will still be found in many Playgrounds.
  131292. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131293. */
  131294. export class UniversalCamera extends TouchCamera {
  131295. /**
  131296. * Defines the gamepad rotation sensiblity.
  131297. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131298. */
  131299. get gamepadAngularSensibility(): number;
  131300. set gamepadAngularSensibility(value: number);
  131301. /**
  131302. * Defines the gamepad move sensiblity.
  131303. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131304. */
  131305. get gamepadMoveSensibility(): number;
  131306. set gamepadMoveSensibility(value: number);
  131307. /**
  131308. * 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,
  131309. * which still works and will still be found in many Playgrounds.
  131310. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131311. * @param name Define the name of the camera in the scene
  131312. * @param position Define the start position of the camera in the scene
  131313. * @param scene Define the scene the camera belongs to
  131314. */
  131315. constructor(name: string, position: Vector3, scene: Scene);
  131316. /**
  131317. * Gets the current object class name.
  131318. * @return the class name
  131319. */
  131320. getClassName(): string;
  131321. }
  131322. }
  131323. declare module BABYLON {
  131324. /**
  131325. * This represents a FPS type of camera. This is only here for back compat purpose.
  131326. * Please use the UniversalCamera instead as both are identical.
  131327. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131328. */
  131329. export class GamepadCamera extends UniversalCamera {
  131330. /**
  131331. * Instantiates a new Gamepad Camera
  131332. * This represents a FPS type of camera. This is only here for back compat purpose.
  131333. * Please use the UniversalCamera instead as both are identical.
  131334. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131335. * @param name Define the name of the camera in the scene
  131336. * @param position Define the start position of the camera in the scene
  131337. * @param scene Define the scene the camera belongs to
  131338. */
  131339. constructor(name: string, position: Vector3, scene: Scene);
  131340. /**
  131341. * Gets the current object class name.
  131342. * @return the class name
  131343. */
  131344. getClassName(): string;
  131345. }
  131346. }
  131347. declare module BABYLON {
  131348. /** @hidden */
  131349. export var passPixelShader: {
  131350. name: string;
  131351. shader: string;
  131352. };
  131353. }
  131354. declare module BABYLON {
  131355. /** @hidden */
  131356. export var passCubePixelShader: {
  131357. name: string;
  131358. shader: string;
  131359. };
  131360. }
  131361. declare module BABYLON {
  131362. /**
  131363. * PassPostProcess which produces an output the same as it's input
  131364. */
  131365. export class PassPostProcess extends PostProcess {
  131366. /**
  131367. * Gets a string identifying the name of the class
  131368. * @returns "PassPostProcess" string
  131369. */
  131370. getClassName(): string;
  131371. /**
  131372. * Creates the PassPostProcess
  131373. * @param name The name of the effect.
  131374. * @param options The required width/height ratio to downsize to before computing the render pass.
  131375. * @param camera The camera to apply the render pass to.
  131376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131377. * @param engine The engine which the post process will be applied. (default: current engine)
  131378. * @param reusable If the post process can be reused on the same frame. (default: false)
  131379. * @param textureType The type of texture to be used when performing the post processing.
  131380. * @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)
  131381. */
  131382. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131383. /** @hidden */
  131384. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131385. }
  131386. /**
  131387. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131388. */
  131389. export class PassCubePostProcess extends PostProcess {
  131390. private _face;
  131391. /**
  131392. * Gets or sets the cube face to display.
  131393. * * 0 is +X
  131394. * * 1 is -X
  131395. * * 2 is +Y
  131396. * * 3 is -Y
  131397. * * 4 is +Z
  131398. * * 5 is -Z
  131399. */
  131400. get face(): number;
  131401. set face(value: number);
  131402. /**
  131403. * Gets a string identifying the name of the class
  131404. * @returns "PassCubePostProcess" string
  131405. */
  131406. getClassName(): string;
  131407. /**
  131408. * Creates the PassCubePostProcess
  131409. * @param name The name of the effect.
  131410. * @param options The required width/height ratio to downsize to before computing the render pass.
  131411. * @param camera The camera to apply the render pass to.
  131412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131413. * @param engine The engine which the post process will be applied. (default: current engine)
  131414. * @param reusable If the post process can be reused on the same frame. (default: false)
  131415. * @param textureType The type of texture to be used when performing the post processing.
  131416. * @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)
  131417. */
  131418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131419. /** @hidden */
  131420. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131421. }
  131422. }
  131423. declare module BABYLON {
  131424. /** @hidden */
  131425. export var anaglyphPixelShader: {
  131426. name: string;
  131427. shader: string;
  131428. };
  131429. }
  131430. declare module BABYLON {
  131431. /**
  131432. * Postprocess used to generate anaglyphic rendering
  131433. */
  131434. export class AnaglyphPostProcess extends PostProcess {
  131435. private _passedProcess;
  131436. /**
  131437. * Gets a string identifying the name of the class
  131438. * @returns "AnaglyphPostProcess" string
  131439. */
  131440. getClassName(): string;
  131441. /**
  131442. * Creates a new AnaglyphPostProcess
  131443. * @param name defines postprocess name
  131444. * @param options defines creation options or target ratio scale
  131445. * @param rigCameras defines cameras using this postprocess
  131446. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131447. * @param engine defines hosting engine
  131448. * @param reusable defines if the postprocess will be reused multiple times per frame
  131449. */
  131450. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131451. }
  131452. }
  131453. declare module BABYLON {
  131454. /**
  131455. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131456. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131457. */
  131458. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131459. /**
  131460. * Creates a new AnaglyphArcRotateCamera
  131461. * @param name defines camera name
  131462. * @param alpha defines alpha angle (in radians)
  131463. * @param beta defines beta angle (in radians)
  131464. * @param radius defines radius
  131465. * @param target defines camera target
  131466. * @param interaxialDistance defines distance between each color axis
  131467. * @param scene defines the hosting scene
  131468. */
  131469. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131470. /**
  131471. * Gets camera class name
  131472. * @returns AnaglyphArcRotateCamera
  131473. */
  131474. getClassName(): string;
  131475. }
  131476. }
  131477. declare module BABYLON {
  131478. /**
  131479. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131480. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131481. */
  131482. export class AnaglyphFreeCamera extends FreeCamera {
  131483. /**
  131484. * Creates a new AnaglyphFreeCamera
  131485. * @param name defines camera name
  131486. * @param position defines initial position
  131487. * @param interaxialDistance defines distance between each color axis
  131488. * @param scene defines the hosting scene
  131489. */
  131490. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131491. /**
  131492. * Gets camera class name
  131493. * @returns AnaglyphFreeCamera
  131494. */
  131495. getClassName(): string;
  131496. }
  131497. }
  131498. declare module BABYLON {
  131499. /**
  131500. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131501. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131502. */
  131503. export class AnaglyphGamepadCamera extends GamepadCamera {
  131504. /**
  131505. * Creates a new AnaglyphGamepadCamera
  131506. * @param name defines camera name
  131507. * @param position defines initial position
  131508. * @param interaxialDistance defines distance between each color axis
  131509. * @param scene defines the hosting scene
  131510. */
  131511. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131512. /**
  131513. * Gets camera class name
  131514. * @returns AnaglyphGamepadCamera
  131515. */
  131516. getClassName(): string;
  131517. }
  131518. }
  131519. declare module BABYLON {
  131520. /**
  131521. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131522. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131523. */
  131524. export class AnaglyphUniversalCamera extends UniversalCamera {
  131525. /**
  131526. * Creates a new AnaglyphUniversalCamera
  131527. * @param name defines camera name
  131528. * @param position defines initial position
  131529. * @param interaxialDistance defines distance between each color axis
  131530. * @param scene defines the hosting scene
  131531. */
  131532. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131533. /**
  131534. * Gets camera class name
  131535. * @returns AnaglyphUniversalCamera
  131536. */
  131537. getClassName(): string;
  131538. }
  131539. }
  131540. declare module BABYLON {
  131541. /**
  131542. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131543. * @see https://doc.babylonjs.com/features/cameras
  131544. */
  131545. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131546. /**
  131547. * Creates a new StereoscopicArcRotateCamera
  131548. * @param name defines camera name
  131549. * @param alpha defines alpha angle (in radians)
  131550. * @param beta defines beta angle (in radians)
  131551. * @param radius defines radius
  131552. * @param target defines camera target
  131553. * @param interaxialDistance defines distance between each color axis
  131554. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131555. * @param scene defines the hosting scene
  131556. */
  131557. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131558. /**
  131559. * Gets camera class name
  131560. * @returns StereoscopicArcRotateCamera
  131561. */
  131562. getClassName(): string;
  131563. }
  131564. }
  131565. declare module BABYLON {
  131566. /**
  131567. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131568. * @see https://doc.babylonjs.com/features/cameras
  131569. */
  131570. export class StereoscopicFreeCamera extends FreeCamera {
  131571. /**
  131572. * Creates a new StereoscopicFreeCamera
  131573. * @param name defines camera name
  131574. * @param position defines initial position
  131575. * @param interaxialDistance defines distance between each color axis
  131576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131577. * @param scene defines the hosting scene
  131578. */
  131579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131580. /**
  131581. * Gets camera class name
  131582. * @returns StereoscopicFreeCamera
  131583. */
  131584. getClassName(): string;
  131585. }
  131586. }
  131587. declare module BABYLON {
  131588. /**
  131589. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131590. * @see https://doc.babylonjs.com/features/cameras
  131591. */
  131592. export class StereoscopicGamepadCamera extends GamepadCamera {
  131593. /**
  131594. * Creates a new StereoscopicGamepadCamera
  131595. * @param name defines camera name
  131596. * @param position defines initial position
  131597. * @param interaxialDistance defines distance between each color axis
  131598. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131599. * @param scene defines the hosting scene
  131600. */
  131601. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131602. /**
  131603. * Gets camera class name
  131604. * @returns StereoscopicGamepadCamera
  131605. */
  131606. getClassName(): string;
  131607. }
  131608. }
  131609. declare module BABYLON {
  131610. /**
  131611. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131612. * @see https://doc.babylonjs.com/features/cameras
  131613. */
  131614. export class StereoscopicUniversalCamera extends UniversalCamera {
  131615. /**
  131616. * Creates a new StereoscopicUniversalCamera
  131617. * @param name defines camera name
  131618. * @param position defines initial position
  131619. * @param interaxialDistance defines distance between each color axis
  131620. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131621. * @param scene defines the hosting scene
  131622. */
  131623. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131624. /**
  131625. * Gets camera class name
  131626. * @returns StereoscopicUniversalCamera
  131627. */
  131628. getClassName(): string;
  131629. }
  131630. }
  131631. declare module BABYLON {
  131632. /**
  131633. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131634. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131635. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131636. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131637. */
  131638. export class VirtualJoysticksCamera extends FreeCamera {
  131639. /**
  131640. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131641. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131642. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131643. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131644. * @param name Define the name of the camera in the scene
  131645. * @param position Define the start position of the camera in the scene
  131646. * @param scene Define the scene the camera belongs to
  131647. */
  131648. constructor(name: string, position: Vector3, scene: Scene);
  131649. /**
  131650. * Gets the current object class name.
  131651. * @return the class name
  131652. */
  131653. getClassName(): string;
  131654. }
  131655. }
  131656. declare module BABYLON {
  131657. /**
  131658. * This represents all the required metrics to create a VR camera.
  131659. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131660. */
  131661. export class VRCameraMetrics {
  131662. /**
  131663. * Define the horizontal resolution off the screen.
  131664. */
  131665. hResolution: number;
  131666. /**
  131667. * Define the vertical resolution off the screen.
  131668. */
  131669. vResolution: number;
  131670. /**
  131671. * Define the horizontal screen size.
  131672. */
  131673. hScreenSize: number;
  131674. /**
  131675. * Define the vertical screen size.
  131676. */
  131677. vScreenSize: number;
  131678. /**
  131679. * Define the vertical screen center position.
  131680. */
  131681. vScreenCenter: number;
  131682. /**
  131683. * Define the distance of the eyes to the screen.
  131684. */
  131685. eyeToScreenDistance: number;
  131686. /**
  131687. * Define the distance between both lenses
  131688. */
  131689. lensSeparationDistance: number;
  131690. /**
  131691. * Define the distance between both viewer's eyes.
  131692. */
  131693. interpupillaryDistance: number;
  131694. /**
  131695. * Define the distortion factor of the VR postprocess.
  131696. * Please, touch with care.
  131697. */
  131698. distortionK: number[];
  131699. /**
  131700. * Define the chromatic aberration correction factors for the VR post process.
  131701. */
  131702. chromaAbCorrection: number[];
  131703. /**
  131704. * Define the scale factor of the post process.
  131705. * The smaller the better but the slower.
  131706. */
  131707. postProcessScaleFactor: number;
  131708. /**
  131709. * Define an offset for the lens center.
  131710. */
  131711. lensCenterOffset: number;
  131712. /**
  131713. * Define if the current vr camera should compensate the distortion of the lense or not.
  131714. */
  131715. compensateDistortion: boolean;
  131716. /**
  131717. * Defines if multiview should be enabled when rendering (Default: false)
  131718. */
  131719. multiviewEnabled: boolean;
  131720. /**
  131721. * Gets the rendering aspect ratio based on the provided resolutions.
  131722. */
  131723. get aspectRatio(): number;
  131724. /**
  131725. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131726. */
  131727. get aspectRatioFov(): number;
  131728. /**
  131729. * @hidden
  131730. */
  131731. get leftHMatrix(): Matrix;
  131732. /**
  131733. * @hidden
  131734. */
  131735. get rightHMatrix(): Matrix;
  131736. /**
  131737. * @hidden
  131738. */
  131739. get leftPreViewMatrix(): Matrix;
  131740. /**
  131741. * @hidden
  131742. */
  131743. get rightPreViewMatrix(): Matrix;
  131744. /**
  131745. * Get the default VRMetrics based on the most generic setup.
  131746. * @returns the default vr metrics
  131747. */
  131748. static GetDefault(): VRCameraMetrics;
  131749. }
  131750. }
  131751. declare module BABYLON {
  131752. /** @hidden */
  131753. export var vrDistortionCorrectionPixelShader: {
  131754. name: string;
  131755. shader: string;
  131756. };
  131757. }
  131758. declare module BABYLON {
  131759. /**
  131760. * VRDistortionCorrectionPostProcess used for mobile VR
  131761. */
  131762. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131763. private _isRightEye;
  131764. private _distortionFactors;
  131765. private _postProcessScaleFactor;
  131766. private _lensCenterOffset;
  131767. private _scaleIn;
  131768. private _scaleFactor;
  131769. private _lensCenter;
  131770. /**
  131771. * Gets a string identifying the name of the class
  131772. * @returns "VRDistortionCorrectionPostProcess" string
  131773. */
  131774. getClassName(): string;
  131775. /**
  131776. * Initializes the VRDistortionCorrectionPostProcess
  131777. * @param name The name of the effect.
  131778. * @param camera The camera to apply the render pass to.
  131779. * @param isRightEye If this is for the right eye distortion
  131780. * @param vrMetrics All the required metrics for the VR camera
  131781. */
  131782. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131783. }
  131784. }
  131785. declare module BABYLON {
  131786. /**
  131787. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131788. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131789. */
  131790. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131791. /**
  131792. * Creates a new VRDeviceOrientationArcRotateCamera
  131793. * @param name defines camera name
  131794. * @param alpha defines the camera rotation along the logitudinal axis
  131795. * @param beta defines the camera rotation along the latitudinal axis
  131796. * @param radius defines the camera distance from its target
  131797. * @param target defines the camera target
  131798. * @param scene defines the scene the camera belongs to
  131799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131801. */
  131802. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131803. /**
  131804. * Gets camera class name
  131805. * @returns VRDeviceOrientationArcRotateCamera
  131806. */
  131807. getClassName(): string;
  131808. }
  131809. }
  131810. declare module BABYLON {
  131811. /**
  131812. * Camera used to simulate VR rendering (based on FreeCamera)
  131813. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131814. */
  131815. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131816. /**
  131817. * Creates a new VRDeviceOrientationFreeCamera
  131818. * @param name defines camera name
  131819. * @param position defines the start position of the camera
  131820. * @param scene defines the scene the camera belongs to
  131821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131823. */
  131824. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131825. /**
  131826. * Gets camera class name
  131827. * @returns VRDeviceOrientationFreeCamera
  131828. */
  131829. getClassName(): string;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131835. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131836. */
  131837. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131838. /**
  131839. * Creates a new VRDeviceOrientationGamepadCamera
  131840. * @param name defines camera name
  131841. * @param position defines the start position of the camera
  131842. * @param scene defines the scene the camera belongs to
  131843. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131844. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131845. */
  131846. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131847. /**
  131848. * Gets camera class name
  131849. * @returns VRDeviceOrientationGamepadCamera
  131850. */
  131851. getClassName(): string;
  131852. }
  131853. }
  131854. declare module BABYLON {
  131855. /**
  131856. * A class extending Texture allowing drawing on a texture
  131857. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131858. */
  131859. export class DynamicTexture extends Texture {
  131860. private _generateMipMaps;
  131861. private _canvas;
  131862. private _context;
  131863. /**
  131864. * Creates a DynamicTexture
  131865. * @param name defines the name of the texture
  131866. * @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
  131867. * @param scene defines the scene where you want the texture
  131868. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131869. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131870. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131871. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131872. */
  131873. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131874. /**
  131875. * Get the current class name of the texture useful for serialization or dynamic coding.
  131876. * @returns "DynamicTexture"
  131877. */
  131878. getClassName(): string;
  131879. /**
  131880. * Gets the current state of canRescale
  131881. */
  131882. get canRescale(): boolean;
  131883. private _recreate;
  131884. /**
  131885. * Scales the texture
  131886. * @param ratio the scale factor to apply to both width and height
  131887. */
  131888. scale(ratio: number): void;
  131889. /**
  131890. * Resizes the texture
  131891. * @param width the new width
  131892. * @param height the new height
  131893. */
  131894. scaleTo(width: number, height: number): void;
  131895. /**
  131896. * Gets the context of the canvas used by the texture
  131897. * @returns the canvas context of the dynamic texture
  131898. */
  131899. getContext(): CanvasRenderingContext2D;
  131900. /**
  131901. * Clears the texture
  131902. */
  131903. clear(): void;
  131904. /**
  131905. * Updates the texture
  131906. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131907. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131908. */
  131909. update(invertY?: boolean, premulAlpha?: boolean): void;
  131910. /**
  131911. * Draws text onto the texture
  131912. * @param text defines the text to be drawn
  131913. * @param x defines the placement of the text from the left
  131914. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131915. * @param font defines the font to be used with font-style, font-size, font-name
  131916. * @param color defines the color used for the text
  131917. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131918. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131919. * @param update defines whether texture is immediately update (default is true)
  131920. */
  131921. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131922. /**
  131923. * Clones the texture
  131924. * @returns the clone of the texture.
  131925. */
  131926. clone(): DynamicTexture;
  131927. /**
  131928. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131929. * @returns a serialized dynamic texture object
  131930. */
  131931. serialize(): any;
  131932. private _IsCanvasElement;
  131933. /** @hidden */
  131934. _rebuild(): void;
  131935. }
  131936. }
  131937. declare module BABYLON {
  131938. /**
  131939. * Class containing static functions to help procedurally build meshes
  131940. */
  131941. export class GroundBuilder {
  131942. /**
  131943. * Creates a ground mesh
  131944. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131945. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131947. * @param name defines the name of the mesh
  131948. * @param options defines the options used to create the mesh
  131949. * @param scene defines the hosting scene
  131950. * @returns the ground mesh
  131951. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131952. */
  131953. static CreateGround(name: string, options: {
  131954. width?: number;
  131955. height?: number;
  131956. subdivisions?: number;
  131957. subdivisionsX?: number;
  131958. subdivisionsY?: number;
  131959. updatable?: boolean;
  131960. }, scene: any): Mesh;
  131961. /**
  131962. * Creates a tiled ground mesh
  131963. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131964. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131965. * * 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
  131966. * * 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
  131967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131968. * @param name defines the name of the mesh
  131969. * @param options defines the options used to create the mesh
  131970. * @param scene defines the hosting scene
  131971. * @returns the tiled ground mesh
  131972. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131973. */
  131974. static CreateTiledGround(name: string, options: {
  131975. xmin: number;
  131976. zmin: number;
  131977. xmax: number;
  131978. zmax: number;
  131979. subdivisions?: {
  131980. w: number;
  131981. h: number;
  131982. };
  131983. precision?: {
  131984. w: number;
  131985. h: number;
  131986. };
  131987. updatable?: boolean;
  131988. }, scene?: Nullable<Scene>): Mesh;
  131989. /**
  131990. * Creates a ground mesh from a height map
  131991. * * The parameter `url` sets the URL of the height map image resource.
  131992. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131993. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131994. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131995. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131996. * * 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.
  131997. * * 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).
  131998. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132000. * @param name defines the name of the mesh
  132001. * @param url defines the url to the height map
  132002. * @param options defines the options used to create the mesh
  132003. * @param scene defines the hosting scene
  132004. * @returns the ground mesh
  132005. * @see https://doc.babylonjs.com/babylon101/height_map
  132006. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  132007. */
  132008. static CreateGroundFromHeightMap(name: string, url: string, options: {
  132009. width?: number;
  132010. height?: number;
  132011. subdivisions?: number;
  132012. minHeight?: number;
  132013. maxHeight?: number;
  132014. colorFilter?: Color3;
  132015. alphaFilter?: number;
  132016. updatable?: boolean;
  132017. onReady?: (mesh: GroundMesh) => void;
  132018. }, scene?: Nullable<Scene>): GroundMesh;
  132019. }
  132020. }
  132021. declare module BABYLON {
  132022. /**
  132023. * Class containing static functions to help procedurally build meshes
  132024. */
  132025. export class TorusBuilder {
  132026. /**
  132027. * Creates a torus mesh
  132028. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  132029. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  132030. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  132031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132034. * @param name defines the name of the mesh
  132035. * @param options defines the options used to create the mesh
  132036. * @param scene defines the hosting scene
  132037. * @returns the torus mesh
  132038. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  132039. */
  132040. static CreateTorus(name: string, options: {
  132041. diameter?: number;
  132042. thickness?: number;
  132043. tessellation?: number;
  132044. updatable?: boolean;
  132045. sideOrientation?: number;
  132046. frontUVs?: Vector4;
  132047. backUVs?: Vector4;
  132048. }, scene: any): Mesh;
  132049. }
  132050. }
  132051. declare module BABYLON {
  132052. /**
  132053. * Class containing static functions to help procedurally build meshes
  132054. */
  132055. export class CylinderBuilder {
  132056. /**
  132057. * Creates a cylinder or a cone mesh
  132058. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  132059. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  132060. * * 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.
  132061. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  132062. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  132063. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  132064. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  132065. * * 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).
  132066. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  132067. * * 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).
  132068. * * 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
  132069. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  132070. * * 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
  132071. * * 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.
  132072. * * If `enclose` is false, a ring surface is one element.
  132073. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  132074. * * 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
  132075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132078. * @param name defines the name of the mesh
  132079. * @param options defines the options used to create the mesh
  132080. * @param scene defines the hosting scene
  132081. * @returns the cylinder mesh
  132082. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  132083. */
  132084. static CreateCylinder(name: string, options: {
  132085. height?: number;
  132086. diameterTop?: number;
  132087. diameterBottom?: number;
  132088. diameter?: number;
  132089. tessellation?: number;
  132090. subdivisions?: number;
  132091. arc?: number;
  132092. faceColors?: Color4[];
  132093. faceUV?: Vector4[];
  132094. updatable?: boolean;
  132095. hasRings?: boolean;
  132096. enclose?: boolean;
  132097. cap?: number;
  132098. sideOrientation?: number;
  132099. frontUVs?: Vector4;
  132100. backUVs?: Vector4;
  132101. }, scene: any): Mesh;
  132102. }
  132103. }
  132104. declare module BABYLON {
  132105. /**
  132106. * States of the webXR experience
  132107. */
  132108. export enum WebXRState {
  132109. /**
  132110. * Transitioning to being in XR mode
  132111. */
  132112. ENTERING_XR = 0,
  132113. /**
  132114. * Transitioning to non XR mode
  132115. */
  132116. EXITING_XR = 1,
  132117. /**
  132118. * In XR mode and presenting
  132119. */
  132120. IN_XR = 2,
  132121. /**
  132122. * Not entered XR mode
  132123. */
  132124. NOT_IN_XR = 3
  132125. }
  132126. /**
  132127. * The state of the XR camera's tracking
  132128. */
  132129. export enum WebXRTrackingState {
  132130. /**
  132131. * No transformation received, device is not being tracked
  132132. */
  132133. NOT_TRACKING = 0,
  132134. /**
  132135. * Tracking lost - using emulated position
  132136. */
  132137. TRACKING_LOST = 1,
  132138. /**
  132139. * Transformation tracking works normally
  132140. */
  132141. TRACKING = 2
  132142. }
  132143. /**
  132144. * Abstraction of the XR render target
  132145. */
  132146. export interface WebXRRenderTarget extends IDisposable {
  132147. /**
  132148. * xrpresent context of the canvas which can be used to display/mirror xr content
  132149. */
  132150. canvasContext: WebGLRenderingContext;
  132151. /**
  132152. * xr layer for the canvas
  132153. */
  132154. xrLayer: Nullable<XRWebGLLayer>;
  132155. /**
  132156. * Initializes the xr layer for the session
  132157. * @param xrSession xr session
  132158. * @returns a promise that will resolve once the XR Layer has been created
  132159. */
  132160. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132161. }
  132162. }
  132163. declare module BABYLON {
  132164. /**
  132165. * COnfiguration object for WebXR output canvas
  132166. */
  132167. export class WebXRManagedOutputCanvasOptions {
  132168. /**
  132169. * An optional canvas in case you wish to create it yourself and provide it here.
  132170. * If not provided, a new canvas will be created
  132171. */
  132172. canvasElement?: HTMLCanvasElement;
  132173. /**
  132174. * Options for this XR Layer output
  132175. */
  132176. canvasOptions?: XRWebGLLayerInit;
  132177. /**
  132178. * CSS styling for a newly created canvas (if not provided)
  132179. */
  132180. newCanvasCssStyle?: string;
  132181. /**
  132182. * Get the default values of the configuration object
  132183. * @param engine defines the engine to use (can be null)
  132184. * @returns default values of this configuration object
  132185. */
  132186. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  132187. }
  132188. /**
  132189. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  132190. */
  132191. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  132192. private _options;
  132193. private _canvas;
  132194. private _engine;
  132195. private _originalCanvasSize;
  132196. /**
  132197. * Rendering context of the canvas which can be used to display/mirror xr content
  132198. */
  132199. canvasContext: WebGLRenderingContext;
  132200. /**
  132201. * xr layer for the canvas
  132202. */
  132203. xrLayer: Nullable<XRWebGLLayer>;
  132204. /**
  132205. * Obseervers registered here will be triggered when the xr layer was initialized
  132206. */
  132207. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  132208. /**
  132209. * Initializes the canvas to be added/removed upon entering/exiting xr
  132210. * @param _xrSessionManager The XR Session manager
  132211. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  132212. */
  132213. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  132214. /**
  132215. * Disposes of the object
  132216. */
  132217. dispose(): void;
  132218. /**
  132219. * Initializes the xr layer for the session
  132220. * @param xrSession xr session
  132221. * @returns a promise that will resolve once the XR Layer has been created
  132222. */
  132223. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132224. private _addCanvas;
  132225. private _removeCanvas;
  132226. private _setCanvasSize;
  132227. private _setManagedOutputCanvas;
  132228. }
  132229. }
  132230. declare module BABYLON {
  132231. /**
  132232. * Manages an XRSession to work with Babylon's engine
  132233. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  132234. */
  132235. export class WebXRSessionManager implements IDisposable {
  132236. /** The scene which the session should be created for */
  132237. scene: Scene;
  132238. private _referenceSpace;
  132239. private _rttProvider;
  132240. private _sessionEnded;
  132241. private _xrNavigator;
  132242. private baseLayer;
  132243. /**
  132244. * The base reference space from which the session started. good if you want to reset your
  132245. * reference space
  132246. */
  132247. baseReferenceSpace: XRReferenceSpace;
  132248. /**
  132249. * Current XR frame
  132250. */
  132251. currentFrame: Nullable<XRFrame>;
  132252. /** WebXR timestamp updated every frame */
  132253. currentTimestamp: number;
  132254. /**
  132255. * Used just in case of a failure to initialize an immersive session.
  132256. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  132257. */
  132258. defaultHeightCompensation: number;
  132259. /**
  132260. * Fires every time a new xrFrame arrives which can be used to update the camera
  132261. */
  132262. onXRFrameObservable: Observable<XRFrame>;
  132263. /**
  132264. * Fires when the reference space changed
  132265. */
  132266. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  132267. /**
  132268. * Fires when the xr session is ended either by the device or manually done
  132269. */
  132270. onXRSessionEnded: Observable<any>;
  132271. /**
  132272. * Fires when the xr session is ended either by the device or manually done
  132273. */
  132274. onXRSessionInit: Observable<XRSession>;
  132275. /**
  132276. * Underlying xr session
  132277. */
  132278. session: XRSession;
  132279. /**
  132280. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  132281. * or get the offset the player is currently at.
  132282. */
  132283. viewerReferenceSpace: XRReferenceSpace;
  132284. /**
  132285. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132286. * @param scene The scene which the session should be created for
  132287. */
  132288. constructor(
  132289. /** The scene which the session should be created for */
  132290. scene: Scene);
  132291. /**
  132292. * The current reference space used in this session. This reference space can constantly change!
  132293. * It is mainly used to offset the camera's position.
  132294. */
  132295. get referenceSpace(): XRReferenceSpace;
  132296. /**
  132297. * Set a new reference space and triggers the observable
  132298. */
  132299. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132300. /**
  132301. * Disposes of the session manager
  132302. */
  132303. dispose(): void;
  132304. /**
  132305. * Stops the xrSession and restores the render loop
  132306. * @returns Promise which resolves after it exits XR
  132307. */
  132308. exitXRAsync(): Promise<void>;
  132309. /**
  132310. * Gets the correct render target texture to be rendered this frame for this eye
  132311. * @param eye the eye for which to get the render target
  132312. * @returns the render target for the specified eye
  132313. */
  132314. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132315. /**
  132316. * Creates a WebXRRenderTarget object for the XR session
  132317. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132318. * @param options optional options to provide when creating a new render target
  132319. * @returns a WebXR render target to which the session can render
  132320. */
  132321. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132322. /**
  132323. * Initializes the manager
  132324. * After initialization enterXR can be called to start an XR session
  132325. * @returns Promise which resolves after it is initialized
  132326. */
  132327. initializeAsync(): Promise<void>;
  132328. /**
  132329. * Initializes an xr session
  132330. * @param xrSessionMode mode to initialize
  132331. * @param xrSessionInit defines optional and required values to pass to the session builder
  132332. * @returns a promise which will resolve once the session has been initialized
  132333. */
  132334. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132335. /**
  132336. * Checks if a session would be supported for the creation options specified
  132337. * @param sessionMode session mode to check if supported eg. immersive-vr
  132338. * @returns A Promise that resolves to true if supported and false if not
  132339. */
  132340. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132341. /**
  132342. * Resets the reference space to the one started the session
  132343. */
  132344. resetReferenceSpace(): void;
  132345. /**
  132346. * Starts rendering to the xr layer
  132347. */
  132348. runXRRenderLoop(): void;
  132349. /**
  132350. * Sets the reference space on the xr session
  132351. * @param referenceSpaceType space to set
  132352. * @returns a promise that will resolve once the reference space has been set
  132353. */
  132354. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132355. /**
  132356. * Updates the render state of the session
  132357. * @param state state to set
  132358. * @returns a promise that resolves once the render state has been updated
  132359. */
  132360. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132361. /**
  132362. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132363. * @param sessionMode defines the session to test
  132364. * @returns a promise with boolean as final value
  132365. */
  132366. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132367. private _createRenderTargetTexture;
  132368. }
  132369. }
  132370. declare module BABYLON {
  132371. /**
  132372. * WebXR Camera which holds the views for the xrSession
  132373. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132374. */
  132375. export class WebXRCamera extends FreeCamera {
  132376. private _xrSessionManager;
  132377. private _firstFrame;
  132378. private _referenceQuaternion;
  132379. private _referencedPosition;
  132380. private _xrInvPositionCache;
  132381. private _xrInvQuaternionCache;
  132382. private _trackingState;
  132383. /**
  132384. * Observable raised before camera teleportation
  132385. */
  132386. onBeforeCameraTeleport: Observable<Vector3>;
  132387. /**
  132388. * Observable raised after camera teleportation
  132389. */
  132390. onAfterCameraTeleport: Observable<Vector3>;
  132391. /**
  132392. * Notifies when the camera's tracking state has changed.
  132393. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132394. */
  132395. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132396. /**
  132397. * Should position compensation execute on first frame.
  132398. * This is used when copying the position from a native (non XR) camera
  132399. */
  132400. compensateOnFirstFrame: boolean;
  132401. /**
  132402. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132403. * @param name the name of the camera
  132404. * @param scene the scene to add the camera to
  132405. * @param _xrSessionManager a constructed xr session manager
  132406. */
  132407. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132408. /**
  132409. * Get the current XR tracking state of the camera
  132410. */
  132411. get trackingState(): WebXRTrackingState;
  132412. private _setTrackingState;
  132413. /**
  132414. * Return the user's height, unrelated to the current ground.
  132415. * This will be the y position of this camera, when ground level is 0.
  132416. */
  132417. get realWorldHeight(): number;
  132418. /** @hidden */
  132419. _updateForDualEyeDebugging(): void;
  132420. /**
  132421. * Sets this camera's transformation based on a non-vr camera
  132422. * @param otherCamera the non-vr camera to copy the transformation from
  132423. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132424. */
  132425. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132426. /**
  132427. * Gets the current instance class name ("WebXRCamera").
  132428. * @returns the class name
  132429. */
  132430. getClassName(): string;
  132431. private _rotate180;
  132432. private _updateFromXRSession;
  132433. private _updateNumberOfRigCameras;
  132434. private _updateReferenceSpace;
  132435. private _updateReferenceSpaceOffset;
  132436. }
  132437. }
  132438. declare module BABYLON {
  132439. /**
  132440. * Defining the interface required for a (webxr) feature
  132441. */
  132442. export interface IWebXRFeature extends IDisposable {
  132443. /**
  132444. * Is this feature attached
  132445. */
  132446. attached: boolean;
  132447. /**
  132448. * Should auto-attach be disabled?
  132449. */
  132450. disableAutoAttach: boolean;
  132451. /**
  132452. * Attach the feature to the session
  132453. * Will usually be called by the features manager
  132454. *
  132455. * @param force should attachment be forced (even when already attached)
  132456. * @returns true if successful.
  132457. */
  132458. attach(force?: boolean): boolean;
  132459. /**
  132460. * Detach the feature from the session
  132461. * Will usually be called by the features manager
  132462. *
  132463. * @returns true if successful.
  132464. */
  132465. detach(): boolean;
  132466. /**
  132467. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132468. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132469. *
  132470. * @returns whether or not the feature is compatible in this environment
  132471. */
  132472. isCompatible(): boolean;
  132473. /**
  132474. * Was this feature disposed;
  132475. */
  132476. isDisposed: boolean;
  132477. /**
  132478. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132479. */
  132480. xrNativeFeatureName?: string;
  132481. /**
  132482. * A list of (Babylon WebXR) features this feature depends on
  132483. */
  132484. dependsOn?: string[];
  132485. }
  132486. /**
  132487. * A list of the currently available features without referencing them
  132488. */
  132489. export class WebXRFeatureName {
  132490. /**
  132491. * The name of the anchor system feature
  132492. */
  132493. static readonly ANCHOR_SYSTEM: string;
  132494. /**
  132495. * The name of the background remover feature
  132496. */
  132497. static readonly BACKGROUND_REMOVER: string;
  132498. /**
  132499. * The name of the hit test feature
  132500. */
  132501. static readonly HIT_TEST: string;
  132502. /**
  132503. * physics impostors for xr controllers feature
  132504. */
  132505. static readonly PHYSICS_CONTROLLERS: string;
  132506. /**
  132507. * The name of the plane detection feature
  132508. */
  132509. static readonly PLANE_DETECTION: string;
  132510. /**
  132511. * The name of the pointer selection feature
  132512. */
  132513. static readonly POINTER_SELECTION: string;
  132514. /**
  132515. * The name of the teleportation feature
  132516. */
  132517. static readonly TELEPORTATION: string;
  132518. /**
  132519. * The name of the feature points feature.
  132520. */
  132521. static readonly FEATURE_POINTS: string;
  132522. /**
  132523. * The name of the hand tracking feature.
  132524. */
  132525. static readonly HAND_TRACKING: string;
  132526. }
  132527. /**
  132528. * Defining the constructor of a feature. Used to register the modules.
  132529. */
  132530. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132531. /**
  132532. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132533. * It is mainly used in AR sessions.
  132534. *
  132535. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132536. */
  132537. export class WebXRFeaturesManager implements IDisposable {
  132538. private _xrSessionManager;
  132539. private static readonly _AvailableFeatures;
  132540. private _features;
  132541. /**
  132542. * constructs a new features manages.
  132543. *
  132544. * @param _xrSessionManager an instance of WebXRSessionManager
  132545. */
  132546. constructor(_xrSessionManager: WebXRSessionManager);
  132547. /**
  132548. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132549. * Mainly used internally.
  132550. *
  132551. * @param featureName the name of the feature to register
  132552. * @param constructorFunction the function used to construct the module
  132553. * @param version the (babylon) version of the module
  132554. * @param stable is that a stable version of this module
  132555. */
  132556. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132557. /**
  132558. * Returns a constructor of a specific feature.
  132559. *
  132560. * @param featureName the name of the feature to construct
  132561. * @param version the version of the feature to load
  132562. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132563. * @param options optional options provided to the module.
  132564. * @returns a function that, when called, will return a new instance of this feature
  132565. */
  132566. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132567. /**
  132568. * Can be used to return the list of features currently registered
  132569. *
  132570. * @returns an Array of available features
  132571. */
  132572. static GetAvailableFeatures(): string[];
  132573. /**
  132574. * Gets the versions available for a specific feature
  132575. * @param featureName the name of the feature
  132576. * @returns an array with the available versions
  132577. */
  132578. static GetAvailableVersions(featureName: string): string[];
  132579. /**
  132580. * Return the latest unstable version of this feature
  132581. * @param featureName the name of the feature to search
  132582. * @returns the version number. if not found will return -1
  132583. */
  132584. static GetLatestVersionOfFeature(featureName: string): number;
  132585. /**
  132586. * Return the latest stable version of this feature
  132587. * @param featureName the name of the feature to search
  132588. * @returns the version number. if not found will return -1
  132589. */
  132590. static GetStableVersionOfFeature(featureName: string): number;
  132591. /**
  132592. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132593. * Can be used during a session to start a feature
  132594. * @param featureName the name of feature to attach
  132595. */
  132596. attachFeature(featureName: string): void;
  132597. /**
  132598. * Can be used inside a session or when the session ends to detach a specific feature
  132599. * @param featureName the name of the feature to detach
  132600. */
  132601. detachFeature(featureName: string): void;
  132602. /**
  132603. * Used to disable an already-enabled feature
  132604. * The feature will be disposed and will be recreated once enabled.
  132605. * @param featureName the feature to disable
  132606. * @returns true if disable was successful
  132607. */
  132608. disableFeature(featureName: string | {
  132609. Name: string;
  132610. }): boolean;
  132611. /**
  132612. * dispose this features manager
  132613. */
  132614. dispose(): void;
  132615. /**
  132616. * 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.
  132617. * 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.
  132618. *
  132619. * @param featureName the name of the feature to load or the class of the feature
  132620. * @param version optional version to load. if not provided the latest version will be enabled
  132621. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132622. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132623. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132624. * @returns a new constructed feature or throws an error if feature not found.
  132625. */
  132626. enableFeature(featureName: string | {
  132627. Name: string;
  132628. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132629. /**
  132630. * get the implementation of an enabled feature.
  132631. * @param featureName the name of the feature to load
  132632. * @returns the feature class, if found
  132633. */
  132634. getEnabledFeature(featureName: string): IWebXRFeature;
  132635. /**
  132636. * Get the list of enabled features
  132637. * @returns an array of enabled features
  132638. */
  132639. getEnabledFeatures(): string[];
  132640. /**
  132641. * This function will exten the session creation configuration object with enabled features.
  132642. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132643. * according to the defined "required" variable, provided during enableFeature call
  132644. * @param xrSessionInit the xr Session init object to extend
  132645. *
  132646. * @returns an extended XRSessionInit object
  132647. */
  132648. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132649. }
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132654. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132655. */
  132656. export class WebXRExperienceHelper implements IDisposable {
  132657. private scene;
  132658. private _nonVRCamera;
  132659. private _originalSceneAutoClear;
  132660. private _supported;
  132661. /**
  132662. * Camera used to render xr content
  132663. */
  132664. camera: WebXRCamera;
  132665. /** A features manager for this xr session */
  132666. featuresManager: WebXRFeaturesManager;
  132667. /**
  132668. * Observers registered here will be triggered after the camera's initial transformation is set
  132669. * This can be used to set a different ground level or an extra rotation.
  132670. *
  132671. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132672. * to the position set after this observable is done executing.
  132673. */
  132674. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132675. /**
  132676. * Fires when the state of the experience helper has changed
  132677. */
  132678. onStateChangedObservable: Observable<WebXRState>;
  132679. /** Session manager used to keep track of xr session */
  132680. sessionManager: WebXRSessionManager;
  132681. /**
  132682. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132683. */
  132684. state: WebXRState;
  132685. /**
  132686. * Creates a WebXRExperienceHelper
  132687. * @param scene The scene the helper should be created in
  132688. */
  132689. private constructor();
  132690. /**
  132691. * Creates the experience helper
  132692. * @param scene the scene to attach the experience helper to
  132693. * @returns a promise for the experience helper
  132694. */
  132695. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132696. /**
  132697. * Disposes of the experience helper
  132698. */
  132699. dispose(): void;
  132700. /**
  132701. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132702. * @param sessionMode options for the XR session
  132703. * @param referenceSpaceType frame of reference of the XR session
  132704. * @param renderTarget the output canvas that will be used to enter XR mode
  132705. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132706. * @returns promise that resolves after xr mode has entered
  132707. */
  132708. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132709. /**
  132710. * Exits XR mode and returns the scene to its original state
  132711. * @returns promise that resolves after xr mode has exited
  132712. */
  132713. exitXRAsync(): Promise<void>;
  132714. private _nonXRToXRCamera;
  132715. private _setState;
  132716. }
  132717. }
  132718. declare module BABYLON {
  132719. /**
  132720. * X-Y values for axes in WebXR
  132721. */
  132722. export interface IWebXRMotionControllerAxesValue {
  132723. /**
  132724. * The value of the x axis
  132725. */
  132726. x: number;
  132727. /**
  132728. * The value of the y-axis
  132729. */
  132730. y: number;
  132731. }
  132732. /**
  132733. * changed / previous values for the values of this component
  132734. */
  132735. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132736. /**
  132737. * current (this frame) value
  132738. */
  132739. current: T;
  132740. /**
  132741. * previous (last change) value
  132742. */
  132743. previous: T;
  132744. }
  132745. /**
  132746. * Represents changes in the component between current frame and last values recorded
  132747. */
  132748. export interface IWebXRMotionControllerComponentChanges {
  132749. /**
  132750. * will be populated with previous and current values if axes changed
  132751. */
  132752. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132753. /**
  132754. * will be populated with previous and current values if pressed changed
  132755. */
  132756. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132757. /**
  132758. * will be populated with previous and current values if touched changed
  132759. */
  132760. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132761. /**
  132762. * will be populated with previous and current values if value changed
  132763. */
  132764. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132765. }
  132766. /**
  132767. * This class represents a single component (for example button or thumbstick) of a motion controller
  132768. */
  132769. export class WebXRControllerComponent implements IDisposable {
  132770. /**
  132771. * the id of this component
  132772. */
  132773. id: string;
  132774. /**
  132775. * the type of the component
  132776. */
  132777. type: MotionControllerComponentType;
  132778. private _buttonIndex;
  132779. private _axesIndices;
  132780. private _axes;
  132781. private _changes;
  132782. private _currentValue;
  132783. private _hasChanges;
  132784. private _pressed;
  132785. private _touched;
  132786. /**
  132787. * button component type
  132788. */
  132789. static BUTTON_TYPE: MotionControllerComponentType;
  132790. /**
  132791. * squeeze component type
  132792. */
  132793. static SQUEEZE_TYPE: MotionControllerComponentType;
  132794. /**
  132795. * Thumbstick component type
  132796. */
  132797. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132798. /**
  132799. * Touchpad component type
  132800. */
  132801. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132802. /**
  132803. * trigger component type
  132804. */
  132805. static TRIGGER_TYPE: MotionControllerComponentType;
  132806. /**
  132807. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132808. * the axes data changes
  132809. */
  132810. onAxisValueChangedObservable: Observable<{
  132811. x: number;
  132812. y: number;
  132813. }>;
  132814. /**
  132815. * Observers registered here will be triggered when the state of a button changes
  132816. * State change is either pressed / touched / value
  132817. */
  132818. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132819. /**
  132820. * Creates a new component for a motion controller.
  132821. * It is created by the motion controller itself
  132822. *
  132823. * @param id the id of this component
  132824. * @param type the type of the component
  132825. * @param _buttonIndex index in the buttons array of the gamepad
  132826. * @param _axesIndices indices of the values in the axes array of the gamepad
  132827. */
  132828. constructor(
  132829. /**
  132830. * the id of this component
  132831. */
  132832. id: string,
  132833. /**
  132834. * the type of the component
  132835. */
  132836. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132837. /**
  132838. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132839. */
  132840. get axes(): IWebXRMotionControllerAxesValue;
  132841. /**
  132842. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132843. */
  132844. get changes(): IWebXRMotionControllerComponentChanges;
  132845. /**
  132846. * Return whether or not the component changed the last frame
  132847. */
  132848. get hasChanges(): boolean;
  132849. /**
  132850. * is the button currently pressed
  132851. */
  132852. get pressed(): boolean;
  132853. /**
  132854. * is the button currently touched
  132855. */
  132856. get touched(): boolean;
  132857. /**
  132858. * Get the current value of this component
  132859. */
  132860. get value(): number;
  132861. /**
  132862. * Dispose this component
  132863. */
  132864. dispose(): void;
  132865. /**
  132866. * Are there axes correlating to this component
  132867. * @return true is axes data is available
  132868. */
  132869. isAxes(): boolean;
  132870. /**
  132871. * Is this component a button (hence - pressable)
  132872. * @returns true if can be pressed
  132873. */
  132874. isButton(): boolean;
  132875. /**
  132876. * update this component using the gamepad object it is in. Called on every frame
  132877. * @param nativeController the native gamepad controller object
  132878. */
  132879. update(nativeController: IMinimalMotionControllerObject): void;
  132880. }
  132881. }
  132882. declare module BABYLON {
  132883. /**
  132884. * Type used for the success callback of ImportMesh
  132885. */
  132886. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  132887. /**
  132888. * Interface used for the result of ImportMeshAsync
  132889. */
  132890. export interface ISceneLoaderAsyncResult {
  132891. /**
  132892. * The array of loaded meshes
  132893. */
  132894. readonly meshes: AbstractMesh[];
  132895. /**
  132896. * The array of loaded particle systems
  132897. */
  132898. readonly particleSystems: IParticleSystem[];
  132899. /**
  132900. * The array of loaded skeletons
  132901. */
  132902. readonly skeletons: Skeleton[];
  132903. /**
  132904. * The array of loaded animation groups
  132905. */
  132906. readonly animationGroups: AnimationGroup[];
  132907. /**
  132908. * The array of loaded transform nodes
  132909. */
  132910. readonly transformNodes: TransformNode[];
  132911. /**
  132912. * The array of loaded geometries
  132913. */
  132914. readonly geometries: Geometry[];
  132915. /**
  132916. * The array of loaded lights
  132917. */
  132918. readonly lights: Light[];
  132919. }
  132920. /**
  132921. * Interface used to represent data loading progression
  132922. */
  132923. export interface ISceneLoaderProgressEvent {
  132924. /**
  132925. * Defines if data length to load can be evaluated
  132926. */
  132927. readonly lengthComputable: boolean;
  132928. /**
  132929. * Defines the loaded data length
  132930. */
  132931. readonly loaded: number;
  132932. /**
  132933. * Defines the data length to load
  132934. */
  132935. readonly total: number;
  132936. }
  132937. /**
  132938. * Interface used by SceneLoader plugins to define supported file extensions
  132939. */
  132940. export interface ISceneLoaderPluginExtensions {
  132941. /**
  132942. * Defines the list of supported extensions
  132943. */
  132944. [extension: string]: {
  132945. isBinary: boolean;
  132946. };
  132947. }
  132948. /**
  132949. * Interface used by SceneLoader plugin factory
  132950. */
  132951. export interface ISceneLoaderPluginFactory {
  132952. /**
  132953. * Defines the name of the factory
  132954. */
  132955. name: string;
  132956. /**
  132957. * Function called to create a new plugin
  132958. * @return the new plugin
  132959. */
  132960. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132961. /**
  132962. * The callback that returns true if the data can be directly loaded.
  132963. * @param data string containing the file data
  132964. * @returns if the data can be loaded directly
  132965. */
  132966. canDirectLoad?(data: string): boolean;
  132967. }
  132968. /**
  132969. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132970. */
  132971. export interface ISceneLoaderPluginBase {
  132972. /**
  132973. * The friendly name of this plugin.
  132974. */
  132975. name: string;
  132976. /**
  132977. * The file extensions supported by this plugin.
  132978. */
  132979. extensions: string | ISceneLoaderPluginExtensions;
  132980. /**
  132981. * The callback called when loading from a url.
  132982. * @param scene scene loading this url
  132983. * @param url url to load
  132984. * @param onSuccess callback called when the file successfully loads
  132985. * @param onProgress callback called while file is loading (if the server supports this mode)
  132986. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132987. * @param onError callback called when the file fails to load
  132988. * @returns a file request object
  132989. */
  132990. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132991. /**
  132992. * The callback called when loading from a file object.
  132993. * @param scene scene loading this file
  132994. * @param file defines the file to load
  132995. * @param onSuccess defines the callback to call when data is loaded
  132996. * @param onProgress defines the callback to call during loading process
  132997. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132998. * @param onError defines the callback to call when an error occurs
  132999. * @returns a file request object
  133000. */
  133001. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  133002. /**
  133003. * The callback that returns true if the data can be directly loaded.
  133004. * @param data string containing the file data
  133005. * @returns if the data can be loaded directly
  133006. */
  133007. canDirectLoad?(data: string): boolean;
  133008. /**
  133009. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  133010. * @param scene scene loading this data
  133011. * @param data string containing the data
  133012. * @returns data to pass to the plugin
  133013. */
  133014. directLoad?(scene: Scene, data: string): any;
  133015. /**
  133016. * The callback that allows custom handling of the root url based on the response url.
  133017. * @param rootUrl the original root url
  133018. * @param responseURL the response url if available
  133019. * @returns the new root url
  133020. */
  133021. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  133022. }
  133023. /**
  133024. * Interface used to define a SceneLoader plugin
  133025. */
  133026. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  133027. /**
  133028. * Import meshes into a scene.
  133029. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133030. * @param scene The scene to import into
  133031. * @param data The data to import
  133032. * @param rootUrl The root url for scene and resources
  133033. * @param meshes The meshes array to import into
  133034. * @param particleSystems The particle systems array to import into
  133035. * @param skeletons The skeletons array to import into
  133036. * @param onError The callback when import fails
  133037. * @returns True if successful or false otherwise
  133038. */
  133039. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  133040. /**
  133041. * Load into a scene.
  133042. * @param scene The scene to load into
  133043. * @param data The data to import
  133044. * @param rootUrl The root url for scene and resources
  133045. * @param onError The callback when import fails
  133046. * @returns True if successful or false otherwise
  133047. */
  133048. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  133049. /**
  133050. * Load into an asset container.
  133051. * @param scene The scene to load into
  133052. * @param data The data to import
  133053. * @param rootUrl The root url for scene and resources
  133054. * @param onError The callback when import fails
  133055. * @returns The loaded asset container
  133056. */
  133057. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  133058. }
  133059. /**
  133060. * Interface used to define an async SceneLoader plugin
  133061. */
  133062. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  133063. /**
  133064. * Import meshes into a scene.
  133065. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133066. * @param scene The scene to import into
  133067. * @param data The data to import
  133068. * @param rootUrl The root url for scene and resources
  133069. * @param onProgress The callback when the load progresses
  133070. * @param fileName Defines the name of the file to load
  133071. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  133072. */
  133073. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  133074. /**
  133075. * Load into a scene.
  133076. * @param scene The scene to load into
  133077. * @param data The data to import
  133078. * @param rootUrl The root url for scene and resources
  133079. * @param onProgress The callback when the load progresses
  133080. * @param fileName Defines the name of the file to load
  133081. * @returns Nothing
  133082. */
  133083. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  133084. /**
  133085. * Load into an asset container.
  133086. * @param scene The scene to load into
  133087. * @param data The data to import
  133088. * @param rootUrl The root url for scene and resources
  133089. * @param onProgress The callback when the load progresses
  133090. * @param fileName Defines the name of the file to load
  133091. * @returns The loaded asset container
  133092. */
  133093. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  133094. }
  133095. /**
  133096. * Mode that determines how to handle old animation groups before loading new ones.
  133097. */
  133098. export enum SceneLoaderAnimationGroupLoadingMode {
  133099. /**
  133100. * Reset all old animations to initial state then dispose them.
  133101. */
  133102. Clean = 0,
  133103. /**
  133104. * Stop all old animations.
  133105. */
  133106. Stop = 1,
  133107. /**
  133108. * Restart old animations from first frame.
  133109. */
  133110. Sync = 2,
  133111. /**
  133112. * Old animations remains untouched.
  133113. */
  133114. NoSync = 3
  133115. }
  133116. /**
  133117. * Defines a plugin registered by the SceneLoader
  133118. */
  133119. interface IRegisteredPlugin {
  133120. /**
  133121. * Defines the plugin to use
  133122. */
  133123. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133124. /**
  133125. * Defines if the plugin supports binary data
  133126. */
  133127. isBinary: boolean;
  133128. }
  133129. /**
  133130. * Class used to load scene from various file formats using registered plugins
  133131. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  133132. */
  133133. export class SceneLoader {
  133134. /**
  133135. * No logging while loading
  133136. */
  133137. static readonly NO_LOGGING: number;
  133138. /**
  133139. * Minimal logging while loading
  133140. */
  133141. static readonly MINIMAL_LOGGING: number;
  133142. /**
  133143. * Summary logging while loading
  133144. */
  133145. static readonly SUMMARY_LOGGING: number;
  133146. /**
  133147. * Detailled logging while loading
  133148. */
  133149. static readonly DETAILED_LOGGING: number;
  133150. /**
  133151. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  133152. */
  133153. static get ForceFullSceneLoadingForIncremental(): boolean;
  133154. static set ForceFullSceneLoadingForIncremental(value: boolean);
  133155. /**
  133156. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  133157. */
  133158. static get ShowLoadingScreen(): boolean;
  133159. static set ShowLoadingScreen(value: boolean);
  133160. /**
  133161. * Defines the current logging level (while loading the scene)
  133162. * @ignorenaming
  133163. */
  133164. static get loggingLevel(): number;
  133165. static set loggingLevel(value: number);
  133166. /**
  133167. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  133168. */
  133169. static get CleanBoneMatrixWeights(): boolean;
  133170. static set CleanBoneMatrixWeights(value: boolean);
  133171. /**
  133172. * Event raised when a plugin is used to load a scene
  133173. */
  133174. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133175. private static _registeredPlugins;
  133176. private static _showingLoadingScreen;
  133177. /**
  133178. * Gets the default plugin (used to load Babylon files)
  133179. * @returns the .babylon plugin
  133180. */
  133181. static GetDefaultPlugin(): IRegisteredPlugin;
  133182. private static _GetPluginForExtension;
  133183. private static _GetPluginForDirectLoad;
  133184. private static _GetPluginForFilename;
  133185. private static _GetDirectLoad;
  133186. private static _LoadData;
  133187. private static _GetFileInfo;
  133188. /**
  133189. * Gets a plugin that can load the given extension
  133190. * @param extension defines the extension to load
  133191. * @returns a plugin or null if none works
  133192. */
  133193. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133194. /**
  133195. * Gets a boolean indicating that the given extension can be loaded
  133196. * @param extension defines the extension to load
  133197. * @returns true if the extension is supported
  133198. */
  133199. static IsPluginForExtensionAvailable(extension: string): boolean;
  133200. /**
  133201. * Adds a new plugin to the list of registered plugins
  133202. * @param plugin defines the plugin to add
  133203. */
  133204. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  133205. /**
  133206. * Import meshes into a scene
  133207. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133208. * @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)
  133209. * @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)
  133210. * @param scene the instance of BABYLON.Scene to append to
  133211. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  133212. * @param onProgress a callback with a progress event for each file being loaded
  133213. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133214. * @param pluginExtension the extension used to determine the plugin
  133215. * @returns The loaded plugin
  133216. */
  133217. 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>;
  133218. /**
  133219. * Import meshes into a scene
  133220. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133221. * @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)
  133222. * @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)
  133223. * @param scene the instance of BABYLON.Scene to append to
  133224. * @param onProgress a callback with a progress event for each file being loaded
  133225. * @param pluginExtension the extension used to determine the plugin
  133226. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  133227. */
  133228. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  133229. /**
  133230. * Load a scene
  133231. * @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)
  133232. * @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)
  133233. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133234. * @param onSuccess a callback with the scene when import succeeds
  133235. * @param onProgress a callback with a progress event for each file being loaded
  133236. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133237. * @param pluginExtension the extension used to determine the plugin
  133238. * @returns The loaded plugin
  133239. */
  133240. 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>;
  133241. /**
  133242. * Load a scene
  133243. * @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)
  133244. * @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)
  133245. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133246. * @param onProgress a callback with a progress event for each file being loaded
  133247. * @param pluginExtension the extension used to determine the plugin
  133248. * @returns The loaded scene
  133249. */
  133250. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133251. /**
  133252. * Append a scene
  133253. * @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)
  133254. * @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)
  133255. * @param scene is the instance of BABYLON.Scene to append to
  133256. * @param onSuccess a callback with the scene when import succeeds
  133257. * @param onProgress a callback with a progress event for each file being loaded
  133258. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133259. * @param pluginExtension the extension used to determine the plugin
  133260. * @returns The loaded plugin
  133261. */
  133262. 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>;
  133263. /**
  133264. * Append a scene
  133265. * @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)
  133266. * @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)
  133267. * @param scene is the instance of BABYLON.Scene to append to
  133268. * @param onProgress a callback with a progress event for each file being loaded
  133269. * @param pluginExtension the extension used to determine the plugin
  133270. * @returns The given scene
  133271. */
  133272. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133273. /**
  133274. * Load a scene into an asset container
  133275. * @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)
  133276. * @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)
  133277. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133278. * @param onSuccess a callback with the scene when import succeeds
  133279. * @param onProgress a callback with a progress event for each file being loaded
  133280. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133281. * @param pluginExtension the extension used to determine the plugin
  133282. * @returns The loaded plugin
  133283. */
  133284. 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>;
  133285. /**
  133286. * Load a scene into an asset container
  133287. * @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)
  133288. * @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)
  133289. * @param scene is the instance of Scene to append to
  133290. * @param onProgress a callback with a progress event for each file being loaded
  133291. * @param pluginExtension the extension used to determine the plugin
  133292. * @returns The loaded asset container
  133293. */
  133294. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  133295. /**
  133296. * Import animations from a file into a scene
  133297. * @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)
  133298. * @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)
  133299. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133300. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133301. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133302. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133303. * @param onSuccess a callback with the scene when import succeeds
  133304. * @param onProgress a callback with a progress event for each file being loaded
  133305. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133306. * @param pluginExtension the extension used to determine the plugin
  133307. */
  133308. 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;
  133309. /**
  133310. * Import animations from a file into a scene
  133311. * @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)
  133312. * @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)
  133313. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133314. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133315. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133316. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133317. * @param onSuccess a callback with the scene when import succeeds
  133318. * @param onProgress a callback with a progress event for each file being loaded
  133319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133320. * @param pluginExtension the extension used to determine the plugin
  133321. * @returns the updated scene with imported animations
  133322. */
  133323. 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>;
  133324. }
  133325. }
  133326. declare module BABYLON {
  133327. /**
  133328. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133329. */
  133330. export type MotionControllerHandedness = "none" | "left" | "right";
  133331. /**
  133332. * The type of components available in motion controllers.
  133333. * This is not the name of the component.
  133334. */
  133335. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133336. /**
  133337. * The state of a controller component
  133338. */
  133339. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133340. /**
  133341. * The schema of motion controller layout.
  133342. * No object will be initialized using this interface
  133343. * This is used just to define the profile.
  133344. */
  133345. export interface IMotionControllerLayout {
  133346. /**
  133347. * Path to load the assets. Usually relative to the base path
  133348. */
  133349. assetPath: string;
  133350. /**
  133351. * Available components (unsorted)
  133352. */
  133353. components: {
  133354. /**
  133355. * A map of component Ids
  133356. */
  133357. [componentId: string]: {
  133358. /**
  133359. * The type of input the component outputs
  133360. */
  133361. type: MotionControllerComponentType;
  133362. /**
  133363. * The indices of this component in the gamepad object
  133364. */
  133365. gamepadIndices: {
  133366. /**
  133367. * Index of button
  133368. */
  133369. button?: number;
  133370. /**
  133371. * If available, index of x-axis
  133372. */
  133373. xAxis?: number;
  133374. /**
  133375. * If available, index of y-axis
  133376. */
  133377. yAxis?: number;
  133378. };
  133379. /**
  133380. * The mesh's root node name
  133381. */
  133382. rootNodeName: string;
  133383. /**
  133384. * Animation definitions for this model
  133385. */
  133386. visualResponses: {
  133387. [stateKey: string]: {
  133388. /**
  133389. * What property will be animated
  133390. */
  133391. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133392. /**
  133393. * What states influence this visual response
  133394. */
  133395. states: MotionControllerComponentStateType[];
  133396. /**
  133397. * Type of animation - movement or visibility
  133398. */
  133399. valueNodeProperty: "transform" | "visibility";
  133400. /**
  133401. * Base node name to move. Its position will be calculated according to the min and max nodes
  133402. */
  133403. valueNodeName?: string;
  133404. /**
  133405. * Minimum movement node
  133406. */
  133407. minNodeName?: string;
  133408. /**
  133409. * Max movement node
  133410. */
  133411. maxNodeName?: string;
  133412. };
  133413. };
  133414. /**
  133415. * If touch enabled, what is the name of node to display user feedback
  133416. */
  133417. touchPointNodeName?: string;
  133418. };
  133419. };
  133420. /**
  133421. * Is it xr standard mapping or not
  133422. */
  133423. gamepadMapping: "" | "xr-standard";
  133424. /**
  133425. * Base root node of this entire model
  133426. */
  133427. rootNodeName: string;
  133428. /**
  133429. * Defines the main button component id
  133430. */
  133431. selectComponentId: string;
  133432. }
  133433. /**
  133434. * A definition for the layout map in the input profile
  133435. */
  133436. export interface IMotionControllerLayoutMap {
  133437. /**
  133438. * Layouts with handedness type as a key
  133439. */
  133440. [handedness: string]: IMotionControllerLayout;
  133441. }
  133442. /**
  133443. * The XR Input profile schema
  133444. * Profiles can be found here:
  133445. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133446. */
  133447. export interface IMotionControllerProfile {
  133448. /**
  133449. * fallback profiles for this profileId
  133450. */
  133451. fallbackProfileIds: string[];
  133452. /**
  133453. * The layout map, with handedness as key
  133454. */
  133455. layouts: IMotionControllerLayoutMap;
  133456. /**
  133457. * The id of this profile
  133458. * correlates to the profile(s) in the xrInput.profiles array
  133459. */
  133460. profileId: string;
  133461. }
  133462. /**
  133463. * A helper-interface for the 3 meshes needed for controller button animation
  133464. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133465. */
  133466. export interface IMotionControllerButtonMeshMap {
  133467. /**
  133468. * the mesh that defines the pressed value mesh position.
  133469. * This is used to find the max-position of this button
  133470. */
  133471. pressedMesh: AbstractMesh;
  133472. /**
  133473. * the mesh that defines the unpressed value mesh position.
  133474. * This is used to find the min (or initial) position of this button
  133475. */
  133476. unpressedMesh: AbstractMesh;
  133477. /**
  133478. * The mesh that will be changed when value changes
  133479. */
  133480. valueMesh: AbstractMesh;
  133481. }
  133482. /**
  133483. * A helper-interface for the 3 meshes needed for controller axis animation.
  133484. * This will be expanded when touchpad animations are fully supported
  133485. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133486. */
  133487. export interface IMotionControllerMeshMap {
  133488. /**
  133489. * the mesh that defines the maximum value mesh position.
  133490. */
  133491. maxMesh?: AbstractMesh;
  133492. /**
  133493. * the mesh that defines the minimum value mesh position.
  133494. */
  133495. minMesh?: AbstractMesh;
  133496. /**
  133497. * The mesh that will be changed when axis value changes
  133498. */
  133499. valueMesh?: AbstractMesh;
  133500. }
  133501. /**
  133502. * The elements needed for change-detection of the gamepad objects in motion controllers
  133503. */
  133504. export interface IMinimalMotionControllerObject {
  133505. /**
  133506. * Available axes of this controller
  133507. */
  133508. axes: number[];
  133509. /**
  133510. * An array of available buttons
  133511. */
  133512. buttons: Array<{
  133513. /**
  133514. * Value of the button/trigger
  133515. */
  133516. value: number;
  133517. /**
  133518. * If the button/trigger is currently touched
  133519. */
  133520. touched: boolean;
  133521. /**
  133522. * If the button/trigger is currently pressed
  133523. */
  133524. pressed: boolean;
  133525. }>;
  133526. /**
  133527. * EXPERIMENTAL haptic support.
  133528. */
  133529. hapticActuators?: Array<{
  133530. pulse: (value: number, duration: number) => Promise<boolean>;
  133531. }>;
  133532. }
  133533. /**
  133534. * An Abstract Motion controller
  133535. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133536. * Each component has an observable to check for changes in value and state
  133537. */
  133538. export abstract class WebXRAbstractMotionController implements IDisposable {
  133539. protected scene: Scene;
  133540. protected layout: IMotionControllerLayout;
  133541. /**
  133542. * The gamepad object correlating to this controller
  133543. */
  133544. gamepadObject: IMinimalMotionControllerObject;
  133545. /**
  133546. * handedness (left/right/none) of this controller
  133547. */
  133548. handedness: MotionControllerHandedness;
  133549. private _initComponent;
  133550. private _modelReady;
  133551. /**
  133552. * A map of components (WebXRControllerComponent) in this motion controller
  133553. * Components have a ComponentType and can also have both button and axis definitions
  133554. */
  133555. readonly components: {
  133556. [id: string]: WebXRControllerComponent;
  133557. };
  133558. /**
  133559. * Disable the model's animation. Can be set at any time.
  133560. */
  133561. disableAnimation: boolean;
  133562. /**
  133563. * Observers registered here will be triggered when the model of this controller is done loading
  133564. */
  133565. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133566. /**
  133567. * The profile id of this motion controller
  133568. */
  133569. abstract profileId: string;
  133570. /**
  133571. * The root mesh of the model. It is null if the model was not yet initialized
  133572. */
  133573. rootMesh: Nullable<AbstractMesh>;
  133574. /**
  133575. * constructs a new abstract motion controller
  133576. * @param scene the scene to which the model of the controller will be added
  133577. * @param layout The profile layout to load
  133578. * @param gamepadObject The gamepad object correlating to this controller
  133579. * @param handedness handedness (left/right/none) of this controller
  133580. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133581. */
  133582. constructor(scene: Scene, layout: IMotionControllerLayout,
  133583. /**
  133584. * The gamepad object correlating to this controller
  133585. */
  133586. gamepadObject: IMinimalMotionControllerObject,
  133587. /**
  133588. * handedness (left/right/none) of this controller
  133589. */
  133590. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133591. /**
  133592. * Dispose this controller, the model mesh and all its components
  133593. */
  133594. dispose(): void;
  133595. /**
  133596. * Returns all components of specific type
  133597. * @param type the type to search for
  133598. * @return an array of components with this type
  133599. */
  133600. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133601. /**
  133602. * get a component based an its component id as defined in layout.components
  133603. * @param id the id of the component
  133604. * @returns the component correlates to the id or undefined if not found
  133605. */
  133606. getComponent(id: string): WebXRControllerComponent;
  133607. /**
  133608. * Get the list of components available in this motion controller
  133609. * @returns an array of strings correlating to available components
  133610. */
  133611. getComponentIds(): string[];
  133612. /**
  133613. * Get the first component of specific type
  133614. * @param type type of component to find
  133615. * @return a controller component or null if not found
  133616. */
  133617. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133618. /**
  133619. * Get the main (Select) component of this controller as defined in the layout
  133620. * @returns the main component of this controller
  133621. */
  133622. getMainComponent(): WebXRControllerComponent;
  133623. /**
  133624. * Loads the model correlating to this controller
  133625. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133626. * @returns A promise fulfilled with the result of the model loading
  133627. */
  133628. loadModel(): Promise<boolean>;
  133629. /**
  133630. * Update this model using the current XRFrame
  133631. * @param xrFrame the current xr frame to use and update the model
  133632. */
  133633. updateFromXRFrame(xrFrame: XRFrame): void;
  133634. /**
  133635. * Backwards compatibility due to a deeply-integrated typo
  133636. */
  133637. get handness(): XREye;
  133638. /**
  133639. * Pulse (vibrate) this controller
  133640. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133641. * Consecutive calls to this function will cancel the last pulse call
  133642. *
  133643. * @param value the strength of the pulse in 0.0...1.0 range
  133644. * @param duration Duration of the pulse in milliseconds
  133645. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133646. * @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
  133647. */
  133648. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133649. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133650. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133651. /**
  133652. * Moves the axis on the controller mesh based on its current state
  133653. * @param axis the index of the axis
  133654. * @param axisValue the value of the axis which determines the meshes new position
  133655. * @hidden
  133656. */
  133657. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133658. /**
  133659. * Update the model itself with the current frame data
  133660. * @param xrFrame the frame to use for updating the model mesh
  133661. */
  133662. protected updateModel(xrFrame: XRFrame): void;
  133663. /**
  133664. * Get the filename and path for this controller's model
  133665. * @returns a map of filename and path
  133666. */
  133667. protected abstract _getFilenameAndPath(): {
  133668. filename: string;
  133669. path: string;
  133670. };
  133671. /**
  133672. * This function is called before the mesh is loaded. It checks for loading constraints.
  133673. * For example, this function can check if the GLB loader is available
  133674. * If this function returns false, the generic controller will be loaded instead
  133675. * @returns Is the client ready to load the mesh
  133676. */
  133677. protected abstract _getModelLoadingConstraints(): boolean;
  133678. /**
  133679. * This function will be called after the model was successfully loaded and can be used
  133680. * for mesh transformations before it is available for the user
  133681. * @param meshes the loaded meshes
  133682. */
  133683. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133684. /**
  133685. * Set the root mesh for this controller. Important for the WebXR controller class
  133686. * @param meshes the loaded meshes
  133687. */
  133688. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133689. /**
  133690. * A function executed each frame that updates the mesh (if needed)
  133691. * @param xrFrame the current xrFrame
  133692. */
  133693. protected abstract _updateModel(xrFrame: XRFrame): void;
  133694. private _getGenericFilenameAndPath;
  133695. private _getGenericParentMesh;
  133696. }
  133697. }
  133698. declare module BABYLON {
  133699. /**
  133700. * A generic trigger-only motion controller for WebXR
  133701. */
  133702. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133703. /**
  133704. * Static version of the profile id of this controller
  133705. */
  133706. static ProfileId: string;
  133707. profileId: string;
  133708. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133709. protected _getFilenameAndPath(): {
  133710. filename: string;
  133711. path: string;
  133712. };
  133713. protected _getModelLoadingConstraints(): boolean;
  133714. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133715. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133716. protected _updateModel(): void;
  133717. }
  133718. }
  133719. declare module BABYLON {
  133720. /**
  133721. * Class containing static functions to help procedurally build meshes
  133722. */
  133723. export class SphereBuilder {
  133724. /**
  133725. * Creates a sphere mesh
  133726. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133727. * * 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`)
  133728. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133729. * * 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
  133730. * * 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)
  133731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133734. * @param name defines the name of the mesh
  133735. * @param options defines the options used to create the mesh
  133736. * @param scene defines the hosting scene
  133737. * @returns the sphere mesh
  133738. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133739. */
  133740. static CreateSphere(name: string, options: {
  133741. segments?: number;
  133742. diameter?: number;
  133743. diameterX?: number;
  133744. diameterY?: number;
  133745. diameterZ?: number;
  133746. arc?: number;
  133747. slice?: number;
  133748. sideOrientation?: number;
  133749. frontUVs?: Vector4;
  133750. backUVs?: Vector4;
  133751. updatable?: boolean;
  133752. }, scene?: Nullable<Scene>): Mesh;
  133753. }
  133754. }
  133755. declare module BABYLON {
  133756. /**
  133757. * A profiled motion controller has its profile loaded from an online repository.
  133758. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133759. */
  133760. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133761. private _repositoryUrl;
  133762. private _buttonMeshMapping;
  133763. private _touchDots;
  133764. /**
  133765. * The profile ID of this controller. Will be populated when the controller initializes.
  133766. */
  133767. profileId: string;
  133768. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133769. dispose(): void;
  133770. protected _getFilenameAndPath(): {
  133771. filename: string;
  133772. path: string;
  133773. };
  133774. protected _getModelLoadingConstraints(): boolean;
  133775. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133776. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133777. protected _updateModel(_xrFrame: XRFrame): void;
  133778. }
  133779. }
  133780. declare module BABYLON {
  133781. /**
  133782. * A construction function type to create a new controller based on an xrInput object
  133783. */
  133784. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133785. /**
  133786. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133787. *
  133788. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133789. * it should be replaced with auto-loaded controllers.
  133790. *
  133791. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133792. */
  133793. export class WebXRMotionControllerManager {
  133794. private static _AvailableControllers;
  133795. private static _Fallbacks;
  133796. private static _ProfileLoadingPromises;
  133797. private static _ProfilesList;
  133798. /**
  133799. * The base URL of the online controller repository. Can be changed at any time.
  133800. */
  133801. static BaseRepositoryUrl: string;
  133802. /**
  133803. * Which repository gets priority - local or online
  133804. */
  133805. static PrioritizeOnlineRepository: boolean;
  133806. /**
  133807. * Use the online repository, or use only locally-defined controllers
  133808. */
  133809. static UseOnlineRepository: boolean;
  133810. /**
  133811. * Clear the cache used for profile loading and reload when requested again
  133812. */
  133813. static ClearProfilesCache(): void;
  133814. /**
  133815. * Register the default fallbacks.
  133816. * This function is called automatically when this file is imported.
  133817. */
  133818. static DefaultFallbacks(): void;
  133819. /**
  133820. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133821. * @param profileId the profile to which a fallback needs to be found
  133822. * @return an array with corresponding fallback profiles
  133823. */
  133824. static FindFallbackWithProfileId(profileId: string): string[];
  133825. /**
  133826. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133827. * The order of search:
  133828. *
  133829. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133830. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133831. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133832. * 4) return the generic trigger controller if none were found
  133833. *
  133834. * @param xrInput the xrInput to which a new controller is initialized
  133835. * @param scene the scene to which the model will be added
  133836. * @param forceProfile force a certain profile for this controller
  133837. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133838. */
  133839. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133840. /**
  133841. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133842. *
  133843. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133844. *
  133845. * @param type the profile type to register
  133846. * @param constructFunction the function to be called when loading this profile
  133847. */
  133848. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133849. /**
  133850. * Register a fallback to a specific profile.
  133851. * @param profileId the profileId that will receive the fallbacks
  133852. * @param fallbacks A list of fallback profiles
  133853. */
  133854. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133855. /**
  133856. * Will update the list of profiles available in the repository
  133857. * @return a promise that resolves to a map of profiles available online
  133858. */
  133859. static UpdateProfilesList(): Promise<{
  133860. [profile: string]: string;
  133861. }>;
  133862. private static _LoadProfileFromRepository;
  133863. private static _LoadProfilesFromAvailableControllers;
  133864. }
  133865. }
  133866. declare module BABYLON {
  133867. /**
  133868. * Configuration options for the WebXR controller creation
  133869. */
  133870. export interface IWebXRControllerOptions {
  133871. /**
  133872. * Should the controller mesh be animated when a user interacts with it
  133873. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133874. */
  133875. disableMotionControllerAnimation?: boolean;
  133876. /**
  133877. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133878. */
  133879. doNotLoadControllerMesh?: boolean;
  133880. /**
  133881. * Force a specific controller type for this controller.
  133882. * This can be used when creating your own profile or when testing different controllers
  133883. */
  133884. forceControllerProfile?: string;
  133885. /**
  133886. * Defines a rendering group ID for meshes that will be loaded.
  133887. * This is for the default controllers only.
  133888. */
  133889. renderingGroupId?: number;
  133890. }
  133891. /**
  133892. * Represents an XR controller
  133893. */
  133894. export class WebXRInputSource {
  133895. private _scene;
  133896. /** The underlying input source for the controller */
  133897. inputSource: XRInputSource;
  133898. private _options;
  133899. private _tmpVector;
  133900. private _uniqueId;
  133901. private _disposed;
  133902. /**
  133903. * 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
  133904. */
  133905. grip?: AbstractMesh;
  133906. /**
  133907. * If available, this is the gamepad object related to this controller.
  133908. * Using this object it is possible to get click events and trackpad changes of the
  133909. * webxr controller that is currently being used.
  133910. */
  133911. motionController?: WebXRAbstractMotionController;
  133912. /**
  133913. * Event that fires when the controller is removed/disposed.
  133914. * The object provided as event data is this controller, after associated assets were disposed.
  133915. * uniqueId is still available.
  133916. */
  133917. onDisposeObservable: Observable<WebXRInputSource>;
  133918. /**
  133919. * Will be triggered when the mesh associated with the motion controller is done loading.
  133920. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133921. * A shortened version of controller -> motion controller -> on mesh loaded.
  133922. */
  133923. onMeshLoadedObservable: Observable<AbstractMesh>;
  133924. /**
  133925. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133926. */
  133927. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133928. /**
  133929. * Pointer which can be used to select objects or attach a visible laser to
  133930. */
  133931. pointer: AbstractMesh;
  133932. /**
  133933. * Creates the input source object
  133934. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133935. * @param _scene the scene which the controller should be associated to
  133936. * @param inputSource the underlying input source for the controller
  133937. * @param _options options for this controller creation
  133938. */
  133939. constructor(_scene: Scene,
  133940. /** The underlying input source for the controller */
  133941. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133942. /**
  133943. * Get this controllers unique id
  133944. */
  133945. get uniqueId(): string;
  133946. /**
  133947. * Disposes of the object
  133948. */
  133949. dispose(): void;
  133950. /**
  133951. * Gets a world space ray coming from the pointer or grip
  133952. * @param result the resulting ray
  133953. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133954. */
  133955. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133956. /**
  133957. * Updates the controller pose based on the given XRFrame
  133958. * @param xrFrame xr frame to update the pose with
  133959. * @param referenceSpace reference space to use
  133960. */
  133961. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133962. }
  133963. }
  133964. declare module BABYLON {
  133965. /**
  133966. * The schema for initialization options of the XR Input class
  133967. */
  133968. export interface IWebXRInputOptions {
  133969. /**
  133970. * If set to true no model will be automatically loaded
  133971. */
  133972. doNotLoadControllerMeshes?: boolean;
  133973. /**
  133974. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133975. * If not found, the xr input profile data will be used.
  133976. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133977. */
  133978. forceInputProfile?: string;
  133979. /**
  133980. * Do not send a request to the controller repository to load the profile.
  133981. *
  133982. * Instead, use the controllers available in babylon itself.
  133983. */
  133984. disableOnlineControllerRepository?: boolean;
  133985. /**
  133986. * A custom URL for the controllers repository
  133987. */
  133988. customControllersRepositoryURL?: string;
  133989. /**
  133990. * Should the controller model's components not move according to the user input
  133991. */
  133992. disableControllerAnimation?: boolean;
  133993. /**
  133994. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133995. */
  133996. controllerOptions?: IWebXRControllerOptions;
  133997. }
  133998. /**
  133999. * XR input used to track XR inputs such as controllers/rays
  134000. */
  134001. export class WebXRInput implements IDisposable {
  134002. /**
  134003. * the xr session manager for this session
  134004. */
  134005. xrSessionManager: WebXRSessionManager;
  134006. /**
  134007. * the WebXR camera for this session. Mainly used for teleportation
  134008. */
  134009. xrCamera: WebXRCamera;
  134010. private readonly options;
  134011. /**
  134012. * XR controllers being tracked
  134013. */
  134014. controllers: Array<WebXRInputSource>;
  134015. private _frameObserver;
  134016. private _sessionEndedObserver;
  134017. private _sessionInitObserver;
  134018. /**
  134019. * Event when a controller has been connected/added
  134020. */
  134021. onControllerAddedObservable: Observable<WebXRInputSource>;
  134022. /**
  134023. * Event when a controller has been removed/disconnected
  134024. */
  134025. onControllerRemovedObservable: Observable<WebXRInputSource>;
  134026. /**
  134027. * Initializes the WebXRInput
  134028. * @param xrSessionManager the xr session manager for this session
  134029. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  134030. * @param options = initialization options for this xr input
  134031. */
  134032. constructor(
  134033. /**
  134034. * the xr session manager for this session
  134035. */
  134036. xrSessionManager: WebXRSessionManager,
  134037. /**
  134038. * the WebXR camera for this session. Mainly used for teleportation
  134039. */
  134040. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  134041. private _onInputSourcesChange;
  134042. private _addAndRemoveControllers;
  134043. /**
  134044. * Disposes of the object
  134045. */
  134046. dispose(): void;
  134047. }
  134048. }
  134049. declare module BABYLON {
  134050. /**
  134051. * This is the base class for all WebXR features.
  134052. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  134053. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  134054. */
  134055. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  134056. protected _xrSessionManager: WebXRSessionManager;
  134057. private _attached;
  134058. private _removeOnDetach;
  134059. /**
  134060. * Is this feature disposed?
  134061. */
  134062. isDisposed: boolean;
  134063. /**
  134064. * Should auto-attach be disabled?
  134065. */
  134066. disableAutoAttach: boolean;
  134067. /**
  134068. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  134069. */
  134070. xrNativeFeatureName: string;
  134071. /**
  134072. * Construct a new (abstract) WebXR feature
  134073. * @param _xrSessionManager the xr session manager for this feature
  134074. */
  134075. constructor(_xrSessionManager: WebXRSessionManager);
  134076. /**
  134077. * Is this feature attached
  134078. */
  134079. get attached(): boolean;
  134080. /**
  134081. * attach this feature
  134082. *
  134083. * @param force should attachment be forced (even when already attached)
  134084. * @returns true if successful, false is failed or already attached
  134085. */
  134086. attach(force?: boolean): boolean;
  134087. /**
  134088. * detach this feature.
  134089. *
  134090. * @returns true if successful, false if failed or already detached
  134091. */
  134092. detach(): boolean;
  134093. /**
  134094. * Dispose this feature and all of the resources attached
  134095. */
  134096. dispose(): void;
  134097. /**
  134098. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  134099. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  134100. *
  134101. * @returns whether or not the feature is compatible in this environment
  134102. */
  134103. isCompatible(): boolean;
  134104. /**
  134105. * This is used to register callbacks that will automatically be removed when detach is called.
  134106. * @param observable the observable to which the observer will be attached
  134107. * @param callback the callback to register
  134108. */
  134109. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  134110. /**
  134111. * Code in this function will be executed on each xrFrame received from the browser.
  134112. * This function will not execute after the feature is detached.
  134113. * @param _xrFrame the current frame
  134114. */
  134115. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  134116. }
  134117. }
  134118. declare module BABYLON {
  134119. /**
  134120. * Renders a layer on top of an existing scene
  134121. */
  134122. export class UtilityLayerRenderer implements IDisposable {
  134123. /** the original scene that will be rendered on top of */
  134124. originalScene: Scene;
  134125. private _pointerCaptures;
  134126. private _lastPointerEvents;
  134127. private static _DefaultUtilityLayer;
  134128. private static _DefaultKeepDepthUtilityLayer;
  134129. private _sharedGizmoLight;
  134130. private _renderCamera;
  134131. /**
  134132. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  134133. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  134134. * @returns the camera that is used when rendering the utility layer
  134135. */
  134136. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  134137. /**
  134138. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  134139. * @param cam the camera that should be used when rendering the utility layer
  134140. */
  134141. setRenderCamera(cam: Nullable<Camera>): void;
  134142. /**
  134143. * @hidden
  134144. * Light which used by gizmos to get light shading
  134145. */
  134146. _getSharedGizmoLight(): HemisphericLight;
  134147. /**
  134148. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  134149. */
  134150. pickUtilitySceneFirst: boolean;
  134151. /**
  134152. * 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)
  134153. */
  134154. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  134155. /**
  134156. * 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)
  134157. */
  134158. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  134159. /**
  134160. * The scene that is rendered on top of the original scene
  134161. */
  134162. utilityLayerScene: Scene;
  134163. /**
  134164. * If the utility layer should automatically be rendered on top of existing scene
  134165. */
  134166. shouldRender: boolean;
  134167. /**
  134168. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  134169. */
  134170. onlyCheckPointerDownEvents: boolean;
  134171. /**
  134172. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  134173. */
  134174. processAllEvents: boolean;
  134175. /**
  134176. * Observable raised when the pointer move from the utility layer scene to the main scene
  134177. */
  134178. onPointerOutObservable: Observable<number>;
  134179. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  134180. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  134181. private _afterRenderObserver;
  134182. private _sceneDisposeObserver;
  134183. private _originalPointerObserver;
  134184. /**
  134185. * Instantiates a UtilityLayerRenderer
  134186. * @param originalScene the original scene that will be rendered on top of
  134187. * @param handleEvents boolean indicating if the utility layer should handle events
  134188. */
  134189. constructor(
  134190. /** the original scene that will be rendered on top of */
  134191. originalScene: Scene, handleEvents?: boolean);
  134192. private _notifyObservers;
  134193. /**
  134194. * Renders the utility layers scene on top of the original scene
  134195. */
  134196. render(): void;
  134197. /**
  134198. * Disposes of the renderer
  134199. */
  134200. dispose(): void;
  134201. private _updateCamera;
  134202. }
  134203. }
  134204. declare module BABYLON {
  134205. /**
  134206. * Options interface for the pointer selection module
  134207. */
  134208. export interface IWebXRControllerPointerSelectionOptions {
  134209. /**
  134210. * if provided, this scene will be used to render meshes.
  134211. */
  134212. customUtilityLayerScene?: Scene;
  134213. /**
  134214. * 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)
  134215. * If not disabled, the last picked point will be used to execute a pointer up event
  134216. * If disabled, pointer up event will be triggered right after the pointer down event.
  134217. * Used in screen and gaze target ray mode only
  134218. */
  134219. disablePointerUpOnTouchOut: boolean;
  134220. /**
  134221. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  134222. */
  134223. forceGazeMode: boolean;
  134224. /**
  134225. * 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
  134226. * to start a new countdown to the pointer down event.
  134227. * Defaults to 1.
  134228. */
  134229. gazeModePointerMovedFactor?: number;
  134230. /**
  134231. * Different button type to use instead of the main component
  134232. */
  134233. overrideButtonId?: string;
  134234. /**
  134235. * use this rendering group id for the meshes (optional)
  134236. */
  134237. renderingGroupId?: number;
  134238. /**
  134239. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  134240. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  134241. * 3000 means 3 seconds between pointing at something and selecting it
  134242. */
  134243. timeToSelect?: number;
  134244. /**
  134245. * Should meshes created here be added to a utility layer or the main scene
  134246. */
  134247. useUtilityLayer?: boolean;
  134248. /**
  134249. * Optional WebXR camera to be used for gaze selection
  134250. */
  134251. gazeCamera?: WebXRCamera;
  134252. /**
  134253. * the xr input to use with this pointer selection
  134254. */
  134255. xrInput: WebXRInput;
  134256. /**
  134257. * Should the scene pointerX and pointerY update be disabled
  134258. * This is required for fullscreen AR GUI, but might slow down other experiences.
  134259. * Disable in VR, if not needed.
  134260. * The first rig camera (left eye) will be used to calculate the projection
  134261. */
  134262. disableScenePointerVectorUpdate: boolean;
  134263. /**
  134264. * Enable pointer selection on all controllers instead of switching between them
  134265. */
  134266. enablePointerSelectionOnAllControllers?: boolean;
  134267. /**
  134268. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  134269. * If switch is enabled, it will still allow the user to switch between the different controllers
  134270. */
  134271. preferredHandedness?: XRHandedness;
  134272. /**
  134273. * Disable switching the pointer selection from one controller to the other.
  134274. * 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
  134275. */
  134276. disableSwitchOnClick?: boolean;
  134277. /**
  134278. * The maximum distance of the pointer selection feature. Defaults to 100.
  134279. */
  134280. maxPointerDistance?: number;
  134281. }
  134282. /**
  134283. * A module that will enable pointer selection for motion controllers of XR Input Sources
  134284. */
  134285. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  134286. private readonly _options;
  134287. private static _idCounter;
  134288. private _attachController;
  134289. private _controllers;
  134290. private _scene;
  134291. private _tmpVectorForPickCompare;
  134292. private _attachedController;
  134293. /**
  134294. * The module's name
  134295. */
  134296. static readonly Name: string;
  134297. /**
  134298. * The (Babylon) version of this module.
  134299. * This is an integer representing the implementation version.
  134300. * This number does not correspond to the WebXR specs version
  134301. */
  134302. static readonly Version: number;
  134303. /**
  134304. * Disable lighting on the laser pointer (so it will always be visible)
  134305. */
  134306. disablePointerLighting: boolean;
  134307. /**
  134308. * Disable lighting on the selection mesh (so it will always be visible)
  134309. */
  134310. disableSelectionMeshLighting: boolean;
  134311. /**
  134312. * Should the laser pointer be displayed
  134313. */
  134314. displayLaserPointer: boolean;
  134315. /**
  134316. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134317. */
  134318. displaySelectionMesh: boolean;
  134319. /**
  134320. * This color will be set to the laser pointer when selection is triggered
  134321. */
  134322. laserPointerPickedColor: Color3;
  134323. /**
  134324. * Default color of the laser pointer
  134325. */
  134326. laserPointerDefaultColor: Color3;
  134327. /**
  134328. * default color of the selection ring
  134329. */
  134330. selectionMeshDefaultColor: Color3;
  134331. /**
  134332. * This color will be applied to the selection ring when selection is triggered
  134333. */
  134334. selectionMeshPickedColor: Color3;
  134335. /**
  134336. * Optional filter to be used for ray selection. This predicate shares behavior with
  134337. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134338. */
  134339. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134340. /**
  134341. * constructs a new background remover module
  134342. * @param _xrSessionManager the session manager for this module
  134343. * @param _options read-only options to be used in this module
  134344. */
  134345. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134346. /**
  134347. * attach this feature
  134348. * Will usually be called by the features manager
  134349. *
  134350. * @returns true if successful.
  134351. */
  134352. attach(): boolean;
  134353. /**
  134354. * detach this feature.
  134355. * Will usually be called by the features manager
  134356. *
  134357. * @returns true if successful.
  134358. */
  134359. detach(): boolean;
  134360. /**
  134361. * Will get the mesh under a specific pointer.
  134362. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134363. * @param controllerId the controllerId to check
  134364. * @returns The mesh under pointer or null if no mesh is under the pointer
  134365. */
  134366. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134367. /**
  134368. * Get the xr controller that correlates to the pointer id in the pointer event
  134369. *
  134370. * @param id the pointer id to search for
  134371. * @returns the controller that correlates to this id or null if not found
  134372. */
  134373. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134374. private _identityMatrix;
  134375. private _screenCoordinatesRef;
  134376. private _viewportRef;
  134377. protected _onXRFrame(_xrFrame: XRFrame): void;
  134378. private _attachGazeMode;
  134379. private _attachScreenRayMode;
  134380. private _attachTrackedPointerRayMode;
  134381. private _convertNormalToDirectionOfRay;
  134382. private _detachController;
  134383. private _generateNewMeshPair;
  134384. private _pickingMoved;
  134385. private _updatePointerDistance;
  134386. /** @hidden */
  134387. get lasterPointerDefaultColor(): Color3;
  134388. }
  134389. }
  134390. declare module BABYLON {
  134391. /**
  134392. * Button which can be used to enter a different mode of XR
  134393. */
  134394. export class WebXREnterExitUIButton {
  134395. /** button element */
  134396. element: HTMLElement;
  134397. /** XR initialization options for the button */
  134398. sessionMode: XRSessionMode;
  134399. /** Reference space type */
  134400. referenceSpaceType: XRReferenceSpaceType;
  134401. /**
  134402. * Creates a WebXREnterExitUIButton
  134403. * @param element button element
  134404. * @param sessionMode XR initialization session mode
  134405. * @param referenceSpaceType the type of reference space to be used
  134406. */
  134407. constructor(
  134408. /** button element */
  134409. element: HTMLElement,
  134410. /** XR initialization options for the button */
  134411. sessionMode: XRSessionMode,
  134412. /** Reference space type */
  134413. referenceSpaceType: XRReferenceSpaceType);
  134414. /**
  134415. * Extendable function which can be used to update the button's visuals when the state changes
  134416. * @param activeButton the current active button in the UI
  134417. */
  134418. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134419. }
  134420. /**
  134421. * Options to create the webXR UI
  134422. */
  134423. export class WebXREnterExitUIOptions {
  134424. /**
  134425. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134426. */
  134427. customButtons?: Array<WebXREnterExitUIButton>;
  134428. /**
  134429. * A reference space type to use when creating the default button.
  134430. * Default is local-floor
  134431. */
  134432. referenceSpaceType?: XRReferenceSpaceType;
  134433. /**
  134434. * Context to enter xr with
  134435. */
  134436. renderTarget?: Nullable<WebXRRenderTarget>;
  134437. /**
  134438. * A session mode to use when creating the default button.
  134439. * Default is immersive-vr
  134440. */
  134441. sessionMode?: XRSessionMode;
  134442. /**
  134443. * A list of optional features to init the session with
  134444. */
  134445. optionalFeatures?: string[];
  134446. /**
  134447. * A list of optional features to init the session with
  134448. */
  134449. requiredFeatures?: string[];
  134450. /**
  134451. * If defined, this function will be executed if the UI encounters an error when entering XR
  134452. */
  134453. onError?: (error: any) => void;
  134454. }
  134455. /**
  134456. * UI to allow the user to enter/exit XR mode
  134457. */
  134458. export class WebXREnterExitUI implements IDisposable {
  134459. private scene;
  134460. /** version of the options passed to this UI */
  134461. options: WebXREnterExitUIOptions;
  134462. private _activeButton;
  134463. private _buttons;
  134464. /**
  134465. * The HTML Div Element to which buttons are added.
  134466. */
  134467. readonly overlay: HTMLDivElement;
  134468. /**
  134469. * Fired every time the active button is changed.
  134470. *
  134471. * When xr is entered via a button that launches xr that button will be the callback parameter
  134472. *
  134473. * When exiting xr the callback parameter will be null)
  134474. */
  134475. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134476. /**
  134477. *
  134478. * @param scene babylon scene object to use
  134479. * @param options (read-only) version of the options passed to this UI
  134480. */
  134481. private constructor();
  134482. /**
  134483. * Creates UI to allow the user to enter/exit XR mode
  134484. * @param scene the scene to add the ui to
  134485. * @param helper the xr experience helper to enter/exit xr with
  134486. * @param options options to configure the UI
  134487. * @returns the created ui
  134488. */
  134489. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134490. /**
  134491. * Disposes of the XR UI component
  134492. */
  134493. dispose(): void;
  134494. private _updateButtons;
  134495. }
  134496. }
  134497. declare module BABYLON {
  134498. /**
  134499. * Class containing static functions to help procedurally build meshes
  134500. */
  134501. export class LinesBuilder {
  134502. /**
  134503. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134504. * * 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
  134505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134506. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134507. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134508. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134509. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134510. * * 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
  134511. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134514. * @param name defines the name of the new line system
  134515. * @param options defines the options used to create the line system
  134516. * @param scene defines the hosting scene
  134517. * @returns a new line system mesh
  134518. */
  134519. static CreateLineSystem(name: string, options: {
  134520. lines: Vector3[][];
  134521. updatable?: boolean;
  134522. instance?: Nullable<LinesMesh>;
  134523. colors?: Nullable<Color4[][]>;
  134524. useVertexAlpha?: boolean;
  134525. }, scene: Nullable<Scene>): LinesMesh;
  134526. /**
  134527. * Creates a line mesh
  134528. * 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
  134529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134530. * * The parameter `points` is an array successive Vector3
  134531. * * 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
  134532. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134533. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134534. * * When updating an instance, remember that only point positions can change, not the number of points
  134535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134537. * @param name defines the name of the new line system
  134538. * @param options defines the options used to create the line system
  134539. * @param scene defines the hosting scene
  134540. * @returns a new line mesh
  134541. */
  134542. static CreateLines(name: string, options: {
  134543. points: Vector3[];
  134544. updatable?: boolean;
  134545. instance?: Nullable<LinesMesh>;
  134546. colors?: Color4[];
  134547. useVertexAlpha?: boolean;
  134548. }, scene?: Nullable<Scene>): LinesMesh;
  134549. /**
  134550. * Creates a dashed line mesh
  134551. * * 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
  134552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134553. * * The parameter `points` is an array successive Vector3
  134554. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134555. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134556. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134557. * * 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
  134558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134559. * * When updating an instance, remember that only point positions can change, not the number of points
  134560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134561. * @param name defines the name of the mesh
  134562. * @param options defines the options used to create the mesh
  134563. * @param scene defines the hosting scene
  134564. * @returns the dashed line mesh
  134565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134566. */
  134567. static CreateDashedLines(name: string, options: {
  134568. points: Vector3[];
  134569. dashSize?: number;
  134570. gapSize?: number;
  134571. dashNb?: number;
  134572. updatable?: boolean;
  134573. instance?: LinesMesh;
  134574. useVertexAlpha?: boolean;
  134575. }, scene?: Nullable<Scene>): LinesMesh;
  134576. }
  134577. }
  134578. declare module BABYLON {
  134579. /**
  134580. * Construction options for a timer
  134581. */
  134582. export interface ITimerOptions<T> {
  134583. /**
  134584. * Time-to-end
  134585. */
  134586. timeout: number;
  134587. /**
  134588. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134589. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134590. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134591. */
  134592. contextObservable: Observable<T>;
  134593. /**
  134594. * Optional parameters when adding an observer to the observable
  134595. */
  134596. observableParameters?: {
  134597. mask?: number;
  134598. insertFirst?: boolean;
  134599. scope?: any;
  134600. };
  134601. /**
  134602. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134603. */
  134604. breakCondition?: (data?: ITimerData<T>) => boolean;
  134605. /**
  134606. * Will be triggered when the time condition has met
  134607. */
  134608. onEnded?: (data: ITimerData<any>) => void;
  134609. /**
  134610. * Will be triggered when the break condition has met (prematurely ended)
  134611. */
  134612. onAborted?: (data: ITimerData<any>) => void;
  134613. /**
  134614. * Optional function to execute on each tick (or count)
  134615. */
  134616. onTick?: (data: ITimerData<any>) => void;
  134617. }
  134618. /**
  134619. * An interface defining the data sent by the timer
  134620. */
  134621. export interface ITimerData<T> {
  134622. /**
  134623. * When did it start
  134624. */
  134625. startTime: number;
  134626. /**
  134627. * Time now
  134628. */
  134629. currentTime: number;
  134630. /**
  134631. * Time passed since started
  134632. */
  134633. deltaTime: number;
  134634. /**
  134635. * How much is completed, in [0.0...1.0].
  134636. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134637. */
  134638. completeRate: number;
  134639. /**
  134640. * What the registered observable sent in the last count
  134641. */
  134642. payload: T;
  134643. }
  134644. /**
  134645. * The current state of the timer
  134646. */
  134647. export enum TimerState {
  134648. /**
  134649. * Timer initialized, not yet started
  134650. */
  134651. INIT = 0,
  134652. /**
  134653. * Timer started and counting
  134654. */
  134655. STARTED = 1,
  134656. /**
  134657. * Timer ended (whether aborted or time reached)
  134658. */
  134659. ENDED = 2
  134660. }
  134661. /**
  134662. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134663. *
  134664. * @param options options with which to initialize this timer
  134665. */
  134666. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134667. /**
  134668. * An advanced implementation of a timer class
  134669. */
  134670. export class AdvancedTimer<T = any> implements IDisposable {
  134671. /**
  134672. * Will notify each time the timer calculates the remaining time
  134673. */
  134674. onEachCountObservable: Observable<ITimerData<T>>;
  134675. /**
  134676. * Will trigger when the timer was aborted due to the break condition
  134677. */
  134678. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134679. /**
  134680. * Will trigger when the timer ended successfully
  134681. */
  134682. onTimerEndedObservable: Observable<ITimerData<T>>;
  134683. /**
  134684. * Will trigger when the timer state has changed
  134685. */
  134686. onStateChangedObservable: Observable<TimerState>;
  134687. private _observer;
  134688. private _contextObservable;
  134689. private _observableParameters;
  134690. private _startTime;
  134691. private _timer;
  134692. private _state;
  134693. private _breakCondition;
  134694. private _timeToEnd;
  134695. private _breakOnNextTick;
  134696. /**
  134697. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134698. * @param options construction options for this advanced timer
  134699. */
  134700. constructor(options: ITimerOptions<T>);
  134701. /**
  134702. * set a breaking condition for this timer. Default is to never break during count
  134703. * @param predicate the new break condition. Returns true to break, false otherwise
  134704. */
  134705. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134706. /**
  134707. * Reset ALL associated observables in this advanced timer
  134708. */
  134709. clearObservables(): void;
  134710. /**
  134711. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134712. *
  134713. * @param timeToEnd how much time to measure until timer ended
  134714. */
  134715. start(timeToEnd?: number): void;
  134716. /**
  134717. * Will force a stop on the next tick.
  134718. */
  134719. stop(): void;
  134720. /**
  134721. * Dispose this timer, clearing all resources
  134722. */
  134723. dispose(): void;
  134724. private _setState;
  134725. private _tick;
  134726. private _stop;
  134727. }
  134728. }
  134729. declare module BABYLON {
  134730. /**
  134731. * The options container for the teleportation module
  134732. */
  134733. export interface IWebXRTeleportationOptions {
  134734. /**
  134735. * if provided, this scene will be used to render meshes.
  134736. */
  134737. customUtilityLayerScene?: Scene;
  134738. /**
  134739. * Values to configure the default target mesh
  134740. */
  134741. defaultTargetMeshOptions?: {
  134742. /**
  134743. * Fill color of the teleportation area
  134744. */
  134745. teleportationFillColor?: string;
  134746. /**
  134747. * Border color for the teleportation area
  134748. */
  134749. teleportationBorderColor?: string;
  134750. /**
  134751. * Disable the mesh's animation sequence
  134752. */
  134753. disableAnimation?: boolean;
  134754. /**
  134755. * Disable lighting on the material or the ring and arrow
  134756. */
  134757. disableLighting?: boolean;
  134758. /**
  134759. * Override the default material of the torus and arrow
  134760. */
  134761. torusArrowMaterial?: Material;
  134762. };
  134763. /**
  134764. * A list of meshes to use as floor meshes.
  134765. * Meshes can be added and removed after initializing the feature using the
  134766. * addFloorMesh and removeFloorMesh functions
  134767. * If empty, rotation will still work
  134768. */
  134769. floorMeshes?: AbstractMesh[];
  134770. /**
  134771. * use this rendering group id for the meshes (optional)
  134772. */
  134773. renderingGroupId?: number;
  134774. /**
  134775. * Should teleportation move only to snap points
  134776. */
  134777. snapPointsOnly?: boolean;
  134778. /**
  134779. * An array of points to which the teleportation will snap to.
  134780. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134781. */
  134782. snapPositions?: Vector3[];
  134783. /**
  134784. * How close should the teleportation ray be in order to snap to position.
  134785. * Default to 0.8 units (meters)
  134786. */
  134787. snapToPositionRadius?: number;
  134788. /**
  134789. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134790. * If you want to support rotation, make sure your mesh has a direction indicator.
  134791. *
  134792. * When left untouched, the default mesh will be initialized.
  134793. */
  134794. teleportationTargetMesh?: AbstractMesh;
  134795. /**
  134796. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134797. */
  134798. timeToTeleport?: number;
  134799. /**
  134800. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134801. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134802. */
  134803. useMainComponentOnly?: boolean;
  134804. /**
  134805. * Should meshes created here be added to a utility layer or the main scene
  134806. */
  134807. useUtilityLayer?: boolean;
  134808. /**
  134809. * Babylon XR Input class for controller
  134810. */
  134811. xrInput: WebXRInput;
  134812. /**
  134813. * Meshes that the teleportation ray cannot go through
  134814. */
  134815. pickBlockerMeshes?: AbstractMesh[];
  134816. /**
  134817. * Should teleport work only on a specific hand?
  134818. */
  134819. forceHandedness?: XRHandedness;
  134820. /**
  134821. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  134822. */
  134823. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  134824. }
  134825. /**
  134826. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134827. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134828. * the input of the attached controllers.
  134829. */
  134830. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134831. private _options;
  134832. private _controllers;
  134833. private _currentTeleportationControllerId;
  134834. private _floorMeshes;
  134835. private _quadraticBezierCurve;
  134836. private _selectionFeature;
  134837. private _snapToPositions;
  134838. private _snappedToPoint;
  134839. private _teleportationRingMaterial?;
  134840. private _tmpRay;
  134841. private _tmpVector;
  134842. private _tmpQuaternion;
  134843. /**
  134844. * The module's name
  134845. */
  134846. static readonly Name: string;
  134847. /**
  134848. * The (Babylon) version of this module.
  134849. * This is an integer representing the implementation version.
  134850. * This number does not correspond to the webxr specs version
  134851. */
  134852. static readonly Version: number;
  134853. /**
  134854. * Is movement backwards enabled
  134855. */
  134856. backwardsMovementEnabled: boolean;
  134857. /**
  134858. * Distance to travel when moving backwards
  134859. */
  134860. backwardsTeleportationDistance: number;
  134861. /**
  134862. * The distance from the user to the inspection point in the direction of the controller
  134863. * A higher number will allow the user to move further
  134864. * defaults to 5 (meters, in xr units)
  134865. */
  134866. parabolicCheckRadius: number;
  134867. /**
  134868. * Should the module support parabolic ray on top of direct ray
  134869. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134870. * Very helpful when moving between floors / different heights
  134871. */
  134872. parabolicRayEnabled: boolean;
  134873. /**
  134874. * The second type of ray - straight line.
  134875. * Should it be enabled or should the parabolic line be the only one.
  134876. */
  134877. straightRayEnabled: boolean;
  134878. /**
  134879. * How much rotation should be applied when rotating right and left
  134880. */
  134881. rotationAngle: number;
  134882. private _rotationEnabled;
  134883. /**
  134884. * Is rotation enabled when moving forward?
  134885. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134886. */
  134887. get rotationEnabled(): boolean;
  134888. /**
  134889. * Sets wether rotation is enabled or not
  134890. * @param enabled is rotation enabled when teleportation is shown
  134891. */
  134892. set rotationEnabled(enabled: boolean);
  134893. /**
  134894. * Exposes the currently set teleportation target mesh.
  134895. */
  134896. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  134897. /**
  134898. * constructs a new anchor system
  134899. * @param _xrSessionManager an instance of WebXRSessionManager
  134900. * @param _options configuration object for this feature
  134901. */
  134902. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134903. /**
  134904. * Get the snapPointsOnly flag
  134905. */
  134906. get snapPointsOnly(): boolean;
  134907. /**
  134908. * Sets the snapPointsOnly flag
  134909. * @param snapToPoints should teleportation be exclusively to snap points
  134910. */
  134911. set snapPointsOnly(snapToPoints: boolean);
  134912. /**
  134913. * Add a new mesh to the floor meshes array
  134914. * @param mesh the mesh to use as floor mesh
  134915. */
  134916. addFloorMesh(mesh: AbstractMesh): void;
  134917. /**
  134918. * Add a new snap-to point to fix teleportation to this position
  134919. * @param newSnapPoint The new Snap-To point
  134920. */
  134921. addSnapPoint(newSnapPoint: Vector3): void;
  134922. attach(): boolean;
  134923. detach(): boolean;
  134924. dispose(): void;
  134925. /**
  134926. * Remove a mesh from the floor meshes array
  134927. * @param mesh the mesh to remove
  134928. */
  134929. removeFloorMesh(mesh: AbstractMesh): void;
  134930. /**
  134931. * Remove a mesh from the floor meshes array using its name
  134932. * @param name the mesh name to remove
  134933. */
  134934. removeFloorMeshByName(name: string): void;
  134935. /**
  134936. * 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
  134937. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134938. * @returns was the point found and removed or not
  134939. */
  134940. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134941. /**
  134942. * This function sets a selection feature that will be disabled when
  134943. * the forward ray is shown and will be reattached when hidden.
  134944. * This is used to remove the selection rays when moving.
  134945. * @param selectionFeature the feature to disable when forward movement is enabled
  134946. */
  134947. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134948. protected _onXRFrame(_xrFrame: XRFrame): void;
  134949. private _attachController;
  134950. private _createDefaultTargetMesh;
  134951. private _detachController;
  134952. private _findClosestSnapPointWithRadius;
  134953. private _setTargetMeshPosition;
  134954. private _setTargetMeshVisibility;
  134955. private _showParabolicPath;
  134956. private _teleportForward;
  134957. }
  134958. }
  134959. declare module BABYLON {
  134960. /**
  134961. * Options for the default xr helper
  134962. */
  134963. export class WebXRDefaultExperienceOptions {
  134964. /**
  134965. * Enable or disable default UI to enter XR
  134966. */
  134967. disableDefaultUI?: boolean;
  134968. /**
  134969. * Should teleportation not initialize. defaults to false.
  134970. */
  134971. disableTeleportation?: boolean;
  134972. /**
  134973. * Floor meshes that will be used for teleport
  134974. */
  134975. floorMeshes?: Array<AbstractMesh>;
  134976. /**
  134977. * If set to true, the first frame will not be used to reset position
  134978. * The first frame is mainly used when copying transformation from the old camera
  134979. * Mainly used in AR
  134980. */
  134981. ignoreNativeCameraTransformation?: boolean;
  134982. /**
  134983. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134984. */
  134985. inputOptions?: IWebXRInputOptions;
  134986. /**
  134987. * optional configuration for the output canvas
  134988. */
  134989. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134990. /**
  134991. * optional UI options. This can be used among other to change session mode and reference space type
  134992. */
  134993. uiOptions?: WebXREnterExitUIOptions;
  134994. /**
  134995. * When loading teleportation and pointer select, use stable versions instead of latest.
  134996. */
  134997. useStablePlugins?: boolean;
  134998. /**
  134999. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  135000. */
  135001. renderingGroupId?: number;
  135002. /**
  135003. * A list of optional features to init the session with
  135004. * If set to true, all features we support will be added
  135005. */
  135006. optionalFeatures?: boolean | string[];
  135007. }
  135008. /**
  135009. * Default experience which provides a similar setup to the previous webVRExperience
  135010. */
  135011. export class WebXRDefaultExperience {
  135012. /**
  135013. * Base experience
  135014. */
  135015. baseExperience: WebXRExperienceHelper;
  135016. /**
  135017. * Enables ui for entering/exiting xr
  135018. */
  135019. enterExitUI: WebXREnterExitUI;
  135020. /**
  135021. * Input experience extension
  135022. */
  135023. input: WebXRInput;
  135024. /**
  135025. * Enables laser pointer and selection
  135026. */
  135027. pointerSelection: WebXRControllerPointerSelection;
  135028. /**
  135029. * Default target xr should render to
  135030. */
  135031. renderTarget: WebXRRenderTarget;
  135032. /**
  135033. * Enables teleportation
  135034. */
  135035. teleportation: WebXRMotionControllerTeleportation;
  135036. private constructor();
  135037. /**
  135038. * Creates the default xr experience
  135039. * @param scene scene
  135040. * @param options options for basic configuration
  135041. * @returns resulting WebXRDefaultExperience
  135042. */
  135043. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135044. /**
  135045. * DIsposes of the experience helper
  135046. */
  135047. dispose(): void;
  135048. }
  135049. }
  135050. declare module BABYLON {
  135051. /**
  135052. * Options to modify the vr teleportation behavior.
  135053. */
  135054. export interface VRTeleportationOptions {
  135055. /**
  135056. * The name of the mesh which should be used as the teleportation floor. (default: null)
  135057. */
  135058. floorMeshName?: string;
  135059. /**
  135060. * A list of meshes to be used as the teleportation floor. (default: empty)
  135061. */
  135062. floorMeshes?: Mesh[];
  135063. /**
  135064. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  135065. */
  135066. teleportationMode?: number;
  135067. /**
  135068. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  135069. */
  135070. teleportationTime?: number;
  135071. /**
  135072. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  135073. */
  135074. teleportationSpeed?: number;
  135075. /**
  135076. * The easing function used in the animation or null for Linear. (default CircleEase)
  135077. */
  135078. easingFunction?: EasingFunction;
  135079. }
  135080. /**
  135081. * Options to modify the vr experience helper's behavior.
  135082. */
  135083. export interface VRExperienceHelperOptions extends WebVROptions {
  135084. /**
  135085. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  135086. */
  135087. createDeviceOrientationCamera?: boolean;
  135088. /**
  135089. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  135090. */
  135091. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  135092. /**
  135093. * Uses the main button on the controller to toggle the laser casted. (default: true)
  135094. */
  135095. laserToggle?: boolean;
  135096. /**
  135097. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  135098. */
  135099. floorMeshes?: Mesh[];
  135100. /**
  135101. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  135102. */
  135103. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  135104. /**
  135105. * Defines if WebXR should be used instead of WebVR (if available)
  135106. */
  135107. useXR?: boolean;
  135108. }
  135109. /**
  135110. * Event containing information after VR has been entered
  135111. */
  135112. export class OnAfterEnteringVRObservableEvent {
  135113. /**
  135114. * If entering vr was successful
  135115. */
  135116. success: boolean;
  135117. }
  135118. /**
  135119. * Helps to quickly add VR support to an existing scene.
  135120. * See https://doc.babylonjs.com/how_to/webvr_helper
  135121. */
  135122. export class VRExperienceHelper {
  135123. /** Options to modify the vr experience helper's behavior. */
  135124. webVROptions: VRExperienceHelperOptions;
  135125. private _scene;
  135126. private _position;
  135127. private _btnVR;
  135128. private _btnVRDisplayed;
  135129. private _webVRsupported;
  135130. private _webVRready;
  135131. private _webVRrequesting;
  135132. private _webVRpresenting;
  135133. private _hasEnteredVR;
  135134. private _fullscreenVRpresenting;
  135135. private _inputElement;
  135136. private _webVRCamera;
  135137. private _vrDeviceOrientationCamera;
  135138. private _deviceOrientationCamera;
  135139. private _existingCamera;
  135140. private _onKeyDown;
  135141. private _onVrDisplayPresentChange;
  135142. private _onVRDisplayChanged;
  135143. private _onVRRequestPresentStart;
  135144. private _onVRRequestPresentComplete;
  135145. /**
  135146. * 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)
  135147. */
  135148. enableGazeEvenWhenNoPointerLock: boolean;
  135149. /**
  135150. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  135151. */
  135152. exitVROnDoubleTap: boolean;
  135153. /**
  135154. * Observable raised right before entering VR.
  135155. */
  135156. onEnteringVRObservable: Observable<VRExperienceHelper>;
  135157. /**
  135158. * Observable raised when entering VR has completed.
  135159. */
  135160. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  135161. /**
  135162. * Observable raised when exiting VR.
  135163. */
  135164. onExitingVRObservable: Observable<VRExperienceHelper>;
  135165. /**
  135166. * Observable raised when controller mesh is loaded.
  135167. */
  135168. onControllerMeshLoadedObservable: Observable<WebVRController>;
  135169. /** Return this.onEnteringVRObservable
  135170. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  135171. */
  135172. get onEnteringVR(): Observable<VRExperienceHelper>;
  135173. /** Return this.onExitingVRObservable
  135174. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  135175. */
  135176. get onExitingVR(): Observable<VRExperienceHelper>;
  135177. /** Return this.onControllerMeshLoadedObservable
  135178. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  135179. */
  135180. get onControllerMeshLoaded(): Observable<WebVRController>;
  135181. private _rayLength;
  135182. private _useCustomVRButton;
  135183. private _teleportationRequested;
  135184. private _teleportActive;
  135185. private _floorMeshName;
  135186. private _floorMeshesCollection;
  135187. private _teleportationMode;
  135188. private _teleportationTime;
  135189. private _teleportationSpeed;
  135190. private _teleportationEasing;
  135191. private _rotationAllowed;
  135192. private _teleportBackwardsVector;
  135193. private _teleportationTarget;
  135194. private _isDefaultTeleportationTarget;
  135195. private _postProcessMove;
  135196. private _teleportationFillColor;
  135197. private _teleportationBorderColor;
  135198. private _rotationAngle;
  135199. private _haloCenter;
  135200. private _cameraGazer;
  135201. private _padSensibilityUp;
  135202. private _padSensibilityDown;
  135203. private _leftController;
  135204. private _rightController;
  135205. private _gazeColor;
  135206. private _laserColor;
  135207. private _pickedLaserColor;
  135208. private _pickedGazeColor;
  135209. /**
  135210. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  135211. */
  135212. onNewMeshSelected: Observable<AbstractMesh>;
  135213. /**
  135214. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  135215. * This observable will provide the mesh and the controller used to select the mesh
  135216. */
  135217. onMeshSelectedWithController: Observable<{
  135218. mesh: AbstractMesh;
  135219. controller: WebVRController;
  135220. }>;
  135221. /**
  135222. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  135223. */
  135224. onNewMeshPicked: Observable<PickingInfo>;
  135225. private _circleEase;
  135226. /**
  135227. * Observable raised before camera teleportation
  135228. */
  135229. onBeforeCameraTeleport: Observable<Vector3>;
  135230. /**
  135231. * Observable raised after camera teleportation
  135232. */
  135233. onAfterCameraTeleport: Observable<Vector3>;
  135234. /**
  135235. * Observable raised when current selected mesh gets unselected
  135236. */
  135237. onSelectedMeshUnselected: Observable<AbstractMesh>;
  135238. private _raySelectionPredicate;
  135239. /**
  135240. * To be optionaly changed by user to define custom ray selection
  135241. */
  135242. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  135243. /**
  135244. * To be optionaly changed by user to define custom selection logic (after ray selection)
  135245. */
  135246. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135247. /**
  135248. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  135249. */
  135250. teleportationEnabled: boolean;
  135251. private _defaultHeight;
  135252. private _teleportationInitialized;
  135253. private _interactionsEnabled;
  135254. private _interactionsRequested;
  135255. private _displayGaze;
  135256. private _displayLaserPointer;
  135257. /**
  135258. * The mesh used to display where the user is going to teleport.
  135259. */
  135260. get teleportationTarget(): Mesh;
  135261. /**
  135262. * Sets the mesh to be used to display where the user is going to teleport.
  135263. */
  135264. set teleportationTarget(value: Mesh);
  135265. /**
  135266. * 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
  135267. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  135268. * See https://doc.babylonjs.com/resources/baking_transformations
  135269. */
  135270. get gazeTrackerMesh(): Mesh;
  135271. set gazeTrackerMesh(value: Mesh);
  135272. /**
  135273. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  135274. */
  135275. updateGazeTrackerScale: boolean;
  135276. /**
  135277. * If the gaze trackers color should be updated when selecting meshes
  135278. */
  135279. updateGazeTrackerColor: boolean;
  135280. /**
  135281. * If the controller laser color should be updated when selecting meshes
  135282. */
  135283. updateControllerLaserColor: boolean;
  135284. /**
  135285. * The gaze tracking mesh corresponding to the left controller
  135286. */
  135287. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  135288. /**
  135289. * The gaze tracking mesh corresponding to the right controller
  135290. */
  135291. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  135292. /**
  135293. * If the ray of the gaze should be displayed.
  135294. */
  135295. get displayGaze(): boolean;
  135296. /**
  135297. * Sets if the ray of the gaze should be displayed.
  135298. */
  135299. set displayGaze(value: boolean);
  135300. /**
  135301. * If the ray of the LaserPointer should be displayed.
  135302. */
  135303. get displayLaserPointer(): boolean;
  135304. /**
  135305. * Sets if the ray of the LaserPointer should be displayed.
  135306. */
  135307. set displayLaserPointer(value: boolean);
  135308. /**
  135309. * The deviceOrientationCamera used as the camera when not in VR.
  135310. */
  135311. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  135312. /**
  135313. * Based on the current WebVR support, returns the current VR camera used.
  135314. */
  135315. get currentVRCamera(): Nullable<Camera>;
  135316. /**
  135317. * The webVRCamera which is used when in VR.
  135318. */
  135319. get webVRCamera(): WebVRFreeCamera;
  135320. /**
  135321. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  135322. */
  135323. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  135324. /**
  135325. * The html button that is used to trigger entering into VR.
  135326. */
  135327. get vrButton(): Nullable<HTMLButtonElement>;
  135328. private get _teleportationRequestInitiated();
  135329. /**
  135330. * Defines whether or not Pointer lock should be requested when switching to
  135331. * full screen.
  135332. */
  135333. requestPointerLockOnFullScreen: boolean;
  135334. /**
  135335. * If asking to force XR, this will be populated with the default xr experience
  135336. */
  135337. xr: WebXRDefaultExperience;
  135338. /**
  135339. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135340. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135341. */
  135342. xrTestDone: boolean;
  135343. /**
  135344. * Instantiates a VRExperienceHelper.
  135345. * Helps to quickly add VR support to an existing scene.
  135346. * @param scene The scene the VRExperienceHelper belongs to.
  135347. * @param webVROptions Options to modify the vr experience helper's behavior.
  135348. */
  135349. constructor(scene: Scene,
  135350. /** Options to modify the vr experience helper's behavior. */
  135351. webVROptions?: VRExperienceHelperOptions);
  135352. private completeVRInit;
  135353. private _onDefaultMeshLoaded;
  135354. private _onResize;
  135355. private _onFullscreenChange;
  135356. /**
  135357. * Gets a value indicating if we are currently in VR mode.
  135358. */
  135359. get isInVRMode(): boolean;
  135360. private onVrDisplayPresentChange;
  135361. private onVRDisplayChanged;
  135362. private moveButtonToBottomRight;
  135363. private displayVRButton;
  135364. private updateButtonVisibility;
  135365. private _cachedAngularSensibility;
  135366. /**
  135367. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135368. * Otherwise, will use the fullscreen API.
  135369. */
  135370. enterVR(): void;
  135371. /**
  135372. * Attempt to exit VR, or fullscreen.
  135373. */
  135374. exitVR(): void;
  135375. /**
  135376. * The position of the vr experience helper.
  135377. */
  135378. get position(): Vector3;
  135379. /**
  135380. * Sets the position of the vr experience helper.
  135381. */
  135382. set position(value: Vector3);
  135383. /**
  135384. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135385. */
  135386. enableInteractions(): void;
  135387. private get _noControllerIsActive();
  135388. private beforeRender;
  135389. private _isTeleportationFloor;
  135390. /**
  135391. * Adds a floor mesh to be used for teleportation.
  135392. * @param floorMesh the mesh to be used for teleportation.
  135393. */
  135394. addFloorMesh(floorMesh: Mesh): void;
  135395. /**
  135396. * Removes a floor mesh from being used for teleportation.
  135397. * @param floorMesh the mesh to be removed.
  135398. */
  135399. removeFloorMesh(floorMesh: Mesh): void;
  135400. /**
  135401. * Enables interactions and teleportation using the VR controllers and gaze.
  135402. * @param vrTeleportationOptions options to modify teleportation behavior.
  135403. */
  135404. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135405. private _onNewGamepadConnected;
  135406. private _tryEnableInteractionOnController;
  135407. private _onNewGamepadDisconnected;
  135408. private _enableInteractionOnController;
  135409. private _checkTeleportWithRay;
  135410. private _checkRotate;
  135411. private _checkTeleportBackwards;
  135412. private _enableTeleportationOnController;
  135413. private _createTeleportationCircles;
  135414. private _displayTeleportationTarget;
  135415. private _hideTeleportationTarget;
  135416. private _rotateCamera;
  135417. private _moveTeleportationSelectorTo;
  135418. private _workingVector;
  135419. private _workingQuaternion;
  135420. private _workingMatrix;
  135421. /**
  135422. * Time Constant Teleportation Mode
  135423. */
  135424. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135425. /**
  135426. * Speed Constant Teleportation Mode
  135427. */
  135428. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135429. /**
  135430. * Teleports the users feet to the desired location
  135431. * @param location The location where the user's feet should be placed
  135432. */
  135433. teleportCamera(location: Vector3): void;
  135434. private _convertNormalToDirectionOfRay;
  135435. private _castRayAndSelectObject;
  135436. private _notifySelectedMeshUnselected;
  135437. /**
  135438. * Permanently set new colors for the laser pointer
  135439. * @param color the new laser color
  135440. * @param pickedColor the new laser color when picked mesh detected
  135441. */
  135442. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135443. /**
  135444. * Set lighting enabled / disabled on the laser pointer of both controllers
  135445. * @param enabled should the lighting be enabled on the laser pointer
  135446. */
  135447. setLaserLightingState(enabled?: boolean): void;
  135448. /**
  135449. * Permanently set new colors for the gaze pointer
  135450. * @param color the new gaze color
  135451. * @param pickedColor the new gaze color when picked mesh detected
  135452. */
  135453. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135454. /**
  135455. * Sets the color of the laser ray from the vr controllers.
  135456. * @param color new color for the ray.
  135457. */
  135458. changeLaserColor(color: Color3): void;
  135459. /**
  135460. * Sets the color of the ray from the vr headsets gaze.
  135461. * @param color new color for the ray.
  135462. */
  135463. changeGazeColor(color: Color3): void;
  135464. /**
  135465. * Exits VR and disposes of the vr experience helper
  135466. */
  135467. dispose(): void;
  135468. /**
  135469. * Gets the name of the VRExperienceHelper class
  135470. * @returns "VRExperienceHelper"
  135471. */
  135472. getClassName(): string;
  135473. }
  135474. }
  135475. declare module BABYLON {
  135476. /**
  135477. * Contains an array of blocks representing the octree
  135478. */
  135479. export interface IOctreeContainer<T> {
  135480. /**
  135481. * Blocks within the octree
  135482. */
  135483. blocks: Array<OctreeBlock<T>>;
  135484. }
  135485. /**
  135486. * Class used to store a cell in an octree
  135487. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135488. */
  135489. export class OctreeBlock<T> {
  135490. /**
  135491. * Gets the content of the current block
  135492. */
  135493. entries: T[];
  135494. /**
  135495. * Gets the list of block children
  135496. */
  135497. blocks: Array<OctreeBlock<T>>;
  135498. private _depth;
  135499. private _maxDepth;
  135500. private _capacity;
  135501. private _minPoint;
  135502. private _maxPoint;
  135503. private _boundingVectors;
  135504. private _creationFunc;
  135505. /**
  135506. * Creates a new block
  135507. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135508. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135509. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135510. * @param depth defines the current depth of this block in the octree
  135511. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135512. * @param creationFunc defines a callback to call when an element is added to the block
  135513. */
  135514. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135515. /**
  135516. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135517. */
  135518. get capacity(): number;
  135519. /**
  135520. * Gets the minimum vector (in world space) of the block's bounding box
  135521. */
  135522. get minPoint(): Vector3;
  135523. /**
  135524. * Gets the maximum vector (in world space) of the block's bounding box
  135525. */
  135526. get maxPoint(): Vector3;
  135527. /**
  135528. * Add a new element to this block
  135529. * @param entry defines the element to add
  135530. */
  135531. addEntry(entry: T): void;
  135532. /**
  135533. * Remove an element from this block
  135534. * @param entry defines the element to remove
  135535. */
  135536. removeEntry(entry: T): void;
  135537. /**
  135538. * Add an array of elements to this block
  135539. * @param entries defines the array of elements to add
  135540. */
  135541. addEntries(entries: T[]): void;
  135542. /**
  135543. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135544. * @param frustumPlanes defines the frustum planes to test
  135545. * @param selection defines the array to store current content if selection is positive
  135546. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135547. */
  135548. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135549. /**
  135550. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135551. * @param sphereCenter defines the bounding sphere center
  135552. * @param sphereRadius defines the bounding sphere radius
  135553. * @param selection defines the array to store current content if selection is positive
  135554. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135555. */
  135556. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135557. /**
  135558. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135559. * @param ray defines the ray to test with
  135560. * @param selection defines the array to store current content if selection is positive
  135561. */
  135562. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135563. /**
  135564. * Subdivide the content into child blocks (this block will then be empty)
  135565. */
  135566. createInnerBlocks(): void;
  135567. /**
  135568. * @hidden
  135569. */
  135570. 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;
  135571. }
  135572. }
  135573. declare module BABYLON {
  135574. /**
  135575. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135576. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135577. */
  135578. export class Octree<T> {
  135579. /** 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.) */
  135580. maxDepth: number;
  135581. /**
  135582. * Blocks within the octree containing objects
  135583. */
  135584. blocks: Array<OctreeBlock<T>>;
  135585. /**
  135586. * Content stored in the octree
  135587. */
  135588. dynamicContent: T[];
  135589. private _maxBlockCapacity;
  135590. private _selectionContent;
  135591. private _creationFunc;
  135592. /**
  135593. * Creates a octree
  135594. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135595. * @param creationFunc function to be used to instatiate the octree
  135596. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135597. * @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.)
  135598. */
  135599. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135600. /** 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.) */
  135601. maxDepth?: number);
  135602. /**
  135603. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135604. * @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);
  135605. * @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);
  135606. * @param entries meshes to be added to the octree blocks
  135607. */
  135608. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135609. /**
  135610. * Adds a mesh to the octree
  135611. * @param entry Mesh to add to the octree
  135612. */
  135613. addMesh(entry: T): void;
  135614. /**
  135615. * Remove an element from the octree
  135616. * @param entry defines the element to remove
  135617. */
  135618. removeMesh(entry: T): void;
  135619. /**
  135620. * Selects an array of meshes within the frustum
  135621. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135622. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135623. * @returns array of meshes within the frustum
  135624. */
  135625. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135626. /**
  135627. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135628. * @param sphereCenter defines the bounding sphere center
  135629. * @param sphereRadius defines the bounding sphere radius
  135630. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135631. * @returns an array of objects that intersect the sphere
  135632. */
  135633. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135634. /**
  135635. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135636. * @param ray defines the ray to test with
  135637. * @returns array of intersected objects
  135638. */
  135639. intersectsRay(ray: Ray): SmartArray<T>;
  135640. /**
  135641. * Adds a mesh into the octree block if it intersects the block
  135642. */
  135643. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135644. /**
  135645. * Adds a submesh into the octree block if it intersects the block
  135646. */
  135647. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135648. }
  135649. }
  135650. declare module BABYLON {
  135651. interface Scene {
  135652. /**
  135653. * @hidden
  135654. * Backing Filed
  135655. */
  135656. _selectionOctree: Octree<AbstractMesh>;
  135657. /**
  135658. * Gets the octree used to boost mesh selection (picking)
  135659. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135660. */
  135661. selectionOctree: Octree<AbstractMesh>;
  135662. /**
  135663. * Creates or updates the octree used to boost selection (picking)
  135664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135665. * @param maxCapacity defines the maximum capacity per leaf
  135666. * @param maxDepth defines the maximum depth of the octree
  135667. * @returns an octree of AbstractMesh
  135668. */
  135669. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135670. }
  135671. interface AbstractMesh {
  135672. /**
  135673. * @hidden
  135674. * Backing Field
  135675. */
  135676. _submeshesOctree: Octree<SubMesh>;
  135677. /**
  135678. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135679. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135680. * @param maxCapacity defines the maximum size of each block (64 by default)
  135681. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135682. * @returns the new octree
  135683. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135684. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135685. */
  135686. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135687. }
  135688. /**
  135689. * Defines the octree scene component responsible to manage any octrees
  135690. * in a given scene.
  135691. */
  135692. export class OctreeSceneComponent {
  135693. /**
  135694. * The component name help to identify the component in the list of scene components.
  135695. */
  135696. readonly name: string;
  135697. /**
  135698. * The scene the component belongs to.
  135699. */
  135700. scene: Scene;
  135701. /**
  135702. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135703. */
  135704. readonly checksIsEnabled: boolean;
  135705. /**
  135706. * Creates a new instance of the component for the given scene
  135707. * @param scene Defines the scene to register the component in
  135708. */
  135709. constructor(scene: Scene);
  135710. /**
  135711. * Registers the component in a given scene
  135712. */
  135713. register(): void;
  135714. /**
  135715. * Return the list of active meshes
  135716. * @returns the list of active meshes
  135717. */
  135718. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135719. /**
  135720. * Return the list of active sub meshes
  135721. * @param mesh The mesh to get the candidates sub meshes from
  135722. * @returns the list of active sub meshes
  135723. */
  135724. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135725. private _tempRay;
  135726. /**
  135727. * Return the list of sub meshes intersecting with a given local ray
  135728. * @param mesh defines the mesh to find the submesh for
  135729. * @param localRay defines the ray in local space
  135730. * @returns the list of intersecting sub meshes
  135731. */
  135732. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135733. /**
  135734. * Return the list of sub meshes colliding with a collider
  135735. * @param mesh defines the mesh to find the submesh for
  135736. * @param collider defines the collider to evaluate the collision against
  135737. * @returns the list of colliding sub meshes
  135738. */
  135739. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135740. /**
  135741. * Rebuilds the elements related to this component in case of
  135742. * context lost for instance.
  135743. */
  135744. rebuild(): void;
  135745. /**
  135746. * Disposes the component and the associated ressources.
  135747. */
  135748. dispose(): void;
  135749. }
  135750. }
  135751. declare module BABYLON {
  135752. /**
  135753. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135754. */
  135755. export interface GizmoAxisCache {
  135756. /** Mesh used to runder the Gizmo */
  135757. gizmoMeshes: Mesh[];
  135758. /** Mesh used to detect user interaction with Gizmo */
  135759. colliderMeshes: Mesh[];
  135760. /** Material used to inicate color of gizmo mesh */
  135761. material: StandardMaterial;
  135762. /** Material used to inicate hover state of the Gizmo */
  135763. hoverMaterial: StandardMaterial;
  135764. /** Material used to inicate disabled state of the Gizmo */
  135765. disableMaterial: StandardMaterial;
  135766. /** Used to indicate Active state of the Gizmo */
  135767. active: boolean;
  135768. }
  135769. /**
  135770. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135771. */
  135772. export class Gizmo implements IDisposable {
  135773. /** The utility layer the gizmo will be added to */
  135774. gizmoLayer: UtilityLayerRenderer;
  135775. /**
  135776. * The root mesh of the gizmo
  135777. */
  135778. _rootMesh: Mesh;
  135779. private _attachedMesh;
  135780. private _attachedNode;
  135781. /**
  135782. * Ratio for the scale of the gizmo (Default: 1)
  135783. */
  135784. protected _scaleRatio: number;
  135785. /**
  135786. * boolean updated by pointermove when a gizmo mesh is hovered
  135787. */
  135788. protected _isHovered: boolean;
  135789. /**
  135790. * Ratio for the scale of the gizmo (Default: 1)
  135791. */
  135792. set scaleRatio(value: number);
  135793. get scaleRatio(): number;
  135794. /**
  135795. * True when the mouse pointer is hovered a gizmo mesh
  135796. */
  135797. get isHovered(): boolean;
  135798. /**
  135799. * If a custom mesh has been set (Default: false)
  135800. */
  135801. protected _customMeshSet: boolean;
  135802. /**
  135803. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135804. * * When set, interactions will be enabled
  135805. */
  135806. get attachedMesh(): Nullable<AbstractMesh>;
  135807. set attachedMesh(value: Nullable<AbstractMesh>);
  135808. /**
  135809. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135810. * * When set, interactions will be enabled
  135811. */
  135812. get attachedNode(): Nullable<Node>;
  135813. set attachedNode(value: Nullable<Node>);
  135814. /**
  135815. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135816. * @param mesh The mesh to replace the default mesh of the gizmo
  135817. */
  135818. setCustomMesh(mesh: Mesh): void;
  135819. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135820. /**
  135821. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135822. */
  135823. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135824. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135825. /**
  135826. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135827. */
  135828. updateGizmoPositionToMatchAttachedMesh: boolean;
  135829. /**
  135830. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135831. */
  135832. updateScale: boolean;
  135833. protected _interactionsEnabled: boolean;
  135834. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135835. private _beforeRenderObserver;
  135836. private _tempQuaternion;
  135837. private _tempVector;
  135838. private _tempVector2;
  135839. private _tempMatrix1;
  135840. private _tempMatrix2;
  135841. private _rightHandtoLeftHandMatrix;
  135842. /**
  135843. * Creates a gizmo
  135844. * @param gizmoLayer The utility layer the gizmo will be added to
  135845. */
  135846. constructor(
  135847. /** The utility layer the gizmo will be added to */
  135848. gizmoLayer?: UtilityLayerRenderer);
  135849. /**
  135850. * Updates the gizmo to match the attached mesh's position/rotation
  135851. */
  135852. protected _update(): void;
  135853. /**
  135854. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135855. * @param value Node, TransformNode or mesh
  135856. */
  135857. protected _matrixChanged(): void;
  135858. /**
  135859. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135860. * @param gizmoLayer The utility layer the gizmo will be added to
  135861. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135862. * @returns {Observer<PointerInfo>} pointerObserver
  135863. */
  135864. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135865. /**
  135866. * Disposes of the gizmo
  135867. */
  135868. dispose(): void;
  135869. }
  135870. }
  135871. declare module BABYLON {
  135872. /**
  135873. * Single plane drag gizmo
  135874. */
  135875. export class PlaneDragGizmo extends Gizmo {
  135876. /**
  135877. * Drag behavior responsible for the gizmos dragging interactions
  135878. */
  135879. dragBehavior: PointerDragBehavior;
  135880. private _pointerObserver;
  135881. /**
  135882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135883. */
  135884. snapDistance: number;
  135885. /**
  135886. * Event that fires each time the gizmo snaps to a new location.
  135887. * * snapDistance is the the change in distance
  135888. */
  135889. onSnapObservable: Observable<{
  135890. snapDistance: number;
  135891. }>;
  135892. private _gizmoMesh;
  135893. private _coloredMaterial;
  135894. private _hoverMaterial;
  135895. private _disableMaterial;
  135896. private _isEnabled;
  135897. private _parent;
  135898. private _dragging;
  135899. /** @hidden */
  135900. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135901. /**
  135902. * Creates a PlaneDragGizmo
  135903. * @param gizmoLayer The utility layer the gizmo will be added to
  135904. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135905. * @param color The color of the gizmo
  135906. */
  135907. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135908. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135909. /**
  135910. * If the gizmo is enabled
  135911. */
  135912. set isEnabled(value: boolean);
  135913. get isEnabled(): boolean;
  135914. /**
  135915. * Disposes of the gizmo
  135916. */
  135917. dispose(): void;
  135918. }
  135919. }
  135920. declare module BABYLON {
  135921. /**
  135922. * Single plane rotation gizmo
  135923. */
  135924. export class PlaneRotationGizmo extends Gizmo {
  135925. /**
  135926. * Drag behavior responsible for the gizmos dragging interactions
  135927. */
  135928. dragBehavior: PointerDragBehavior;
  135929. private _pointerObserver;
  135930. /**
  135931. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135932. */
  135933. snapDistance: number;
  135934. /**
  135935. * Event that fires each time the gizmo snaps to a new location.
  135936. * * snapDistance is the the change in distance
  135937. */
  135938. onSnapObservable: Observable<{
  135939. snapDistance: number;
  135940. }>;
  135941. private _isEnabled;
  135942. private _parent;
  135943. private _coloredMaterial;
  135944. private _hoverMaterial;
  135945. private _disableMaterial;
  135946. private _gizmoMesh;
  135947. private _rotationCircle;
  135948. private _dragging;
  135949. private static _CircleConstants;
  135950. /**
  135951. * Creates a PlaneRotationGizmo
  135952. * @param gizmoLayer The utility layer the gizmo will be added to
  135953. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  135954. * @param color The color of the gizmo
  135955. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135956. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135957. * @param thickness display gizmo axis thickness
  135958. */
  135959. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  135960. /** Create Geometry for Gizmo */
  135961. private _createGizmoMesh;
  135962. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135963. private setupRotationCircle;
  135964. private updateRotationPath;
  135965. private updateRotationCircle;
  135966. /**
  135967. * If the gizmo is enabled
  135968. */
  135969. set isEnabled(value: boolean);
  135970. get isEnabled(): boolean;
  135971. /**
  135972. * Disposes of the gizmo
  135973. */
  135974. dispose(): void;
  135975. }
  135976. }
  135977. declare module BABYLON {
  135978. /**
  135979. * Gizmo that enables rotating a mesh along 3 axis
  135980. */
  135981. export class RotationGizmo extends Gizmo {
  135982. /**
  135983. * Internal gizmo used for interactions on the x axis
  135984. */
  135985. xGizmo: PlaneRotationGizmo;
  135986. /**
  135987. * Internal gizmo used for interactions on the y axis
  135988. */
  135989. yGizmo: PlaneRotationGizmo;
  135990. /**
  135991. * Internal gizmo used for interactions on the z axis
  135992. */
  135993. zGizmo: PlaneRotationGizmo;
  135994. /** Fires an event when any of it's sub gizmos are dragged */
  135995. onDragStartObservable: Observable<unknown>;
  135996. /** Fires an event when any of it's sub gizmos are released from dragging */
  135997. onDragEndObservable: Observable<unknown>;
  135998. private _meshAttached;
  135999. private _nodeAttached;
  136000. private _observables;
  136001. /** Node Caching for quick lookup */
  136002. private _gizmoAxisCache;
  136003. get attachedMesh(): Nullable<AbstractMesh>;
  136004. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136005. get attachedNode(): Nullable<Node>;
  136006. set attachedNode(node: Nullable<Node>);
  136007. protected _checkBillboardTransform(): void;
  136008. /**
  136009. * True when the mouse pointer is hovering a gizmo mesh
  136010. */
  136011. get isHovered(): boolean;
  136012. /**
  136013. * Creates a RotationGizmo
  136014. * @param gizmoLayer The utility layer the gizmo will be added to
  136015. * @param tessellation Amount of tessellation to be used when creating rotation circles
  136016. * @param useEulerRotation Use and update Euler angle instead of quaternion
  136017. * @param thickness display gizmo axis thickness
  136018. */
  136019. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  136020. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136021. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136022. /**
  136023. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136024. */
  136025. set snapDistance(value: number);
  136026. get snapDistance(): number;
  136027. /**
  136028. * Ratio for the scale of the gizmo (Default: 1)
  136029. */
  136030. set scaleRatio(value: number);
  136031. get scaleRatio(): number;
  136032. /**
  136033. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136034. * @param mesh Axis gizmo mesh
  136035. * @param cache Gizmo axis definition used for reactive gizmo UI
  136036. */
  136037. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136038. /**
  136039. * Disposes of the gizmo
  136040. */
  136041. dispose(): void;
  136042. /**
  136043. * CustomMeshes are not supported by this gizmo
  136044. * @param mesh The mesh to replace the default mesh of the gizmo
  136045. */
  136046. setCustomMesh(mesh: Mesh): void;
  136047. }
  136048. }
  136049. declare module BABYLON {
  136050. /**
  136051. * Class containing static functions to help procedurally build meshes
  136052. */
  136053. export class PolyhedronBuilder {
  136054. /**
  136055. * Creates a polyhedron mesh
  136056. * * 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
  136057. * * The parameter `size` (positive float, default 1) sets the polygon size
  136058. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136059. * * 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`
  136060. * * 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
  136061. * * 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)`)
  136062. * * 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
  136063. * * 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
  136064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136067. * @param name defines the name of the mesh
  136068. * @param options defines the options used to create the mesh
  136069. * @param scene defines the hosting scene
  136070. * @returns the polyhedron mesh
  136071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136072. */
  136073. static CreatePolyhedron(name: string, options: {
  136074. type?: number;
  136075. size?: number;
  136076. sizeX?: number;
  136077. sizeY?: number;
  136078. sizeZ?: number;
  136079. custom?: any;
  136080. faceUV?: Vector4[];
  136081. faceColors?: Color4[];
  136082. flat?: boolean;
  136083. updatable?: boolean;
  136084. sideOrientation?: number;
  136085. frontUVs?: Vector4;
  136086. backUVs?: Vector4;
  136087. }, scene?: Nullable<Scene>): Mesh;
  136088. }
  136089. }
  136090. declare module BABYLON {
  136091. /**
  136092. * Class containing static functions to help procedurally build meshes
  136093. */
  136094. export class BoxBuilder {
  136095. /**
  136096. * Creates a box mesh
  136097. * * The parameter `size` sets the size (float) of each box side (default 1)
  136098. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  136099. * * 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)
  136100. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136104. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  136105. * @param name defines the name of the mesh
  136106. * @param options defines the options used to create the mesh
  136107. * @param scene defines the hosting scene
  136108. * @returns the box mesh
  136109. */
  136110. static CreateBox(name: string, options: {
  136111. size?: number;
  136112. width?: number;
  136113. height?: number;
  136114. depth?: number;
  136115. faceUV?: Vector4[];
  136116. faceColors?: Color4[];
  136117. sideOrientation?: number;
  136118. frontUVs?: Vector4;
  136119. backUVs?: Vector4;
  136120. wrap?: boolean;
  136121. topBaseAt?: number;
  136122. bottomBaseAt?: number;
  136123. updatable?: boolean;
  136124. }, scene?: Nullable<Scene>): Mesh;
  136125. }
  136126. }
  136127. declare module BABYLON {
  136128. /**
  136129. * Single axis scale gizmo
  136130. */
  136131. export class AxisScaleGizmo extends Gizmo {
  136132. /**
  136133. * Drag behavior responsible for the gizmos dragging interactions
  136134. */
  136135. dragBehavior: PointerDragBehavior;
  136136. private _pointerObserver;
  136137. /**
  136138. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136139. */
  136140. snapDistance: number;
  136141. /**
  136142. * Event that fires each time the gizmo snaps to a new location.
  136143. * * snapDistance is the the change in distance
  136144. */
  136145. onSnapObservable: Observable<{
  136146. snapDistance: number;
  136147. }>;
  136148. /**
  136149. * If the scaling operation should be done on all axis (default: false)
  136150. */
  136151. uniformScaling: boolean;
  136152. /**
  136153. * Custom sensitivity value for the drag strength
  136154. */
  136155. sensitivity: number;
  136156. private _isEnabled;
  136157. private _parent;
  136158. private _gizmoMesh;
  136159. private _coloredMaterial;
  136160. private _hoverMaterial;
  136161. private _disableMaterial;
  136162. private _dragging;
  136163. private _tmpVector;
  136164. private _tmpMatrix;
  136165. private _tmpMatrix2;
  136166. /**
  136167. * Creates an AxisScaleGizmo
  136168. * @param gizmoLayer The utility layer the gizmo will be added to
  136169. * @param dragAxis The axis which the gizmo will be able to scale on
  136170. * @param color The color of the gizmo
  136171. * @param thickness display gizmo axis thickness
  136172. */
  136173. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  136174. /** Create Geometry for Gizmo */
  136175. private _createGizmoMesh;
  136176. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136177. /**
  136178. * If the gizmo is enabled
  136179. */
  136180. set isEnabled(value: boolean);
  136181. get isEnabled(): boolean;
  136182. /**
  136183. * Disposes of the gizmo
  136184. */
  136185. dispose(): void;
  136186. /**
  136187. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  136188. * @param mesh The mesh to replace the default mesh of the gizmo
  136189. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  136190. */
  136191. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  136192. }
  136193. }
  136194. declare module BABYLON {
  136195. /**
  136196. * Gizmo that enables scaling a mesh along 3 axis
  136197. */
  136198. export class ScaleGizmo extends Gizmo {
  136199. /**
  136200. * Internal gizmo used for interactions on the x axis
  136201. */
  136202. xGizmo: AxisScaleGizmo;
  136203. /**
  136204. * Internal gizmo used for interactions on the y axis
  136205. */
  136206. yGizmo: AxisScaleGizmo;
  136207. /**
  136208. * Internal gizmo used for interactions on the z axis
  136209. */
  136210. zGizmo: AxisScaleGizmo;
  136211. /**
  136212. * Internal gizmo used to scale all axis equally
  136213. */
  136214. uniformScaleGizmo: AxisScaleGizmo;
  136215. private _meshAttached;
  136216. private _nodeAttached;
  136217. private _snapDistance;
  136218. private _uniformScalingMesh;
  136219. private _octahedron;
  136220. private _sensitivity;
  136221. private _coloredMaterial;
  136222. private _hoverMaterial;
  136223. private _disableMaterial;
  136224. private _observables;
  136225. /** Node Caching for quick lookup */
  136226. private _gizmoAxisCache;
  136227. /** Fires an event when any of it's sub gizmos are dragged */
  136228. onDragStartObservable: Observable<unknown>;
  136229. /** Fires an event when any of it's sub gizmos are released from dragging */
  136230. onDragEndObservable: Observable<unknown>;
  136231. get attachedMesh(): Nullable<AbstractMesh>;
  136232. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136233. get attachedNode(): Nullable<Node>;
  136234. set attachedNode(node: Nullable<Node>);
  136235. /**
  136236. * True when the mouse pointer is hovering a gizmo mesh
  136237. */
  136238. get isHovered(): boolean;
  136239. /**
  136240. * Creates a ScaleGizmo
  136241. * @param gizmoLayer The utility layer the gizmo will be added to
  136242. * @param thickness display gizmo axis thickness
  136243. */
  136244. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136245. /** Create Geometry for Gizmo */
  136246. private _createUniformScaleMesh;
  136247. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136248. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136249. /**
  136250. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136251. */
  136252. set snapDistance(value: number);
  136253. get snapDistance(): number;
  136254. /**
  136255. * Ratio for the scale of the gizmo (Default: 1)
  136256. */
  136257. set scaleRatio(value: number);
  136258. get scaleRatio(): number;
  136259. /**
  136260. * Sensitivity factor for dragging (Default: 1)
  136261. */
  136262. set sensitivity(value: number);
  136263. get sensitivity(): number;
  136264. /**
  136265. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136266. * @param mesh Axis gizmo mesh
  136267. * @param cache Gizmo axis definition used for reactive gizmo UI
  136268. */
  136269. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136270. /**
  136271. * Disposes of the gizmo
  136272. */
  136273. dispose(): void;
  136274. }
  136275. }
  136276. declare module BABYLON {
  136277. /**
  136278. * Bounding box gizmo
  136279. */
  136280. export class BoundingBoxGizmo extends Gizmo {
  136281. private _lineBoundingBox;
  136282. private _rotateSpheresParent;
  136283. private _scaleBoxesParent;
  136284. private _boundingDimensions;
  136285. private _renderObserver;
  136286. private _pointerObserver;
  136287. private _scaleDragSpeed;
  136288. private _tmpQuaternion;
  136289. private _tmpVector;
  136290. private _tmpRotationMatrix;
  136291. /**
  136292. * 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)
  136293. */
  136294. ignoreChildren: boolean;
  136295. /**
  136296. * 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)
  136297. */
  136298. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  136299. /**
  136300. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  136301. */
  136302. rotationSphereSize: number;
  136303. /**
  136304. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  136305. */
  136306. scaleBoxSize: number;
  136307. /**
  136308. * 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)
  136309. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136310. */
  136311. fixedDragMeshScreenSize: boolean;
  136312. /**
  136313. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  136314. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136315. */
  136316. fixedDragMeshBoundsSize: boolean;
  136317. /**
  136318. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  136319. */
  136320. fixedDragMeshScreenSizeDistanceFactor: number;
  136321. /**
  136322. * Fired when a rotation sphere or scale box is dragged
  136323. */
  136324. onDragStartObservable: Observable<{}>;
  136325. /**
  136326. * Fired when a scale box is dragged
  136327. */
  136328. onScaleBoxDragObservable: Observable<{}>;
  136329. /**
  136330. * Fired when a scale box drag is ended
  136331. */
  136332. onScaleBoxDragEndObservable: Observable<{}>;
  136333. /**
  136334. * Fired when a rotation sphere is dragged
  136335. */
  136336. onRotationSphereDragObservable: Observable<{}>;
  136337. /**
  136338. * Fired when a rotation sphere drag is ended
  136339. */
  136340. onRotationSphereDragEndObservable: Observable<{}>;
  136341. /**
  136342. * 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)
  136343. */
  136344. scalePivot: Nullable<Vector3>;
  136345. /**
  136346. * Mesh used as a pivot to rotate the attached node
  136347. */
  136348. private _anchorMesh;
  136349. private _existingMeshScale;
  136350. private _dragMesh;
  136351. private pointerDragBehavior;
  136352. private coloredMaterial;
  136353. private hoverColoredMaterial;
  136354. /**
  136355. * Sets the color of the bounding box gizmo
  136356. * @param color the color to set
  136357. */
  136358. setColor(color: Color3): void;
  136359. /**
  136360. * Creates an BoundingBoxGizmo
  136361. * @param gizmoLayer The utility layer the gizmo will be added to
  136362. * @param color The color of the gizmo
  136363. */
  136364. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136365. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136366. private _selectNode;
  136367. /**
  136368. * Updates the bounding box information for the Gizmo
  136369. */
  136370. updateBoundingBox(): void;
  136371. private _updateRotationSpheres;
  136372. private _updateScaleBoxes;
  136373. /**
  136374. * Enables rotation on the specified axis and disables rotation on the others
  136375. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136376. */
  136377. setEnabledRotationAxis(axis: string): void;
  136378. /**
  136379. * Enables/disables scaling
  136380. * @param enable if scaling should be enabled
  136381. * @param homogeneousScaling defines if scaling should only be homogeneous
  136382. */
  136383. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136384. private _updateDummy;
  136385. /**
  136386. * Enables a pointer drag behavior on the bounding box of the gizmo
  136387. */
  136388. enableDragBehavior(): void;
  136389. /**
  136390. * Disposes of the gizmo
  136391. */
  136392. dispose(): void;
  136393. /**
  136394. * 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)
  136395. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136396. * @returns the bounding box mesh with the passed in mesh as a child
  136397. */
  136398. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136399. /**
  136400. * CustomMeshes are not supported by this gizmo
  136401. * @param mesh The mesh to replace the default mesh of the gizmo
  136402. */
  136403. setCustomMesh(mesh: Mesh): void;
  136404. }
  136405. }
  136406. declare module BABYLON {
  136407. /**
  136408. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136409. */
  136410. export class GizmoManager implements IDisposable {
  136411. private scene;
  136412. /**
  136413. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136414. */
  136415. gizmos: {
  136416. positionGizmo: Nullable<PositionGizmo>;
  136417. rotationGizmo: Nullable<RotationGizmo>;
  136418. scaleGizmo: Nullable<ScaleGizmo>;
  136419. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136420. };
  136421. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136422. clearGizmoOnEmptyPointerEvent: boolean;
  136423. /** Fires an event when the manager is attached to a mesh */
  136424. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136425. /** Fires an event when the manager is attached to a node */
  136426. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136427. private _gizmosEnabled;
  136428. private _pointerObservers;
  136429. private _attachedMesh;
  136430. private _attachedNode;
  136431. private _boundingBoxColor;
  136432. private _defaultUtilityLayer;
  136433. private _defaultKeepDepthUtilityLayer;
  136434. private _thickness;
  136435. /** Node Caching for quick lookup */
  136436. private _gizmoAxisCache;
  136437. /**
  136438. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136439. */
  136440. boundingBoxDragBehavior: SixDofDragBehavior;
  136441. /**
  136442. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136443. */
  136444. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136445. /**
  136446. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136447. */
  136448. attachableNodes: Nullable<Array<Node>>;
  136449. /**
  136450. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136451. */
  136452. usePointerToAttachGizmos: boolean;
  136453. /**
  136454. * Utility layer that the bounding box gizmo belongs to
  136455. */
  136456. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136457. /**
  136458. * Utility layer that all gizmos besides bounding box belong to
  136459. */
  136460. get utilityLayer(): UtilityLayerRenderer;
  136461. /**
  136462. * True when the mouse pointer is hovering a gizmo mesh
  136463. */
  136464. get isHovered(): boolean;
  136465. /**
  136466. * Instatiates a gizmo manager
  136467. * @param scene the scene to overlay the gizmos on top of
  136468. * @param thickness display gizmo axis thickness
  136469. * @param utilityLayer the layer where gizmos are rendered
  136470. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136471. */
  136472. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136473. /**
  136474. * Subscribes to pointer down events, for attaching and detaching mesh
  136475. * @param scene The sceme layer the observer will be added to
  136476. */
  136477. private _attachToMeshPointerObserver;
  136478. /**
  136479. * Attaches a set of gizmos to the specified mesh
  136480. * @param mesh The mesh the gizmo's should be attached to
  136481. */
  136482. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136483. /**
  136484. * Attaches a set of gizmos to the specified node
  136485. * @param node The node the gizmo's should be attached to
  136486. */
  136487. attachToNode(node: Nullable<Node>): void;
  136488. /**
  136489. * If the position gizmo is enabled
  136490. */
  136491. set positionGizmoEnabled(value: boolean);
  136492. get positionGizmoEnabled(): boolean;
  136493. /**
  136494. * If the rotation gizmo is enabled
  136495. */
  136496. set rotationGizmoEnabled(value: boolean);
  136497. get rotationGizmoEnabled(): boolean;
  136498. /**
  136499. * If the scale gizmo is enabled
  136500. */
  136501. set scaleGizmoEnabled(value: boolean);
  136502. get scaleGizmoEnabled(): boolean;
  136503. /**
  136504. * If the boundingBox gizmo is enabled
  136505. */
  136506. set boundingBoxGizmoEnabled(value: boolean);
  136507. get boundingBoxGizmoEnabled(): boolean;
  136508. /**
  136509. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136510. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136511. */
  136512. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136513. /**
  136514. * Disposes of the gizmo manager
  136515. */
  136516. dispose(): void;
  136517. }
  136518. }
  136519. declare module BABYLON {
  136520. /**
  136521. * Gizmo that enables dragging a mesh along 3 axis
  136522. */
  136523. export class PositionGizmo extends Gizmo {
  136524. /**
  136525. * Internal gizmo used for interactions on the x axis
  136526. */
  136527. xGizmo: AxisDragGizmo;
  136528. /**
  136529. * Internal gizmo used for interactions on the y axis
  136530. */
  136531. yGizmo: AxisDragGizmo;
  136532. /**
  136533. * Internal gizmo used for interactions on the z axis
  136534. */
  136535. zGizmo: AxisDragGizmo;
  136536. /**
  136537. * Internal gizmo used for interactions on the yz plane
  136538. */
  136539. xPlaneGizmo: PlaneDragGizmo;
  136540. /**
  136541. * Internal gizmo used for interactions on the xz plane
  136542. */
  136543. yPlaneGizmo: PlaneDragGizmo;
  136544. /**
  136545. * Internal gizmo used for interactions on the xy plane
  136546. */
  136547. zPlaneGizmo: PlaneDragGizmo;
  136548. /**
  136549. * private variables
  136550. */
  136551. private _meshAttached;
  136552. private _nodeAttached;
  136553. private _snapDistance;
  136554. private _observables;
  136555. /** Node Caching for quick lookup */
  136556. private _gizmoAxisCache;
  136557. /** Fires an event when any of it's sub gizmos are dragged */
  136558. onDragStartObservable: Observable<unknown>;
  136559. /** Fires an event when any of it's sub gizmos are released from dragging */
  136560. onDragEndObservable: Observable<unknown>;
  136561. /**
  136562. * If set to true, planar drag is enabled
  136563. */
  136564. private _planarGizmoEnabled;
  136565. get attachedMesh(): Nullable<AbstractMesh>;
  136566. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136567. get attachedNode(): Nullable<Node>;
  136568. set attachedNode(node: Nullable<Node>);
  136569. /**
  136570. * True when the mouse pointer is hovering a gizmo mesh
  136571. */
  136572. get isHovered(): boolean;
  136573. /**
  136574. * Creates a PositionGizmo
  136575. * @param gizmoLayer The utility layer the gizmo will be added to
  136576. @param thickness display gizmo axis thickness
  136577. */
  136578. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136579. /**
  136580. * If the planar drag gizmo is enabled
  136581. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136582. */
  136583. set planarGizmoEnabled(value: boolean);
  136584. get planarGizmoEnabled(): boolean;
  136585. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136586. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136587. /**
  136588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136589. */
  136590. set snapDistance(value: number);
  136591. get snapDistance(): number;
  136592. /**
  136593. * Ratio for the scale of the gizmo (Default: 1)
  136594. */
  136595. set scaleRatio(value: number);
  136596. get scaleRatio(): number;
  136597. /**
  136598. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136599. * @param mesh Axis gizmo mesh
  136600. * @param cache Gizmo axis definition used for reactive gizmo UI
  136601. */
  136602. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136603. /**
  136604. * Disposes of the gizmo
  136605. */
  136606. dispose(): void;
  136607. /**
  136608. * CustomMeshes are not supported by this gizmo
  136609. * @param mesh The mesh to replace the default mesh of the gizmo
  136610. */
  136611. setCustomMesh(mesh: Mesh): void;
  136612. }
  136613. }
  136614. declare module BABYLON {
  136615. /**
  136616. * Single axis drag gizmo
  136617. */
  136618. export class AxisDragGizmo extends Gizmo {
  136619. /**
  136620. * Drag behavior responsible for the gizmos dragging interactions
  136621. */
  136622. dragBehavior: PointerDragBehavior;
  136623. private _pointerObserver;
  136624. /**
  136625. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136626. */
  136627. snapDistance: number;
  136628. /**
  136629. * Event that fires each time the gizmo snaps to a new location.
  136630. * * snapDistance is the the change in distance
  136631. */
  136632. onSnapObservable: Observable<{
  136633. snapDistance: number;
  136634. }>;
  136635. private _isEnabled;
  136636. private _parent;
  136637. private _gizmoMesh;
  136638. private _coloredMaterial;
  136639. private _hoverMaterial;
  136640. private _disableMaterial;
  136641. private _dragging;
  136642. /** @hidden */
  136643. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136644. /** @hidden */
  136645. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136646. /**
  136647. * Creates an AxisDragGizmo
  136648. * @param gizmoLayer The utility layer the gizmo will be added to
  136649. * @param dragAxis The axis which the gizmo will be able to drag on
  136650. * @param color The color of the gizmo
  136651. * @param thickness display gizmo axis thickness
  136652. */
  136653. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136654. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136655. /**
  136656. * If the gizmo is enabled
  136657. */
  136658. set isEnabled(value: boolean);
  136659. get isEnabled(): boolean;
  136660. /**
  136661. * Disposes of the gizmo
  136662. */
  136663. dispose(): void;
  136664. }
  136665. }
  136666. declare module BABYLON.Debug {
  136667. /**
  136668. * The Axes viewer will show 3 axes in a specific point in space
  136669. */
  136670. export class AxesViewer {
  136671. private _xAxis;
  136672. private _yAxis;
  136673. private _zAxis;
  136674. private _scaleLinesFactor;
  136675. private _instanced;
  136676. /**
  136677. * Gets the hosting scene
  136678. */
  136679. scene: Nullable<Scene>;
  136680. /**
  136681. * Gets or sets a number used to scale line length
  136682. */
  136683. scaleLines: number;
  136684. /** Gets the node hierarchy used to render x-axis */
  136685. get xAxis(): TransformNode;
  136686. /** Gets the node hierarchy used to render y-axis */
  136687. get yAxis(): TransformNode;
  136688. /** Gets the node hierarchy used to render z-axis */
  136689. get zAxis(): TransformNode;
  136690. /**
  136691. * Creates a new AxesViewer
  136692. * @param scene defines the hosting scene
  136693. * @param scaleLines defines a number used to scale line length (1 by default)
  136694. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136695. * @param xAxis defines the node hierarchy used to render the x-axis
  136696. * @param yAxis defines the node hierarchy used to render the y-axis
  136697. * @param zAxis defines the node hierarchy used to render the z-axis
  136698. */
  136699. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136700. /**
  136701. * Force the viewer to update
  136702. * @param position defines the position of the viewer
  136703. * @param xaxis defines the x axis of the viewer
  136704. * @param yaxis defines the y axis of the viewer
  136705. * @param zaxis defines the z axis of the viewer
  136706. */
  136707. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136708. /**
  136709. * Creates an instance of this axes viewer.
  136710. * @returns a new axes viewer with instanced meshes
  136711. */
  136712. createInstance(): AxesViewer;
  136713. /** Releases resources */
  136714. dispose(): void;
  136715. private static _SetRenderingGroupId;
  136716. }
  136717. }
  136718. declare module BABYLON.Debug {
  136719. /**
  136720. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136721. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136722. */
  136723. export class BoneAxesViewer extends AxesViewer {
  136724. /**
  136725. * Gets or sets the target mesh where to display the axes viewer
  136726. */
  136727. mesh: Nullable<Mesh>;
  136728. /**
  136729. * Gets or sets the target bone where to display the axes viewer
  136730. */
  136731. bone: Nullable<Bone>;
  136732. /** Gets current position */
  136733. pos: Vector3;
  136734. /** Gets direction of X axis */
  136735. xaxis: Vector3;
  136736. /** Gets direction of Y axis */
  136737. yaxis: Vector3;
  136738. /** Gets direction of Z axis */
  136739. zaxis: Vector3;
  136740. /**
  136741. * Creates a new BoneAxesViewer
  136742. * @param scene defines the hosting scene
  136743. * @param bone defines the target bone
  136744. * @param mesh defines the target mesh
  136745. * @param scaleLines defines a scaling factor for line length (1 by default)
  136746. */
  136747. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136748. /**
  136749. * Force the viewer to update
  136750. */
  136751. update(): void;
  136752. /** Releases resources */
  136753. dispose(): void;
  136754. }
  136755. }
  136756. declare module BABYLON {
  136757. /**
  136758. * Interface used to define scene explorer extensibility option
  136759. */
  136760. export interface IExplorerExtensibilityOption {
  136761. /**
  136762. * Define the option label
  136763. */
  136764. label: string;
  136765. /**
  136766. * Defines the action to execute on click
  136767. */
  136768. action: (entity: any) => void;
  136769. }
  136770. /**
  136771. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136772. */
  136773. export interface IExplorerExtensibilityGroup {
  136774. /**
  136775. * Defines a predicate to test if a given type mut be extended
  136776. */
  136777. predicate: (entity: any) => boolean;
  136778. /**
  136779. * Gets the list of options added to a type
  136780. */
  136781. entries: IExplorerExtensibilityOption[];
  136782. }
  136783. /**
  136784. * Interface used to define the options to use to create the Inspector
  136785. */
  136786. export interface IInspectorOptions {
  136787. /**
  136788. * Display in overlay mode (default: false)
  136789. */
  136790. overlay?: boolean;
  136791. /**
  136792. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136793. */
  136794. globalRoot?: HTMLElement;
  136795. /**
  136796. * Display the Scene explorer
  136797. */
  136798. showExplorer?: boolean;
  136799. /**
  136800. * Display the property inspector
  136801. */
  136802. showInspector?: boolean;
  136803. /**
  136804. * Display in embed mode (both panes on the right)
  136805. */
  136806. embedMode?: boolean;
  136807. /**
  136808. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136809. */
  136810. handleResize?: boolean;
  136811. /**
  136812. * Allow the panes to popup (default: true)
  136813. */
  136814. enablePopup?: boolean;
  136815. /**
  136816. * Allow the panes to be closed by users (default: true)
  136817. */
  136818. enableClose?: boolean;
  136819. /**
  136820. * Optional list of extensibility entries
  136821. */
  136822. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136823. /**
  136824. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136825. */
  136826. inspectorURL?: string;
  136827. /**
  136828. * Optional initial tab (default to DebugLayerTab.Properties)
  136829. */
  136830. initialTab?: DebugLayerTab;
  136831. }
  136832. interface Scene {
  136833. /**
  136834. * @hidden
  136835. * Backing field
  136836. */
  136837. _debugLayer: DebugLayer;
  136838. /**
  136839. * Gets the debug layer (aka Inspector) associated with the scene
  136840. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136841. */
  136842. debugLayer: DebugLayer;
  136843. }
  136844. /**
  136845. * Enum of inspector action tab
  136846. */
  136847. export enum DebugLayerTab {
  136848. /**
  136849. * Properties tag (default)
  136850. */
  136851. Properties = 0,
  136852. /**
  136853. * Debug tab
  136854. */
  136855. Debug = 1,
  136856. /**
  136857. * Statistics tab
  136858. */
  136859. Statistics = 2,
  136860. /**
  136861. * Tools tab
  136862. */
  136863. Tools = 3,
  136864. /**
  136865. * Settings tab
  136866. */
  136867. Settings = 4
  136868. }
  136869. /**
  136870. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136871. * what is happening in your scene
  136872. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136873. */
  136874. export class DebugLayer {
  136875. /**
  136876. * Define the url to get the inspector script from.
  136877. * By default it uses the babylonjs CDN.
  136878. * @ignoreNaming
  136879. */
  136880. static InspectorURL: string;
  136881. private _scene;
  136882. private BJSINSPECTOR;
  136883. private _onPropertyChangedObservable?;
  136884. /**
  136885. * Observable triggered when a property is changed through the inspector.
  136886. */
  136887. get onPropertyChangedObservable(): any;
  136888. /**
  136889. * Instantiates a new debug layer.
  136890. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136891. * what is happening in your scene
  136892. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136893. * @param scene Defines the scene to inspect
  136894. */
  136895. constructor(scene: Scene);
  136896. /** Creates the inspector window. */
  136897. private _createInspector;
  136898. /**
  136899. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136900. * @param entity defines the entity to select
  136901. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136902. */
  136903. select(entity: any, lineContainerTitles?: string | string[]): void;
  136904. /** Get the inspector from bundle or global */
  136905. private _getGlobalInspector;
  136906. /**
  136907. * Get if the inspector is visible or not.
  136908. * @returns true if visible otherwise, false
  136909. */
  136910. isVisible(): boolean;
  136911. /**
  136912. * Hide the inspector and close its window.
  136913. */
  136914. hide(): void;
  136915. /**
  136916. * Update the scene in the inspector
  136917. */
  136918. setAsActiveScene(): void;
  136919. /**
  136920. * Launch the debugLayer.
  136921. * @param config Define the configuration of the inspector
  136922. * @return a promise fulfilled when the debug layer is visible
  136923. */
  136924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136925. }
  136926. }
  136927. declare module BABYLON.Debug {
  136928. /**
  136929. * Used to show the physics impostor around the specific mesh
  136930. */
  136931. export class PhysicsViewer {
  136932. /** @hidden */
  136933. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136934. /** @hidden */
  136935. protected _meshes: Array<Nullable<AbstractMesh>>;
  136936. /** @hidden */
  136937. protected _scene: Nullable<Scene>;
  136938. /** @hidden */
  136939. protected _numMeshes: number;
  136940. /** @hidden */
  136941. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  136942. private _renderFunction;
  136943. private _utilityLayer;
  136944. private _debugBoxMesh;
  136945. private _debugSphereMesh;
  136946. private _debugCylinderMesh;
  136947. private _debugMaterial;
  136948. private _debugMeshMeshes;
  136949. /**
  136950. * Creates a new PhysicsViewer
  136951. * @param scene defines the hosting scene
  136952. */
  136953. constructor(scene: Scene);
  136954. /** @hidden */
  136955. protected _updateDebugMeshes(): void;
  136956. /**
  136957. * Renders a specified physic impostor
  136958. * @param impostor defines the impostor to render
  136959. * @param targetMesh defines the mesh represented by the impostor
  136960. * @returns the new debug mesh used to render the impostor
  136961. */
  136962. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  136963. /**
  136964. * Hides a specified physic impostor
  136965. * @param impostor defines the impostor to hide
  136966. */
  136967. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  136968. private _getDebugMaterial;
  136969. private _getDebugBoxMesh;
  136970. private _getDebugSphereMesh;
  136971. private _getDebugCylinderMesh;
  136972. private _getDebugMeshMesh;
  136973. private _getDebugMesh;
  136974. /** Releases all resources */
  136975. dispose(): void;
  136976. }
  136977. }
  136978. declare module BABYLON {
  136979. /**
  136980. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136981. * in order to better appreciate the issue one might have.
  136982. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136983. */
  136984. export class RayHelper {
  136985. /**
  136986. * Defines the ray we are currently tryin to visualize.
  136987. */
  136988. ray: Nullable<Ray>;
  136989. private _renderPoints;
  136990. private _renderLine;
  136991. private _renderFunction;
  136992. private _scene;
  136993. private _onAfterRenderObserver;
  136994. private _onAfterStepObserver;
  136995. private _attachedToMesh;
  136996. private _meshSpaceDirection;
  136997. private _meshSpaceOrigin;
  136998. /**
  136999. * Helper function to create a colored helper in a scene in one line.
  137000. * @param ray Defines the ray we are currently tryin to visualize
  137001. * @param scene Defines the scene the ray is used in
  137002. * @param color Defines the color we want to see the ray in
  137003. * @returns The newly created ray helper.
  137004. */
  137005. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  137006. /**
  137007. * Instantiate a new ray helper.
  137008. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  137009. * in order to better appreciate the issue one might have.
  137010. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  137011. * @param ray Defines the ray we are currently tryin to visualize
  137012. */
  137013. constructor(ray: Ray);
  137014. /**
  137015. * Shows the ray we are willing to debug.
  137016. * @param scene Defines the scene the ray needs to be rendered in
  137017. * @param color Defines the color the ray needs to be rendered in
  137018. */
  137019. show(scene: Scene, color?: Color3): void;
  137020. /**
  137021. * Hides the ray we are debugging.
  137022. */
  137023. hide(): void;
  137024. private _render;
  137025. /**
  137026. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  137027. * @param mesh Defines the mesh we want the helper attached to
  137028. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  137029. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  137030. * @param length Defines the length of the ray
  137031. */
  137032. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  137033. /**
  137034. * Detach the ray helper from the mesh it has previously been attached to.
  137035. */
  137036. detachFromMesh(): void;
  137037. private _updateToMesh;
  137038. /**
  137039. * Dispose the helper and release its associated resources.
  137040. */
  137041. dispose(): void;
  137042. }
  137043. }
  137044. declare module BABYLON {
  137045. /**
  137046. * Defines the options associated with the creation of a SkeletonViewer.
  137047. */
  137048. export interface ISkeletonViewerOptions {
  137049. /** Should the system pause animations before building the Viewer? */
  137050. pauseAnimations: boolean;
  137051. /** Should the system return the skeleton to rest before building? */
  137052. returnToRest: boolean;
  137053. /** public Display Mode of the Viewer */
  137054. displayMode: number;
  137055. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137056. displayOptions: ISkeletonViewerDisplayOptions;
  137057. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137058. computeBonesUsingShaders: boolean;
  137059. /** Flag ignore non weighted bones */
  137060. useAllBones: boolean;
  137061. }
  137062. /**
  137063. * Defines how to display the various bone meshes for the viewer.
  137064. */
  137065. export interface ISkeletonViewerDisplayOptions {
  137066. /** How far down to start tapering the bone spurs */
  137067. midStep?: number;
  137068. /** How big is the midStep? */
  137069. midStepFactor?: number;
  137070. /** Base for the Sphere Size */
  137071. sphereBaseSize?: number;
  137072. /** The ratio of the sphere to the longest bone in units */
  137073. sphereScaleUnit?: number;
  137074. /** Ratio for the Sphere Size */
  137075. sphereFactor?: number;
  137076. /** Whether a spur should attach its far end to the child bone position */
  137077. spurFollowsChild?: boolean;
  137078. /** Whether to show local axes or not */
  137079. showLocalAxes?: boolean;
  137080. /** Length of each local axis */
  137081. localAxesSize?: number;
  137082. }
  137083. /**
  137084. * Defines the constructor options for the BoneWeight Shader.
  137085. */
  137086. export interface IBoneWeightShaderOptions {
  137087. /** Skeleton to Map */
  137088. skeleton: Skeleton;
  137089. /** Colors for Uninfluenced bones */
  137090. colorBase?: Color3;
  137091. /** Colors for 0.0-0.25 Weight bones */
  137092. colorZero?: Color3;
  137093. /** Color for 0.25-0.5 Weight Influence */
  137094. colorQuarter?: Color3;
  137095. /** Color for 0.5-0.75 Weight Influence */
  137096. colorHalf?: Color3;
  137097. /** Color for 0.75-1 Weight Influence */
  137098. colorFull?: Color3;
  137099. /** Color for Zero Weight Influence */
  137100. targetBoneIndex?: number;
  137101. }
  137102. /**
  137103. * Simple structure of the gradient steps for the Color Map.
  137104. */
  137105. export interface ISkeletonMapShaderColorMapKnot {
  137106. /** Color of the Knot */
  137107. color: Color3;
  137108. /** Location of the Knot */
  137109. location: number;
  137110. }
  137111. /**
  137112. * Defines the constructor options for the SkeletonMap Shader.
  137113. */
  137114. export interface ISkeletonMapShaderOptions {
  137115. /** Skeleton to Map */
  137116. skeleton: Skeleton;
  137117. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  137118. colorMap?: ISkeletonMapShaderColorMapKnot[];
  137119. }
  137120. }
  137121. declare module BABYLON {
  137122. /**
  137123. * Class containing static functions to help procedurally build meshes
  137124. */
  137125. export class RibbonBuilder {
  137126. /**
  137127. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137128. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137129. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137130. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137131. * * 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
  137132. * * 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
  137133. * * 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
  137134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137137. * * 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
  137138. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137139. * * 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
  137140. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137142. * @param name defines the name of the mesh
  137143. * @param options defines the options used to create the mesh
  137144. * @param scene defines the hosting scene
  137145. * @returns the ribbon mesh
  137146. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137148. */
  137149. static CreateRibbon(name: string, options: {
  137150. pathArray: Vector3[][];
  137151. closeArray?: boolean;
  137152. closePath?: boolean;
  137153. offset?: number;
  137154. updatable?: boolean;
  137155. sideOrientation?: number;
  137156. frontUVs?: Vector4;
  137157. backUVs?: Vector4;
  137158. instance?: Mesh;
  137159. invertUV?: boolean;
  137160. uvs?: Vector2[];
  137161. colors?: Color4[];
  137162. }, scene?: Nullable<Scene>): Mesh;
  137163. }
  137164. }
  137165. declare module BABYLON {
  137166. /**
  137167. * Class containing static functions to help procedurally build meshes
  137168. */
  137169. export class ShapeBuilder {
  137170. /**
  137171. * 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.
  137172. * * 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.
  137173. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137174. * * 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.
  137175. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137176. * * 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
  137177. * * 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
  137178. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137183. * @param name defines the name of the mesh
  137184. * @param options defines the options used to create the mesh
  137185. * @param scene defines the hosting scene
  137186. * @returns the extruded shape mesh
  137187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137189. */
  137190. static ExtrudeShape(name: string, options: {
  137191. shape: Vector3[];
  137192. path: Vector3[];
  137193. scale?: number;
  137194. rotation?: number;
  137195. cap?: number;
  137196. updatable?: boolean;
  137197. sideOrientation?: number;
  137198. frontUVs?: Vector4;
  137199. backUVs?: Vector4;
  137200. instance?: Mesh;
  137201. invertUV?: boolean;
  137202. }, scene?: Nullable<Scene>): Mesh;
  137203. /**
  137204. * Creates an custom extruded shape mesh.
  137205. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137206. * * 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.
  137207. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137208. * * 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
  137209. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137210. * * 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
  137211. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137212. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137213. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137214. * * 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
  137215. * * 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
  137216. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137221. * @param name defines the name of the mesh
  137222. * @param options defines the options used to create the mesh
  137223. * @param scene defines the hosting scene
  137224. * @returns the custom extruded shape mesh
  137225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137228. */
  137229. static ExtrudeShapeCustom(name: string, options: {
  137230. shape: Vector3[];
  137231. path: Vector3[];
  137232. scaleFunction?: any;
  137233. rotationFunction?: any;
  137234. ribbonCloseArray?: boolean;
  137235. ribbonClosePath?: boolean;
  137236. cap?: number;
  137237. updatable?: boolean;
  137238. sideOrientation?: number;
  137239. frontUVs?: Vector4;
  137240. backUVs?: Vector4;
  137241. instance?: Mesh;
  137242. invertUV?: boolean;
  137243. }, scene?: Nullable<Scene>): Mesh;
  137244. private static _ExtrudeShapeGeneric;
  137245. }
  137246. }
  137247. declare module BABYLON.Debug {
  137248. /**
  137249. * Class used to render a debug view of a given skeleton
  137250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  137251. */
  137252. export class SkeletonViewer {
  137253. /** defines the skeleton to render */
  137254. skeleton: Skeleton;
  137255. /** defines the mesh attached to the skeleton */
  137256. mesh: AbstractMesh;
  137257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137258. autoUpdateBonesMatrices: boolean;
  137259. /** defines the rendering group id to use with the viewer */
  137260. renderingGroupId: number;
  137261. /** is the options for the viewer */
  137262. options: Partial<ISkeletonViewerOptions>;
  137263. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  137264. static readonly DISPLAY_LINES: number;
  137265. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  137266. static readonly DISPLAY_SPHERES: number;
  137267. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  137268. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  137269. /** public static method to create a BoneWeight Shader
  137270. * @param options The constructor options
  137271. * @param scene The scene that the shader is scoped to
  137272. * @returns The created ShaderMaterial
  137273. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  137274. */
  137275. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  137276. /** public static method to create a BoneWeight Shader
  137277. * @param options The constructor options
  137278. * @param scene The scene that the shader is scoped to
  137279. * @returns The created ShaderMaterial
  137280. */
  137281. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  137282. /** private static method to create a BoneWeight Shader
  137283. * @param size The size of the buffer to create (usually the bone count)
  137284. * @param colorMap The gradient data to generate
  137285. * @param scene The scene that the shader is scoped to
  137286. * @returns an Array of floats from the color gradient values
  137287. */
  137288. private static _CreateBoneMapColorBuffer;
  137289. /** If SkeletonViewer scene scope. */
  137290. private _scene;
  137291. /** Gets or sets the color used to render the skeleton */
  137292. color: Color3;
  137293. /** Array of the points of the skeleton fo the line view. */
  137294. private _debugLines;
  137295. /** The SkeletonViewers Mesh. */
  137296. private _debugMesh;
  137297. /** The local axes Meshes. */
  137298. private _localAxes;
  137299. /** If SkeletonViewer is enabled. */
  137300. private _isEnabled;
  137301. /** If SkeletonViewer is ready. */
  137302. private _ready;
  137303. /** SkeletonViewer render observable. */
  137304. private _obs;
  137305. /** The Utility Layer to render the gizmos in. */
  137306. private _utilityLayer;
  137307. private _boneIndices;
  137308. /** Gets the Scene. */
  137309. get scene(): Scene;
  137310. /** Gets the utilityLayer. */
  137311. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  137312. /** Checks Ready Status. */
  137313. get isReady(): Boolean;
  137314. /** Sets Ready Status. */
  137315. set ready(value: boolean);
  137316. /** Gets the debugMesh */
  137317. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  137318. /** Sets the debugMesh */
  137319. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  137320. /** Gets the displayMode */
  137321. get displayMode(): number;
  137322. /** Sets the displayMode */
  137323. set displayMode(value: number);
  137324. /**
  137325. * Creates a new SkeletonViewer
  137326. * @param skeleton defines the skeleton to render
  137327. * @param mesh defines the mesh attached to the skeleton
  137328. * @param scene defines the hosting scene
  137329. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  137330. * @param renderingGroupId defines the rendering group id to use with the viewer
  137331. * @param options All of the extra constructor options for the SkeletonViewer
  137332. */
  137333. constructor(
  137334. /** defines the skeleton to render */
  137335. skeleton: Skeleton,
  137336. /** defines the mesh attached to the skeleton */
  137337. mesh: AbstractMesh,
  137338. /** The Scene scope*/
  137339. scene: Scene,
  137340. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137341. autoUpdateBonesMatrices?: boolean,
  137342. /** defines the rendering group id to use with the viewer */
  137343. renderingGroupId?: number,
  137344. /** is the options for the viewer */
  137345. options?: Partial<ISkeletonViewerOptions>);
  137346. /** The Dynamic bindings for the update functions */
  137347. private _bindObs;
  137348. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137349. update(): void;
  137350. /** Gets or sets a boolean indicating if the viewer is enabled */
  137351. set isEnabled(value: boolean);
  137352. get isEnabled(): boolean;
  137353. private _getBonePosition;
  137354. private _getLinesForBonesWithLength;
  137355. private _getLinesForBonesNoLength;
  137356. /** function to revert the mesh and scene back to the initial state. */
  137357. private _revert;
  137358. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137359. private _getAbsoluteBindPoseToRef;
  137360. /** function to build and bind sphere joint points and spur bone representations. */
  137361. private _buildSpheresAndSpurs;
  137362. private _buildLocalAxes;
  137363. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137364. private _displayLinesUpdate;
  137365. /** Changes the displayMode of the skeleton viewer
  137366. * @param mode The displayMode numerical value
  137367. */
  137368. changeDisplayMode(mode: number): void;
  137369. /** Sets a display option of the skeleton viewer
  137370. *
  137371. * | Option | Type | Default | Description |
  137372. * | ---------------- | ------- | ------- | ----------- |
  137373. * | 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`. |
  137374. * | 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`. |
  137375. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137376. * | 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`. |
  137377. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137378. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137379. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137380. *
  137381. * @param option String of the option name
  137382. * @param value The numerical option value
  137383. */
  137384. changeDisplayOptions(option: string, value: number): void;
  137385. /** Release associated resources */
  137386. dispose(): void;
  137387. }
  137388. }
  137389. declare module BABYLON {
  137390. /**
  137391. * Enum for Device Types
  137392. */
  137393. export enum DeviceType {
  137394. /** Generic */
  137395. Generic = 0,
  137396. /** Keyboard */
  137397. Keyboard = 1,
  137398. /** Mouse */
  137399. Mouse = 2,
  137400. /** Touch Pointers */
  137401. Touch = 3,
  137402. /** PS4 Dual Shock */
  137403. DualShock = 4,
  137404. /** Xbox */
  137405. Xbox = 5,
  137406. /** Switch Controller */
  137407. Switch = 6
  137408. }
  137409. /**
  137410. * Enum for All Pointers (Touch/Mouse)
  137411. */
  137412. export enum PointerInput {
  137413. /** Horizontal Axis */
  137414. Horizontal = 0,
  137415. /** Vertical Axis */
  137416. Vertical = 1,
  137417. /** Left Click or Touch */
  137418. LeftClick = 2,
  137419. /** Middle Click */
  137420. MiddleClick = 3,
  137421. /** Right Click */
  137422. RightClick = 4,
  137423. /** Browser Back */
  137424. BrowserBack = 5,
  137425. /** Browser Forward */
  137426. BrowserForward = 6
  137427. }
  137428. /**
  137429. * Enum for Dual Shock Gamepad
  137430. */
  137431. export enum DualShockInput {
  137432. /** Cross */
  137433. Cross = 0,
  137434. /** Circle */
  137435. Circle = 1,
  137436. /** Square */
  137437. Square = 2,
  137438. /** Triangle */
  137439. Triangle = 3,
  137440. /** L1 */
  137441. L1 = 4,
  137442. /** R1 */
  137443. R1 = 5,
  137444. /** L2 */
  137445. L2 = 6,
  137446. /** R2 */
  137447. R2 = 7,
  137448. /** Share */
  137449. Share = 8,
  137450. /** Options */
  137451. Options = 9,
  137452. /** L3 */
  137453. L3 = 10,
  137454. /** R3 */
  137455. R3 = 11,
  137456. /** DPadUp */
  137457. DPadUp = 12,
  137458. /** DPadDown */
  137459. DPadDown = 13,
  137460. /** DPadLeft */
  137461. DPadLeft = 14,
  137462. /** DRight */
  137463. DPadRight = 15,
  137464. /** Home */
  137465. Home = 16,
  137466. /** TouchPad */
  137467. TouchPad = 17,
  137468. /** LStickXAxis */
  137469. LStickXAxis = 18,
  137470. /** LStickYAxis */
  137471. LStickYAxis = 19,
  137472. /** RStickXAxis */
  137473. RStickXAxis = 20,
  137474. /** RStickYAxis */
  137475. RStickYAxis = 21
  137476. }
  137477. /**
  137478. * Enum for Xbox Gamepad
  137479. */
  137480. export enum XboxInput {
  137481. /** A */
  137482. A = 0,
  137483. /** B */
  137484. B = 1,
  137485. /** X */
  137486. X = 2,
  137487. /** Y */
  137488. Y = 3,
  137489. /** LB */
  137490. LB = 4,
  137491. /** RB */
  137492. RB = 5,
  137493. /** LT */
  137494. LT = 6,
  137495. /** RT */
  137496. RT = 7,
  137497. /** Back */
  137498. Back = 8,
  137499. /** Start */
  137500. Start = 9,
  137501. /** LS */
  137502. LS = 10,
  137503. /** RS */
  137504. RS = 11,
  137505. /** DPadUp */
  137506. DPadUp = 12,
  137507. /** DPadDown */
  137508. DPadDown = 13,
  137509. /** DPadLeft */
  137510. DPadLeft = 14,
  137511. /** DRight */
  137512. DPadRight = 15,
  137513. /** Home */
  137514. Home = 16,
  137515. /** LStickXAxis */
  137516. LStickXAxis = 17,
  137517. /** LStickYAxis */
  137518. LStickYAxis = 18,
  137519. /** RStickXAxis */
  137520. RStickXAxis = 19,
  137521. /** RStickYAxis */
  137522. RStickYAxis = 20
  137523. }
  137524. /**
  137525. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137526. */
  137527. export enum SwitchInput {
  137528. /** B */
  137529. B = 0,
  137530. /** A */
  137531. A = 1,
  137532. /** Y */
  137533. Y = 2,
  137534. /** X */
  137535. X = 3,
  137536. /** L */
  137537. L = 4,
  137538. /** R */
  137539. R = 5,
  137540. /** ZL */
  137541. ZL = 6,
  137542. /** ZR */
  137543. ZR = 7,
  137544. /** Minus */
  137545. Minus = 8,
  137546. /** Plus */
  137547. Plus = 9,
  137548. /** LS */
  137549. LS = 10,
  137550. /** RS */
  137551. RS = 11,
  137552. /** DPadUp */
  137553. DPadUp = 12,
  137554. /** DPadDown */
  137555. DPadDown = 13,
  137556. /** DPadLeft */
  137557. DPadLeft = 14,
  137558. /** DRight */
  137559. DPadRight = 15,
  137560. /** Home */
  137561. Home = 16,
  137562. /** Capture */
  137563. Capture = 17,
  137564. /** LStickXAxis */
  137565. LStickXAxis = 18,
  137566. /** LStickYAxis */
  137567. LStickYAxis = 19,
  137568. /** RStickXAxis */
  137569. RStickXAxis = 20,
  137570. /** RStickYAxis */
  137571. RStickYAxis = 21
  137572. }
  137573. }
  137574. declare module BABYLON {
  137575. /**
  137576. * This class will take all inputs from Keyboard, Pointer, and
  137577. * any Gamepads and provide a polling system that all devices
  137578. * will use. This class assumes that there will only be one
  137579. * pointer device and one keyboard.
  137580. */
  137581. export class DeviceInputSystem implements IDisposable {
  137582. /**
  137583. * Returns onDeviceConnected callback property
  137584. * @returns Callback with function to execute when a device is connected
  137585. */
  137586. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137587. /**
  137588. * Sets callback function when a device is connected and executes against all connected devices
  137589. * @param callback Function to execute when a device is connected
  137590. */
  137591. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137592. /**
  137593. * Callback to be triggered when a device is disconnected
  137594. */
  137595. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137596. /**
  137597. * Callback to be triggered when event driven input is updated
  137598. */
  137599. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137600. private _inputs;
  137601. private _gamepads;
  137602. private _keyboardActive;
  137603. private _pointerActive;
  137604. private _elementToAttachTo;
  137605. private _keyboardDownEvent;
  137606. private _keyboardUpEvent;
  137607. private _pointerMoveEvent;
  137608. private _pointerDownEvent;
  137609. private _pointerUpEvent;
  137610. private _gamepadConnectedEvent;
  137611. private _gamepadDisconnectedEvent;
  137612. private _onDeviceConnected;
  137613. private static _MAX_KEYCODES;
  137614. private static _MAX_POINTER_INPUTS;
  137615. private constructor();
  137616. /**
  137617. * Creates a new DeviceInputSystem instance
  137618. * @param engine Engine to pull input element from
  137619. * @returns The new instance
  137620. */
  137621. static Create(engine: Engine): DeviceInputSystem;
  137622. /**
  137623. * Checks for current device input value, given an id and input index
  137624. * @param deviceName Id of connected device
  137625. * @param inputIndex Index of device input
  137626. * @returns Current value of input
  137627. */
  137628. /**
  137629. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137630. * @param deviceType Enum specifiying device type
  137631. * @param deviceSlot "Slot" or index that device is referenced in
  137632. * @param inputIndex Id of input to be checked
  137633. * @returns Current value of input
  137634. */
  137635. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137636. /**
  137637. * Dispose of all the eventlisteners
  137638. */
  137639. dispose(): void;
  137640. /**
  137641. * Checks for existing connections to devices and register them, if necessary
  137642. * Currently handles gamepads and mouse
  137643. */
  137644. private _checkForConnectedDevices;
  137645. /**
  137646. * Add a gamepad to the DeviceInputSystem
  137647. * @param gamepad A single DOM Gamepad object
  137648. */
  137649. private _addGamePad;
  137650. /**
  137651. * Add pointer device to DeviceInputSystem
  137652. * @param deviceType Type of Pointer to add
  137653. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137654. * @param currentX Current X at point of adding
  137655. * @param currentY Current Y at point of adding
  137656. */
  137657. private _addPointerDevice;
  137658. /**
  137659. * Add device and inputs to device array
  137660. * @param deviceType Enum specifiying device type
  137661. * @param deviceSlot "Slot" or index that device is referenced in
  137662. * @param numberOfInputs Number of input entries to create for given device
  137663. */
  137664. private _registerDevice;
  137665. /**
  137666. * Given a specific device name, remove that device from the device map
  137667. * @param deviceType Enum specifiying device type
  137668. * @param deviceSlot "Slot" or index that device is referenced in
  137669. */
  137670. private _unregisterDevice;
  137671. /**
  137672. * Handle all actions that come from keyboard interaction
  137673. */
  137674. private _handleKeyActions;
  137675. /**
  137676. * Handle all actions that come from pointer interaction
  137677. */
  137678. private _handlePointerActions;
  137679. /**
  137680. * Handle all actions that come from gamepad interaction
  137681. */
  137682. private _handleGamepadActions;
  137683. /**
  137684. * Update all non-event based devices with each frame
  137685. * @param deviceType Enum specifiying device type
  137686. * @param deviceSlot "Slot" or index that device is referenced in
  137687. * @param inputIndex Id of input to be checked
  137688. */
  137689. private _updateDevice;
  137690. /**
  137691. * Gets DeviceType from the device name
  137692. * @param deviceName Name of Device from DeviceInputSystem
  137693. * @returns DeviceType enum value
  137694. */
  137695. private _getGamepadDeviceType;
  137696. }
  137697. }
  137698. declare module BABYLON {
  137699. /**
  137700. * Type to handle enforcement of inputs
  137701. */
  137702. 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;
  137703. }
  137704. declare module BABYLON {
  137705. /**
  137706. * Class that handles all input for a specific device
  137707. */
  137708. export class DeviceSource<T extends DeviceType> {
  137709. /** Type of device */
  137710. readonly deviceType: DeviceType;
  137711. /** "Slot" or index that device is referenced in */
  137712. readonly deviceSlot: number;
  137713. /**
  137714. * Observable to handle device input changes per device
  137715. */
  137716. readonly onInputChangedObservable: Observable<{
  137717. inputIndex: DeviceInput<T>;
  137718. previousState: Nullable<number>;
  137719. currentState: Nullable<number>;
  137720. }>;
  137721. private readonly _deviceInputSystem;
  137722. /**
  137723. * Default Constructor
  137724. * @param deviceInputSystem Reference to DeviceInputSystem
  137725. * @param deviceType Type of device
  137726. * @param deviceSlot "Slot" or index that device is referenced in
  137727. */
  137728. constructor(deviceInputSystem: DeviceInputSystem,
  137729. /** Type of device */
  137730. deviceType: DeviceType,
  137731. /** "Slot" or index that device is referenced in */
  137732. deviceSlot?: number);
  137733. /**
  137734. * Get input for specific input
  137735. * @param inputIndex index of specific input on device
  137736. * @returns Input value from DeviceInputSystem
  137737. */
  137738. getInput(inputIndex: DeviceInput<T>): number;
  137739. }
  137740. /**
  137741. * Class to keep track of devices
  137742. */
  137743. export class DeviceSourceManager implements IDisposable {
  137744. /**
  137745. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137746. */
  137747. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137748. /**
  137749. * Observable to be triggered when after a device is disconnected
  137750. */
  137751. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137752. private readonly _devices;
  137753. private readonly _firstDevice;
  137754. private readonly _deviceInputSystem;
  137755. /**
  137756. * Default Constructor
  137757. * @param engine engine to pull input element from
  137758. */
  137759. constructor(engine: Engine);
  137760. /**
  137761. * Gets a DeviceSource, given a type and slot
  137762. * @param deviceType Enum specifying device type
  137763. * @param deviceSlot "Slot" or index that device is referenced in
  137764. * @returns DeviceSource object
  137765. */
  137766. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137767. /**
  137768. * Gets an array of DeviceSource objects for a given device type
  137769. * @param deviceType Enum specifying device type
  137770. * @returns Array of DeviceSource objects
  137771. */
  137772. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137773. /**
  137774. * Returns a read-only list of all available devices
  137775. * @returns Read-only array with active devices
  137776. */
  137777. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137778. /**
  137779. * Dispose of DeviceInputSystem and other parts
  137780. */
  137781. dispose(): void;
  137782. /**
  137783. * Function to add device name to device list
  137784. * @param deviceType Enum specifying device type
  137785. * @param deviceSlot "Slot" or index that device is referenced in
  137786. */
  137787. private _addDevice;
  137788. /**
  137789. * Function to remove device name to device list
  137790. * @param deviceType Enum specifying device type
  137791. * @param deviceSlot "Slot" or index that device is referenced in
  137792. */
  137793. private _removeDevice;
  137794. /**
  137795. * Updates array storing first connected device of each type
  137796. * @param type Type of Device
  137797. */
  137798. private _updateFirstDevices;
  137799. }
  137800. }
  137801. declare module BABYLON {
  137802. /**
  137803. * Options to create the null engine
  137804. */
  137805. export class NullEngineOptions {
  137806. /**
  137807. * Render width (Default: 512)
  137808. */
  137809. renderWidth: number;
  137810. /**
  137811. * Render height (Default: 256)
  137812. */
  137813. renderHeight: number;
  137814. /**
  137815. * Texture size (Default: 512)
  137816. */
  137817. textureSize: number;
  137818. /**
  137819. * If delta time between frames should be constant
  137820. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137821. */
  137822. deterministicLockstep: boolean;
  137823. /**
  137824. * Maximum about of steps between frames (Default: 4)
  137825. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137826. */
  137827. lockstepMaxSteps: number;
  137828. /**
  137829. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137830. */
  137831. useHighPrecisionMatrix?: boolean;
  137832. }
  137833. /**
  137834. * The null engine class provides support for headless version of babylon.js.
  137835. * This can be used in server side scenario or for testing purposes
  137836. */
  137837. export class NullEngine extends Engine {
  137838. private _options;
  137839. /**
  137840. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137841. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137842. * @returns true if engine is in deterministic lock step mode
  137843. */
  137844. isDeterministicLockStep(): boolean;
  137845. /**
  137846. * Gets the max steps when engine is running in deterministic lock step
  137847. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137848. * @returns the max steps
  137849. */
  137850. getLockstepMaxSteps(): number;
  137851. /**
  137852. * Gets the current hardware scaling level.
  137853. * By default the hardware scaling level is computed from the window device ratio.
  137854. * 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.
  137855. * @returns a number indicating the current hardware scaling level
  137856. */
  137857. getHardwareScalingLevel(): number;
  137858. constructor(options?: NullEngineOptions);
  137859. /**
  137860. * Creates a vertex buffer
  137861. * @param vertices the data for the vertex buffer
  137862. * @returns the new WebGL static buffer
  137863. */
  137864. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137865. /**
  137866. * Creates a new index buffer
  137867. * @param indices defines the content of the index buffer
  137868. * @param updatable defines if the index buffer must be updatable
  137869. * @returns a new webGL buffer
  137870. */
  137871. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137872. /**
  137873. * Clear the current render buffer or the current render target (if any is set up)
  137874. * @param color defines the color to use
  137875. * @param backBuffer defines if the back buffer must be cleared
  137876. * @param depth defines if the depth buffer must be cleared
  137877. * @param stencil defines if the stencil buffer must be cleared
  137878. */
  137879. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137880. /**
  137881. * Gets the current render width
  137882. * @param useScreen defines if screen size must be used (or the current render target if any)
  137883. * @returns a number defining the current render width
  137884. */
  137885. getRenderWidth(useScreen?: boolean): number;
  137886. /**
  137887. * Gets the current render height
  137888. * @param useScreen defines if screen size must be used (or the current render target if any)
  137889. * @returns a number defining the current render height
  137890. */
  137891. getRenderHeight(useScreen?: boolean): number;
  137892. /**
  137893. * Set the WebGL's viewport
  137894. * @param viewport defines the viewport element to be used
  137895. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137896. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137897. */
  137898. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137899. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137900. /**
  137901. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137902. * @param pipelineContext defines the pipeline context to use
  137903. * @param uniformsNames defines the list of uniform names
  137904. * @returns an array of webGL uniform locations
  137905. */
  137906. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137907. /**
  137908. * Gets the lsit of active attributes for a given webGL program
  137909. * @param pipelineContext defines the pipeline context to use
  137910. * @param attributesNames defines the list of attribute names to get
  137911. * @returns an array of indices indicating the offset of each attribute
  137912. */
  137913. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137914. /**
  137915. * Binds an effect to the webGL context
  137916. * @param effect defines the effect to bind
  137917. */
  137918. bindSamplers(effect: Effect): void;
  137919. /**
  137920. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137921. * @param effect defines the effect to activate
  137922. */
  137923. enableEffect(effect: Effect): void;
  137924. /**
  137925. * Set various states to the webGL context
  137926. * @param culling defines backface culling state
  137927. * @param zOffset defines the value to apply to zOffset (0 by default)
  137928. * @param force defines if states must be applied even if cache is up to date
  137929. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137930. */
  137931. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137932. /**
  137933. * Set the value of an uniform to an array of int32
  137934. * @param uniform defines the webGL uniform location where to store the value
  137935. * @param array defines the array of int32 to store
  137936. * @returns true if value was set
  137937. */
  137938. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137939. /**
  137940. * Set the value of an uniform to an array of int32 (stored as vec2)
  137941. * @param uniform defines the webGL uniform location where to store the value
  137942. * @param array defines the array of int32 to store
  137943. * @returns true if value was set
  137944. */
  137945. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137946. /**
  137947. * Set the value of an uniform to an array of int32 (stored as vec3)
  137948. * @param uniform defines the webGL uniform location where to store the value
  137949. * @param array defines the array of int32 to store
  137950. * @returns true if value was set
  137951. */
  137952. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137953. /**
  137954. * Set the value of an uniform to an array of int32 (stored as vec4)
  137955. * @param uniform defines the webGL uniform location where to store the value
  137956. * @param array defines the array of int32 to store
  137957. * @returns true if value was set
  137958. */
  137959. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137960. /**
  137961. * Set the value of an uniform to an array of float32
  137962. * @param uniform defines the webGL uniform location where to store the value
  137963. * @param array defines the array of float32 to store
  137964. * @returns true if value was set
  137965. */
  137966. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137967. /**
  137968. * Set the value of an uniform to an array of float32 (stored as vec2)
  137969. * @param uniform defines the webGL uniform location where to store the value
  137970. * @param array defines the array of float32 to store
  137971. * @returns true if value was set
  137972. */
  137973. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137974. /**
  137975. * Set the value of an uniform to an array of float32 (stored as vec3)
  137976. * @param uniform defines the webGL uniform location where to store the value
  137977. * @param array defines the array of float32 to store
  137978. * @returns true if value was set
  137979. */
  137980. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137981. /**
  137982. * Set the value of an uniform to an array of float32 (stored as vec4)
  137983. * @param uniform defines the webGL uniform location where to store the value
  137984. * @param array defines the array of float32 to store
  137985. * @returns true if value was set
  137986. */
  137987. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137988. /**
  137989. * Set the value of an uniform to an array of number
  137990. * @param uniform defines the webGL uniform location where to store the value
  137991. * @param array defines the array of number to store
  137992. * @returns true if value was set
  137993. */
  137994. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137995. /**
  137996. * Set the value of an uniform to an array of number (stored as vec2)
  137997. * @param uniform defines the webGL uniform location where to store the value
  137998. * @param array defines the array of number to store
  137999. * @returns true if value was set
  138000. */
  138001. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138002. /**
  138003. * Set the value of an uniform to an array of number (stored as vec3)
  138004. * @param uniform defines the webGL uniform location where to store the value
  138005. * @param array defines the array of number to store
  138006. * @returns true if value was set
  138007. */
  138008. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138009. /**
  138010. * Set the value of an uniform to an array of number (stored as vec4)
  138011. * @param uniform defines the webGL uniform location where to store the value
  138012. * @param array defines the array of number to store
  138013. * @returns true if value was set
  138014. */
  138015. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138016. /**
  138017. * Set the value of an uniform to an array of float32 (stored as matrices)
  138018. * @param uniform defines the webGL uniform location where to store the value
  138019. * @param matrices defines the array of float32 to store
  138020. * @returns true if value was set
  138021. */
  138022. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138023. /**
  138024. * Set the value of an uniform to a matrix (3x3)
  138025. * @param uniform defines the webGL uniform location where to store the value
  138026. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  138027. * @returns true if value was set
  138028. */
  138029. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138030. /**
  138031. * Set the value of an uniform to a matrix (2x2)
  138032. * @param uniform defines the webGL uniform location where to store the value
  138033. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  138034. * @returns true if value was set
  138035. */
  138036. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138037. /**
  138038. * Set the value of an uniform to a number (float)
  138039. * @param uniform defines the webGL uniform location where to store the value
  138040. * @param value defines the float number to store
  138041. * @returns true if value was set
  138042. */
  138043. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138044. /**
  138045. * Set the value of an uniform to a vec2
  138046. * @param uniform defines the webGL uniform location where to store the value
  138047. * @param x defines the 1st component of the value
  138048. * @param y defines the 2nd component of the value
  138049. * @returns true if value was set
  138050. */
  138051. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138052. /**
  138053. * Set the value of an uniform to a vec3
  138054. * @param uniform defines the webGL uniform location where to store the value
  138055. * @param x defines the 1st component of the value
  138056. * @param y defines the 2nd component of the value
  138057. * @param z defines the 3rd component of the value
  138058. * @returns true if value was set
  138059. */
  138060. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138061. /**
  138062. * Set the value of an uniform to a boolean
  138063. * @param uniform defines the webGL uniform location where to store the value
  138064. * @param bool defines the boolean to store
  138065. * @returns true if value was set
  138066. */
  138067. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  138068. /**
  138069. * Set the value of an uniform to a vec4
  138070. * @param uniform defines the webGL uniform location where to store the value
  138071. * @param x defines the 1st component of the value
  138072. * @param y defines the 2nd component of the value
  138073. * @param z defines the 3rd component of the value
  138074. * @param w defines the 4th component of the value
  138075. * @returns true if value was set
  138076. */
  138077. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138078. /**
  138079. * Sets the current alpha mode
  138080. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  138081. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138082. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138083. */
  138084. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138085. /**
  138086. * Bind webGl buffers directly to the webGL context
  138087. * @param vertexBuffers defines the vertex buffer to bind
  138088. * @param indexBuffer defines the index buffer to bind
  138089. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  138090. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  138091. * @param effect defines the effect associated with the vertex buffer
  138092. */
  138093. bindBuffers(vertexBuffers: {
  138094. [key: string]: VertexBuffer;
  138095. }, indexBuffer: DataBuffer, effect: Effect): void;
  138096. /**
  138097. * Force the entire cache to be cleared
  138098. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  138099. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  138100. */
  138101. wipeCaches(bruteForce?: boolean): void;
  138102. /**
  138103. * Send a draw order
  138104. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  138105. * @param indexStart defines the starting index
  138106. * @param indexCount defines the number of index to draw
  138107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138108. */
  138109. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  138110. /**
  138111. * Draw a list of indexed primitives
  138112. * @param fillMode defines the primitive to use
  138113. * @param indexStart defines the starting index
  138114. * @param indexCount defines the number of index to draw
  138115. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138116. */
  138117. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138118. /**
  138119. * Draw a list of unindexed primitives
  138120. * @param fillMode defines the primitive to use
  138121. * @param verticesStart defines the index of first vertex to draw
  138122. * @param verticesCount defines the count of vertices to draw
  138123. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138124. */
  138125. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138126. /** @hidden */
  138127. _createTexture(): WebGLTexture;
  138128. /** @hidden */
  138129. _releaseTexture(texture: InternalTexture): void;
  138130. /**
  138131. * Usually called from Texture.ts.
  138132. * Passed information to create a WebGLTexture
  138133. * @param urlArg defines a value which contains one of the following:
  138134. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138135. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138136. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138137. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138138. * @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)
  138139. * @param scene needed for loading to the correct scene
  138140. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138141. * @param onLoad optional callback to be called upon successful completion
  138142. * @param onError optional callback to be called upon failure
  138143. * @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
  138144. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138145. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138146. * @param forcedExtension defines the extension to use to pick the right loader
  138147. * @param mimeType defines an optional mime type
  138148. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138149. */
  138150. 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;
  138151. /**
  138152. * Creates a new render target texture
  138153. * @param size defines the size of the texture
  138154. * @param options defines the options used to create the texture
  138155. * @returns a new render target texture stored in an InternalTexture
  138156. */
  138157. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  138158. /**
  138159. * Update the sampling mode of a given texture
  138160. * @param samplingMode defines the required sampling mode
  138161. * @param texture defines the texture to update
  138162. */
  138163. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138164. /**
  138165. * Binds the frame buffer to the specified texture.
  138166. * @param texture The texture to render to or null for the default canvas
  138167. * @param faceIndex The face of the texture to render to in case of cube texture
  138168. * @param requiredWidth The width of the target to render to
  138169. * @param requiredHeight The height of the target to render to
  138170. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  138171. * @param lodLevel defines le lod level to bind to the frame buffer
  138172. */
  138173. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138174. /**
  138175. * Unbind the current render target texture from the webGL context
  138176. * @param texture defines the render target texture to unbind
  138177. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  138178. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  138179. */
  138180. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138181. /**
  138182. * Creates a dynamic vertex buffer
  138183. * @param vertices the data for the dynamic vertex buffer
  138184. * @returns the new WebGL dynamic buffer
  138185. */
  138186. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  138187. /**
  138188. * Update the content of a dynamic texture
  138189. * @param texture defines the texture to update
  138190. * @param canvas defines the canvas containing the source
  138191. * @param invertY defines if data must be stored with Y axis inverted
  138192. * @param premulAlpha defines if alpha is stored as premultiplied
  138193. * @param format defines the format of the data
  138194. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138195. */
  138196. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138197. /**
  138198. * Gets a boolean indicating if all created effects are ready
  138199. * @returns true if all effects are ready
  138200. */
  138201. areAllEffectsReady(): boolean;
  138202. /**
  138203. * @hidden
  138204. * Get the current error code of the webGL context
  138205. * @returns the error code
  138206. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  138207. */
  138208. getError(): number;
  138209. /** @hidden */
  138210. _getUnpackAlignement(): number;
  138211. /** @hidden */
  138212. _unpackFlipY(value: boolean): void;
  138213. /**
  138214. * Update a dynamic index buffer
  138215. * @param indexBuffer defines the target index buffer
  138216. * @param indices defines the data to update
  138217. * @param offset defines the offset in the target index buffer where update should start
  138218. */
  138219. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  138220. /**
  138221. * Updates a dynamic vertex buffer.
  138222. * @param vertexBuffer the vertex buffer to update
  138223. * @param vertices the data used to update the vertex buffer
  138224. * @param byteOffset the byte offset of the data (optional)
  138225. * @param byteLength the byte length of the data (optional)
  138226. */
  138227. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  138228. /** @hidden */
  138229. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  138230. /** @hidden */
  138231. _bindTexture(channel: number, texture: InternalTexture): void;
  138232. protected _deleteBuffer(buffer: WebGLBuffer): void;
  138233. /**
  138234. * 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
  138235. */
  138236. releaseEffects(): void;
  138237. displayLoadingUI(): void;
  138238. hideLoadingUI(): void;
  138239. /** @hidden */
  138240. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138241. /** @hidden */
  138242. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138243. /** @hidden */
  138244. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138245. /** @hidden */
  138246. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138247. }
  138248. }
  138249. declare module BABYLON {
  138250. /**
  138251. * @hidden
  138252. **/
  138253. export class _TimeToken {
  138254. _startTimeQuery: Nullable<WebGLQuery>;
  138255. _endTimeQuery: Nullable<WebGLQuery>;
  138256. _timeElapsedQuery: Nullable<WebGLQuery>;
  138257. _timeElapsedQueryEnded: boolean;
  138258. }
  138259. }
  138260. declare module BABYLON {
  138261. /** @hidden */
  138262. export class _OcclusionDataStorage {
  138263. /** @hidden */
  138264. occlusionInternalRetryCounter: number;
  138265. /** @hidden */
  138266. isOcclusionQueryInProgress: boolean;
  138267. /** @hidden */
  138268. isOccluded: boolean;
  138269. /** @hidden */
  138270. occlusionRetryCount: number;
  138271. /** @hidden */
  138272. occlusionType: number;
  138273. /** @hidden */
  138274. occlusionQueryAlgorithmType: number;
  138275. }
  138276. interface Engine {
  138277. /**
  138278. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  138279. * @return the new query
  138280. */
  138281. createQuery(): WebGLQuery;
  138282. /**
  138283. * Delete and release a webGL query
  138284. * @param query defines the query to delete
  138285. * @return the current engine
  138286. */
  138287. deleteQuery(query: WebGLQuery): Engine;
  138288. /**
  138289. * Check if a given query has resolved and got its value
  138290. * @param query defines the query to check
  138291. * @returns true if the query got its value
  138292. */
  138293. isQueryResultAvailable(query: WebGLQuery): boolean;
  138294. /**
  138295. * Gets the value of a given query
  138296. * @param query defines the query to check
  138297. * @returns the value of the query
  138298. */
  138299. getQueryResult(query: WebGLQuery): number;
  138300. /**
  138301. * Initiates an occlusion query
  138302. * @param algorithmType defines the algorithm to use
  138303. * @param query defines the query to use
  138304. * @returns the current engine
  138305. * @see https://doc.babylonjs.com/features/occlusionquery
  138306. */
  138307. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  138308. /**
  138309. * Ends an occlusion query
  138310. * @see https://doc.babylonjs.com/features/occlusionquery
  138311. * @param algorithmType defines the algorithm to use
  138312. * @returns the current engine
  138313. */
  138314. endOcclusionQuery(algorithmType: number): Engine;
  138315. /**
  138316. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  138317. * Please note that only one query can be issued at a time
  138318. * @returns a time token used to track the time span
  138319. */
  138320. startTimeQuery(): Nullable<_TimeToken>;
  138321. /**
  138322. * Ends a time query
  138323. * @param token defines the token used to measure the time span
  138324. * @returns the time spent (in ns)
  138325. */
  138326. endTimeQuery(token: _TimeToken): int;
  138327. /** @hidden */
  138328. _currentNonTimestampToken: Nullable<_TimeToken>;
  138329. /** @hidden */
  138330. _createTimeQuery(): WebGLQuery;
  138331. /** @hidden */
  138332. _deleteTimeQuery(query: WebGLQuery): void;
  138333. /** @hidden */
  138334. _getGlAlgorithmType(algorithmType: number): number;
  138335. /** @hidden */
  138336. _getTimeQueryResult(query: WebGLQuery): any;
  138337. /** @hidden */
  138338. _getTimeQueryAvailability(query: WebGLQuery): any;
  138339. }
  138340. interface AbstractMesh {
  138341. /**
  138342. * Backing filed
  138343. * @hidden
  138344. */
  138345. __occlusionDataStorage: _OcclusionDataStorage;
  138346. /**
  138347. * Access property
  138348. * @hidden
  138349. */
  138350. _occlusionDataStorage: _OcclusionDataStorage;
  138351. /**
  138352. * 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.
  138353. * The default value is -1 which means don't break the query and wait till the result
  138354. * @see https://doc.babylonjs.com/features/occlusionquery
  138355. */
  138356. occlusionRetryCount: number;
  138357. /**
  138358. * 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:
  138359. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138360. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138361. * * 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.
  138362. * @see https://doc.babylonjs.com/features/occlusionquery
  138363. */
  138364. occlusionType: number;
  138365. /**
  138366. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138367. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138368. * * 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.
  138369. * @see https://doc.babylonjs.com/features/occlusionquery
  138370. */
  138371. occlusionQueryAlgorithmType: number;
  138372. /**
  138373. * 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
  138374. * @see https://doc.babylonjs.com/features/occlusionquery
  138375. */
  138376. isOccluded: boolean;
  138377. /**
  138378. * Flag to check the progress status of the query
  138379. * @see https://doc.babylonjs.com/features/occlusionquery
  138380. */
  138381. isOcclusionQueryInProgress: boolean;
  138382. }
  138383. }
  138384. declare module BABYLON {
  138385. /** @hidden */
  138386. export var _forceTransformFeedbackToBundle: boolean;
  138387. interface Engine {
  138388. /**
  138389. * Creates a webGL transform feedback object
  138390. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138391. * @returns the webGL transform feedback object
  138392. */
  138393. createTransformFeedback(): WebGLTransformFeedback;
  138394. /**
  138395. * Delete a webGL transform feedback object
  138396. * @param value defines the webGL transform feedback object to delete
  138397. */
  138398. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138399. /**
  138400. * Bind a webGL transform feedback object to the webgl context
  138401. * @param value defines the webGL transform feedback object to bind
  138402. */
  138403. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138404. /**
  138405. * Begins a transform feedback operation
  138406. * @param usePoints defines if points or triangles must be used
  138407. */
  138408. beginTransformFeedback(usePoints: boolean): void;
  138409. /**
  138410. * Ends a transform feedback operation
  138411. */
  138412. endTransformFeedback(): void;
  138413. /**
  138414. * Specify the varyings to use with transform feedback
  138415. * @param program defines the associated webGL program
  138416. * @param value defines the list of strings representing the varying names
  138417. */
  138418. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138419. /**
  138420. * Bind a webGL buffer for a transform feedback operation
  138421. * @param value defines the webGL buffer to bind
  138422. */
  138423. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138424. }
  138425. }
  138426. declare module BABYLON {
  138427. /**
  138428. * Class used to define an additional view for the engine
  138429. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138430. */
  138431. export class EngineView {
  138432. /** Defines the canvas where to render the view */
  138433. target: HTMLCanvasElement;
  138434. /** Defines an optional camera used to render the view (will use active camera else) */
  138435. camera?: Camera;
  138436. }
  138437. interface Engine {
  138438. /**
  138439. * Gets or sets the HTML element to use for attaching events
  138440. */
  138441. inputElement: Nullable<HTMLElement>;
  138442. /**
  138443. * Gets the current engine view
  138444. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138445. */
  138446. activeView: Nullable<EngineView>;
  138447. /** Gets or sets the list of views */
  138448. views: EngineView[];
  138449. /**
  138450. * Register a new child canvas
  138451. * @param canvas defines the canvas to register
  138452. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138453. * @returns the associated view
  138454. */
  138455. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138456. /**
  138457. * Remove a registered child canvas
  138458. * @param canvas defines the canvas to remove
  138459. * @returns the current engine
  138460. */
  138461. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138462. }
  138463. }
  138464. declare module BABYLON {
  138465. interface Engine {
  138466. /** @hidden */
  138467. _excludedCompressedTextures: string[];
  138468. /** @hidden */
  138469. _textureFormatInUse: string;
  138470. /**
  138471. * Gets the list of texture formats supported
  138472. */
  138473. readonly texturesSupported: Array<string>;
  138474. /**
  138475. * Gets the texture format in use
  138476. */
  138477. readonly textureFormatInUse: Nullable<string>;
  138478. /**
  138479. * Set the compressed texture extensions or file names to skip.
  138480. *
  138481. * @param skippedFiles defines the list of those texture files you want to skip
  138482. * Example: [".dds", ".env", "myfile.png"]
  138483. */
  138484. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138485. /**
  138486. * Set the compressed texture format to use, based on the formats you have, and the formats
  138487. * supported by the hardware / browser.
  138488. *
  138489. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138490. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138491. * to API arguments needed to compressed textures. This puts the burden on the container
  138492. * generator to house the arcane code for determining these for current & future formats.
  138493. *
  138494. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138495. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138496. *
  138497. * Note: The result of this call is not taken into account when a texture is base64.
  138498. *
  138499. * @param formatsAvailable defines the list of those format families you have created
  138500. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138501. *
  138502. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138503. * @returns The extension selected.
  138504. */
  138505. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138506. }
  138507. }
  138508. declare module BABYLON {
  138509. /** @hidden */
  138510. export var rgbdEncodePixelShader: {
  138511. name: string;
  138512. shader: string;
  138513. };
  138514. }
  138515. declare module BABYLON {
  138516. /**
  138517. * Raw texture data and descriptor sufficient for WebGL texture upload
  138518. */
  138519. export interface EnvironmentTextureInfo {
  138520. /**
  138521. * Version of the environment map
  138522. */
  138523. version: number;
  138524. /**
  138525. * Width of image
  138526. */
  138527. width: number;
  138528. /**
  138529. * Irradiance information stored in the file.
  138530. */
  138531. irradiance: any;
  138532. /**
  138533. * Specular information stored in the file.
  138534. */
  138535. specular: any;
  138536. }
  138537. /**
  138538. * Defines One Image in the file. It requires only the position in the file
  138539. * as well as the length.
  138540. */
  138541. interface BufferImageData {
  138542. /**
  138543. * Length of the image data.
  138544. */
  138545. length: number;
  138546. /**
  138547. * Position of the data from the null terminator delimiting the end of the JSON.
  138548. */
  138549. position: number;
  138550. }
  138551. /**
  138552. * Defines the specular data enclosed in the file.
  138553. * This corresponds to the version 1 of the data.
  138554. */
  138555. export interface EnvironmentTextureSpecularInfoV1 {
  138556. /**
  138557. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138558. */
  138559. specularDataPosition?: number;
  138560. /**
  138561. * This contains all the images data needed to reconstruct the cubemap.
  138562. */
  138563. mipmaps: Array<BufferImageData>;
  138564. /**
  138565. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138566. */
  138567. lodGenerationScale: number;
  138568. }
  138569. /**
  138570. * Sets of helpers addressing the serialization and deserialization of environment texture
  138571. * stored in a BabylonJS env file.
  138572. * Those files are usually stored as .env files.
  138573. */
  138574. export class EnvironmentTextureTools {
  138575. /**
  138576. * Magic number identifying the env file.
  138577. */
  138578. private static _MagicBytes;
  138579. /**
  138580. * Gets the environment info from an env file.
  138581. * @param data The array buffer containing the .env bytes.
  138582. * @returns the environment file info (the json header) if successfully parsed.
  138583. */
  138584. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138585. /**
  138586. * Creates an environment texture from a loaded cube texture.
  138587. * @param texture defines the cube texture to convert in env file
  138588. * @return a promise containing the environment data if succesfull.
  138589. */
  138590. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138591. /**
  138592. * Creates a JSON representation of the spherical data.
  138593. * @param texture defines the texture containing the polynomials
  138594. * @return the JSON representation of the spherical info
  138595. */
  138596. private static _CreateEnvTextureIrradiance;
  138597. /**
  138598. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138599. * @param data the image data
  138600. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138601. * @return the views described by info providing access to the underlying buffer
  138602. */
  138603. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138604. /**
  138605. * Uploads the texture info contained in the env file to the GPU.
  138606. * @param texture defines the internal texture to upload to
  138607. * @param data defines the data to load
  138608. * @param info defines the texture info retrieved through the GetEnvInfo method
  138609. * @returns a promise
  138610. */
  138611. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138612. private static _OnImageReadyAsync;
  138613. /**
  138614. * Uploads the levels of image data to the GPU.
  138615. * @param texture defines the internal texture to upload to
  138616. * @param imageData defines the array buffer views of image data [mipmap][face]
  138617. * @returns a promise
  138618. */
  138619. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138620. /**
  138621. * Uploads spherical polynomials information to the texture.
  138622. * @param texture defines the texture we are trying to upload the information to
  138623. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138624. */
  138625. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138626. /** @hidden */
  138627. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138628. }
  138629. }
  138630. declare module BABYLON {
  138631. /**
  138632. * Class used to inline functions in shader code
  138633. */
  138634. export class ShaderCodeInliner {
  138635. private static readonly _RegexpFindFunctionNameAndType;
  138636. private _sourceCode;
  138637. private _functionDescr;
  138638. private _numMaxIterations;
  138639. /** Gets or sets the token used to mark the functions to inline */
  138640. inlineToken: string;
  138641. /** Gets or sets the debug mode */
  138642. debug: boolean;
  138643. /** Gets the code after the inlining process */
  138644. get code(): string;
  138645. /**
  138646. * Initializes the inliner
  138647. * @param sourceCode shader code source to inline
  138648. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138649. */
  138650. constructor(sourceCode: string, numMaxIterations?: number);
  138651. /**
  138652. * Start the processing of the shader code
  138653. */
  138654. processCode(): void;
  138655. private _collectFunctions;
  138656. private _processInlining;
  138657. private _extractBetweenMarkers;
  138658. private _skipWhitespaces;
  138659. private _removeComments;
  138660. private _replaceFunctionCallsByCode;
  138661. private _findBackward;
  138662. private _escapeRegExp;
  138663. private _replaceNames;
  138664. }
  138665. }
  138666. declare module BABYLON {
  138667. /**
  138668. * Container for accessors for natively-stored mesh data buffers.
  138669. */
  138670. class NativeDataBuffer extends DataBuffer {
  138671. /**
  138672. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138673. */
  138674. nativeIndexBuffer?: any;
  138675. /**
  138676. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138677. */
  138678. nativeVertexBuffer?: any;
  138679. }
  138680. /** @hidden */
  138681. class NativeTexture extends InternalTexture {
  138682. getInternalTexture(): InternalTexture;
  138683. getViewCount(): number;
  138684. }
  138685. /** @hidden */
  138686. export class NativeEngine extends Engine {
  138687. private readonly _native;
  138688. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138689. private readonly INVALID_HANDLE;
  138690. private _boundBuffersVertexArray;
  138691. private _currentDepthTest;
  138692. getHardwareScalingLevel(): number;
  138693. constructor();
  138694. dispose(): void;
  138695. /**
  138696. * Can be used to override the current requestAnimationFrame requester.
  138697. * @hidden
  138698. */
  138699. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138700. /**
  138701. * Override default engine behavior.
  138702. * @param color
  138703. * @param backBuffer
  138704. * @param depth
  138705. * @param stencil
  138706. */
  138707. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138708. /**
  138709. * Gets host document
  138710. * @returns the host document object
  138711. */
  138712. getHostDocument(): Nullable<Document>;
  138713. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138714. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138715. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138716. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138717. [key: string]: VertexBuffer;
  138718. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138719. bindBuffers(vertexBuffers: {
  138720. [key: string]: VertexBuffer;
  138721. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138722. recordVertexArrayObject(vertexBuffers: {
  138723. [key: string]: VertexBuffer;
  138724. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138725. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138726. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138727. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138728. /**
  138729. * Draw a list of indexed primitives
  138730. * @param fillMode defines the primitive to use
  138731. * @param indexStart defines the starting index
  138732. * @param indexCount defines the number of index to draw
  138733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138734. */
  138735. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138736. /**
  138737. * Draw a list of unindexed primitives
  138738. * @param fillMode defines the primitive to use
  138739. * @param verticesStart defines the index of first vertex to draw
  138740. * @param verticesCount defines the count of vertices to draw
  138741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138742. */
  138743. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138744. createPipelineContext(): IPipelineContext;
  138745. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138746. /** @hidden */
  138747. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138748. /** @hidden */
  138749. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138750. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138751. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138752. protected _setProgram(program: WebGLProgram): void;
  138753. _releaseEffect(effect: Effect): void;
  138754. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138755. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138756. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138757. bindSamplers(effect: Effect): void;
  138758. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138759. getRenderWidth(useScreen?: boolean): number;
  138760. getRenderHeight(useScreen?: boolean): number;
  138761. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138762. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138763. /**
  138764. * Set the z offset to apply to current rendering
  138765. * @param value defines the offset to apply
  138766. */
  138767. setZOffset(value: number): void;
  138768. /**
  138769. * Gets the current value of the zOffset
  138770. * @returns the current zOffset state
  138771. */
  138772. getZOffset(): number;
  138773. /**
  138774. * Enable or disable depth buffering
  138775. * @param enable defines the state to set
  138776. */
  138777. setDepthBuffer(enable: boolean): void;
  138778. /**
  138779. * Gets a boolean indicating if depth writing is enabled
  138780. * @returns the current depth writing state
  138781. */
  138782. getDepthWrite(): boolean;
  138783. setDepthFunctionToGreater(): void;
  138784. setDepthFunctionToGreaterOrEqual(): void;
  138785. setDepthFunctionToLess(): void;
  138786. setDepthFunctionToLessOrEqual(): void;
  138787. /**
  138788. * Enable or disable depth writing
  138789. * @param enable defines the state to set
  138790. */
  138791. setDepthWrite(enable: boolean): void;
  138792. /**
  138793. * Enable or disable color writing
  138794. * @param enable defines the state to set
  138795. */
  138796. setColorWrite(enable: boolean): void;
  138797. /**
  138798. * Gets a boolean indicating if color writing is enabled
  138799. * @returns the current color writing state
  138800. */
  138801. getColorWrite(): boolean;
  138802. /**
  138803. * Sets alpha constants used by some alpha blending modes
  138804. * @param r defines the red component
  138805. * @param g defines the green component
  138806. * @param b defines the blue component
  138807. * @param a defines the alpha component
  138808. */
  138809. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138810. /**
  138811. * Sets the current alpha mode
  138812. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138813. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138814. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138815. */
  138816. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138817. /**
  138818. * Gets the current alpha mode
  138819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138820. * @returns the current alpha mode
  138821. */
  138822. getAlphaMode(): number;
  138823. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138824. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138825. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138826. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138827. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138828. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138829. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138830. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138831. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138832. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138833. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138834. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138835. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138836. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138837. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138838. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138839. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138840. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138841. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138842. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138843. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138844. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138845. wipeCaches(bruteForce?: boolean): void;
  138846. _createTexture(): WebGLTexture;
  138847. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138848. /**
  138849. * Update the content of a dynamic texture
  138850. * @param texture defines the texture to update
  138851. * @param canvas defines the canvas containing the source
  138852. * @param invertY defines if data must be stored with Y axis inverted
  138853. * @param premulAlpha defines if alpha is stored as premultiplied
  138854. * @param format defines the format of the data
  138855. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138856. */
  138857. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138858. /**
  138859. * Usually called from Texture.ts.
  138860. * Passed information to create a WebGLTexture
  138861. * @param url defines a value which contains one of the following:
  138862. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138863. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138864. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138865. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138866. * @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)
  138867. * @param scene needed for loading to the correct scene
  138868. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138869. * @param onLoad optional callback to be called upon successful completion
  138870. * @param onError optional callback to be called upon failure
  138871. * @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
  138872. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138873. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138874. * @param forcedExtension defines the extension to use to pick the right loader
  138875. * @param mimeType defines an optional mime type
  138876. * @param loaderOptions options to be passed to the loader
  138877. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138878. */
  138879. 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;
  138880. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138881. _releaseFramebufferObjects(texture: InternalTexture): void;
  138882. /**
  138883. * Creates a cube texture
  138884. * @param rootUrl defines the url where the files to load is located
  138885. * @param scene defines the current scene
  138886. * @param files defines the list of files to load (1 per face)
  138887. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138888. * @param onLoad defines an optional callback raised when the texture is loaded
  138889. * @param onError defines an optional callback raised if there is an issue to load the texture
  138890. * @param format defines the format of the data
  138891. * @param forcedExtension defines the extension to use to pick the right loader
  138892. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138893. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138894. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138895. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138896. * @returns the cube texture as an InternalTexture
  138897. */
  138898. 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;
  138899. createRenderTargetTexture(size: number | {
  138900. width: number;
  138901. height: number;
  138902. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138903. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138904. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138905. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138906. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138907. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138908. /**
  138909. * Updates a dynamic vertex buffer.
  138910. * @param vertexBuffer the vertex buffer to update
  138911. * @param data the data used to update the vertex buffer
  138912. * @param byteOffset the byte offset of the data (optional)
  138913. * @param byteLength the byte length of the data (optional)
  138914. */
  138915. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138916. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138917. private _updateAnisotropicLevel;
  138918. private _getAddressMode;
  138919. /** @hidden */
  138920. _bindTexture(channel: number, texture: InternalTexture): void;
  138921. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138922. releaseEffects(): void;
  138923. /** @hidden */
  138924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138925. /** @hidden */
  138926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138927. /** @hidden */
  138928. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138929. /** @hidden */
  138930. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138931. private _getNativeSamplingMode;
  138932. private _getNativeTextureFormat;
  138933. private _getNativeAlphaMode;
  138934. private _getNativeAttribType;
  138935. }
  138936. }
  138937. declare module BABYLON {
  138938. /**
  138939. * Gather the list of clipboard event types as constants.
  138940. */
  138941. export class ClipboardEventTypes {
  138942. /**
  138943. * The clipboard event is fired when a copy command is active (pressed).
  138944. */
  138945. static readonly COPY: number;
  138946. /**
  138947. * The clipboard event is fired when a cut command is active (pressed).
  138948. */
  138949. static readonly CUT: number;
  138950. /**
  138951. * The clipboard event is fired when a paste command is active (pressed).
  138952. */
  138953. static readonly PASTE: number;
  138954. }
  138955. /**
  138956. * This class is used to store clipboard related info for the onClipboardObservable event.
  138957. */
  138958. export class ClipboardInfo {
  138959. /**
  138960. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138961. */
  138962. type: number;
  138963. /**
  138964. * Defines the related dom event
  138965. */
  138966. event: ClipboardEvent;
  138967. /**
  138968. *Creates an instance of ClipboardInfo.
  138969. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  138970. * @param event Defines the related dom event
  138971. */
  138972. constructor(
  138973. /**
  138974. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138975. */
  138976. type: number,
  138977. /**
  138978. * Defines the related dom event
  138979. */
  138980. event: ClipboardEvent);
  138981. /**
  138982. * Get the clipboard event's type from the keycode.
  138983. * @param keyCode Defines the keyCode for the current keyboard event.
  138984. * @return {number}
  138985. */
  138986. static GetTypeFromCharacter(keyCode: number): number;
  138987. }
  138988. }
  138989. declare module BABYLON {
  138990. /**
  138991. * Google Daydream controller
  138992. */
  138993. export class DaydreamController extends WebVRController {
  138994. /**
  138995. * Base Url for the controller model.
  138996. */
  138997. static MODEL_BASE_URL: string;
  138998. /**
  138999. * File name for the controller model.
  139000. */
  139001. static MODEL_FILENAME: string;
  139002. /**
  139003. * Gamepad Id prefix used to identify Daydream Controller.
  139004. */
  139005. static readonly GAMEPAD_ID_PREFIX: string;
  139006. /**
  139007. * Creates a new DaydreamController from a gamepad
  139008. * @param vrGamepad the gamepad that the controller should be created from
  139009. */
  139010. constructor(vrGamepad: any);
  139011. /**
  139012. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139013. * @param scene scene in which to add meshes
  139014. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139015. */
  139016. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139017. /**
  139018. * Called once for each button that changed state since the last frame
  139019. * @param buttonIdx Which button index changed
  139020. * @param state New state of the button
  139021. * @param changes Which properties on the state changed since last frame
  139022. */
  139023. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139024. }
  139025. }
  139026. declare module BABYLON {
  139027. /**
  139028. * Gear VR Controller
  139029. */
  139030. export class GearVRController extends WebVRController {
  139031. /**
  139032. * Base Url for the controller model.
  139033. */
  139034. static MODEL_BASE_URL: string;
  139035. /**
  139036. * File name for the controller model.
  139037. */
  139038. static MODEL_FILENAME: string;
  139039. /**
  139040. * Gamepad Id prefix used to identify this controller.
  139041. */
  139042. static readonly GAMEPAD_ID_PREFIX: string;
  139043. private readonly _buttonIndexToObservableNameMap;
  139044. /**
  139045. * Creates a new GearVRController from a gamepad
  139046. * @param vrGamepad the gamepad that the controller should be created from
  139047. */
  139048. constructor(vrGamepad: any);
  139049. /**
  139050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139051. * @param scene scene in which to add meshes
  139052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139053. */
  139054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139055. /**
  139056. * Called once for each button that changed state since the last frame
  139057. * @param buttonIdx Which button index changed
  139058. * @param state New state of the button
  139059. * @param changes Which properties on the state changed since last frame
  139060. */
  139061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139062. }
  139063. }
  139064. declare module BABYLON {
  139065. /**
  139066. * Generic Controller
  139067. */
  139068. export class GenericController extends WebVRController {
  139069. /**
  139070. * Base Url for the controller model.
  139071. */
  139072. static readonly MODEL_BASE_URL: string;
  139073. /**
  139074. * File name for the controller model.
  139075. */
  139076. static readonly MODEL_FILENAME: string;
  139077. /**
  139078. * Creates a new GenericController from a gamepad
  139079. * @param vrGamepad the gamepad that the controller should be created from
  139080. */
  139081. constructor(vrGamepad: any);
  139082. /**
  139083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139084. * @param scene scene in which to add meshes
  139085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139086. */
  139087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139088. /**
  139089. * Called once for each button that changed state since the last frame
  139090. * @param buttonIdx Which button index changed
  139091. * @param state New state of the button
  139092. * @param changes Which properties on the state changed since last frame
  139093. */
  139094. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139095. }
  139096. }
  139097. declare module BABYLON {
  139098. /**
  139099. * Oculus Touch Controller
  139100. */
  139101. export class OculusTouchController extends WebVRController {
  139102. /**
  139103. * Base Url for the controller model.
  139104. */
  139105. static MODEL_BASE_URL: string;
  139106. /**
  139107. * File name for the left controller model.
  139108. */
  139109. static MODEL_LEFT_FILENAME: string;
  139110. /**
  139111. * File name for the right controller model.
  139112. */
  139113. static MODEL_RIGHT_FILENAME: string;
  139114. /**
  139115. * Base Url for the Quest controller model.
  139116. */
  139117. static QUEST_MODEL_BASE_URL: string;
  139118. /**
  139119. * @hidden
  139120. * If the controllers are running on a device that needs the updated Quest controller models
  139121. */
  139122. static _IsQuest: boolean;
  139123. /**
  139124. * Fired when the secondary trigger on this controller is modified
  139125. */
  139126. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  139127. /**
  139128. * Fired when the thumb rest on this controller is modified
  139129. */
  139130. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  139131. /**
  139132. * Creates a new OculusTouchController from a gamepad
  139133. * @param vrGamepad the gamepad that the controller should be created from
  139134. */
  139135. constructor(vrGamepad: any);
  139136. /**
  139137. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139138. * @param scene scene in which to add meshes
  139139. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139140. */
  139141. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139142. /**
  139143. * Fired when the A button on this controller is modified
  139144. */
  139145. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139146. /**
  139147. * Fired when the B button on this controller is modified
  139148. */
  139149. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139150. /**
  139151. * Fired when the X button on this controller is modified
  139152. */
  139153. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139154. /**
  139155. * Fired when the Y button on this controller is modified
  139156. */
  139157. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139158. /**
  139159. * Called once for each button that changed state since the last frame
  139160. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  139161. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  139162. * 2) secondary trigger (same)
  139163. * 3) A (right) X (left), touch, pressed = value
  139164. * 4) B / Y
  139165. * 5) thumb rest
  139166. * @param buttonIdx Which button index changed
  139167. * @param state New state of the button
  139168. * @param changes Which properties on the state changed since last frame
  139169. */
  139170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139171. }
  139172. }
  139173. declare module BABYLON {
  139174. /**
  139175. * Vive Controller
  139176. */
  139177. export class ViveController extends WebVRController {
  139178. /**
  139179. * Base Url for the controller model.
  139180. */
  139181. static MODEL_BASE_URL: string;
  139182. /**
  139183. * File name for the controller model.
  139184. */
  139185. static MODEL_FILENAME: string;
  139186. /**
  139187. * Creates a new ViveController from a gamepad
  139188. * @param vrGamepad the gamepad that the controller should be created from
  139189. */
  139190. constructor(vrGamepad: any);
  139191. /**
  139192. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139193. * @param scene scene in which to add meshes
  139194. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139195. */
  139196. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139197. /**
  139198. * Fired when the left button on this controller is modified
  139199. */
  139200. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139201. /**
  139202. * Fired when the right button on this controller is modified
  139203. */
  139204. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139205. /**
  139206. * Fired when the menu button on this controller is modified
  139207. */
  139208. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139209. /**
  139210. * Called once for each button that changed state since the last frame
  139211. * Vive mapping:
  139212. * 0: touchpad
  139213. * 1: trigger
  139214. * 2: left AND right buttons
  139215. * 3: menu button
  139216. * @param buttonIdx Which button index changed
  139217. * @param state New state of the button
  139218. * @param changes Which properties on the state changed since last frame
  139219. */
  139220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139221. }
  139222. }
  139223. declare module BABYLON {
  139224. /**
  139225. * Defines the WindowsMotionController object that the state of the windows motion controller
  139226. */
  139227. export class WindowsMotionController extends WebVRController {
  139228. /**
  139229. * The base url used to load the left and right controller models
  139230. */
  139231. static MODEL_BASE_URL: string;
  139232. /**
  139233. * The name of the left controller model file
  139234. */
  139235. static MODEL_LEFT_FILENAME: string;
  139236. /**
  139237. * The name of the right controller model file
  139238. */
  139239. static MODEL_RIGHT_FILENAME: string;
  139240. /**
  139241. * The controller name prefix for this controller type
  139242. */
  139243. static readonly GAMEPAD_ID_PREFIX: string;
  139244. /**
  139245. * The controller id pattern for this controller type
  139246. */
  139247. private static readonly GAMEPAD_ID_PATTERN;
  139248. private _loadedMeshInfo;
  139249. protected readonly _mapping: {
  139250. buttons: string[];
  139251. buttonMeshNames: {
  139252. trigger: string;
  139253. menu: string;
  139254. grip: string;
  139255. thumbstick: string;
  139256. trackpad: string;
  139257. };
  139258. buttonObservableNames: {
  139259. trigger: string;
  139260. menu: string;
  139261. grip: string;
  139262. thumbstick: string;
  139263. trackpad: string;
  139264. };
  139265. axisMeshNames: string[];
  139266. pointingPoseMeshName: string;
  139267. };
  139268. /**
  139269. * Fired when the trackpad on this controller is clicked
  139270. */
  139271. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139272. /**
  139273. * Fired when the trackpad on this controller is modified
  139274. */
  139275. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139276. /**
  139277. * The current x and y values of this controller's trackpad
  139278. */
  139279. trackpad: StickValues;
  139280. /**
  139281. * Creates a new WindowsMotionController from a gamepad
  139282. * @param vrGamepad the gamepad that the controller should be created from
  139283. */
  139284. constructor(vrGamepad: any);
  139285. /**
  139286. * Fired when the trigger on this controller is modified
  139287. */
  139288. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139289. /**
  139290. * Fired when the menu button on this controller is modified
  139291. */
  139292. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139293. /**
  139294. * Fired when the grip button on this controller is modified
  139295. */
  139296. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139297. /**
  139298. * Fired when the thumbstick button on this controller is modified
  139299. */
  139300. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139301. /**
  139302. * Fired when the touchpad button on this controller is modified
  139303. */
  139304. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139305. /**
  139306. * Fired when the touchpad values on this controller are modified
  139307. */
  139308. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  139309. protected _updateTrackpad(): void;
  139310. /**
  139311. * Called once per frame by the engine.
  139312. */
  139313. update(): void;
  139314. /**
  139315. * Called once for each button that changed state since the last frame
  139316. * @param buttonIdx Which button index changed
  139317. * @param state New state of the button
  139318. * @param changes Which properties on the state changed since last frame
  139319. */
  139320. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139321. /**
  139322. * Moves the buttons on the controller mesh based on their current state
  139323. * @param buttonName the name of the button to move
  139324. * @param buttonValue the value of the button which determines the buttons new position
  139325. */
  139326. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  139327. /**
  139328. * Moves the axis on the controller mesh based on its current state
  139329. * @param axis the index of the axis
  139330. * @param axisValue the value of the axis which determines the meshes new position
  139331. * @hidden
  139332. */
  139333. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  139334. /**
  139335. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139336. * @param scene scene in which to add meshes
  139337. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139338. */
  139339. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  139340. /**
  139341. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  139342. * can be transformed by button presses and axes values, based on this._mapping.
  139343. *
  139344. * @param scene scene in which the meshes exist
  139345. * @param meshes list of meshes that make up the controller model to process
  139346. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139347. */
  139348. private processModel;
  139349. private createMeshInfo;
  139350. /**
  139351. * Gets the ray of the controller in the direction the controller is pointing
  139352. * @param length the length the resulting ray should be
  139353. * @returns a ray in the direction the controller is pointing
  139354. */
  139355. getForwardRay(length?: number): Ray;
  139356. /**
  139357. * Disposes of the controller
  139358. */
  139359. dispose(): void;
  139360. }
  139361. /**
  139362. * This class represents a new windows motion controller in XR.
  139363. */
  139364. export class XRWindowsMotionController extends WindowsMotionController {
  139365. /**
  139366. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139367. */
  139368. protected readonly _mapping: {
  139369. buttons: string[];
  139370. buttonMeshNames: {
  139371. trigger: string;
  139372. menu: string;
  139373. grip: string;
  139374. thumbstick: string;
  139375. trackpad: string;
  139376. };
  139377. buttonObservableNames: {
  139378. trigger: string;
  139379. menu: string;
  139380. grip: string;
  139381. thumbstick: string;
  139382. trackpad: string;
  139383. };
  139384. axisMeshNames: string[];
  139385. pointingPoseMeshName: string;
  139386. };
  139387. /**
  139388. * Construct a new XR-Based windows motion controller
  139389. *
  139390. * @param gamepadInfo the gamepad object from the browser
  139391. */
  139392. constructor(gamepadInfo: any);
  139393. /**
  139394. * holds the thumbstick values (X,Y)
  139395. */
  139396. thumbstickValues: StickValues;
  139397. /**
  139398. * Fired when the thumbstick on this controller is clicked
  139399. */
  139400. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139401. /**
  139402. * Fired when the thumbstick on this controller is modified
  139403. */
  139404. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139405. /**
  139406. * Fired when the touchpad button on this controller is modified
  139407. */
  139408. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139409. /**
  139410. * Fired when the touchpad values on this controller are modified
  139411. */
  139412. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139413. /**
  139414. * Fired when the thumbstick button on this controller is modified
  139415. * here to prevent breaking changes
  139416. */
  139417. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139418. /**
  139419. * updating the thumbstick(!) and not the trackpad.
  139420. * This is named this way due to the difference between WebVR and XR and to avoid
  139421. * changing the parent class.
  139422. */
  139423. protected _updateTrackpad(): void;
  139424. /**
  139425. * Disposes the class with joy
  139426. */
  139427. dispose(): void;
  139428. }
  139429. }
  139430. declare module BABYLON {
  139431. /**
  139432. * A directional light is defined by a direction (what a surprise!).
  139433. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139434. * 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.
  139435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139436. */
  139437. export class DirectionalLight extends ShadowLight {
  139438. private _shadowFrustumSize;
  139439. /**
  139440. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139441. */
  139442. get shadowFrustumSize(): number;
  139443. /**
  139444. * Specifies a fix frustum size for the shadow generation.
  139445. */
  139446. set shadowFrustumSize(value: number);
  139447. private _shadowOrthoScale;
  139448. /**
  139449. * Gets the shadow projection scale against the optimal computed one.
  139450. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139451. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139452. */
  139453. get shadowOrthoScale(): number;
  139454. /**
  139455. * Sets the shadow projection scale against the optimal computed one.
  139456. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139457. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139458. */
  139459. set shadowOrthoScale(value: number);
  139460. /**
  139461. * Automatically compute the projection matrix to best fit (including all the casters)
  139462. * on each frame.
  139463. */
  139464. autoUpdateExtends: boolean;
  139465. /**
  139466. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139467. * on each frame. autoUpdateExtends must be set to true for this to work
  139468. */
  139469. autoCalcShadowZBounds: boolean;
  139470. private _orthoLeft;
  139471. private _orthoRight;
  139472. private _orthoTop;
  139473. private _orthoBottom;
  139474. /**
  139475. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139476. * The directional light is emitted from everywhere in the given direction.
  139477. * It can cast shadows.
  139478. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139479. * @param name The friendly name of the light
  139480. * @param direction The direction of the light
  139481. * @param scene The scene the light belongs to
  139482. */
  139483. constructor(name: string, direction: Vector3, scene: Scene);
  139484. /**
  139485. * Returns the string "DirectionalLight".
  139486. * @return The class name
  139487. */
  139488. getClassName(): string;
  139489. /**
  139490. * Returns the integer 1.
  139491. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139492. */
  139493. getTypeID(): number;
  139494. /**
  139495. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139496. * Returns the DirectionalLight Shadow projection matrix.
  139497. */
  139498. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139499. /**
  139500. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139501. * Returns the DirectionalLight Shadow projection matrix.
  139502. */
  139503. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139504. /**
  139505. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139506. * Returns the DirectionalLight Shadow projection matrix.
  139507. */
  139508. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139509. protected _buildUniformLayout(): void;
  139510. /**
  139511. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139512. * @param effect The effect to update
  139513. * @param lightIndex The index of the light in the effect to update
  139514. * @returns The directional light
  139515. */
  139516. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139517. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139518. /**
  139519. * Gets the minZ used for shadow according to both the scene and the light.
  139520. *
  139521. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139522. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139523. * @param activeCamera The camera we are returning the min for
  139524. * @returns the depth min z
  139525. */
  139526. getDepthMinZ(activeCamera: Camera): number;
  139527. /**
  139528. * Gets the maxZ used for shadow according to both the scene and the light.
  139529. *
  139530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139532. * @param activeCamera The camera we are returning the max for
  139533. * @returns the depth max z
  139534. */
  139535. getDepthMaxZ(activeCamera: Camera): number;
  139536. /**
  139537. * Prepares the list of defines specific to the light type.
  139538. * @param defines the list of defines
  139539. * @param lightIndex defines the index of the light for the effect
  139540. */
  139541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139542. }
  139543. }
  139544. declare module BABYLON {
  139545. /**
  139546. * Class containing static functions to help procedurally build meshes
  139547. */
  139548. export class HemisphereBuilder {
  139549. /**
  139550. * Creates a hemisphere mesh
  139551. * @param name defines the name of the mesh
  139552. * @param options defines the options used to create the mesh
  139553. * @param scene defines the hosting scene
  139554. * @returns the hemisphere mesh
  139555. */
  139556. static CreateHemisphere(name: string, options: {
  139557. segments?: number;
  139558. diameter?: number;
  139559. sideOrientation?: number;
  139560. }, scene: any): Mesh;
  139561. }
  139562. }
  139563. declare module BABYLON {
  139564. /**
  139565. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139566. * These values define a cone of light starting from the position, emitting toward the direction.
  139567. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139568. * and the exponent defines the speed of the decay of the light with distance (reach).
  139569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139570. */
  139571. export class SpotLight extends ShadowLight {
  139572. private _angle;
  139573. private _innerAngle;
  139574. private _cosHalfAngle;
  139575. private _lightAngleScale;
  139576. private _lightAngleOffset;
  139577. /**
  139578. * Gets the cone angle of the spot light in Radians.
  139579. */
  139580. get angle(): number;
  139581. /**
  139582. * Sets the cone angle of the spot light in Radians.
  139583. */
  139584. set angle(value: number);
  139585. /**
  139586. * Only used in gltf falloff mode, this defines the angle where
  139587. * the directional falloff will start before cutting at angle which could be seen
  139588. * as outer angle.
  139589. */
  139590. get innerAngle(): number;
  139591. /**
  139592. * Only used in gltf falloff mode, this defines the angle where
  139593. * the directional falloff will start before cutting at angle which could be seen
  139594. * as outer angle.
  139595. */
  139596. set innerAngle(value: number);
  139597. private _shadowAngleScale;
  139598. /**
  139599. * Allows scaling the angle of the light for shadow generation only.
  139600. */
  139601. get shadowAngleScale(): number;
  139602. /**
  139603. * Allows scaling the angle of the light for shadow generation only.
  139604. */
  139605. set shadowAngleScale(value: number);
  139606. /**
  139607. * The light decay speed with the distance from the emission spot.
  139608. */
  139609. exponent: number;
  139610. private _projectionTextureMatrix;
  139611. /**
  139612. * Allows reading the projecton texture
  139613. */
  139614. get projectionTextureMatrix(): Matrix;
  139615. protected _projectionTextureLightNear: number;
  139616. /**
  139617. * Gets the near clip of the Spotlight for texture projection.
  139618. */
  139619. get projectionTextureLightNear(): number;
  139620. /**
  139621. * Sets the near clip of the Spotlight for texture projection.
  139622. */
  139623. set projectionTextureLightNear(value: number);
  139624. protected _projectionTextureLightFar: number;
  139625. /**
  139626. * Gets the far clip of the Spotlight for texture projection.
  139627. */
  139628. get projectionTextureLightFar(): number;
  139629. /**
  139630. * Sets the far clip of the Spotlight for texture projection.
  139631. */
  139632. set projectionTextureLightFar(value: number);
  139633. protected _projectionTextureUpDirection: Vector3;
  139634. /**
  139635. * Gets the Up vector of the Spotlight for texture projection.
  139636. */
  139637. get projectionTextureUpDirection(): Vector3;
  139638. /**
  139639. * Sets the Up vector of the Spotlight for texture projection.
  139640. */
  139641. set projectionTextureUpDirection(value: Vector3);
  139642. private _projectionTexture;
  139643. /**
  139644. * Gets the projection texture of the light.
  139645. */
  139646. get projectionTexture(): Nullable<BaseTexture>;
  139647. /**
  139648. * Sets the projection texture of the light.
  139649. */
  139650. set projectionTexture(value: Nullable<BaseTexture>);
  139651. private static _IsProceduralTexture;
  139652. private static _IsTexture;
  139653. private _projectionTextureViewLightDirty;
  139654. private _projectionTextureProjectionLightDirty;
  139655. private _projectionTextureDirty;
  139656. private _projectionTextureViewTargetVector;
  139657. private _projectionTextureViewLightMatrix;
  139658. private _projectionTextureProjectionLightMatrix;
  139659. private _projectionTextureScalingMatrix;
  139660. /**
  139661. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139662. * It can cast shadows.
  139663. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139664. * @param name The light friendly name
  139665. * @param position The position of the spot light in the scene
  139666. * @param direction The direction of the light in the scene
  139667. * @param angle The cone angle of the light in Radians
  139668. * @param exponent The light decay speed with the distance from the emission spot
  139669. * @param scene The scene the lights belongs to
  139670. */
  139671. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139672. /**
  139673. * Returns the string "SpotLight".
  139674. * @returns the class name
  139675. */
  139676. getClassName(): string;
  139677. /**
  139678. * Returns the integer 2.
  139679. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139680. */
  139681. getTypeID(): number;
  139682. /**
  139683. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139684. */
  139685. protected _setDirection(value: Vector3): void;
  139686. /**
  139687. * Overrides the position setter to recompute the projection texture view light Matrix.
  139688. */
  139689. protected _setPosition(value: Vector3): void;
  139690. /**
  139691. * 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.
  139692. * Returns the SpotLight.
  139693. */
  139694. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139695. protected _computeProjectionTextureViewLightMatrix(): void;
  139696. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139697. /**
  139698. * Main function for light texture projection matrix computing.
  139699. */
  139700. protected _computeProjectionTextureMatrix(): void;
  139701. protected _buildUniformLayout(): void;
  139702. private _computeAngleValues;
  139703. /**
  139704. * Sets the passed Effect "effect" with the Light textures.
  139705. * @param effect The effect to update
  139706. * @param lightIndex The index of the light in the effect to update
  139707. * @returns The light
  139708. */
  139709. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139710. /**
  139711. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139712. * @param effect The effect to update
  139713. * @param lightIndex The index of the light in the effect to update
  139714. * @returns The spot light
  139715. */
  139716. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139717. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139718. /**
  139719. * Disposes the light and the associated resources.
  139720. */
  139721. dispose(): void;
  139722. /**
  139723. * Prepares the list of defines specific to the light type.
  139724. * @param defines the list of defines
  139725. * @param lightIndex defines the index of the light for the effect
  139726. */
  139727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139728. }
  139729. }
  139730. declare module BABYLON {
  139731. /**
  139732. * Gizmo that enables viewing a light
  139733. */
  139734. export class LightGizmo extends Gizmo {
  139735. private _lightMesh;
  139736. private _material;
  139737. private _cachedPosition;
  139738. private _cachedForward;
  139739. private _attachedMeshParent;
  139740. private _pointerObserver;
  139741. /**
  139742. * Event that fires each time the gizmo is clicked
  139743. */
  139744. onClickedObservable: Observable<Light>;
  139745. /**
  139746. * Creates a LightGizmo
  139747. * @param gizmoLayer The utility layer the gizmo will be added to
  139748. */
  139749. constructor(gizmoLayer?: UtilityLayerRenderer);
  139750. private _light;
  139751. /**
  139752. * The light that the gizmo is attached to
  139753. */
  139754. set light(light: Nullable<Light>);
  139755. get light(): Nullable<Light>;
  139756. /**
  139757. * Gets the material used to render the light gizmo
  139758. */
  139759. get material(): StandardMaterial;
  139760. /**
  139761. * @hidden
  139762. * Updates the gizmo to match the attached mesh's position/rotation
  139763. */
  139764. protected _update(): void;
  139765. private static _Scale;
  139766. /**
  139767. * Creates the lines for a light mesh
  139768. */
  139769. private static _CreateLightLines;
  139770. /**
  139771. * Disposes of the light gizmo
  139772. */
  139773. dispose(): void;
  139774. private static _CreateHemisphericLightMesh;
  139775. private static _CreatePointLightMesh;
  139776. private static _CreateSpotLightMesh;
  139777. private static _CreateDirectionalLightMesh;
  139778. }
  139779. }
  139780. declare module BABYLON {
  139781. /**
  139782. * Gizmo that enables viewing a camera
  139783. */
  139784. export class CameraGizmo extends Gizmo {
  139785. private _cameraMesh;
  139786. private _cameraLinesMesh;
  139787. private _material;
  139788. private _pointerObserver;
  139789. /**
  139790. * Event that fires each time the gizmo is clicked
  139791. */
  139792. onClickedObservable: Observable<Camera>;
  139793. /**
  139794. * Creates a CameraGizmo
  139795. * @param gizmoLayer The utility layer the gizmo will be added to
  139796. */
  139797. constructor(gizmoLayer?: UtilityLayerRenderer);
  139798. private _camera;
  139799. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139800. get displayFrustum(): boolean;
  139801. set displayFrustum(value: boolean);
  139802. /**
  139803. * The camera that the gizmo is attached to
  139804. */
  139805. set camera(camera: Nullable<Camera>);
  139806. get camera(): Nullable<Camera>;
  139807. /**
  139808. * Gets the material used to render the camera gizmo
  139809. */
  139810. get material(): StandardMaterial;
  139811. /**
  139812. * @hidden
  139813. * Updates the gizmo to match the attached mesh's position/rotation
  139814. */
  139815. protected _update(): void;
  139816. private static _Scale;
  139817. private _invProjection;
  139818. /**
  139819. * Disposes of the camera gizmo
  139820. */
  139821. dispose(): void;
  139822. private static _CreateCameraMesh;
  139823. private static _CreateCameraFrustum;
  139824. }
  139825. }
  139826. declare module BABYLON {
  139827. /** @hidden */
  139828. export var backgroundFragmentDeclaration: {
  139829. name: string;
  139830. shader: string;
  139831. };
  139832. }
  139833. declare module BABYLON {
  139834. /** @hidden */
  139835. export var backgroundUboDeclaration: {
  139836. name: string;
  139837. shader: string;
  139838. };
  139839. }
  139840. declare module BABYLON {
  139841. /** @hidden */
  139842. export var backgroundPixelShader: {
  139843. name: string;
  139844. shader: string;
  139845. };
  139846. }
  139847. declare module BABYLON {
  139848. /** @hidden */
  139849. export var backgroundVertexDeclaration: {
  139850. name: string;
  139851. shader: string;
  139852. };
  139853. }
  139854. declare module BABYLON {
  139855. /** @hidden */
  139856. export var backgroundVertexShader: {
  139857. name: string;
  139858. shader: string;
  139859. };
  139860. }
  139861. declare module BABYLON {
  139862. /**
  139863. * Background material used to create an efficient environement around your scene.
  139864. */
  139865. export class BackgroundMaterial extends PushMaterial {
  139866. /**
  139867. * Standard reflectance value at parallel view angle.
  139868. */
  139869. static StandardReflectance0: number;
  139870. /**
  139871. * Standard reflectance value at grazing angle.
  139872. */
  139873. static StandardReflectance90: number;
  139874. protected _primaryColor: Color3;
  139875. /**
  139876. * Key light Color (multiply against the environement texture)
  139877. */
  139878. primaryColor: Color3;
  139879. protected __perceptualColor: Nullable<Color3>;
  139880. /**
  139881. * Experimental Internal Use Only.
  139882. *
  139883. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139884. * This acts as a helper to set the primary color to a more "human friendly" value.
  139885. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139886. * output color as close as possible from the chosen value.
  139887. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139888. * part of lighting setup.)
  139889. */
  139890. get _perceptualColor(): Nullable<Color3>;
  139891. set _perceptualColor(value: Nullable<Color3>);
  139892. protected _primaryColorShadowLevel: float;
  139893. /**
  139894. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139895. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139896. */
  139897. get primaryColorShadowLevel(): float;
  139898. set primaryColorShadowLevel(value: float);
  139899. protected _primaryColorHighlightLevel: float;
  139900. /**
  139901. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139902. * The primary color is used at the level chosen to define what the white area would look.
  139903. */
  139904. get primaryColorHighlightLevel(): float;
  139905. set primaryColorHighlightLevel(value: float);
  139906. protected _reflectionTexture: Nullable<BaseTexture>;
  139907. /**
  139908. * Reflection Texture used in the material.
  139909. * Should be author in a specific way for the best result (refer to the documentation).
  139910. */
  139911. reflectionTexture: Nullable<BaseTexture>;
  139912. protected _reflectionBlur: float;
  139913. /**
  139914. * Reflection Texture level of blur.
  139915. *
  139916. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139917. * texture twice.
  139918. */
  139919. reflectionBlur: float;
  139920. protected _diffuseTexture: Nullable<BaseTexture>;
  139921. /**
  139922. * Diffuse Texture used in the material.
  139923. * Should be author in a specific way for the best result (refer to the documentation).
  139924. */
  139925. diffuseTexture: Nullable<BaseTexture>;
  139926. protected _shadowLights: Nullable<IShadowLight[]>;
  139927. /**
  139928. * Specify the list of lights casting shadow on the material.
  139929. * All scene shadow lights will be included if null.
  139930. */
  139931. shadowLights: Nullable<IShadowLight[]>;
  139932. protected _shadowLevel: float;
  139933. /**
  139934. * Helps adjusting the shadow to a softer level if required.
  139935. * 0 means black shadows and 1 means no shadows.
  139936. */
  139937. shadowLevel: float;
  139938. protected _sceneCenter: Vector3;
  139939. /**
  139940. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139941. * It is usually zero but might be interesting to modify according to your setup.
  139942. */
  139943. sceneCenter: Vector3;
  139944. protected _opacityFresnel: boolean;
  139945. /**
  139946. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139947. * This helps ensuring a nice transition when the camera goes under the ground.
  139948. */
  139949. opacityFresnel: boolean;
  139950. protected _reflectionFresnel: boolean;
  139951. /**
  139952. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139953. * This helps adding a mirror texture on the ground.
  139954. */
  139955. reflectionFresnel: boolean;
  139956. protected _reflectionFalloffDistance: number;
  139957. /**
  139958. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139959. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139960. */
  139961. reflectionFalloffDistance: number;
  139962. protected _reflectionAmount: number;
  139963. /**
  139964. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139965. */
  139966. reflectionAmount: number;
  139967. protected _reflectionReflectance0: number;
  139968. /**
  139969. * This specifies the weight of the reflection at grazing angle.
  139970. */
  139971. reflectionReflectance0: number;
  139972. protected _reflectionReflectance90: number;
  139973. /**
  139974. * This specifies the weight of the reflection at a perpendicular point of view.
  139975. */
  139976. reflectionReflectance90: number;
  139977. /**
  139978. * Sets the reflection reflectance fresnel values according to the default standard
  139979. * empirically know to work well :-)
  139980. */
  139981. set reflectionStandardFresnelWeight(value: number);
  139982. protected _useRGBColor: boolean;
  139983. /**
  139984. * Helps to directly use the maps channels instead of their level.
  139985. */
  139986. useRGBColor: boolean;
  139987. protected _enableNoise: boolean;
  139988. /**
  139989. * This helps reducing the banding effect that could occur on the background.
  139990. */
  139991. enableNoise: boolean;
  139992. /**
  139993. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139994. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139995. * Recommended to be keep at 1.0 except for special cases.
  139996. */
  139997. get fovMultiplier(): number;
  139998. set fovMultiplier(value: number);
  139999. private _fovMultiplier;
  140000. /**
  140001. * Enable the FOV adjustment feature controlled by fovMultiplier.
  140002. */
  140003. useEquirectangularFOV: boolean;
  140004. private _maxSimultaneousLights;
  140005. /**
  140006. * Number of Simultaneous lights allowed on the material.
  140007. */
  140008. maxSimultaneousLights: int;
  140009. private _shadowOnly;
  140010. /**
  140011. * Make the material only render shadows
  140012. */
  140013. shadowOnly: boolean;
  140014. /**
  140015. * Default configuration related to image processing available in the Background Material.
  140016. */
  140017. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  140018. /**
  140019. * Keep track of the image processing observer to allow dispose and replace.
  140020. */
  140021. private _imageProcessingObserver;
  140022. /**
  140023. * Attaches a new image processing configuration to the PBR Material.
  140024. * @param configuration (if null the scene configuration will be use)
  140025. */
  140026. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  140027. /**
  140028. * Gets the image processing configuration used either in this material.
  140029. */
  140030. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  140031. /**
  140032. * Sets the Default image processing configuration used either in the this material.
  140033. *
  140034. * If sets to null, the scene one is in use.
  140035. */
  140036. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  140037. /**
  140038. * Gets wether the color curves effect is enabled.
  140039. */
  140040. get cameraColorCurvesEnabled(): boolean;
  140041. /**
  140042. * Sets wether the color curves effect is enabled.
  140043. */
  140044. set cameraColorCurvesEnabled(value: boolean);
  140045. /**
  140046. * Gets wether the color grading effect is enabled.
  140047. */
  140048. get cameraColorGradingEnabled(): boolean;
  140049. /**
  140050. * Gets wether the color grading effect is enabled.
  140051. */
  140052. set cameraColorGradingEnabled(value: boolean);
  140053. /**
  140054. * Gets wether tonemapping is enabled or not.
  140055. */
  140056. get cameraToneMappingEnabled(): boolean;
  140057. /**
  140058. * Sets wether tonemapping is enabled or not
  140059. */
  140060. set cameraToneMappingEnabled(value: boolean);
  140061. /**
  140062. * The camera exposure used on this material.
  140063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140064. * This corresponds to a photographic exposure.
  140065. */
  140066. get cameraExposure(): float;
  140067. /**
  140068. * The camera exposure used on this material.
  140069. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140070. * This corresponds to a photographic exposure.
  140071. */
  140072. set cameraExposure(value: float);
  140073. /**
  140074. * Gets The camera contrast used on this material.
  140075. */
  140076. get cameraContrast(): float;
  140077. /**
  140078. * Sets The camera contrast used on this material.
  140079. */
  140080. set cameraContrast(value: float);
  140081. /**
  140082. * Gets the Color Grading 2D Lookup Texture.
  140083. */
  140084. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  140085. /**
  140086. * Sets the Color Grading 2D Lookup Texture.
  140087. */
  140088. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  140089. /**
  140090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140092. * 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;
  140093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140094. */
  140095. get cameraColorCurves(): Nullable<ColorCurves>;
  140096. /**
  140097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140099. * 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;
  140100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140101. */
  140102. set cameraColorCurves(value: Nullable<ColorCurves>);
  140103. /**
  140104. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  140105. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  140106. */
  140107. switchToBGR: boolean;
  140108. private _renderTargets;
  140109. private _reflectionControls;
  140110. private _white;
  140111. private _primaryShadowColor;
  140112. private _primaryHighlightColor;
  140113. /**
  140114. * Instantiates a Background Material in the given scene
  140115. * @param name The friendly name of the material
  140116. * @param scene The scene to add the material to
  140117. */
  140118. constructor(name: string, scene: Scene);
  140119. /**
  140120. * Gets a boolean indicating that current material needs to register RTT
  140121. */
  140122. get hasRenderTargetTextures(): boolean;
  140123. /**
  140124. * The entire material has been created in order to prevent overdraw.
  140125. * @returns false
  140126. */
  140127. needAlphaTesting(): boolean;
  140128. /**
  140129. * The entire material has been created in order to prevent overdraw.
  140130. * @returns true if blending is enable
  140131. */
  140132. needAlphaBlending(): boolean;
  140133. /**
  140134. * Checks wether the material is ready to be rendered for a given mesh.
  140135. * @param mesh The mesh to render
  140136. * @param subMesh The submesh to check against
  140137. * @param useInstances Specify wether or not the material is used with instances
  140138. * @returns true if all the dependencies are ready (Textures, Effects...)
  140139. */
  140140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  140141. /**
  140142. * Compute the primary color according to the chosen perceptual color.
  140143. */
  140144. private _computePrimaryColorFromPerceptualColor;
  140145. /**
  140146. * Compute the highlights and shadow colors according to their chosen levels.
  140147. */
  140148. private _computePrimaryColors;
  140149. /**
  140150. * Build the uniform buffer used in the material.
  140151. */
  140152. buildUniformLayout(): void;
  140153. /**
  140154. * Unbind the material.
  140155. */
  140156. unbind(): void;
  140157. /**
  140158. * Bind only the world matrix to the material.
  140159. * @param world The world matrix to bind.
  140160. */
  140161. bindOnlyWorldMatrix(world: Matrix): void;
  140162. /**
  140163. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  140164. * @param world The world matrix to bind.
  140165. * @param subMesh The submesh to bind for.
  140166. */
  140167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  140168. /**
  140169. * Checks to see if a texture is used in the material.
  140170. * @param texture - Base texture to use.
  140171. * @returns - Boolean specifying if a texture is used in the material.
  140172. */
  140173. hasTexture(texture: BaseTexture): boolean;
  140174. /**
  140175. * Dispose the material.
  140176. * @param forceDisposeEffect Force disposal of the associated effect.
  140177. * @param forceDisposeTextures Force disposal of the associated textures.
  140178. */
  140179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  140180. /**
  140181. * Clones the material.
  140182. * @param name The cloned name.
  140183. * @returns The cloned material.
  140184. */
  140185. clone(name: string): BackgroundMaterial;
  140186. /**
  140187. * Serializes the current material to its JSON representation.
  140188. * @returns The JSON representation.
  140189. */
  140190. serialize(): any;
  140191. /**
  140192. * Gets the class name of the material
  140193. * @returns "BackgroundMaterial"
  140194. */
  140195. getClassName(): string;
  140196. /**
  140197. * Parse a JSON input to create back a background material.
  140198. * @param source The JSON data to parse
  140199. * @param scene The scene to create the parsed material in
  140200. * @param rootUrl The root url of the assets the material depends upon
  140201. * @returns the instantiated BackgroundMaterial.
  140202. */
  140203. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  140204. }
  140205. }
  140206. declare module BABYLON {
  140207. /**
  140208. * Represents the different options available during the creation of
  140209. * a Environment helper.
  140210. *
  140211. * This can control the default ground, skybox and image processing setup of your scene.
  140212. */
  140213. export interface IEnvironmentHelperOptions {
  140214. /**
  140215. * Specifies whether or not to create a ground.
  140216. * True by default.
  140217. */
  140218. createGround: boolean;
  140219. /**
  140220. * Specifies the ground size.
  140221. * 15 by default.
  140222. */
  140223. groundSize: number;
  140224. /**
  140225. * The texture used on the ground for the main color.
  140226. * Comes from the BabylonJS CDN by default.
  140227. *
  140228. * Remarks: Can be either a texture or a url.
  140229. */
  140230. groundTexture: string | BaseTexture;
  140231. /**
  140232. * The color mixed in the ground texture by default.
  140233. * BabylonJS clearColor by default.
  140234. */
  140235. groundColor: Color3;
  140236. /**
  140237. * Specifies the ground opacity.
  140238. * 1 by default.
  140239. */
  140240. groundOpacity: number;
  140241. /**
  140242. * Enables the ground to receive shadows.
  140243. * True by default.
  140244. */
  140245. enableGroundShadow: boolean;
  140246. /**
  140247. * Helps preventing the shadow to be fully black on the ground.
  140248. * 0.5 by default.
  140249. */
  140250. groundShadowLevel: number;
  140251. /**
  140252. * Creates a mirror texture attach to the ground.
  140253. * false by default.
  140254. */
  140255. enableGroundMirror: boolean;
  140256. /**
  140257. * Specifies the ground mirror size ratio.
  140258. * 0.3 by default as the default kernel is 64.
  140259. */
  140260. groundMirrorSizeRatio: number;
  140261. /**
  140262. * Specifies the ground mirror blur kernel size.
  140263. * 64 by default.
  140264. */
  140265. groundMirrorBlurKernel: number;
  140266. /**
  140267. * Specifies the ground mirror visibility amount.
  140268. * 1 by default
  140269. */
  140270. groundMirrorAmount: number;
  140271. /**
  140272. * Specifies the ground mirror reflectance weight.
  140273. * This uses the standard weight of the background material to setup the fresnel effect
  140274. * of the mirror.
  140275. * 1 by default.
  140276. */
  140277. groundMirrorFresnelWeight: number;
  140278. /**
  140279. * Specifies the ground mirror Falloff distance.
  140280. * This can helps reducing the size of the reflection.
  140281. * 0 by Default.
  140282. */
  140283. groundMirrorFallOffDistance: number;
  140284. /**
  140285. * Specifies the ground mirror texture type.
  140286. * Unsigned Int by Default.
  140287. */
  140288. groundMirrorTextureType: number;
  140289. /**
  140290. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  140291. * the shown objects.
  140292. */
  140293. groundYBias: number;
  140294. /**
  140295. * Specifies whether or not to create a skybox.
  140296. * True by default.
  140297. */
  140298. createSkybox: boolean;
  140299. /**
  140300. * Specifies the skybox size.
  140301. * 20 by default.
  140302. */
  140303. skyboxSize: number;
  140304. /**
  140305. * The texture used on the skybox for the main color.
  140306. * Comes from the BabylonJS CDN by default.
  140307. *
  140308. * Remarks: Can be either a texture or a url.
  140309. */
  140310. skyboxTexture: string | BaseTexture;
  140311. /**
  140312. * The color mixed in the skybox texture by default.
  140313. * BabylonJS clearColor by default.
  140314. */
  140315. skyboxColor: Color3;
  140316. /**
  140317. * The background rotation around the Y axis of the scene.
  140318. * This helps aligning the key lights of your scene with the background.
  140319. * 0 by default.
  140320. */
  140321. backgroundYRotation: number;
  140322. /**
  140323. * Compute automatically the size of the elements to best fit with the scene.
  140324. */
  140325. sizeAuto: boolean;
  140326. /**
  140327. * Default position of the rootMesh if autoSize is not true.
  140328. */
  140329. rootPosition: Vector3;
  140330. /**
  140331. * Sets up the image processing in the scene.
  140332. * true by default.
  140333. */
  140334. setupImageProcessing: boolean;
  140335. /**
  140336. * The texture used as your environment texture in the scene.
  140337. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  140338. *
  140339. * Remarks: Can be either a texture or a url.
  140340. */
  140341. environmentTexture: string | BaseTexture;
  140342. /**
  140343. * The value of the exposure to apply to the scene.
  140344. * 0.6 by default if setupImageProcessing is true.
  140345. */
  140346. cameraExposure: number;
  140347. /**
  140348. * The value of the contrast to apply to the scene.
  140349. * 1.6 by default if setupImageProcessing is true.
  140350. */
  140351. cameraContrast: number;
  140352. /**
  140353. * Specifies whether or not tonemapping should be enabled in the scene.
  140354. * true by default if setupImageProcessing is true.
  140355. */
  140356. toneMappingEnabled: boolean;
  140357. }
  140358. /**
  140359. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140360. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140361. * It also helps with the default setup of your imageProcessing configuration.
  140362. */
  140363. export class EnvironmentHelper {
  140364. /**
  140365. * Default ground texture URL.
  140366. */
  140367. private static _groundTextureCDNUrl;
  140368. /**
  140369. * Default skybox texture URL.
  140370. */
  140371. private static _skyboxTextureCDNUrl;
  140372. /**
  140373. * Default environment texture URL.
  140374. */
  140375. private static _environmentTextureCDNUrl;
  140376. /**
  140377. * Creates the default options for the helper.
  140378. */
  140379. private static _getDefaultOptions;
  140380. private _rootMesh;
  140381. /**
  140382. * Gets the root mesh created by the helper.
  140383. */
  140384. get rootMesh(): Mesh;
  140385. private _skybox;
  140386. /**
  140387. * Gets the skybox created by the helper.
  140388. */
  140389. get skybox(): Nullable<Mesh>;
  140390. private _skyboxTexture;
  140391. /**
  140392. * Gets the skybox texture created by the helper.
  140393. */
  140394. get skyboxTexture(): Nullable<BaseTexture>;
  140395. private _skyboxMaterial;
  140396. /**
  140397. * Gets the skybox material created by the helper.
  140398. */
  140399. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140400. private _ground;
  140401. /**
  140402. * Gets the ground mesh created by the helper.
  140403. */
  140404. get ground(): Nullable<Mesh>;
  140405. private _groundTexture;
  140406. /**
  140407. * Gets the ground texture created by the helper.
  140408. */
  140409. get groundTexture(): Nullable<BaseTexture>;
  140410. private _groundMirror;
  140411. /**
  140412. * Gets the ground mirror created by the helper.
  140413. */
  140414. get groundMirror(): Nullable<MirrorTexture>;
  140415. /**
  140416. * Gets the ground mirror render list to helps pushing the meshes
  140417. * you wish in the ground reflection.
  140418. */
  140419. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140420. private _groundMaterial;
  140421. /**
  140422. * Gets the ground material created by the helper.
  140423. */
  140424. get groundMaterial(): Nullable<BackgroundMaterial>;
  140425. /**
  140426. * Stores the creation options.
  140427. */
  140428. private readonly _scene;
  140429. private _options;
  140430. /**
  140431. * This observable will be notified with any error during the creation of the environment,
  140432. * mainly texture creation errors.
  140433. */
  140434. onErrorObservable: Observable<{
  140435. message?: string;
  140436. exception?: any;
  140437. }>;
  140438. /**
  140439. * constructor
  140440. * @param options Defines the options we want to customize the helper
  140441. * @param scene The scene to add the material to
  140442. */
  140443. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140444. /**
  140445. * Updates the background according to the new options
  140446. * @param options
  140447. */
  140448. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140449. /**
  140450. * Sets the primary color of all the available elements.
  140451. * @param color the main color to affect to the ground and the background
  140452. */
  140453. setMainColor(color: Color3): void;
  140454. /**
  140455. * Setup the image processing according to the specified options.
  140456. */
  140457. private _setupImageProcessing;
  140458. /**
  140459. * Setup the environment texture according to the specified options.
  140460. */
  140461. private _setupEnvironmentTexture;
  140462. /**
  140463. * Setup the background according to the specified options.
  140464. */
  140465. private _setupBackground;
  140466. /**
  140467. * Get the scene sizes according to the setup.
  140468. */
  140469. private _getSceneSize;
  140470. /**
  140471. * Setup the ground according to the specified options.
  140472. */
  140473. private _setupGround;
  140474. /**
  140475. * Setup the ground material according to the specified options.
  140476. */
  140477. private _setupGroundMaterial;
  140478. /**
  140479. * Setup the ground diffuse texture according to the specified options.
  140480. */
  140481. private _setupGroundDiffuseTexture;
  140482. /**
  140483. * Setup the ground mirror texture according to the specified options.
  140484. */
  140485. private _setupGroundMirrorTexture;
  140486. /**
  140487. * Setup the ground to receive the mirror texture.
  140488. */
  140489. private _setupMirrorInGroundMaterial;
  140490. /**
  140491. * Setup the skybox according to the specified options.
  140492. */
  140493. private _setupSkybox;
  140494. /**
  140495. * Setup the skybox material according to the specified options.
  140496. */
  140497. private _setupSkyboxMaterial;
  140498. /**
  140499. * Setup the skybox reflection texture according to the specified options.
  140500. */
  140501. private _setupSkyboxReflectionTexture;
  140502. private _errorHandler;
  140503. /**
  140504. * Dispose all the elements created by the Helper.
  140505. */
  140506. dispose(): void;
  140507. }
  140508. }
  140509. declare module BABYLON {
  140510. /**
  140511. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140512. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140513. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140514. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140515. */
  140516. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140517. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140518. /**
  140519. * Define the source as a Monoscopic panoramic 360/180.
  140520. */
  140521. static readonly MODE_MONOSCOPIC: number;
  140522. /**
  140523. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140524. */
  140525. static readonly MODE_TOPBOTTOM: number;
  140526. /**
  140527. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140528. */
  140529. static readonly MODE_SIDEBYSIDE: number;
  140530. private _halfDome;
  140531. private _crossEye;
  140532. protected _useDirectMapping: boolean;
  140533. /**
  140534. * The texture being displayed on the sphere
  140535. */
  140536. protected _texture: T;
  140537. /**
  140538. * Gets the texture being displayed on the sphere
  140539. */
  140540. get texture(): T;
  140541. /**
  140542. * Sets the texture being displayed on the sphere
  140543. */
  140544. set texture(newTexture: T);
  140545. /**
  140546. * The skybox material
  140547. */
  140548. protected _material: BackgroundMaterial;
  140549. /**
  140550. * The surface used for the dome
  140551. */
  140552. protected _mesh: Mesh;
  140553. /**
  140554. * Gets the mesh used for the dome.
  140555. */
  140556. get mesh(): Mesh;
  140557. /**
  140558. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140559. */
  140560. private _halfDomeMask;
  140561. /**
  140562. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140563. * Also see the options.resolution property.
  140564. */
  140565. get fovMultiplier(): number;
  140566. set fovMultiplier(value: number);
  140567. protected _textureMode: number;
  140568. /**
  140569. * Gets or set the current texture mode for the texture. It can be:
  140570. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140571. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140572. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140573. */
  140574. get textureMode(): number;
  140575. /**
  140576. * Sets the current texture mode for the texture. It can be:
  140577. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140578. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140579. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140580. */
  140581. set textureMode(value: number);
  140582. /**
  140583. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140584. */
  140585. get halfDome(): boolean;
  140586. /**
  140587. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140588. */
  140589. set halfDome(enabled: boolean);
  140590. /**
  140591. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140592. */
  140593. set crossEye(enabled: boolean);
  140594. /**
  140595. * Is it a cross-eye texture?
  140596. */
  140597. get crossEye(): boolean;
  140598. /**
  140599. * The background material of this dome.
  140600. */
  140601. get material(): BackgroundMaterial;
  140602. /**
  140603. * Oberserver used in Stereoscopic VR Mode.
  140604. */
  140605. private _onBeforeCameraRenderObserver;
  140606. /**
  140607. * Observable raised when an error occured while loading the 360 image
  140608. */
  140609. onLoadErrorObservable: Observable<string>;
  140610. /**
  140611. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140612. * @param name Element's name, child elements will append suffixes for their own names.
  140613. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140614. * @param options An object containing optional or exposed sub element properties
  140615. */
  140616. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140617. resolution?: number;
  140618. clickToPlay?: boolean;
  140619. autoPlay?: boolean;
  140620. loop?: boolean;
  140621. size?: number;
  140622. poster?: string;
  140623. faceForward?: boolean;
  140624. useDirectMapping?: boolean;
  140625. halfDomeMode?: boolean;
  140626. crossEyeMode?: boolean;
  140627. generateMipMaps?: boolean;
  140628. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140629. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140630. protected _changeTextureMode(value: number): void;
  140631. /**
  140632. * Releases resources associated with this node.
  140633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140635. */
  140636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140637. }
  140638. }
  140639. declare module BABYLON {
  140640. /**
  140641. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140642. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140643. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140644. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140645. */
  140646. export class PhotoDome extends TextureDome<Texture> {
  140647. /**
  140648. * Define the image as a Monoscopic panoramic 360 image.
  140649. */
  140650. static readonly MODE_MONOSCOPIC: number;
  140651. /**
  140652. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140653. */
  140654. static readonly MODE_TOPBOTTOM: number;
  140655. /**
  140656. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140657. */
  140658. static readonly MODE_SIDEBYSIDE: number;
  140659. /**
  140660. * Gets or sets the texture being displayed on the sphere
  140661. */
  140662. get photoTexture(): Texture;
  140663. /**
  140664. * sets the texture being displayed on the sphere
  140665. */
  140666. set photoTexture(value: Texture);
  140667. /**
  140668. * Gets the current video mode for the video. It can be:
  140669. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140670. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140671. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140672. */
  140673. get imageMode(): number;
  140674. /**
  140675. * Sets the current video mode for the video. It can be:
  140676. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140677. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140678. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140679. */
  140680. set imageMode(value: number);
  140681. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140682. }
  140683. }
  140684. declare module BABYLON {
  140685. /**
  140686. * Direct draw surface info
  140687. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140688. */
  140689. export interface DDSInfo {
  140690. /**
  140691. * Width of the texture
  140692. */
  140693. width: number;
  140694. /**
  140695. * Width of the texture
  140696. */
  140697. height: number;
  140698. /**
  140699. * Number of Mipmaps for the texture
  140700. * @see https://en.wikipedia.org/wiki/Mipmap
  140701. */
  140702. mipmapCount: number;
  140703. /**
  140704. * If the textures format is a known fourCC format
  140705. * @see https://www.fourcc.org/
  140706. */
  140707. isFourCC: boolean;
  140708. /**
  140709. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140710. */
  140711. isRGB: boolean;
  140712. /**
  140713. * If the texture is a lumincance format
  140714. */
  140715. isLuminance: boolean;
  140716. /**
  140717. * If this is a cube texture
  140718. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140719. */
  140720. isCube: boolean;
  140721. /**
  140722. * If the texture is a compressed format eg. FOURCC_DXT1
  140723. */
  140724. isCompressed: boolean;
  140725. /**
  140726. * The dxgiFormat of the texture
  140727. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140728. */
  140729. dxgiFormat: number;
  140730. /**
  140731. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140732. */
  140733. textureType: number;
  140734. /**
  140735. * Sphericle polynomial created for the dds texture
  140736. */
  140737. sphericalPolynomial?: SphericalPolynomial;
  140738. }
  140739. /**
  140740. * Class used to provide DDS decompression tools
  140741. */
  140742. export class DDSTools {
  140743. /**
  140744. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140745. */
  140746. static StoreLODInAlphaChannel: boolean;
  140747. /**
  140748. * Gets DDS information from an array buffer
  140749. * @param data defines the array buffer view to read data from
  140750. * @returns the DDS information
  140751. */
  140752. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140753. private static _FloatView;
  140754. private static _Int32View;
  140755. private static _ToHalfFloat;
  140756. private static _FromHalfFloat;
  140757. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140758. private static _GetHalfFloatRGBAArrayBuffer;
  140759. private static _GetFloatRGBAArrayBuffer;
  140760. private static _GetFloatAsUIntRGBAArrayBuffer;
  140761. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140762. private static _GetRGBAArrayBuffer;
  140763. private static _ExtractLongWordOrder;
  140764. private static _GetRGBArrayBuffer;
  140765. private static _GetLuminanceArrayBuffer;
  140766. /**
  140767. * Uploads DDS Levels to a Babylon Texture
  140768. * @hidden
  140769. */
  140770. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140771. }
  140772. interface ThinEngine {
  140773. /**
  140774. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140775. * @param rootUrl defines the url where the file to load is located
  140776. * @param scene defines the current scene
  140777. * @param lodScale defines scale to apply to the mip map selection
  140778. * @param lodOffset defines offset to apply to the mip map selection
  140779. * @param onLoad defines an optional callback raised when the texture is loaded
  140780. * @param onError defines an optional callback raised if there is an issue to load the texture
  140781. * @param format defines the format of the data
  140782. * @param forcedExtension defines the extension to use to pick the right loader
  140783. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140784. * @returns the cube texture as an InternalTexture
  140785. */
  140786. 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;
  140787. }
  140788. }
  140789. declare module BABYLON {
  140790. /**
  140791. * Implementation of the DDS Texture Loader.
  140792. * @hidden
  140793. */
  140794. export class _DDSTextureLoader implements IInternalTextureLoader {
  140795. /**
  140796. * Defines wether the loader supports cascade loading the different faces.
  140797. */
  140798. readonly supportCascades: boolean;
  140799. /**
  140800. * This returns if the loader support the current file information.
  140801. * @param extension defines the file extension of the file being loaded
  140802. * @returns true if the loader can load the specified file
  140803. */
  140804. canLoad(extension: string): boolean;
  140805. /**
  140806. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140807. * @param data contains the texture data
  140808. * @param texture defines the BabylonJS internal texture
  140809. * @param createPolynomials will be true if polynomials have been requested
  140810. * @param onLoad defines the callback to trigger once the texture is ready
  140811. * @param onError defines the callback to trigger in case of error
  140812. */
  140813. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140814. /**
  140815. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140816. * @param data contains the texture data
  140817. * @param texture defines the BabylonJS internal texture
  140818. * @param callback defines the method to call once ready to upload
  140819. */
  140820. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140821. }
  140822. }
  140823. declare module BABYLON {
  140824. /**
  140825. * Implementation of the ENV Texture Loader.
  140826. * @hidden
  140827. */
  140828. export class _ENVTextureLoader implements IInternalTextureLoader {
  140829. /**
  140830. * Defines wether the loader supports cascade loading the different faces.
  140831. */
  140832. readonly supportCascades: boolean;
  140833. /**
  140834. * This returns if the loader support the current file information.
  140835. * @param extension defines the file extension of the file being loaded
  140836. * @returns true if the loader can load the specified file
  140837. */
  140838. canLoad(extension: string): boolean;
  140839. /**
  140840. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140841. * @param data contains the texture data
  140842. * @param texture defines the BabylonJS internal texture
  140843. * @param createPolynomials will be true if polynomials have been requested
  140844. * @param onLoad defines the callback to trigger once the texture is ready
  140845. * @param onError defines the callback to trigger in case of error
  140846. */
  140847. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140848. /**
  140849. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140850. * @param data contains the texture data
  140851. * @param texture defines the BabylonJS internal texture
  140852. * @param callback defines the method to call once ready to upload
  140853. */
  140854. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140855. }
  140856. }
  140857. declare module BABYLON {
  140858. /**
  140859. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140860. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140861. */
  140862. export class KhronosTextureContainer {
  140863. /** contents of the KTX container file */
  140864. data: ArrayBufferView;
  140865. private static HEADER_LEN;
  140866. private static COMPRESSED_2D;
  140867. private static COMPRESSED_3D;
  140868. private static TEX_2D;
  140869. private static TEX_3D;
  140870. /**
  140871. * Gets the openGL type
  140872. */
  140873. glType: number;
  140874. /**
  140875. * Gets the openGL type size
  140876. */
  140877. glTypeSize: number;
  140878. /**
  140879. * Gets the openGL format
  140880. */
  140881. glFormat: number;
  140882. /**
  140883. * Gets the openGL internal format
  140884. */
  140885. glInternalFormat: number;
  140886. /**
  140887. * Gets the base internal format
  140888. */
  140889. glBaseInternalFormat: number;
  140890. /**
  140891. * Gets image width in pixel
  140892. */
  140893. pixelWidth: number;
  140894. /**
  140895. * Gets image height in pixel
  140896. */
  140897. pixelHeight: number;
  140898. /**
  140899. * Gets image depth in pixels
  140900. */
  140901. pixelDepth: number;
  140902. /**
  140903. * Gets the number of array elements
  140904. */
  140905. numberOfArrayElements: number;
  140906. /**
  140907. * Gets the number of faces
  140908. */
  140909. numberOfFaces: number;
  140910. /**
  140911. * Gets the number of mipmap levels
  140912. */
  140913. numberOfMipmapLevels: number;
  140914. /**
  140915. * Gets the bytes of key value data
  140916. */
  140917. bytesOfKeyValueData: number;
  140918. /**
  140919. * Gets the load type
  140920. */
  140921. loadType: number;
  140922. /**
  140923. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140924. */
  140925. isInvalid: boolean;
  140926. /**
  140927. * Creates a new KhronosTextureContainer
  140928. * @param data contents of the KTX container file
  140929. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140930. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140931. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140932. */
  140933. constructor(
  140934. /** contents of the KTX container file */
  140935. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140936. /**
  140937. * Uploads KTX content to a Babylon Texture.
  140938. * It is assumed that the texture has already been created & is currently bound
  140939. * @hidden
  140940. */
  140941. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140942. private _upload2DCompressedLevels;
  140943. /**
  140944. * Checks if the given data starts with a KTX file identifier.
  140945. * @param data the data to check
  140946. * @returns true if the data is a KTX file or false otherwise
  140947. */
  140948. static IsValid(data: ArrayBufferView): boolean;
  140949. }
  140950. }
  140951. declare module BABYLON {
  140952. /**
  140953. * Helper class to push actions to a pool of workers.
  140954. */
  140955. export class WorkerPool implements IDisposable {
  140956. private _workerInfos;
  140957. private _pendingActions;
  140958. /**
  140959. * Constructor
  140960. * @param workers Array of workers to use for actions
  140961. */
  140962. constructor(workers: Array<Worker>);
  140963. /**
  140964. * Terminates all workers and clears any pending actions.
  140965. */
  140966. dispose(): void;
  140967. /**
  140968. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140969. * pended until a worker has completed its action.
  140970. * @param action The action to perform. Call onComplete when the action is complete.
  140971. */
  140972. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140973. private _execute;
  140974. }
  140975. }
  140976. declare module BABYLON {
  140977. /**
  140978. * Class for loading KTX2 files
  140979. */
  140980. export class KhronosTextureContainer2 {
  140981. private static _WorkerPoolPromise?;
  140982. private static _Initialized;
  140983. private static _Ktx2Decoder;
  140984. /**
  140985. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140986. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140987. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140988. * Urls you can change:
  140989. * URLConfig.jsDecoderModule
  140990. * URLConfig.wasmUASTCToASTC
  140991. * URLConfig.wasmUASTCToBC7
  140992. * URLConfig.wasmUASTCToRGBA_UNORM
  140993. * URLConfig.wasmUASTCToRGBA_SRGB
  140994. * URLConfig.jsMSCTranscoder
  140995. * URLConfig.wasmMSCTranscoder
  140996. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140997. */
  140998. static URLConfig: {
  140999. jsDecoderModule: string;
  141000. wasmUASTCToASTC: null;
  141001. wasmUASTCToBC7: null;
  141002. wasmUASTCToRGBA_UNORM: null;
  141003. wasmUASTCToRGBA_SRGB: null;
  141004. jsMSCTranscoder: null;
  141005. wasmMSCTranscoder: null;
  141006. };
  141007. /**
  141008. * Default number of workers used to handle data decoding
  141009. */
  141010. static DefaultNumWorkers: number;
  141011. private static GetDefaultNumWorkers;
  141012. private _engine;
  141013. private static _CreateWorkerPool;
  141014. /**
  141015. * Constructor
  141016. * @param engine The engine to use
  141017. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141018. */
  141019. constructor(engine: ThinEngine, numWorkers?: number);
  141020. /** @hidden */
  141021. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  141022. /**
  141023. * Stop all async operations and release resources.
  141024. */
  141025. dispose(): void;
  141026. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  141027. /**
  141028. * Checks if the given data starts with a KTX2 file identifier.
  141029. * @param data the data to check
  141030. * @returns true if the data is a KTX2 file or false otherwise
  141031. */
  141032. static IsValid(data: ArrayBufferView): boolean;
  141033. }
  141034. }
  141035. declare module BABYLON {
  141036. /**
  141037. * Implementation of the KTX Texture Loader.
  141038. * @hidden
  141039. */
  141040. export class _KTXTextureLoader implements IInternalTextureLoader {
  141041. /**
  141042. * Defines wether the loader supports cascade loading the different faces.
  141043. */
  141044. readonly supportCascades: boolean;
  141045. /**
  141046. * This returns if the loader support the current file information.
  141047. * @param extension defines the file extension of the file being loaded
  141048. * @param mimeType defines the optional mime type of the file being loaded
  141049. * @returns true if the loader can load the specified file
  141050. */
  141051. canLoad(extension: string, mimeType?: string): boolean;
  141052. /**
  141053. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141054. * @param data contains the texture data
  141055. * @param texture defines the BabylonJS internal texture
  141056. * @param createPolynomials will be true if polynomials have been requested
  141057. * @param onLoad defines the callback to trigger once the texture is ready
  141058. * @param onError defines the callback to trigger in case of error
  141059. */
  141060. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141061. /**
  141062. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141063. * @param data contains the texture data
  141064. * @param texture defines the BabylonJS internal texture
  141065. * @param callback defines the method to call once ready to upload
  141066. */
  141067. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  141068. }
  141069. }
  141070. declare module BABYLON {
  141071. /** @hidden */
  141072. export var _forceSceneHelpersToBundle: boolean;
  141073. interface Scene {
  141074. /**
  141075. * Creates a default light for the scene.
  141076. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  141077. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  141078. */
  141079. createDefaultLight(replace?: boolean): void;
  141080. /**
  141081. * Creates a default camera for the scene.
  141082. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  141083. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141084. * @param replace has default false, when true replaces the active camera in the scene
  141085. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  141086. */
  141087. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141088. /**
  141089. * Creates a default camera and a default light.
  141090. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  141091. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141092. * @param replace has the default false, when true replaces the active camera/light in the scene
  141093. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  141094. */
  141095. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141096. /**
  141097. * Creates a new sky box
  141098. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  141099. * @param environmentTexture defines the texture to use as environment texture
  141100. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  141101. * @param scale defines the overall scale of the skybox
  141102. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  141103. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  141104. * @returns a new mesh holding the sky box
  141105. */
  141106. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  141107. /**
  141108. * Creates a new environment
  141109. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  141110. * @param options defines the options you can use to configure the environment
  141111. * @returns the new EnvironmentHelper
  141112. */
  141113. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  141114. /**
  141115. * Creates a new VREXperienceHelper
  141116. * @see https://doc.babylonjs.com/how_to/webvr_helper
  141117. * @param webVROptions defines the options used to create the new VREXperienceHelper
  141118. * @returns a new VREXperienceHelper
  141119. */
  141120. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  141121. /**
  141122. * Creates a new WebXRDefaultExperience
  141123. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  141124. * @param options experience options
  141125. * @returns a promise for a new WebXRDefaultExperience
  141126. */
  141127. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  141128. }
  141129. }
  141130. declare module BABYLON {
  141131. /**
  141132. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  141133. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  141134. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  141135. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  141136. */
  141137. export class VideoDome extends TextureDome<VideoTexture> {
  141138. /**
  141139. * Define the video source as a Monoscopic panoramic 360 video.
  141140. */
  141141. static readonly MODE_MONOSCOPIC: number;
  141142. /**
  141143. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  141144. */
  141145. static readonly MODE_TOPBOTTOM: number;
  141146. /**
  141147. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  141148. */
  141149. static readonly MODE_SIDEBYSIDE: number;
  141150. /**
  141151. * Get the video texture associated with this video dome
  141152. */
  141153. get videoTexture(): VideoTexture;
  141154. /**
  141155. * Get the video mode of this dome
  141156. */
  141157. get videoMode(): number;
  141158. /**
  141159. * Set the video mode of this dome.
  141160. * @see textureMode
  141161. */
  141162. set videoMode(value: number);
  141163. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  141164. }
  141165. }
  141166. declare module BABYLON {
  141167. /**
  141168. * This class can be used to get instrumentation data from a Babylon engine
  141169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141170. */
  141171. export class EngineInstrumentation implements IDisposable {
  141172. /**
  141173. * Define the instrumented engine.
  141174. */
  141175. engine: Engine;
  141176. private _captureGPUFrameTime;
  141177. private _gpuFrameTimeToken;
  141178. private _gpuFrameTime;
  141179. private _captureShaderCompilationTime;
  141180. private _shaderCompilationTime;
  141181. private _onBeginFrameObserver;
  141182. private _onEndFrameObserver;
  141183. private _onBeforeShaderCompilationObserver;
  141184. private _onAfterShaderCompilationObserver;
  141185. /**
  141186. * Gets the perf counter used for GPU frame time
  141187. */
  141188. get gpuFrameTimeCounter(): PerfCounter;
  141189. /**
  141190. * Gets the GPU frame time capture status
  141191. */
  141192. get captureGPUFrameTime(): boolean;
  141193. /**
  141194. * Enable or disable the GPU frame time capture
  141195. */
  141196. set captureGPUFrameTime(value: boolean);
  141197. /**
  141198. * Gets the perf counter used for shader compilation time
  141199. */
  141200. get shaderCompilationTimeCounter(): PerfCounter;
  141201. /**
  141202. * Gets the shader compilation time capture status
  141203. */
  141204. get captureShaderCompilationTime(): boolean;
  141205. /**
  141206. * Enable or disable the shader compilation time capture
  141207. */
  141208. set captureShaderCompilationTime(value: boolean);
  141209. /**
  141210. * Instantiates a new engine instrumentation.
  141211. * This class can be used to get instrumentation data from a Babylon engine
  141212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141213. * @param engine Defines the engine to instrument
  141214. */
  141215. constructor(
  141216. /**
  141217. * Define the instrumented engine.
  141218. */
  141219. engine: Engine);
  141220. /**
  141221. * Dispose and release associated resources.
  141222. */
  141223. dispose(): void;
  141224. }
  141225. }
  141226. declare module BABYLON {
  141227. /**
  141228. * This class can be used to get instrumentation data from a Babylon engine
  141229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141230. */
  141231. export class SceneInstrumentation implements IDisposable {
  141232. /**
  141233. * Defines the scene to instrument
  141234. */
  141235. scene: Scene;
  141236. private _captureActiveMeshesEvaluationTime;
  141237. private _activeMeshesEvaluationTime;
  141238. private _captureRenderTargetsRenderTime;
  141239. private _renderTargetsRenderTime;
  141240. private _captureFrameTime;
  141241. private _frameTime;
  141242. private _captureRenderTime;
  141243. private _renderTime;
  141244. private _captureInterFrameTime;
  141245. private _interFrameTime;
  141246. private _captureParticlesRenderTime;
  141247. private _particlesRenderTime;
  141248. private _captureSpritesRenderTime;
  141249. private _spritesRenderTime;
  141250. private _capturePhysicsTime;
  141251. private _physicsTime;
  141252. private _captureAnimationsTime;
  141253. private _animationsTime;
  141254. private _captureCameraRenderTime;
  141255. private _cameraRenderTime;
  141256. private _onBeforeActiveMeshesEvaluationObserver;
  141257. private _onAfterActiveMeshesEvaluationObserver;
  141258. private _onBeforeRenderTargetsRenderObserver;
  141259. private _onAfterRenderTargetsRenderObserver;
  141260. private _onAfterRenderObserver;
  141261. private _onBeforeDrawPhaseObserver;
  141262. private _onAfterDrawPhaseObserver;
  141263. private _onBeforeAnimationsObserver;
  141264. private _onBeforeParticlesRenderingObserver;
  141265. private _onAfterParticlesRenderingObserver;
  141266. private _onBeforeSpritesRenderingObserver;
  141267. private _onAfterSpritesRenderingObserver;
  141268. private _onBeforePhysicsObserver;
  141269. private _onAfterPhysicsObserver;
  141270. private _onAfterAnimationsObserver;
  141271. private _onBeforeCameraRenderObserver;
  141272. private _onAfterCameraRenderObserver;
  141273. /**
  141274. * Gets the perf counter used for active meshes evaluation time
  141275. */
  141276. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  141277. /**
  141278. * Gets the active meshes evaluation time capture status
  141279. */
  141280. get captureActiveMeshesEvaluationTime(): boolean;
  141281. /**
  141282. * Enable or disable the active meshes evaluation time capture
  141283. */
  141284. set captureActiveMeshesEvaluationTime(value: boolean);
  141285. /**
  141286. * Gets the perf counter used for render targets render time
  141287. */
  141288. get renderTargetsRenderTimeCounter(): PerfCounter;
  141289. /**
  141290. * Gets the render targets render time capture status
  141291. */
  141292. get captureRenderTargetsRenderTime(): boolean;
  141293. /**
  141294. * Enable or disable the render targets render time capture
  141295. */
  141296. set captureRenderTargetsRenderTime(value: boolean);
  141297. /**
  141298. * Gets the perf counter used for particles render time
  141299. */
  141300. get particlesRenderTimeCounter(): PerfCounter;
  141301. /**
  141302. * Gets the particles render time capture status
  141303. */
  141304. get captureParticlesRenderTime(): boolean;
  141305. /**
  141306. * Enable or disable the particles render time capture
  141307. */
  141308. set captureParticlesRenderTime(value: boolean);
  141309. /**
  141310. * Gets the perf counter used for sprites render time
  141311. */
  141312. get spritesRenderTimeCounter(): PerfCounter;
  141313. /**
  141314. * Gets the sprites render time capture status
  141315. */
  141316. get captureSpritesRenderTime(): boolean;
  141317. /**
  141318. * Enable or disable the sprites render time capture
  141319. */
  141320. set captureSpritesRenderTime(value: boolean);
  141321. /**
  141322. * Gets the perf counter used for physics time
  141323. */
  141324. get physicsTimeCounter(): PerfCounter;
  141325. /**
  141326. * Gets the physics time capture status
  141327. */
  141328. get capturePhysicsTime(): boolean;
  141329. /**
  141330. * Enable or disable the physics time capture
  141331. */
  141332. set capturePhysicsTime(value: boolean);
  141333. /**
  141334. * Gets the perf counter used for animations time
  141335. */
  141336. get animationsTimeCounter(): PerfCounter;
  141337. /**
  141338. * Gets the animations time capture status
  141339. */
  141340. get captureAnimationsTime(): boolean;
  141341. /**
  141342. * Enable or disable the animations time capture
  141343. */
  141344. set captureAnimationsTime(value: boolean);
  141345. /**
  141346. * Gets the perf counter used for frame time capture
  141347. */
  141348. get frameTimeCounter(): PerfCounter;
  141349. /**
  141350. * Gets the frame time capture status
  141351. */
  141352. get captureFrameTime(): boolean;
  141353. /**
  141354. * Enable or disable the frame time capture
  141355. */
  141356. set captureFrameTime(value: boolean);
  141357. /**
  141358. * Gets the perf counter used for inter-frames time capture
  141359. */
  141360. get interFrameTimeCounter(): PerfCounter;
  141361. /**
  141362. * Gets the inter-frames time capture status
  141363. */
  141364. get captureInterFrameTime(): boolean;
  141365. /**
  141366. * Enable or disable the inter-frames time capture
  141367. */
  141368. set captureInterFrameTime(value: boolean);
  141369. /**
  141370. * Gets the perf counter used for render time capture
  141371. */
  141372. get renderTimeCounter(): PerfCounter;
  141373. /**
  141374. * Gets the render time capture status
  141375. */
  141376. get captureRenderTime(): boolean;
  141377. /**
  141378. * Enable or disable the render time capture
  141379. */
  141380. set captureRenderTime(value: boolean);
  141381. /**
  141382. * Gets the perf counter used for camera render time capture
  141383. */
  141384. get cameraRenderTimeCounter(): PerfCounter;
  141385. /**
  141386. * Gets the camera render time capture status
  141387. */
  141388. get captureCameraRenderTime(): boolean;
  141389. /**
  141390. * Enable or disable the camera render time capture
  141391. */
  141392. set captureCameraRenderTime(value: boolean);
  141393. /**
  141394. * Gets the perf counter used for draw calls
  141395. */
  141396. get drawCallsCounter(): PerfCounter;
  141397. /**
  141398. * Instantiates a new scene instrumentation.
  141399. * This class can be used to get instrumentation data from a Babylon engine
  141400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141401. * @param scene Defines the scene to instrument
  141402. */
  141403. constructor(
  141404. /**
  141405. * Defines the scene to instrument
  141406. */
  141407. scene: Scene);
  141408. /**
  141409. * Dispose and release associated resources.
  141410. */
  141411. dispose(): void;
  141412. }
  141413. }
  141414. declare module BABYLON {
  141415. /** @hidden */
  141416. export var glowMapGenerationPixelShader: {
  141417. name: string;
  141418. shader: string;
  141419. };
  141420. }
  141421. declare module BABYLON {
  141422. /** @hidden */
  141423. export var glowMapGenerationVertexShader: {
  141424. name: string;
  141425. shader: string;
  141426. };
  141427. }
  141428. declare module BABYLON {
  141429. /**
  141430. * Effect layer options. This helps customizing the behaviour
  141431. * of the effect layer.
  141432. */
  141433. export interface IEffectLayerOptions {
  141434. /**
  141435. * Multiplication factor apply to the canvas size to compute the render target size
  141436. * used to generated the objects (the smaller the faster).
  141437. */
  141438. mainTextureRatio: number;
  141439. /**
  141440. * Enforces a fixed size texture to ensure effect stability across devices.
  141441. */
  141442. mainTextureFixedSize?: number;
  141443. /**
  141444. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141445. */
  141446. alphaBlendingMode: number;
  141447. /**
  141448. * The camera attached to the layer.
  141449. */
  141450. camera: Nullable<Camera>;
  141451. /**
  141452. * The rendering group to draw the layer in.
  141453. */
  141454. renderingGroupId: number;
  141455. }
  141456. /**
  141457. * The effect layer Helps adding post process effect blended with the main pass.
  141458. *
  141459. * This can be for instance use to generate glow or higlight effects on the scene.
  141460. *
  141461. * The effect layer class can not be used directly and is intented to inherited from to be
  141462. * customized per effects.
  141463. */
  141464. export abstract class EffectLayer {
  141465. private _vertexBuffers;
  141466. private _indexBuffer;
  141467. private _cachedDefines;
  141468. private _effectLayerMapGenerationEffect;
  141469. private _effectLayerOptions;
  141470. private _mergeEffect;
  141471. protected _scene: Scene;
  141472. protected _engine: Engine;
  141473. protected _maxSize: number;
  141474. protected _mainTextureDesiredSize: ISize;
  141475. protected _mainTexture: RenderTargetTexture;
  141476. protected _shouldRender: boolean;
  141477. protected _postProcesses: PostProcess[];
  141478. protected _textures: BaseTexture[];
  141479. protected _emissiveTextureAndColor: {
  141480. texture: Nullable<BaseTexture>;
  141481. color: Color4;
  141482. };
  141483. /**
  141484. * The name of the layer
  141485. */
  141486. name: string;
  141487. /**
  141488. * The clear color of the texture used to generate the glow map.
  141489. */
  141490. neutralColor: Color4;
  141491. /**
  141492. * Specifies whether the highlight layer is enabled or not.
  141493. */
  141494. isEnabled: boolean;
  141495. /**
  141496. * Gets the camera attached to the layer.
  141497. */
  141498. get camera(): Nullable<Camera>;
  141499. /**
  141500. * Gets the rendering group id the layer should render in.
  141501. */
  141502. get renderingGroupId(): number;
  141503. set renderingGroupId(renderingGroupId: number);
  141504. /**
  141505. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141506. */
  141507. disableBoundingBoxesFromEffectLayer: boolean;
  141508. /**
  141509. * An event triggered when the effect layer has been disposed.
  141510. */
  141511. onDisposeObservable: Observable<EffectLayer>;
  141512. /**
  141513. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141514. */
  141515. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141516. /**
  141517. * An event triggered when the generated texture is being merged in the scene.
  141518. */
  141519. onBeforeComposeObservable: Observable<EffectLayer>;
  141520. /**
  141521. * An event triggered when the mesh is rendered into the effect render target.
  141522. */
  141523. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141524. /**
  141525. * An event triggered after the mesh has been rendered into the effect render target.
  141526. */
  141527. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141528. /**
  141529. * An event triggered when the generated texture has been merged in the scene.
  141530. */
  141531. onAfterComposeObservable: Observable<EffectLayer>;
  141532. /**
  141533. * An event triggered when the efffect layer changes its size.
  141534. */
  141535. onSizeChangedObservable: Observable<EffectLayer>;
  141536. /** @hidden */
  141537. static _SceneComponentInitialization: (scene: Scene) => void;
  141538. /**
  141539. * Instantiates a new effect Layer and references it in the scene.
  141540. * @param name The name of the layer
  141541. * @param scene The scene to use the layer in
  141542. */
  141543. constructor(
  141544. /** The Friendly of the effect in the scene */
  141545. name: string, scene: Scene);
  141546. /**
  141547. * Get the effect name of the layer.
  141548. * @return The effect name
  141549. */
  141550. abstract getEffectName(): string;
  141551. /**
  141552. * Checks for the readiness of the element composing the layer.
  141553. * @param subMesh the mesh to check for
  141554. * @param useInstances specify whether or not to use instances to render the mesh
  141555. * @return true if ready otherwise, false
  141556. */
  141557. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141558. /**
  141559. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141560. * @returns true if the effect requires stencil during the main canvas render pass.
  141561. */
  141562. abstract needStencil(): boolean;
  141563. /**
  141564. * Create the merge effect. This is the shader use to blit the information back
  141565. * to the main canvas at the end of the scene rendering.
  141566. * @returns The effect containing the shader used to merge the effect on the main canvas
  141567. */
  141568. protected abstract _createMergeEffect(): Effect;
  141569. /**
  141570. * Creates the render target textures and post processes used in the effect layer.
  141571. */
  141572. protected abstract _createTextureAndPostProcesses(): void;
  141573. /**
  141574. * Implementation specific of rendering the generating effect on the main canvas.
  141575. * @param effect The effect used to render through
  141576. */
  141577. protected abstract _internalRender(effect: Effect): void;
  141578. /**
  141579. * Sets the required values for both the emissive texture and and the main color.
  141580. */
  141581. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141582. /**
  141583. * Free any resources and references associated to a mesh.
  141584. * Internal use
  141585. * @param mesh The mesh to free.
  141586. */
  141587. abstract _disposeMesh(mesh: Mesh): void;
  141588. /**
  141589. * Serializes this layer (Glow or Highlight for example)
  141590. * @returns a serialized layer object
  141591. */
  141592. abstract serialize?(): any;
  141593. /**
  141594. * Initializes the effect layer with the required options.
  141595. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141596. */
  141597. protected _init(options: Partial<IEffectLayerOptions>): void;
  141598. /**
  141599. * Generates the index buffer of the full screen quad blending to the main canvas.
  141600. */
  141601. private _generateIndexBuffer;
  141602. /**
  141603. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141604. */
  141605. private _generateVertexBuffer;
  141606. /**
  141607. * Sets the main texture desired size which is the closest power of two
  141608. * of the engine canvas size.
  141609. */
  141610. private _setMainTextureSize;
  141611. /**
  141612. * Creates the main texture for the effect layer.
  141613. */
  141614. protected _createMainTexture(): void;
  141615. /**
  141616. * Adds specific effects defines.
  141617. * @param defines The defines to add specifics to.
  141618. */
  141619. protected _addCustomEffectDefines(defines: string[]): void;
  141620. /**
  141621. * Checks for the readiness of the element composing the layer.
  141622. * @param subMesh the mesh to check for
  141623. * @param useInstances specify whether or not to use instances to render the mesh
  141624. * @param emissiveTexture the associated emissive texture used to generate the glow
  141625. * @return true if ready otherwise, false
  141626. */
  141627. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141628. /**
  141629. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141630. */
  141631. render(): void;
  141632. /**
  141633. * Determine if a given mesh will be used in the current effect.
  141634. * @param mesh mesh to test
  141635. * @returns true if the mesh will be used
  141636. */
  141637. hasMesh(mesh: AbstractMesh): boolean;
  141638. /**
  141639. * Returns true if the layer contains information to display, otherwise false.
  141640. * @returns true if the glow layer should be rendered
  141641. */
  141642. shouldRender(): boolean;
  141643. /**
  141644. * Returns true if the mesh should render, otherwise false.
  141645. * @param mesh The mesh to render
  141646. * @returns true if it should render otherwise false
  141647. */
  141648. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141649. /**
  141650. * Returns true if the mesh can be rendered, otherwise false.
  141651. * @param mesh The mesh to render
  141652. * @param material The material used on the mesh
  141653. * @returns true if it can be rendered otherwise false
  141654. */
  141655. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141656. /**
  141657. * Returns true if the mesh should render, otherwise false.
  141658. * @param mesh The mesh to render
  141659. * @returns true if it should render otherwise false
  141660. */
  141661. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141662. /**
  141663. * Renders the submesh passed in parameter to the generation map.
  141664. */
  141665. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141666. /**
  141667. * Defines whether the current material of the mesh should be use to render the effect.
  141668. * @param mesh defines the current mesh to render
  141669. */
  141670. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141671. /**
  141672. * Rebuild the required buffers.
  141673. * @hidden Internal use only.
  141674. */
  141675. _rebuild(): void;
  141676. /**
  141677. * Dispose only the render target textures and post process.
  141678. */
  141679. private _disposeTextureAndPostProcesses;
  141680. /**
  141681. * Dispose the highlight layer and free resources.
  141682. */
  141683. dispose(): void;
  141684. /**
  141685. * Gets the class name of the effect layer
  141686. * @returns the string with the class name of the effect layer
  141687. */
  141688. getClassName(): string;
  141689. /**
  141690. * Creates an effect layer from parsed effect layer data
  141691. * @param parsedEffectLayer defines effect layer data
  141692. * @param scene defines the current scene
  141693. * @param rootUrl defines the root URL containing the effect layer information
  141694. * @returns a parsed effect Layer
  141695. */
  141696. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141697. }
  141698. }
  141699. declare module BABYLON {
  141700. interface AbstractScene {
  141701. /**
  141702. * The list of effect layers (highlights/glow) added to the scene
  141703. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141704. * @see https://doc.babylonjs.com/how_to/glow_layer
  141705. */
  141706. effectLayers: Array<EffectLayer>;
  141707. /**
  141708. * Removes the given effect layer from this scene.
  141709. * @param toRemove defines the effect layer to remove
  141710. * @returns the index of the removed effect layer
  141711. */
  141712. removeEffectLayer(toRemove: EffectLayer): number;
  141713. /**
  141714. * Adds the given effect layer to this scene
  141715. * @param newEffectLayer defines the effect layer to add
  141716. */
  141717. addEffectLayer(newEffectLayer: EffectLayer): void;
  141718. }
  141719. /**
  141720. * Defines the layer scene component responsible to manage any effect layers
  141721. * in a given scene.
  141722. */
  141723. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141724. /**
  141725. * The component name helpfull to identify the component in the list of scene components.
  141726. */
  141727. readonly name: string;
  141728. /**
  141729. * The scene the component belongs to.
  141730. */
  141731. scene: Scene;
  141732. private _engine;
  141733. private _renderEffects;
  141734. private _needStencil;
  141735. private _previousStencilState;
  141736. /**
  141737. * Creates a new instance of the component for the given scene
  141738. * @param scene Defines the scene to register the component in
  141739. */
  141740. constructor(scene: Scene);
  141741. /**
  141742. * Registers the component in a given scene
  141743. */
  141744. register(): void;
  141745. /**
  141746. * Rebuilds the elements related to this component in case of
  141747. * context lost for instance.
  141748. */
  141749. rebuild(): void;
  141750. /**
  141751. * Serializes the component data to the specified json object
  141752. * @param serializationObject The object to serialize to
  141753. */
  141754. serialize(serializationObject: any): void;
  141755. /**
  141756. * Adds all the elements from the container to the scene
  141757. * @param container the container holding the elements
  141758. */
  141759. addFromContainer(container: AbstractScene): void;
  141760. /**
  141761. * Removes all the elements in the container from the scene
  141762. * @param container contains the elements to remove
  141763. * @param dispose if the removed element should be disposed (default: false)
  141764. */
  141765. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141766. /**
  141767. * Disposes the component and the associated ressources.
  141768. */
  141769. dispose(): void;
  141770. private _isReadyForMesh;
  141771. private _renderMainTexture;
  141772. private _setStencil;
  141773. private _setStencilBack;
  141774. private _draw;
  141775. private _drawCamera;
  141776. private _drawRenderingGroup;
  141777. }
  141778. }
  141779. declare module BABYLON {
  141780. /** @hidden */
  141781. export var glowMapMergePixelShader: {
  141782. name: string;
  141783. shader: string;
  141784. };
  141785. }
  141786. declare module BABYLON {
  141787. /** @hidden */
  141788. export var glowMapMergeVertexShader: {
  141789. name: string;
  141790. shader: string;
  141791. };
  141792. }
  141793. declare module BABYLON {
  141794. interface AbstractScene {
  141795. /**
  141796. * Return a the first highlight layer of the scene with a given name.
  141797. * @param name The name of the highlight layer to look for.
  141798. * @return The highlight layer if found otherwise null.
  141799. */
  141800. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141801. }
  141802. /**
  141803. * Glow layer options. This helps customizing the behaviour
  141804. * of the glow layer.
  141805. */
  141806. export interface IGlowLayerOptions {
  141807. /**
  141808. * Multiplication factor apply to the canvas size to compute the render target size
  141809. * used to generated the glowing objects (the smaller the faster).
  141810. */
  141811. mainTextureRatio: number;
  141812. /**
  141813. * Enforces a fixed size texture to ensure resize independant blur.
  141814. */
  141815. mainTextureFixedSize?: number;
  141816. /**
  141817. * How big is the kernel of the blur texture.
  141818. */
  141819. blurKernelSize: number;
  141820. /**
  141821. * The camera attached to the layer.
  141822. */
  141823. camera: Nullable<Camera>;
  141824. /**
  141825. * Enable MSAA by chosing the number of samples.
  141826. */
  141827. mainTextureSamples?: number;
  141828. /**
  141829. * The rendering group to draw the layer in.
  141830. */
  141831. renderingGroupId: number;
  141832. }
  141833. /**
  141834. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141835. *
  141836. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141837. *
  141838. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141839. */
  141840. export class GlowLayer extends EffectLayer {
  141841. /**
  141842. * Effect Name of the layer.
  141843. */
  141844. static readonly EffectName: string;
  141845. /**
  141846. * The default blur kernel size used for the glow.
  141847. */
  141848. static DefaultBlurKernelSize: number;
  141849. /**
  141850. * The default texture size ratio used for the glow.
  141851. */
  141852. static DefaultTextureRatio: number;
  141853. /**
  141854. * Sets the kernel size of the blur.
  141855. */
  141856. set blurKernelSize(value: number);
  141857. /**
  141858. * Gets the kernel size of the blur.
  141859. */
  141860. get blurKernelSize(): number;
  141861. /**
  141862. * Sets the glow intensity.
  141863. */
  141864. set intensity(value: number);
  141865. /**
  141866. * Gets the glow intensity.
  141867. */
  141868. get intensity(): number;
  141869. private _options;
  141870. private _intensity;
  141871. private _horizontalBlurPostprocess1;
  141872. private _verticalBlurPostprocess1;
  141873. private _horizontalBlurPostprocess2;
  141874. private _verticalBlurPostprocess2;
  141875. private _blurTexture1;
  141876. private _blurTexture2;
  141877. private _postProcesses1;
  141878. private _postProcesses2;
  141879. private _includedOnlyMeshes;
  141880. private _excludedMeshes;
  141881. private _meshesUsingTheirOwnMaterials;
  141882. /**
  141883. * Callback used to let the user override the color selection on a per mesh basis
  141884. */
  141885. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141886. /**
  141887. * Callback used to let the user override the texture selection on a per mesh basis
  141888. */
  141889. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141890. /**
  141891. * Instantiates a new glow Layer and references it to the scene.
  141892. * @param name The name of the layer
  141893. * @param scene The scene to use the layer in
  141894. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141895. */
  141896. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141897. /**
  141898. * Get the effect name of the layer.
  141899. * @return The effect name
  141900. */
  141901. getEffectName(): string;
  141902. /**
  141903. * Create the merge effect. This is the shader use to blit the information back
  141904. * to the main canvas at the end of the scene rendering.
  141905. */
  141906. protected _createMergeEffect(): Effect;
  141907. /**
  141908. * Creates the render target textures and post processes used in the glow layer.
  141909. */
  141910. protected _createTextureAndPostProcesses(): void;
  141911. /**
  141912. * Checks for the readiness of the element composing the layer.
  141913. * @param subMesh the mesh to check for
  141914. * @param useInstances specify wether or not to use instances to render the mesh
  141915. * @param emissiveTexture the associated emissive texture used to generate the glow
  141916. * @return true if ready otherwise, false
  141917. */
  141918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141919. /**
  141920. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141921. */
  141922. needStencil(): boolean;
  141923. /**
  141924. * Returns true if the mesh can be rendered, otherwise false.
  141925. * @param mesh The mesh to render
  141926. * @param material The material used on the mesh
  141927. * @returns true if it can be rendered otherwise false
  141928. */
  141929. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141930. /**
  141931. * Implementation specific of rendering the generating effect on the main canvas.
  141932. * @param effect The effect used to render through
  141933. */
  141934. protected _internalRender(effect: Effect): void;
  141935. /**
  141936. * Sets the required values for both the emissive texture and and the main color.
  141937. */
  141938. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141939. /**
  141940. * Returns true if the mesh should render, otherwise false.
  141941. * @param mesh The mesh to render
  141942. * @returns true if it should render otherwise false
  141943. */
  141944. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141945. /**
  141946. * Adds specific effects defines.
  141947. * @param defines The defines to add specifics to.
  141948. */
  141949. protected _addCustomEffectDefines(defines: string[]): void;
  141950. /**
  141951. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141952. * @param mesh The mesh to exclude from the glow layer
  141953. */
  141954. addExcludedMesh(mesh: Mesh): void;
  141955. /**
  141956. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141957. * @param mesh The mesh to remove
  141958. */
  141959. removeExcludedMesh(mesh: Mesh): void;
  141960. /**
  141961. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141962. * @param mesh The mesh to include in the glow layer
  141963. */
  141964. addIncludedOnlyMesh(mesh: Mesh): void;
  141965. /**
  141966. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141967. * @param mesh The mesh to remove
  141968. */
  141969. removeIncludedOnlyMesh(mesh: Mesh): void;
  141970. /**
  141971. * Determine if a given mesh will be used in the glow layer
  141972. * @param mesh The mesh to test
  141973. * @returns true if the mesh will be highlighted by the current glow layer
  141974. */
  141975. hasMesh(mesh: AbstractMesh): boolean;
  141976. /**
  141977. * Defines whether the current material of the mesh should be use to render the effect.
  141978. * @param mesh defines the current mesh to render
  141979. */
  141980. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141981. /**
  141982. * Add a mesh to be rendered through its own material and not with emissive only.
  141983. * @param mesh The mesh for which we need to use its material
  141984. */
  141985. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141986. /**
  141987. * Remove a mesh from being rendered through its own material and not with emissive only.
  141988. * @param mesh The mesh for which we need to not use its material
  141989. */
  141990. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141991. /**
  141992. * Free any resources and references associated to a mesh.
  141993. * Internal use
  141994. * @param mesh The mesh to free.
  141995. * @hidden
  141996. */
  141997. _disposeMesh(mesh: Mesh): void;
  141998. /**
  141999. * Gets the class name of the effect layer
  142000. * @returns the string with the class name of the effect layer
  142001. */
  142002. getClassName(): string;
  142003. /**
  142004. * Serializes this glow layer
  142005. * @returns a serialized glow layer object
  142006. */
  142007. serialize(): any;
  142008. /**
  142009. * Creates a Glow Layer from parsed glow layer data
  142010. * @param parsedGlowLayer defines glow layer data
  142011. * @param scene defines the current scene
  142012. * @param rootUrl defines the root URL containing the glow layer information
  142013. * @returns a parsed Glow Layer
  142014. */
  142015. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  142016. }
  142017. }
  142018. declare module BABYLON {
  142019. /** @hidden */
  142020. export var glowBlurPostProcessPixelShader: {
  142021. name: string;
  142022. shader: string;
  142023. };
  142024. }
  142025. declare module BABYLON {
  142026. interface AbstractScene {
  142027. /**
  142028. * Return a the first highlight layer of the scene with a given name.
  142029. * @param name The name of the highlight layer to look for.
  142030. * @return The highlight layer if found otherwise null.
  142031. */
  142032. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  142033. }
  142034. /**
  142035. * Highlight layer options. This helps customizing the behaviour
  142036. * of the highlight layer.
  142037. */
  142038. export interface IHighlightLayerOptions {
  142039. /**
  142040. * Multiplication factor apply to the canvas size to compute the render target size
  142041. * used to generated the glowing objects (the smaller the faster).
  142042. */
  142043. mainTextureRatio: number;
  142044. /**
  142045. * Enforces a fixed size texture to ensure resize independant blur.
  142046. */
  142047. mainTextureFixedSize?: number;
  142048. /**
  142049. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  142050. * of the picture to blur (the smaller the faster).
  142051. */
  142052. blurTextureSizeRatio: number;
  142053. /**
  142054. * How big in texel of the blur texture is the vertical blur.
  142055. */
  142056. blurVerticalSize: number;
  142057. /**
  142058. * How big in texel of the blur texture is the horizontal blur.
  142059. */
  142060. blurHorizontalSize: number;
  142061. /**
  142062. * Alpha blending mode used to apply the blur. Default is combine.
  142063. */
  142064. alphaBlendingMode: number;
  142065. /**
  142066. * The camera attached to the layer.
  142067. */
  142068. camera: Nullable<Camera>;
  142069. /**
  142070. * Should we display highlight as a solid stroke?
  142071. */
  142072. isStroke?: boolean;
  142073. /**
  142074. * The rendering group to draw the layer in.
  142075. */
  142076. renderingGroupId: number;
  142077. }
  142078. /**
  142079. * The highlight layer Helps adding a glow effect around a mesh.
  142080. *
  142081. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  142082. * glowy meshes to your scene.
  142083. *
  142084. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  142085. */
  142086. export class HighlightLayer extends EffectLayer {
  142087. name: string;
  142088. /**
  142089. * Effect Name of the highlight layer.
  142090. */
  142091. static readonly EffectName: string;
  142092. /**
  142093. * The neutral color used during the preparation of the glow effect.
  142094. * This is black by default as the blend operation is a blend operation.
  142095. */
  142096. static NeutralColor: Color4;
  142097. /**
  142098. * Stencil value used for glowing meshes.
  142099. */
  142100. static GlowingMeshStencilReference: number;
  142101. /**
  142102. * Stencil value used for the other meshes in the scene.
  142103. */
  142104. static NormalMeshStencilReference: number;
  142105. /**
  142106. * Specifies whether or not the inner glow is ACTIVE in the layer.
  142107. */
  142108. innerGlow: boolean;
  142109. /**
  142110. * Specifies whether or not the outer glow is ACTIVE in the layer.
  142111. */
  142112. outerGlow: boolean;
  142113. /**
  142114. * Specifies the horizontal size of the blur.
  142115. */
  142116. set blurHorizontalSize(value: number);
  142117. /**
  142118. * Specifies the vertical size of the blur.
  142119. */
  142120. set blurVerticalSize(value: number);
  142121. /**
  142122. * Gets the horizontal size of the blur.
  142123. */
  142124. get blurHorizontalSize(): number;
  142125. /**
  142126. * Gets the vertical size of the blur.
  142127. */
  142128. get blurVerticalSize(): number;
  142129. /**
  142130. * An event triggered when the highlight layer is being blurred.
  142131. */
  142132. onBeforeBlurObservable: Observable<HighlightLayer>;
  142133. /**
  142134. * An event triggered when the highlight layer has been blurred.
  142135. */
  142136. onAfterBlurObservable: Observable<HighlightLayer>;
  142137. private _instanceGlowingMeshStencilReference;
  142138. private _options;
  142139. private _downSamplePostprocess;
  142140. private _horizontalBlurPostprocess;
  142141. private _verticalBlurPostprocess;
  142142. private _blurTexture;
  142143. private _meshes;
  142144. private _excludedMeshes;
  142145. /**
  142146. * Instantiates a new highlight Layer and references it to the scene..
  142147. * @param name The name of the layer
  142148. * @param scene The scene to use the layer in
  142149. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  142150. */
  142151. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  142152. /**
  142153. * Get the effect name of the layer.
  142154. * @return The effect name
  142155. */
  142156. getEffectName(): string;
  142157. /**
  142158. * Create the merge effect. This is the shader use to blit the information back
  142159. * to the main canvas at the end of the scene rendering.
  142160. */
  142161. protected _createMergeEffect(): Effect;
  142162. /**
  142163. * Creates the render target textures and post processes used in the highlight layer.
  142164. */
  142165. protected _createTextureAndPostProcesses(): void;
  142166. /**
  142167. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  142168. */
  142169. needStencil(): boolean;
  142170. /**
  142171. * Checks for the readiness of the element composing the layer.
  142172. * @param subMesh the mesh to check for
  142173. * @param useInstances specify wether or not to use instances to render the mesh
  142174. * @param emissiveTexture the associated emissive texture used to generate the glow
  142175. * @return true if ready otherwise, false
  142176. */
  142177. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142178. /**
  142179. * Implementation specific of rendering the generating effect on the main canvas.
  142180. * @param effect The effect used to render through
  142181. */
  142182. protected _internalRender(effect: Effect): void;
  142183. /**
  142184. * Returns true if the layer contains information to display, otherwise false.
  142185. */
  142186. shouldRender(): boolean;
  142187. /**
  142188. * Returns true if the mesh should render, otherwise false.
  142189. * @param mesh The mesh to render
  142190. * @returns true if it should render otherwise false
  142191. */
  142192. protected _shouldRenderMesh(mesh: Mesh): boolean;
  142193. /**
  142194. * Returns true if the mesh can be rendered, otherwise false.
  142195. * @param mesh The mesh to render
  142196. * @param material The material used on the mesh
  142197. * @returns true if it can be rendered otherwise false
  142198. */
  142199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  142200. /**
  142201. * Adds specific effects defines.
  142202. * @param defines The defines to add specifics to.
  142203. */
  142204. protected _addCustomEffectDefines(defines: string[]): void;
  142205. /**
  142206. * Sets the required values for both the emissive texture and and the main color.
  142207. */
  142208. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  142209. /**
  142210. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  142211. * @param mesh The mesh to exclude from the highlight layer
  142212. */
  142213. addExcludedMesh(mesh: Mesh): void;
  142214. /**
  142215. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  142216. * @param mesh The mesh to highlight
  142217. */
  142218. removeExcludedMesh(mesh: Mesh): void;
  142219. /**
  142220. * Determine if a given mesh will be highlighted by the current HighlightLayer
  142221. * @param mesh mesh to test
  142222. * @returns true if the mesh will be highlighted by the current HighlightLayer
  142223. */
  142224. hasMesh(mesh: AbstractMesh): boolean;
  142225. /**
  142226. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  142227. * @param mesh The mesh to highlight
  142228. * @param color The color of the highlight
  142229. * @param glowEmissiveOnly Extract the glow from the emissive texture
  142230. */
  142231. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  142232. /**
  142233. * Remove a mesh from the highlight layer in order to make it stop glowing.
  142234. * @param mesh The mesh to highlight
  142235. */
  142236. removeMesh(mesh: Mesh): void;
  142237. /**
  142238. * Remove all the meshes currently referenced in the highlight layer
  142239. */
  142240. removeAllMeshes(): void;
  142241. /**
  142242. * Force the stencil to the normal expected value for none glowing parts
  142243. */
  142244. private _defaultStencilReference;
  142245. /**
  142246. * Free any resources and references associated to a mesh.
  142247. * Internal use
  142248. * @param mesh The mesh to free.
  142249. * @hidden
  142250. */
  142251. _disposeMesh(mesh: Mesh): void;
  142252. /**
  142253. * Dispose the highlight layer and free resources.
  142254. */
  142255. dispose(): void;
  142256. /**
  142257. * Gets the class name of the effect layer
  142258. * @returns the string with the class name of the effect layer
  142259. */
  142260. getClassName(): string;
  142261. /**
  142262. * Serializes this Highlight layer
  142263. * @returns a serialized Highlight layer object
  142264. */
  142265. serialize(): any;
  142266. /**
  142267. * Creates a Highlight layer from parsed Highlight layer data
  142268. * @param parsedHightlightLayer defines the Highlight layer data
  142269. * @param scene defines the current scene
  142270. * @param rootUrl defines the root URL containing the Highlight layer information
  142271. * @returns a parsed Highlight layer
  142272. */
  142273. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  142274. }
  142275. }
  142276. declare module BABYLON {
  142277. interface AbstractScene {
  142278. /**
  142279. * The list of layers (background and foreground) of the scene
  142280. */
  142281. layers: Array<Layer>;
  142282. }
  142283. /**
  142284. * Defines the layer scene component responsible to manage any layers
  142285. * in a given scene.
  142286. */
  142287. export class LayerSceneComponent implements ISceneComponent {
  142288. /**
  142289. * The component name helpfull to identify the component in the list of scene components.
  142290. */
  142291. readonly name: string;
  142292. /**
  142293. * The scene the component belongs to.
  142294. */
  142295. scene: Scene;
  142296. private _engine;
  142297. /**
  142298. * Creates a new instance of the component for the given scene
  142299. * @param scene Defines the scene to register the component in
  142300. */
  142301. constructor(scene: Scene);
  142302. /**
  142303. * Registers the component in a given scene
  142304. */
  142305. register(): void;
  142306. /**
  142307. * Rebuilds the elements related to this component in case of
  142308. * context lost for instance.
  142309. */
  142310. rebuild(): void;
  142311. /**
  142312. * Disposes the component and the associated ressources.
  142313. */
  142314. dispose(): void;
  142315. private _draw;
  142316. private _drawCameraPredicate;
  142317. private _drawCameraBackground;
  142318. private _drawCameraForeground;
  142319. private _drawRenderTargetPredicate;
  142320. private _drawRenderTargetBackground;
  142321. private _drawRenderTargetForeground;
  142322. /**
  142323. * Adds all the elements from the container to the scene
  142324. * @param container the container holding the elements
  142325. */
  142326. addFromContainer(container: AbstractScene): void;
  142327. /**
  142328. * Removes all the elements in the container from the scene
  142329. * @param container contains the elements to remove
  142330. * @param dispose if the removed element should be disposed (default: false)
  142331. */
  142332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142333. }
  142334. }
  142335. declare module BABYLON {
  142336. /** @hidden */
  142337. export var layerPixelShader: {
  142338. name: string;
  142339. shader: string;
  142340. };
  142341. }
  142342. declare module BABYLON {
  142343. /** @hidden */
  142344. export var layerVertexShader: {
  142345. name: string;
  142346. shader: string;
  142347. };
  142348. }
  142349. declare module BABYLON {
  142350. /**
  142351. * This represents a full screen 2d layer.
  142352. * This can be useful to display a picture in the background of your scene for instance.
  142353. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142354. */
  142355. export class Layer {
  142356. /**
  142357. * Define the name of the layer.
  142358. */
  142359. name: string;
  142360. /**
  142361. * Define the texture the layer should display.
  142362. */
  142363. texture: Nullable<Texture>;
  142364. /**
  142365. * Is the layer in background or foreground.
  142366. */
  142367. isBackground: boolean;
  142368. /**
  142369. * Define the color of the layer (instead of texture).
  142370. */
  142371. color: Color4;
  142372. /**
  142373. * Define the scale of the layer in order to zoom in out of the texture.
  142374. */
  142375. scale: Vector2;
  142376. /**
  142377. * Define an offset for the layer in order to shift the texture.
  142378. */
  142379. offset: Vector2;
  142380. /**
  142381. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142382. */
  142383. alphaBlendingMode: number;
  142384. /**
  142385. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142386. * Alpha test will not mix with the background color in case of transparency.
  142387. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142388. */
  142389. alphaTest: boolean;
  142390. /**
  142391. * Define a mask to restrict the layer to only some of the scene cameras.
  142392. */
  142393. layerMask: number;
  142394. /**
  142395. * Define the list of render target the layer is visible into.
  142396. */
  142397. renderTargetTextures: RenderTargetTexture[];
  142398. /**
  142399. * Define if the layer is only used in renderTarget or if it also
  142400. * renders in the main frame buffer of the canvas.
  142401. */
  142402. renderOnlyInRenderTargetTextures: boolean;
  142403. private _scene;
  142404. private _vertexBuffers;
  142405. private _indexBuffer;
  142406. private _effect;
  142407. private _previousDefines;
  142408. /**
  142409. * An event triggered when the layer is disposed.
  142410. */
  142411. onDisposeObservable: Observable<Layer>;
  142412. private _onDisposeObserver;
  142413. /**
  142414. * Back compatibility with callback before the onDisposeObservable existed.
  142415. * The set callback will be triggered when the layer has been disposed.
  142416. */
  142417. set onDispose(callback: () => void);
  142418. /**
  142419. * An event triggered before rendering the scene
  142420. */
  142421. onBeforeRenderObservable: Observable<Layer>;
  142422. private _onBeforeRenderObserver;
  142423. /**
  142424. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142425. * The set callback will be triggered just before rendering the layer.
  142426. */
  142427. set onBeforeRender(callback: () => void);
  142428. /**
  142429. * An event triggered after rendering the scene
  142430. */
  142431. onAfterRenderObservable: Observable<Layer>;
  142432. private _onAfterRenderObserver;
  142433. /**
  142434. * Back compatibility with callback before the onAfterRenderObservable existed.
  142435. * The set callback will be triggered just after rendering the layer.
  142436. */
  142437. set onAfterRender(callback: () => void);
  142438. /**
  142439. * Instantiates a new layer.
  142440. * This represents a full screen 2d layer.
  142441. * This can be useful to display a picture in the background of your scene for instance.
  142442. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142443. * @param name Define the name of the layer in the scene
  142444. * @param imgUrl Define the url of the texture to display in the layer
  142445. * @param scene Define the scene the layer belongs to
  142446. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142447. * @param color Defines a color for the layer
  142448. */
  142449. constructor(
  142450. /**
  142451. * Define the name of the layer.
  142452. */
  142453. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142454. private _createIndexBuffer;
  142455. /** @hidden */
  142456. _rebuild(): void;
  142457. /**
  142458. * Renders the layer in the scene.
  142459. */
  142460. render(): void;
  142461. /**
  142462. * Disposes and releases the associated ressources.
  142463. */
  142464. dispose(): void;
  142465. }
  142466. }
  142467. declare module BABYLON {
  142468. /** @hidden */
  142469. export var lensFlarePixelShader: {
  142470. name: string;
  142471. shader: string;
  142472. };
  142473. }
  142474. declare module BABYLON {
  142475. /** @hidden */
  142476. export var lensFlareVertexShader: {
  142477. name: string;
  142478. shader: string;
  142479. };
  142480. }
  142481. declare module BABYLON {
  142482. /**
  142483. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142484. * It is usually composed of several `lensFlare`.
  142485. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142486. */
  142487. export class LensFlareSystem {
  142488. /**
  142489. * Define the name of the lens flare system
  142490. */
  142491. name: string;
  142492. /**
  142493. * List of lens flares used in this system.
  142494. */
  142495. lensFlares: LensFlare[];
  142496. /**
  142497. * Define a limit from the border the lens flare can be visible.
  142498. */
  142499. borderLimit: number;
  142500. /**
  142501. * Define a viewport border we do not want to see the lens flare in.
  142502. */
  142503. viewportBorder: number;
  142504. /**
  142505. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142506. */
  142507. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142508. /**
  142509. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142510. */
  142511. layerMask: number;
  142512. /**
  142513. * Define the id of the lens flare system in the scene.
  142514. * (equal to name by default)
  142515. */
  142516. id: string;
  142517. private _scene;
  142518. private _emitter;
  142519. private _vertexBuffers;
  142520. private _indexBuffer;
  142521. private _effect;
  142522. private _positionX;
  142523. private _positionY;
  142524. private _isEnabled;
  142525. /** @hidden */
  142526. static _SceneComponentInitialization: (scene: Scene) => void;
  142527. /**
  142528. * Instantiates a lens flare system.
  142529. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142530. * It is usually composed of several `lensFlare`.
  142531. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142532. * @param name Define the name of the lens flare system in the scene
  142533. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142534. * @param scene Define the scene the lens flare system belongs to
  142535. */
  142536. constructor(
  142537. /**
  142538. * Define the name of the lens flare system
  142539. */
  142540. name: string, emitter: any, scene: Scene);
  142541. /**
  142542. * Define if the lens flare system is enabled.
  142543. */
  142544. get isEnabled(): boolean;
  142545. set isEnabled(value: boolean);
  142546. /**
  142547. * Get the scene the effects belongs to.
  142548. * @returns the scene holding the lens flare system
  142549. */
  142550. getScene(): Scene;
  142551. /**
  142552. * Get the emitter of the lens flare system.
  142553. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142554. * @returns the emitter of the lens flare system
  142555. */
  142556. getEmitter(): any;
  142557. /**
  142558. * Set the emitter of the lens flare system.
  142559. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142560. * @param newEmitter Define the new emitter of the system
  142561. */
  142562. setEmitter(newEmitter: any): void;
  142563. /**
  142564. * Get the lens flare system emitter position.
  142565. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142566. * @returns the position
  142567. */
  142568. getEmitterPosition(): Vector3;
  142569. /**
  142570. * @hidden
  142571. */
  142572. computeEffectivePosition(globalViewport: Viewport): boolean;
  142573. /** @hidden */
  142574. _isVisible(): boolean;
  142575. /**
  142576. * @hidden
  142577. */
  142578. render(): boolean;
  142579. /**
  142580. * Dispose and release the lens flare with its associated resources.
  142581. */
  142582. dispose(): void;
  142583. /**
  142584. * Parse a lens flare system from a JSON repressentation
  142585. * @param parsedLensFlareSystem Define the JSON to parse
  142586. * @param scene Define the scene the parsed system should be instantiated in
  142587. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142588. * @returns the parsed system
  142589. */
  142590. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142591. /**
  142592. * Serialize the current Lens Flare System into a JSON representation.
  142593. * @returns the serialized JSON
  142594. */
  142595. serialize(): any;
  142596. }
  142597. }
  142598. declare module BABYLON {
  142599. /**
  142600. * This represents one of the lens effect in a `lensFlareSystem`.
  142601. * It controls one of the indiviual texture used in the effect.
  142602. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142603. */
  142604. export class LensFlare {
  142605. /**
  142606. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142607. */
  142608. size: number;
  142609. /**
  142610. * 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.
  142611. */
  142612. position: number;
  142613. /**
  142614. * Define the lens color.
  142615. */
  142616. color: Color3;
  142617. /**
  142618. * Define the lens texture.
  142619. */
  142620. texture: Nullable<Texture>;
  142621. /**
  142622. * Define the alpha mode to render this particular lens.
  142623. */
  142624. alphaMode: number;
  142625. private _system;
  142626. /**
  142627. * Creates a new Lens Flare.
  142628. * This represents one of the lens effect in a `lensFlareSystem`.
  142629. * It controls one of the indiviual texture used in the effect.
  142630. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142631. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142632. * @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.
  142633. * @param color Define the lens color
  142634. * @param imgUrl Define the lens texture url
  142635. * @param system Define the `lensFlareSystem` this flare is part of
  142636. * @returns The newly created Lens Flare
  142637. */
  142638. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142639. /**
  142640. * Instantiates a new Lens Flare.
  142641. * This represents one of the lens effect in a `lensFlareSystem`.
  142642. * It controls one of the indiviual texture used in the effect.
  142643. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142644. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142645. * @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.
  142646. * @param color Define the lens color
  142647. * @param imgUrl Define the lens texture url
  142648. * @param system Define the `lensFlareSystem` this flare is part of
  142649. */
  142650. constructor(
  142651. /**
  142652. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142653. */
  142654. size: number,
  142655. /**
  142656. * 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.
  142657. */
  142658. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142659. /**
  142660. * Dispose and release the lens flare with its associated resources.
  142661. */
  142662. dispose(): void;
  142663. }
  142664. }
  142665. declare module BABYLON {
  142666. interface AbstractScene {
  142667. /**
  142668. * The list of lens flare system added to the scene
  142669. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142670. */
  142671. lensFlareSystems: Array<LensFlareSystem>;
  142672. /**
  142673. * Removes the given lens flare system from this scene.
  142674. * @param toRemove The lens flare system to remove
  142675. * @returns The index of the removed lens flare system
  142676. */
  142677. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142678. /**
  142679. * Adds the given lens flare system to this scene
  142680. * @param newLensFlareSystem The lens flare system to add
  142681. */
  142682. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142683. /**
  142684. * Gets a lens flare system using its name
  142685. * @param name defines the name to look for
  142686. * @returns the lens flare system or null if not found
  142687. */
  142688. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142689. /**
  142690. * Gets a lens flare system using its id
  142691. * @param id defines the id to look for
  142692. * @returns the lens flare system or null if not found
  142693. */
  142694. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142695. }
  142696. /**
  142697. * Defines the lens flare scene component responsible to manage any lens flares
  142698. * in a given scene.
  142699. */
  142700. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142701. /**
  142702. * The component name helpfull to identify the component in the list of scene components.
  142703. */
  142704. readonly name: string;
  142705. /**
  142706. * The scene the component belongs to.
  142707. */
  142708. scene: Scene;
  142709. /**
  142710. * Creates a new instance of the component for the given scene
  142711. * @param scene Defines the scene to register the component in
  142712. */
  142713. constructor(scene: Scene);
  142714. /**
  142715. * Registers the component in a given scene
  142716. */
  142717. register(): void;
  142718. /**
  142719. * Rebuilds the elements related to this component in case of
  142720. * context lost for instance.
  142721. */
  142722. rebuild(): void;
  142723. /**
  142724. * Adds all the elements from the container to the scene
  142725. * @param container the container holding the elements
  142726. */
  142727. addFromContainer(container: AbstractScene): void;
  142728. /**
  142729. * Removes all the elements in the container from the scene
  142730. * @param container contains the elements to remove
  142731. * @param dispose if the removed element should be disposed (default: false)
  142732. */
  142733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142734. /**
  142735. * Serializes the component data to the specified json object
  142736. * @param serializationObject The object to serialize to
  142737. */
  142738. serialize(serializationObject: any): void;
  142739. /**
  142740. * Disposes the component and the associated ressources.
  142741. */
  142742. dispose(): void;
  142743. private _draw;
  142744. }
  142745. }
  142746. declare module BABYLON {
  142747. /** @hidden */
  142748. export var depthPixelShader: {
  142749. name: string;
  142750. shader: string;
  142751. };
  142752. }
  142753. declare module BABYLON {
  142754. /** @hidden */
  142755. export var depthVertexShader: {
  142756. name: string;
  142757. shader: string;
  142758. };
  142759. }
  142760. declare module BABYLON {
  142761. /**
  142762. * This represents a depth renderer in Babylon.
  142763. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142764. */
  142765. export class DepthRenderer {
  142766. private _scene;
  142767. private _depthMap;
  142768. private _effect;
  142769. private readonly _storeNonLinearDepth;
  142770. private readonly _clearColor;
  142771. /** Get if the depth renderer is using packed depth or not */
  142772. readonly isPacked: boolean;
  142773. private _cachedDefines;
  142774. private _camera;
  142775. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142776. enabled: boolean;
  142777. /**
  142778. * Specifiess that the depth renderer will only be used within
  142779. * the camera it is created for.
  142780. * This can help forcing its rendering during the camera processing.
  142781. */
  142782. useOnlyInActiveCamera: boolean;
  142783. /** @hidden */
  142784. static _SceneComponentInitialization: (scene: Scene) => void;
  142785. /**
  142786. * Instantiates a depth renderer
  142787. * @param scene The scene the renderer belongs to
  142788. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142789. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142790. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142791. */
  142792. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142793. /**
  142794. * Creates the depth rendering effect and checks if the effect is ready.
  142795. * @param subMesh The submesh to be used to render the depth map of
  142796. * @param useInstances If multiple world instances should be used
  142797. * @returns if the depth renderer is ready to render the depth map
  142798. */
  142799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142800. /**
  142801. * Gets the texture which the depth map will be written to.
  142802. * @returns The depth map texture
  142803. */
  142804. getDepthMap(): RenderTargetTexture;
  142805. /**
  142806. * Disposes of the depth renderer.
  142807. */
  142808. dispose(): void;
  142809. }
  142810. }
  142811. declare module BABYLON {
  142812. /** @hidden */
  142813. export var minmaxReduxPixelShader: {
  142814. name: string;
  142815. shader: string;
  142816. };
  142817. }
  142818. declare module BABYLON {
  142819. /**
  142820. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142821. * and maximum values from all values of the texture.
  142822. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142823. * The source values are read from the red channel of the texture.
  142824. */
  142825. export class MinMaxReducer {
  142826. /**
  142827. * Observable triggered when the computation has been performed
  142828. */
  142829. onAfterReductionPerformed: Observable<{
  142830. min: number;
  142831. max: number;
  142832. }>;
  142833. protected _camera: Camera;
  142834. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142835. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142836. protected _postProcessManager: PostProcessManager;
  142837. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142838. protected _forceFullscreenViewport: boolean;
  142839. /**
  142840. * Creates a min/max reducer
  142841. * @param camera The camera to use for the post processes
  142842. */
  142843. constructor(camera: Camera);
  142844. /**
  142845. * Gets the texture used to read the values from.
  142846. */
  142847. get sourceTexture(): Nullable<RenderTargetTexture>;
  142848. /**
  142849. * Sets the source texture to read the values from.
  142850. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142851. * because in such textures '1' value must not be taken into account to compute the maximum
  142852. * as this value is used to clear the texture.
  142853. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142854. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142855. * @param depthRedux Indicates if the texture is a depth texture or not
  142856. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142857. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142858. */
  142859. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142860. /**
  142861. * Defines the refresh rate of the computation.
  142862. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142863. */
  142864. get refreshRate(): number;
  142865. set refreshRate(value: number);
  142866. protected _activated: boolean;
  142867. /**
  142868. * Gets the activation status of the reducer
  142869. */
  142870. get activated(): boolean;
  142871. /**
  142872. * Activates the reduction computation.
  142873. * When activated, the observers registered in onAfterReductionPerformed are
  142874. * called after the compuation is performed
  142875. */
  142876. activate(): void;
  142877. /**
  142878. * Deactivates the reduction computation.
  142879. */
  142880. deactivate(): void;
  142881. /**
  142882. * Disposes the min/max reducer
  142883. * @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.
  142884. */
  142885. dispose(disposeAll?: boolean): void;
  142886. }
  142887. }
  142888. declare module BABYLON {
  142889. /**
  142890. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142891. */
  142892. export class DepthReducer extends MinMaxReducer {
  142893. private _depthRenderer;
  142894. private _depthRendererId;
  142895. /**
  142896. * Gets the depth renderer used for the computation.
  142897. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142898. */
  142899. get depthRenderer(): Nullable<DepthRenderer>;
  142900. /**
  142901. * Creates a depth reducer
  142902. * @param camera The camera used to render the depth texture
  142903. */
  142904. constructor(camera: Camera);
  142905. /**
  142906. * Sets the depth renderer to use to generate the depth map
  142907. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142908. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142909. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142910. */
  142911. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142912. /** @hidden */
  142913. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142914. /**
  142915. * Activates the reduction computation.
  142916. * When activated, the observers registered in onAfterReductionPerformed are
  142917. * called after the compuation is performed
  142918. */
  142919. activate(): void;
  142920. /**
  142921. * Deactivates the reduction computation.
  142922. */
  142923. deactivate(): void;
  142924. /**
  142925. * Disposes the depth reducer
  142926. * @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.
  142927. */
  142928. dispose(disposeAll?: boolean): void;
  142929. }
  142930. }
  142931. declare module BABYLON {
  142932. /**
  142933. * A CSM implementation allowing casting shadows on large scenes.
  142934. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142935. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142936. */
  142937. export class CascadedShadowGenerator extends ShadowGenerator {
  142938. private static readonly frustumCornersNDCSpace;
  142939. /**
  142940. * Name of the CSM class
  142941. */
  142942. static CLASSNAME: string;
  142943. /**
  142944. * Defines the default number of cascades used by the CSM.
  142945. */
  142946. static readonly DEFAULT_CASCADES_COUNT: number;
  142947. /**
  142948. * Defines the minimum number of cascades used by the CSM.
  142949. */
  142950. static readonly MIN_CASCADES_COUNT: number;
  142951. /**
  142952. * Defines the maximum number of cascades used by the CSM.
  142953. */
  142954. static readonly MAX_CASCADES_COUNT: number;
  142955. protected _validateFilter(filter: number): number;
  142956. /**
  142957. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142958. */
  142959. penumbraDarkness: number;
  142960. private _numCascades;
  142961. /**
  142962. * Gets or set the number of cascades used by the CSM.
  142963. */
  142964. get numCascades(): number;
  142965. set numCascades(value: number);
  142966. /**
  142967. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142968. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142969. */
  142970. stabilizeCascades: boolean;
  142971. private _freezeShadowCastersBoundingInfo;
  142972. private _freezeShadowCastersBoundingInfoObservable;
  142973. /**
  142974. * Enables or disables the shadow casters bounding info computation.
  142975. * If your shadow casters don't move, you can disable this feature.
  142976. * If it is enabled, the bounding box computation is done every frame.
  142977. */
  142978. get freezeShadowCastersBoundingInfo(): boolean;
  142979. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142980. private _scbiMin;
  142981. private _scbiMax;
  142982. protected _computeShadowCastersBoundingInfo(): void;
  142983. protected _shadowCastersBoundingInfo: BoundingInfo;
  142984. /**
  142985. * Gets or sets the shadow casters bounding info.
  142986. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142987. * so that the system won't overwrite the bounds you provide
  142988. */
  142989. get shadowCastersBoundingInfo(): BoundingInfo;
  142990. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142991. protected _breaksAreDirty: boolean;
  142992. protected _minDistance: number;
  142993. protected _maxDistance: number;
  142994. /**
  142995. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142996. *
  142997. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142998. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142999. * @param min minimal distance for the breaks (default to 0.)
  143000. * @param max maximal distance for the breaks (default to 1.)
  143001. */
  143002. setMinMaxDistance(min: number, max: number): void;
  143003. /** Gets the minimal distance used in the cascade break computation */
  143004. get minDistance(): number;
  143005. /** Gets the maximal distance used in the cascade break computation */
  143006. get maxDistance(): number;
  143007. /**
  143008. * Gets the class name of that object
  143009. * @returns "CascadedShadowGenerator"
  143010. */
  143011. getClassName(): string;
  143012. private _cascadeMinExtents;
  143013. private _cascadeMaxExtents;
  143014. /**
  143015. * Gets a cascade minimum extents
  143016. * @param cascadeIndex index of the cascade
  143017. * @returns the minimum cascade extents
  143018. */
  143019. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  143020. /**
  143021. * Gets a cascade maximum extents
  143022. * @param cascadeIndex index of the cascade
  143023. * @returns the maximum cascade extents
  143024. */
  143025. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  143026. private _cascades;
  143027. private _currentLayer;
  143028. private _viewSpaceFrustumsZ;
  143029. private _viewMatrices;
  143030. private _projectionMatrices;
  143031. private _transformMatrices;
  143032. private _transformMatricesAsArray;
  143033. private _frustumLengths;
  143034. private _lightSizeUVCorrection;
  143035. private _depthCorrection;
  143036. private _frustumCornersWorldSpace;
  143037. private _frustumCenter;
  143038. private _shadowCameraPos;
  143039. private _shadowMaxZ;
  143040. /**
  143041. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  143042. * It defaults to camera.maxZ
  143043. */
  143044. get shadowMaxZ(): number;
  143045. /**
  143046. * Sets the shadow max z distance.
  143047. */
  143048. set shadowMaxZ(value: number);
  143049. protected _debug: boolean;
  143050. /**
  143051. * Gets or sets the debug flag.
  143052. * When enabled, the cascades are materialized by different colors on the screen.
  143053. */
  143054. get debug(): boolean;
  143055. set debug(dbg: boolean);
  143056. private _depthClamp;
  143057. /**
  143058. * Gets or sets the depth clamping value.
  143059. *
  143060. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  143061. * to account for the shadow casters far away.
  143062. *
  143063. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  143064. */
  143065. get depthClamp(): boolean;
  143066. set depthClamp(value: boolean);
  143067. private _cascadeBlendPercentage;
  143068. /**
  143069. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  143070. * It defaults to 0.1 (10% blending).
  143071. */
  143072. get cascadeBlendPercentage(): number;
  143073. set cascadeBlendPercentage(value: number);
  143074. private _lambda;
  143075. /**
  143076. * Gets or set the lambda parameter.
  143077. * This parameter is used to split the camera frustum and create the cascades.
  143078. * 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.
  143079. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  143080. */
  143081. get lambda(): number;
  143082. set lambda(value: number);
  143083. /**
  143084. * Gets the view matrix corresponding to a given cascade
  143085. * @param cascadeNum cascade to retrieve the view matrix from
  143086. * @returns the cascade view matrix
  143087. */
  143088. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  143089. /**
  143090. * Gets the projection matrix corresponding to a given cascade
  143091. * @param cascadeNum cascade to retrieve the projection matrix from
  143092. * @returns the cascade projection matrix
  143093. */
  143094. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  143095. /**
  143096. * Gets the transformation matrix corresponding to a given cascade
  143097. * @param cascadeNum cascade to retrieve the transformation matrix from
  143098. * @returns the cascade transformation matrix
  143099. */
  143100. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  143101. private _depthRenderer;
  143102. /**
  143103. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  143104. *
  143105. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  143106. *
  143107. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  143108. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  143109. * @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
  143110. */
  143111. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  143112. private _depthReducer;
  143113. private _autoCalcDepthBounds;
  143114. /**
  143115. * Gets or sets the autoCalcDepthBounds property.
  143116. *
  143117. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  143118. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  143119. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  143120. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  143121. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  143122. */
  143123. get autoCalcDepthBounds(): boolean;
  143124. set autoCalcDepthBounds(value: boolean);
  143125. /**
  143126. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  143127. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  143128. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  143129. * for setting the refresh rate on the renderer yourself!
  143130. */
  143131. get autoCalcDepthBoundsRefreshRate(): number;
  143132. set autoCalcDepthBoundsRefreshRate(value: number);
  143133. /**
  143134. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  143135. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  143136. * you change the camera near/far planes!
  143137. */
  143138. splitFrustum(): void;
  143139. private _splitFrustum;
  143140. private _computeMatrices;
  143141. private _computeFrustumInWorldSpace;
  143142. private _computeCascadeFrustum;
  143143. /**
  143144. * Support test.
  143145. */
  143146. static get IsSupported(): boolean;
  143147. /** @hidden */
  143148. static _SceneComponentInitialization: (scene: Scene) => void;
  143149. /**
  143150. * Creates a Cascaded Shadow Generator object.
  143151. * A ShadowGenerator is the required tool to use the shadows.
  143152. * Each directional light casting shadows needs to use its own ShadowGenerator.
  143153. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  143154. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  143155. * @param light The directional light object generating the shadows.
  143156. * @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.
  143157. */
  143158. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  143159. protected _initializeGenerator(): void;
  143160. protected _createTargetRenderTexture(): void;
  143161. protected _initializeShadowMap(): void;
  143162. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  143163. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  143164. /**
  143165. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  143166. * @param defines Defines of the material we want to update
  143167. * @param lightIndex Index of the light in the enabled light list of the material
  143168. */
  143169. prepareDefines(defines: any, lightIndex: number): void;
  143170. /**
  143171. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  143172. * defined in the generator but impacting the effect).
  143173. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  143174. * @param effect The effect we are binfing the information for
  143175. */
  143176. bindShadowLight(lightIndex: string, effect: Effect): void;
  143177. /**
  143178. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  143179. * (eq to view projection * shadow projection matrices)
  143180. * @returns The transform matrix used to create the shadow map
  143181. */
  143182. getTransformMatrix(): Matrix;
  143183. /**
  143184. * Disposes the ShadowGenerator.
  143185. * Returns nothing.
  143186. */
  143187. dispose(): void;
  143188. /**
  143189. * Serializes the shadow generator setup to a json object.
  143190. * @returns The serialized JSON object
  143191. */
  143192. serialize(): any;
  143193. /**
  143194. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  143195. * @param parsedShadowGenerator The JSON object to parse
  143196. * @param scene The scene to create the shadow map for
  143197. * @returns The parsed shadow generator
  143198. */
  143199. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  143200. }
  143201. }
  143202. declare module BABYLON {
  143203. /**
  143204. * Defines the shadow generator component responsible to manage any shadow generators
  143205. * in a given scene.
  143206. */
  143207. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  143208. /**
  143209. * The component name helpfull to identify the component in the list of scene components.
  143210. */
  143211. readonly name: string;
  143212. /**
  143213. * The scene the component belongs to.
  143214. */
  143215. scene: Scene;
  143216. /**
  143217. * Creates a new instance of the component for the given scene
  143218. * @param scene Defines the scene to register the component in
  143219. */
  143220. constructor(scene: Scene);
  143221. /**
  143222. * Registers the component in a given scene
  143223. */
  143224. register(): void;
  143225. /**
  143226. * Rebuilds the elements related to this component in case of
  143227. * context lost for instance.
  143228. */
  143229. rebuild(): void;
  143230. /**
  143231. * Serializes the component data to the specified json object
  143232. * @param serializationObject The object to serialize to
  143233. */
  143234. serialize(serializationObject: any): void;
  143235. /**
  143236. * Adds all the elements from the container to the scene
  143237. * @param container the container holding the elements
  143238. */
  143239. addFromContainer(container: AbstractScene): void;
  143240. /**
  143241. * Removes all the elements in the container from the scene
  143242. * @param container contains the elements to remove
  143243. * @param dispose if the removed element should be disposed (default: false)
  143244. */
  143245. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  143246. /**
  143247. * Rebuilds the elements related to this component in case of
  143248. * context lost for instance.
  143249. */
  143250. dispose(): void;
  143251. private _gatherRenderTargets;
  143252. }
  143253. }
  143254. declare module BABYLON {
  143255. /**
  143256. * A point light is a light defined by an unique point in world space.
  143257. * The light is emitted in every direction from this point.
  143258. * A good example of a point light is a standard light bulb.
  143259. * Documentation: https://doc.babylonjs.com/babylon101/lights
  143260. */
  143261. export class PointLight extends ShadowLight {
  143262. private _shadowAngle;
  143263. /**
  143264. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143265. * This specifies what angle the shadow will use to be created.
  143266. *
  143267. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143268. */
  143269. get shadowAngle(): number;
  143270. /**
  143271. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143272. * This specifies what angle the shadow will use to be created.
  143273. *
  143274. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143275. */
  143276. set shadowAngle(value: number);
  143277. /**
  143278. * Gets the direction if it has been set.
  143279. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143280. */
  143281. get direction(): Vector3;
  143282. /**
  143283. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143284. */
  143285. set direction(value: Vector3);
  143286. /**
  143287. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  143288. * A PointLight emits the light in every direction.
  143289. * It can cast shadows.
  143290. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  143291. * ```javascript
  143292. * var pointLight = new PointLight("pl", camera.position, scene);
  143293. * ```
  143294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  143295. * @param name The light friendly name
  143296. * @param position The position of the point light in the scene
  143297. * @param scene The scene the lights belongs to
  143298. */
  143299. constructor(name: string, position: Vector3, scene: Scene);
  143300. /**
  143301. * Returns the string "PointLight"
  143302. * @returns the class name
  143303. */
  143304. getClassName(): string;
  143305. /**
  143306. * Returns the integer 0.
  143307. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  143308. */
  143309. getTypeID(): number;
  143310. /**
  143311. * Specifies wether or not the shadowmap should be a cube texture.
  143312. * @returns true if the shadowmap needs to be a cube texture.
  143313. */
  143314. needCube(): boolean;
  143315. /**
  143316. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  143317. * @param faceIndex The index of the face we are computed the direction to generate shadow
  143318. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  143319. */
  143320. getShadowDirection(faceIndex?: number): Vector3;
  143321. /**
  143322. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  143323. * - fov = PI / 2
  143324. * - aspect ratio : 1.0
  143325. * - z-near and far equal to the active camera minZ and maxZ.
  143326. * Returns the PointLight.
  143327. */
  143328. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  143329. protected _buildUniformLayout(): void;
  143330. /**
  143331. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  143332. * @param effect The effect to update
  143333. * @param lightIndex The index of the light in the effect to update
  143334. * @returns The point light
  143335. */
  143336. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  143337. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  143338. /**
  143339. * Prepares the list of defines specific to the light type.
  143340. * @param defines the list of defines
  143341. * @param lightIndex defines the index of the light for the effect
  143342. */
  143343. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  143344. }
  143345. }
  143346. declare module BABYLON {
  143347. /**
  143348. * Header information of HDR texture files.
  143349. */
  143350. export interface HDRInfo {
  143351. /**
  143352. * The height of the texture in pixels.
  143353. */
  143354. height: number;
  143355. /**
  143356. * The width of the texture in pixels.
  143357. */
  143358. width: number;
  143359. /**
  143360. * The index of the beginning of the data in the binary file.
  143361. */
  143362. dataPosition: number;
  143363. }
  143364. /**
  143365. * This groups tools to convert HDR texture to native colors array.
  143366. */
  143367. export class HDRTools {
  143368. private static Ldexp;
  143369. private static Rgbe2float;
  143370. private static readStringLine;
  143371. /**
  143372. * Reads header information from an RGBE texture stored in a native array.
  143373. * More information on this format are available here:
  143374. * https://en.wikipedia.org/wiki/RGBE_image_format
  143375. *
  143376. * @param uint8array The binary file stored in native array.
  143377. * @return The header information.
  143378. */
  143379. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143380. /**
  143381. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143382. * This RGBE texture needs to store the information as a panorama.
  143383. *
  143384. * More information on this format are available here:
  143385. * https://en.wikipedia.org/wiki/RGBE_image_format
  143386. *
  143387. * @param buffer The binary file stored in an array buffer.
  143388. * @param size The expected size of the extracted cubemap.
  143389. * @return The Cube Map information.
  143390. */
  143391. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143392. /**
  143393. * Returns the pixels data extracted from an RGBE texture.
  143394. * This pixels will be stored left to right up to down in the R G B order in one array.
  143395. *
  143396. * More information on this format are available here:
  143397. * https://en.wikipedia.org/wiki/RGBE_image_format
  143398. *
  143399. * @param uint8array The binary file stored in an array buffer.
  143400. * @param hdrInfo The header information of the file.
  143401. * @return The pixels data in RGB right to left up to down order.
  143402. */
  143403. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143404. private static RGBE_ReadPixels_RLE;
  143405. private static RGBE_ReadPixels_NOT_RLE;
  143406. }
  143407. }
  143408. declare module BABYLON {
  143409. /**
  143410. * Effect Render Options
  143411. */
  143412. export interface IEffectRendererOptions {
  143413. /**
  143414. * Defines the vertices positions.
  143415. */
  143416. positions?: number[];
  143417. /**
  143418. * Defines the indices.
  143419. */
  143420. indices?: number[];
  143421. }
  143422. /**
  143423. * Helper class to render one or more effects.
  143424. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143425. */
  143426. export class EffectRenderer {
  143427. private engine;
  143428. private static _DefaultOptions;
  143429. private _vertexBuffers;
  143430. private _indexBuffer;
  143431. private _fullscreenViewport;
  143432. /**
  143433. * Creates an effect renderer
  143434. * @param engine the engine to use for rendering
  143435. * @param options defines the options of the effect renderer
  143436. */
  143437. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143438. /**
  143439. * Sets the current viewport in normalized coordinates 0-1
  143440. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143441. */
  143442. setViewport(viewport?: Viewport): void;
  143443. /**
  143444. * Binds the embedded attributes buffer to the effect.
  143445. * @param effect Defines the effect to bind the attributes for
  143446. */
  143447. bindBuffers(effect: Effect): void;
  143448. /**
  143449. * Sets the current effect wrapper to use during draw.
  143450. * The effect needs to be ready before calling this api.
  143451. * This also sets the default full screen position attribute.
  143452. * @param effectWrapper Defines the effect to draw with
  143453. */
  143454. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143455. /**
  143456. * Restores engine states
  143457. */
  143458. restoreStates(): void;
  143459. /**
  143460. * Draws a full screen quad.
  143461. */
  143462. draw(): void;
  143463. private isRenderTargetTexture;
  143464. /**
  143465. * renders one or more effects to a specified texture
  143466. * @param effectWrapper the effect to renderer
  143467. * @param outputTexture texture to draw to, if null it will render to the screen.
  143468. */
  143469. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143470. /**
  143471. * Disposes of the effect renderer
  143472. */
  143473. dispose(): void;
  143474. }
  143475. /**
  143476. * Options to create an EffectWrapper
  143477. */
  143478. interface EffectWrapperCreationOptions {
  143479. /**
  143480. * Engine to use to create the effect
  143481. */
  143482. engine: ThinEngine;
  143483. /**
  143484. * Fragment shader for the effect
  143485. */
  143486. fragmentShader: string;
  143487. /**
  143488. * Use the shader store instead of direct source code
  143489. */
  143490. useShaderStore?: boolean;
  143491. /**
  143492. * Vertex shader for the effect
  143493. */
  143494. vertexShader?: string;
  143495. /**
  143496. * Attributes to use in the shader
  143497. */
  143498. attributeNames?: Array<string>;
  143499. /**
  143500. * Uniforms to use in the shader
  143501. */
  143502. uniformNames?: Array<string>;
  143503. /**
  143504. * Texture sampler names to use in the shader
  143505. */
  143506. samplerNames?: Array<string>;
  143507. /**
  143508. * Defines to use in the shader
  143509. */
  143510. defines?: Array<string>;
  143511. /**
  143512. * Callback when effect is compiled
  143513. */
  143514. onCompiled?: Nullable<(effect: Effect) => void>;
  143515. /**
  143516. * The friendly name of the effect displayed in Spector.
  143517. */
  143518. name?: string;
  143519. }
  143520. /**
  143521. * Wraps an effect to be used for rendering
  143522. */
  143523. export class EffectWrapper {
  143524. /**
  143525. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143526. */
  143527. onApplyObservable: Observable<{}>;
  143528. /**
  143529. * The underlying effect
  143530. */
  143531. effect: Effect;
  143532. /**
  143533. * Creates an effect to be renderer
  143534. * @param creationOptions options to create the effect
  143535. */
  143536. constructor(creationOptions: EffectWrapperCreationOptions);
  143537. /**
  143538. * Disposes of the effect wrapper
  143539. */
  143540. dispose(): void;
  143541. }
  143542. }
  143543. declare module BABYLON {
  143544. /** @hidden */
  143545. export var hdrFilteringVertexShader: {
  143546. name: string;
  143547. shader: string;
  143548. };
  143549. }
  143550. declare module BABYLON {
  143551. /** @hidden */
  143552. export var hdrFilteringPixelShader: {
  143553. name: string;
  143554. shader: string;
  143555. };
  143556. }
  143557. declare module BABYLON {
  143558. /**
  143559. * Options for texture filtering
  143560. */
  143561. interface IHDRFilteringOptions {
  143562. /**
  143563. * Scales pixel intensity for the input HDR map.
  143564. */
  143565. hdrScale?: number;
  143566. /**
  143567. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143568. */
  143569. quality?: number;
  143570. }
  143571. /**
  143572. * Filters HDR maps to get correct renderings of PBR reflections
  143573. */
  143574. export class HDRFiltering {
  143575. private _engine;
  143576. private _effectRenderer;
  143577. private _effectWrapper;
  143578. private _lodGenerationOffset;
  143579. private _lodGenerationScale;
  143580. /**
  143581. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143582. * you care about baking speed.
  143583. */
  143584. quality: number;
  143585. /**
  143586. * Scales pixel intensity for the input HDR map.
  143587. */
  143588. hdrScale: number;
  143589. /**
  143590. * Instantiates HDR filter for reflection maps
  143591. *
  143592. * @param engine Thin engine
  143593. * @param options Options
  143594. */
  143595. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143596. private _createRenderTarget;
  143597. private _prefilterInternal;
  143598. private _createEffect;
  143599. /**
  143600. * Get a value indicating if the filter is ready to be used
  143601. * @param texture Texture to filter
  143602. * @returns true if the filter is ready
  143603. */
  143604. isReady(texture: BaseTexture): boolean;
  143605. /**
  143606. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143607. * Prefiltering will be invoked at the end of next rendering pass.
  143608. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143609. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143610. * @param texture Texture to filter
  143611. * @param onFinished Callback when filtering is done
  143612. * @return Promise called when prefiltering is done
  143613. */
  143614. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143615. }
  143616. }
  143617. declare module BABYLON {
  143618. /**
  143619. * This represents a texture coming from an HDR input.
  143620. *
  143621. * The only supported format is currently panorama picture stored in RGBE format.
  143622. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143623. */
  143624. export class HDRCubeTexture extends BaseTexture {
  143625. private static _facesMapping;
  143626. private _generateHarmonics;
  143627. private _noMipmap;
  143628. private _prefilterOnLoad;
  143629. private _textureMatrix;
  143630. private _size;
  143631. private _onLoad;
  143632. private _onError;
  143633. /**
  143634. * The texture URL.
  143635. */
  143636. url: string;
  143637. protected _isBlocking: boolean;
  143638. /**
  143639. * Sets wether or not the texture is blocking during loading.
  143640. */
  143641. set isBlocking(value: boolean);
  143642. /**
  143643. * Gets wether or not the texture is blocking during loading.
  143644. */
  143645. get isBlocking(): boolean;
  143646. protected _rotationY: number;
  143647. /**
  143648. * Sets texture matrix rotation angle around Y axis in radians.
  143649. */
  143650. set rotationY(value: number);
  143651. /**
  143652. * Gets texture matrix rotation angle around Y axis radians.
  143653. */
  143654. get rotationY(): number;
  143655. /**
  143656. * Gets or sets the center of the bounding box associated with the cube texture
  143657. * It must define where the camera used to render the texture was set
  143658. */
  143659. boundingBoxPosition: Vector3;
  143660. private _boundingBoxSize;
  143661. /**
  143662. * Gets or sets the size of the bounding box associated with the cube texture
  143663. * When defined, the cubemap will switch to local mode
  143664. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143665. * @example https://www.babylonjs-playground.com/#RNASML
  143666. */
  143667. set boundingBoxSize(value: Vector3);
  143668. get boundingBoxSize(): Vector3;
  143669. /**
  143670. * Instantiates an HDRTexture from the following parameters.
  143671. *
  143672. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143673. * @param sceneOrEngine The scene or engine the texture will be used in
  143674. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143675. * @param noMipmap Forces to not generate the mipmap if true
  143676. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143677. * @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)
  143678. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143679. */
  143680. 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>);
  143681. /**
  143682. * Get the current class name of the texture useful for serialization or dynamic coding.
  143683. * @returns "HDRCubeTexture"
  143684. */
  143685. getClassName(): string;
  143686. /**
  143687. * Occurs when the file is raw .hdr file.
  143688. */
  143689. private loadTexture;
  143690. clone(): HDRCubeTexture;
  143691. delayLoad(): void;
  143692. /**
  143693. * Get the texture reflection matrix used to rotate/transform the reflection.
  143694. * @returns the reflection matrix
  143695. */
  143696. getReflectionTextureMatrix(): Matrix;
  143697. /**
  143698. * Set the texture reflection matrix used to rotate/transform the reflection.
  143699. * @param value Define the reflection matrix to set
  143700. */
  143701. setReflectionTextureMatrix(value: Matrix): void;
  143702. /**
  143703. * Parses a JSON representation of an HDR Texture in order to create the texture
  143704. * @param parsedTexture Define the JSON representation
  143705. * @param scene Define the scene the texture should be created in
  143706. * @param rootUrl Define the root url in case we need to load relative dependencies
  143707. * @returns the newly created texture after parsing
  143708. */
  143709. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143710. serialize(): any;
  143711. }
  143712. }
  143713. declare module BABYLON {
  143714. /**
  143715. * Class used to control physics engine
  143716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143717. */
  143718. export class PhysicsEngine implements IPhysicsEngine {
  143719. private _physicsPlugin;
  143720. /**
  143721. * Global value used to control the smallest number supported by the simulation
  143722. */
  143723. static Epsilon: number;
  143724. private _impostors;
  143725. private _joints;
  143726. private _subTimeStep;
  143727. /**
  143728. * Gets the gravity vector used by the simulation
  143729. */
  143730. gravity: Vector3;
  143731. /**
  143732. * Factory used to create the default physics plugin.
  143733. * @returns The default physics plugin
  143734. */
  143735. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143736. /**
  143737. * Creates a new Physics Engine
  143738. * @param gravity defines the gravity vector used by the simulation
  143739. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143740. */
  143741. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143742. /**
  143743. * Sets the gravity vector used by the simulation
  143744. * @param gravity defines the gravity vector to use
  143745. */
  143746. setGravity(gravity: Vector3): void;
  143747. /**
  143748. * Set the time step of the physics engine.
  143749. * Default is 1/60.
  143750. * To slow it down, enter 1/600 for example.
  143751. * To speed it up, 1/30
  143752. * @param newTimeStep defines the new timestep to apply to this world.
  143753. */
  143754. setTimeStep(newTimeStep?: number): void;
  143755. /**
  143756. * Get the time step of the physics engine.
  143757. * @returns the current time step
  143758. */
  143759. getTimeStep(): number;
  143760. /**
  143761. * Set the sub time step of the physics engine.
  143762. * Default is 0 meaning there is no sub steps
  143763. * To increase physics resolution precision, set a small value (like 1 ms)
  143764. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143765. */
  143766. setSubTimeStep(subTimeStep?: number): void;
  143767. /**
  143768. * Get the sub time step of the physics engine.
  143769. * @returns the current sub time step
  143770. */
  143771. getSubTimeStep(): number;
  143772. /**
  143773. * Release all resources
  143774. */
  143775. dispose(): void;
  143776. /**
  143777. * Gets the name of the current physics plugin
  143778. * @returns the name of the plugin
  143779. */
  143780. getPhysicsPluginName(): string;
  143781. /**
  143782. * Adding a new impostor for the impostor tracking.
  143783. * This will be done by the impostor itself.
  143784. * @param impostor the impostor to add
  143785. */
  143786. addImpostor(impostor: PhysicsImpostor): void;
  143787. /**
  143788. * Remove an impostor from the engine.
  143789. * This impostor and its mesh will not longer be updated by the physics engine.
  143790. * @param impostor the impostor to remove
  143791. */
  143792. removeImpostor(impostor: PhysicsImpostor): void;
  143793. /**
  143794. * Add a joint to the physics engine
  143795. * @param mainImpostor defines the main impostor to which the joint is added.
  143796. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143797. * @param joint defines the joint that will connect both impostors.
  143798. */
  143799. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143800. /**
  143801. * Removes a joint from the simulation
  143802. * @param mainImpostor defines the impostor used with the joint
  143803. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143804. * @param joint defines the joint to remove
  143805. */
  143806. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143807. /**
  143808. * Called by the scene. No need to call it.
  143809. * @param delta defines the timespam between frames
  143810. */
  143811. _step(delta: number): void;
  143812. /**
  143813. * Gets the current plugin used to run the simulation
  143814. * @returns current plugin
  143815. */
  143816. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143817. /**
  143818. * Gets the list of physic impostors
  143819. * @returns an array of PhysicsImpostor
  143820. */
  143821. getImpostors(): Array<PhysicsImpostor>;
  143822. /**
  143823. * Gets the impostor for a physics enabled object
  143824. * @param object defines the object impersonated by the impostor
  143825. * @returns the PhysicsImpostor or null if not found
  143826. */
  143827. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143828. /**
  143829. * Gets the impostor for a physics body object
  143830. * @param body defines physics body used by the impostor
  143831. * @returns the PhysicsImpostor or null if not found
  143832. */
  143833. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143834. /**
  143835. * Does a raycast in the physics world
  143836. * @param from when should the ray start?
  143837. * @param to when should the ray end?
  143838. * @returns PhysicsRaycastResult
  143839. */
  143840. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143841. }
  143842. }
  143843. declare module BABYLON {
  143844. /** @hidden */
  143845. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143846. private _useDeltaForWorldStep;
  143847. world: any;
  143848. name: string;
  143849. private _physicsMaterials;
  143850. private _fixedTimeStep;
  143851. private _cannonRaycastResult;
  143852. private _raycastResult;
  143853. private _physicsBodysToRemoveAfterStep;
  143854. private _firstFrame;
  143855. BJSCANNON: any;
  143856. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143857. setGravity(gravity: Vector3): void;
  143858. setTimeStep(timeStep: number): void;
  143859. getTimeStep(): number;
  143860. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143861. private _removeMarkedPhysicsBodiesFromWorld;
  143862. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143863. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143864. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143865. private _processChildMeshes;
  143866. removePhysicsBody(impostor: PhysicsImpostor): void;
  143867. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143868. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143869. private _addMaterial;
  143870. private _checkWithEpsilon;
  143871. private _createShape;
  143872. private _createHeightmap;
  143873. private _minus90X;
  143874. private _plus90X;
  143875. private _tmpPosition;
  143876. private _tmpDeltaPosition;
  143877. private _tmpUnityRotation;
  143878. private _updatePhysicsBodyTransformation;
  143879. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143880. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143881. isSupported(): boolean;
  143882. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143883. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143884. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143885. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143886. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143887. getBodyMass(impostor: PhysicsImpostor): number;
  143888. getBodyFriction(impostor: PhysicsImpostor): number;
  143889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143890. getBodyRestitution(impostor: PhysicsImpostor): number;
  143891. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143892. sleepBody(impostor: PhysicsImpostor): void;
  143893. wakeUpBody(impostor: PhysicsImpostor): void;
  143894. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143895. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143897. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143898. getRadius(impostor: PhysicsImpostor): number;
  143899. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143900. dispose(): void;
  143901. private _extendNamespace;
  143902. /**
  143903. * Does a raycast in the physics world
  143904. * @param from when should the ray start?
  143905. * @param to when should the ray end?
  143906. * @returns PhysicsRaycastResult
  143907. */
  143908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143909. }
  143910. }
  143911. declare module BABYLON {
  143912. /** @hidden */
  143913. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143914. private _useDeltaForWorldStep;
  143915. world: any;
  143916. name: string;
  143917. BJSOIMO: any;
  143918. private _raycastResult;
  143919. private _fixedTimeStep;
  143920. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143921. setGravity(gravity: Vector3): void;
  143922. setTimeStep(timeStep: number): void;
  143923. getTimeStep(): number;
  143924. private _tmpImpostorsArray;
  143925. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  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 _tmpPositionVector;
  143930. removePhysicsBody(impostor: PhysicsImpostor): void;
  143931. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143933. isSupported(): boolean;
  143934. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143935. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143936. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143937. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143938. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143939. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143940. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143941. getBodyMass(impostor: PhysicsImpostor): number;
  143942. getBodyFriction(impostor: PhysicsImpostor): number;
  143943. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143944. getBodyRestitution(impostor: PhysicsImpostor): number;
  143945. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143946. sleepBody(impostor: PhysicsImpostor): void;
  143947. wakeUpBody(impostor: PhysicsImpostor): void;
  143948. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143949. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143950. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143952. getRadius(impostor: PhysicsImpostor): number;
  143953. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143954. dispose(): void;
  143955. /**
  143956. * Does a raycast in the physics world
  143957. * @param from when should the ray start?
  143958. * @param to when should the ray end?
  143959. * @returns PhysicsRaycastResult
  143960. */
  143961. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143962. }
  143963. }
  143964. declare module BABYLON {
  143965. /**
  143966. * AmmoJS Physics plugin
  143967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143968. * @see https://github.com/kripken/ammo.js/
  143969. */
  143970. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143971. private _useDeltaForWorldStep;
  143972. /**
  143973. * Reference to the Ammo library
  143974. */
  143975. bjsAMMO: any;
  143976. /**
  143977. * Created ammoJS world which physics bodies are added to
  143978. */
  143979. world: any;
  143980. /**
  143981. * Name of the plugin
  143982. */
  143983. name: string;
  143984. private _timeStep;
  143985. private _fixedTimeStep;
  143986. private _maxSteps;
  143987. private _tmpQuaternion;
  143988. private _tmpAmmoTransform;
  143989. private _tmpAmmoQuaternion;
  143990. private _tmpAmmoConcreteContactResultCallback;
  143991. private _collisionConfiguration;
  143992. private _dispatcher;
  143993. private _overlappingPairCache;
  143994. private _solver;
  143995. private _softBodySolver;
  143996. private _tmpAmmoVectorA;
  143997. private _tmpAmmoVectorB;
  143998. private _tmpAmmoVectorC;
  143999. private _tmpAmmoVectorD;
  144000. private _tmpContactCallbackResult;
  144001. private _tmpAmmoVectorRCA;
  144002. private _tmpAmmoVectorRCB;
  144003. private _raycastResult;
  144004. private _tmpContactPoint;
  144005. private static readonly DISABLE_COLLISION_FLAG;
  144006. private static readonly KINEMATIC_FLAG;
  144007. private static readonly DISABLE_DEACTIVATION_FLAG;
  144008. /**
  144009. * Initializes the ammoJS plugin
  144010. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  144011. * @param ammoInjection can be used to inject your own ammo reference
  144012. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  144013. */
  144014. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  144015. /**
  144016. * Sets the gravity of the physics world (m/(s^2))
  144017. * @param gravity Gravity to set
  144018. */
  144019. setGravity(gravity: Vector3): void;
  144020. /**
  144021. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  144022. * @param timeStep timestep to use in seconds
  144023. */
  144024. setTimeStep(timeStep: number): void;
  144025. /**
  144026. * 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)
  144027. * @param fixedTimeStep fixedTimeStep to use in seconds
  144028. */
  144029. setFixedTimeStep(fixedTimeStep: number): void;
  144030. /**
  144031. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  144032. * @param maxSteps the maximum number of steps by the physics engine per frame
  144033. */
  144034. setMaxSteps(maxSteps: number): void;
  144035. /**
  144036. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  144037. * @returns the current timestep in seconds
  144038. */
  144039. getTimeStep(): number;
  144040. /**
  144041. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  144042. */
  144043. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  144044. private _isImpostorInContact;
  144045. private _isImpostorPairInContact;
  144046. private _stepSimulation;
  144047. /**
  144048. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  144049. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  144050. * After the step the babylon meshes are set to the position of the physics imposters
  144051. * @param delta amount of time to step forward
  144052. * @param impostors array of imposters to update before/after the step
  144053. */
  144054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  144055. /**
  144056. * Update babylon mesh to match physics world object
  144057. * @param impostor imposter to match
  144058. */
  144059. private _afterSoftStep;
  144060. /**
  144061. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144062. * @param impostor imposter to match
  144063. */
  144064. private _ropeStep;
  144065. /**
  144066. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144067. * @param impostor imposter to match
  144068. */
  144069. private _softbodyOrClothStep;
  144070. private _tmpMatrix;
  144071. /**
  144072. * Applies an impulse on the imposter
  144073. * @param impostor imposter to apply impulse to
  144074. * @param force amount of force to be applied to the imposter
  144075. * @param contactPoint the location to apply the impulse on the imposter
  144076. */
  144077. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144078. /**
  144079. * Applies a force on the imposter
  144080. * @param impostor imposter to apply force
  144081. * @param force amount of force to be applied to the imposter
  144082. * @param contactPoint the location to apply the force on the imposter
  144083. */
  144084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144085. /**
  144086. * Creates a physics body using the plugin
  144087. * @param impostor the imposter to create the physics body on
  144088. */
  144089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  144090. /**
  144091. * Removes the physics body from the imposter and disposes of the body's memory
  144092. * @param impostor imposter to remove the physics body from
  144093. */
  144094. removePhysicsBody(impostor: PhysicsImpostor): void;
  144095. /**
  144096. * Generates a joint
  144097. * @param impostorJoint the imposter joint to create the joint with
  144098. */
  144099. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  144100. /**
  144101. * Removes a joint
  144102. * @param impostorJoint the imposter joint to remove the joint from
  144103. */
  144104. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  144105. private _addMeshVerts;
  144106. /**
  144107. * Initialise the soft body vertices to match its object's (mesh) vertices
  144108. * Softbody vertices (nodes) are in world space and to match this
  144109. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  144110. * @param impostor to create the softbody for
  144111. */
  144112. private _softVertexData;
  144113. /**
  144114. * Create an impostor's soft body
  144115. * @param impostor to create the softbody for
  144116. */
  144117. private _createSoftbody;
  144118. /**
  144119. * Create cloth for an impostor
  144120. * @param impostor to create the softbody for
  144121. */
  144122. private _createCloth;
  144123. /**
  144124. * Create rope for an impostor
  144125. * @param impostor to create the softbody for
  144126. */
  144127. private _createRope;
  144128. /**
  144129. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  144130. * @param impostor to create the custom physics shape for
  144131. */
  144132. private _createCustom;
  144133. private _addHullVerts;
  144134. private _createShape;
  144135. /**
  144136. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  144137. * @param impostor imposter containing the physics body and babylon object
  144138. */
  144139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  144140. /**
  144141. * Sets the babylon object's position/rotation from the physics body's position/rotation
  144142. * @param impostor imposter containing the physics body and babylon object
  144143. * @param newPosition new position
  144144. * @param newRotation new rotation
  144145. */
  144146. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  144147. /**
  144148. * If this plugin is supported
  144149. * @returns true if its supported
  144150. */
  144151. isSupported(): boolean;
  144152. /**
  144153. * Sets the linear velocity of the physics body
  144154. * @param impostor imposter to set the velocity on
  144155. * @param velocity velocity to set
  144156. */
  144157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144158. /**
  144159. * Sets the angular velocity of the physics body
  144160. * @param impostor imposter to set the velocity on
  144161. * @param velocity velocity to set
  144162. */
  144163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144164. /**
  144165. * gets the linear velocity
  144166. * @param impostor imposter to get linear velocity from
  144167. * @returns linear velocity
  144168. */
  144169. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144170. /**
  144171. * gets the angular velocity
  144172. * @param impostor imposter to get angular velocity from
  144173. * @returns angular velocity
  144174. */
  144175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144176. /**
  144177. * Sets the mass of physics body
  144178. * @param impostor imposter to set the mass on
  144179. * @param mass mass to set
  144180. */
  144181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  144182. /**
  144183. * Gets the mass of the physics body
  144184. * @param impostor imposter to get the mass from
  144185. * @returns mass
  144186. */
  144187. getBodyMass(impostor: PhysicsImpostor): number;
  144188. /**
  144189. * Gets friction of the impostor
  144190. * @param impostor impostor to get friction from
  144191. * @returns friction value
  144192. */
  144193. getBodyFriction(impostor: PhysicsImpostor): number;
  144194. /**
  144195. * Sets friction of the impostor
  144196. * @param impostor impostor to set friction on
  144197. * @param friction friction value
  144198. */
  144199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  144200. /**
  144201. * Gets restitution of the impostor
  144202. * @param impostor impostor to get restitution from
  144203. * @returns restitution value
  144204. */
  144205. getBodyRestitution(impostor: PhysicsImpostor): number;
  144206. /**
  144207. * Sets resitution of the impostor
  144208. * @param impostor impostor to set resitution on
  144209. * @param restitution resitution value
  144210. */
  144211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  144212. /**
  144213. * Gets pressure inside the impostor
  144214. * @param impostor impostor to get pressure from
  144215. * @returns pressure value
  144216. */
  144217. getBodyPressure(impostor: PhysicsImpostor): number;
  144218. /**
  144219. * Sets pressure inside a soft body impostor
  144220. * Cloth and rope must remain 0 pressure
  144221. * @param impostor impostor to set pressure on
  144222. * @param pressure pressure value
  144223. */
  144224. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  144225. /**
  144226. * Gets stiffness of the impostor
  144227. * @param impostor impostor to get stiffness from
  144228. * @returns pressure value
  144229. */
  144230. getBodyStiffness(impostor: PhysicsImpostor): number;
  144231. /**
  144232. * Sets stiffness of the impostor
  144233. * @param impostor impostor to set stiffness on
  144234. * @param stiffness stiffness value from 0 to 1
  144235. */
  144236. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  144237. /**
  144238. * Gets velocityIterations of the impostor
  144239. * @param impostor impostor to get velocity iterations from
  144240. * @returns velocityIterations value
  144241. */
  144242. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  144243. /**
  144244. * Sets velocityIterations of the impostor
  144245. * @param impostor impostor to set velocity iterations on
  144246. * @param velocityIterations velocityIterations value
  144247. */
  144248. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  144249. /**
  144250. * Gets positionIterations of the impostor
  144251. * @param impostor impostor to get position iterations from
  144252. * @returns positionIterations value
  144253. */
  144254. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  144255. /**
  144256. * Sets positionIterations of the impostor
  144257. * @param impostor impostor to set position on
  144258. * @param positionIterations positionIterations value
  144259. */
  144260. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  144261. /**
  144262. * Append an anchor to a cloth object
  144263. * @param impostor is the cloth impostor to add anchor to
  144264. * @param otherImpostor is the rigid impostor to anchor to
  144265. * @param width ratio across width from 0 to 1
  144266. * @param height ratio up height from 0 to 1
  144267. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  144268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144269. */
  144270. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144271. /**
  144272. * Append an hook to a rope object
  144273. * @param impostor is the rope impostor to add hook to
  144274. * @param otherImpostor is the rigid impostor to hook to
  144275. * @param length ratio along the rope from 0 to 1
  144276. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  144277. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144278. */
  144279. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144280. /**
  144281. * Sleeps the physics body and stops it from being active
  144282. * @param impostor impostor to sleep
  144283. */
  144284. sleepBody(impostor: PhysicsImpostor): void;
  144285. /**
  144286. * Activates the physics body
  144287. * @param impostor impostor to activate
  144288. */
  144289. wakeUpBody(impostor: PhysicsImpostor): void;
  144290. /**
  144291. * Updates the distance parameters of the joint
  144292. * @param joint joint to update
  144293. * @param maxDistance maximum distance of the joint
  144294. * @param minDistance minimum distance of the joint
  144295. */
  144296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144297. /**
  144298. * Sets a motor on the joint
  144299. * @param joint joint to set motor on
  144300. * @param speed speed of the motor
  144301. * @param maxForce maximum force of the motor
  144302. * @param motorIndex index of the motor
  144303. */
  144304. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  144305. /**
  144306. * Sets the motors limit
  144307. * @param joint joint to set limit on
  144308. * @param upperLimit upper limit
  144309. * @param lowerLimit lower limit
  144310. */
  144311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  144312. /**
  144313. * Syncs the position and rotation of a mesh with the impostor
  144314. * @param mesh mesh to sync
  144315. * @param impostor impostor to update the mesh with
  144316. */
  144317. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144318. /**
  144319. * Gets the radius of the impostor
  144320. * @param impostor impostor to get radius from
  144321. * @returns the radius
  144322. */
  144323. getRadius(impostor: PhysicsImpostor): number;
  144324. /**
  144325. * Gets the box size of the impostor
  144326. * @param impostor impostor to get box size from
  144327. * @param result the resulting box size
  144328. */
  144329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144330. /**
  144331. * Disposes of the impostor
  144332. */
  144333. dispose(): void;
  144334. /**
  144335. * Does a raycast in the physics world
  144336. * @param from when should the ray start?
  144337. * @param to when should the ray end?
  144338. * @returns PhysicsRaycastResult
  144339. */
  144340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144341. }
  144342. }
  144343. declare module BABYLON {
  144344. interface AbstractScene {
  144345. /**
  144346. * The list of reflection probes added to the scene
  144347. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144348. */
  144349. reflectionProbes: Array<ReflectionProbe>;
  144350. /**
  144351. * Removes the given reflection probe from this scene.
  144352. * @param toRemove The reflection probe to remove
  144353. * @returns The index of the removed reflection probe
  144354. */
  144355. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144356. /**
  144357. * Adds the given reflection probe to this scene.
  144358. * @param newReflectionProbe The reflection probe to add
  144359. */
  144360. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144361. }
  144362. /**
  144363. * Class used to generate realtime reflection / refraction cube textures
  144364. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144365. */
  144366. export class ReflectionProbe {
  144367. /** defines the name of the probe */
  144368. name: string;
  144369. private _scene;
  144370. private _renderTargetTexture;
  144371. private _projectionMatrix;
  144372. private _viewMatrix;
  144373. private _target;
  144374. private _add;
  144375. private _attachedMesh;
  144376. private _invertYAxis;
  144377. /** Gets or sets probe position (center of the cube map) */
  144378. position: Vector3;
  144379. /**
  144380. * Creates a new reflection probe
  144381. * @param name defines the name of the probe
  144382. * @param size defines the texture resolution (for each face)
  144383. * @param scene defines the hosting scene
  144384. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144385. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144386. */
  144387. constructor(
  144388. /** defines the name of the probe */
  144389. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144390. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144391. get samples(): number;
  144392. set samples(value: number);
  144393. /** Gets or sets the refresh rate to use (on every frame by default) */
  144394. get refreshRate(): number;
  144395. set refreshRate(value: number);
  144396. /**
  144397. * Gets the hosting scene
  144398. * @returns a Scene
  144399. */
  144400. getScene(): Scene;
  144401. /** Gets the internal CubeTexture used to render to */
  144402. get cubeTexture(): RenderTargetTexture;
  144403. /** Gets the list of meshes to render */
  144404. get renderList(): Nullable<AbstractMesh[]>;
  144405. /**
  144406. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144407. * @param mesh defines the mesh to attach to
  144408. */
  144409. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144410. /**
  144411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144412. * @param renderingGroupId The rendering group id corresponding to its index
  144413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144414. */
  144415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144416. /**
  144417. * Clean all associated resources
  144418. */
  144419. dispose(): void;
  144420. /**
  144421. * Converts the reflection probe information to a readable string for debug purpose.
  144422. * @param fullDetails Supports for multiple levels of logging within scene loading
  144423. * @returns the human readable reflection probe info
  144424. */
  144425. toString(fullDetails?: boolean): string;
  144426. /**
  144427. * Get the class name of the relfection probe.
  144428. * @returns "ReflectionProbe"
  144429. */
  144430. getClassName(): string;
  144431. /**
  144432. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144433. * @returns The JSON representation of the texture
  144434. */
  144435. serialize(): any;
  144436. /**
  144437. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144438. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144439. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144440. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144441. * @returns The parsed reflection probe if successful
  144442. */
  144443. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144444. }
  144445. }
  144446. declare module BABYLON {
  144447. /** @hidden */
  144448. export var _BabylonLoaderRegistered: boolean;
  144449. /**
  144450. * Helps setting up some configuration for the babylon file loader.
  144451. */
  144452. export class BabylonFileLoaderConfiguration {
  144453. /**
  144454. * The loader does not allow injecting custom physix engine into the plugins.
  144455. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144456. * So you could set this variable to your engine import to make it work.
  144457. */
  144458. static LoaderInjectedPhysicsEngine: any;
  144459. }
  144460. }
  144461. declare module BABYLON {
  144462. /**
  144463. * The Physically based simple base material of BJS.
  144464. *
  144465. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144466. * It is used as the base class for both the specGloss and metalRough conventions.
  144467. */
  144468. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144469. /**
  144470. * Number of Simultaneous lights allowed on the material.
  144471. */
  144472. maxSimultaneousLights: number;
  144473. /**
  144474. * If sets to true, disables all the lights affecting the material.
  144475. */
  144476. disableLighting: boolean;
  144477. /**
  144478. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144479. */
  144480. environmentTexture: BaseTexture;
  144481. /**
  144482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144483. */
  144484. invertNormalMapX: boolean;
  144485. /**
  144486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144487. */
  144488. invertNormalMapY: boolean;
  144489. /**
  144490. * Normal map used in the model.
  144491. */
  144492. normalTexture: BaseTexture;
  144493. /**
  144494. * Emissivie color used to self-illuminate the model.
  144495. */
  144496. emissiveColor: Color3;
  144497. /**
  144498. * Emissivie texture used to self-illuminate the model.
  144499. */
  144500. emissiveTexture: BaseTexture;
  144501. /**
  144502. * Occlusion Channel Strenght.
  144503. */
  144504. occlusionStrength: number;
  144505. /**
  144506. * Occlusion Texture of the material (adding extra occlusion effects).
  144507. */
  144508. occlusionTexture: BaseTexture;
  144509. /**
  144510. * Defines the alpha limits in alpha test mode.
  144511. */
  144512. alphaCutOff: number;
  144513. /**
  144514. * Gets the current double sided mode.
  144515. */
  144516. get doubleSided(): boolean;
  144517. /**
  144518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144519. */
  144520. set doubleSided(value: boolean);
  144521. /**
  144522. * Stores the pre-calculated light information of a mesh in a texture.
  144523. */
  144524. lightmapTexture: BaseTexture;
  144525. /**
  144526. * If true, the light map contains occlusion information instead of lighting info.
  144527. */
  144528. useLightmapAsShadowmap: boolean;
  144529. /**
  144530. * Instantiates a new PBRMaterial instance.
  144531. *
  144532. * @param name The material name
  144533. * @param scene The scene the material will be use in.
  144534. */
  144535. constructor(name: string, scene: Scene);
  144536. getClassName(): string;
  144537. }
  144538. }
  144539. declare module BABYLON {
  144540. /**
  144541. * The PBR material of BJS following the metal roughness convention.
  144542. *
  144543. * This fits to the PBR convention in the GLTF definition:
  144544. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144545. */
  144546. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144547. /**
  144548. * The base color has two different interpretations depending on the value of metalness.
  144549. * When the material is a metal, the base color is the specific measured reflectance value
  144550. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144551. * of the material.
  144552. */
  144553. baseColor: Color3;
  144554. /**
  144555. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144556. * well as opacity information in the alpha channel.
  144557. */
  144558. baseTexture: BaseTexture;
  144559. /**
  144560. * Specifies the metallic scalar value of the material.
  144561. * Can also be used to scale the metalness values of the metallic texture.
  144562. */
  144563. metallic: number;
  144564. /**
  144565. * Specifies the roughness scalar value of the material.
  144566. * Can also be used to scale the roughness values of the metallic texture.
  144567. */
  144568. roughness: number;
  144569. /**
  144570. * Texture containing both the metallic value in the B channel and the
  144571. * roughness value in the G channel to keep better precision.
  144572. */
  144573. metallicRoughnessTexture: BaseTexture;
  144574. /**
  144575. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144576. *
  144577. * @param name The material name
  144578. * @param scene The scene the material will be use in.
  144579. */
  144580. constructor(name: string, scene: Scene);
  144581. /**
  144582. * Return the currrent class name of the material.
  144583. */
  144584. getClassName(): string;
  144585. /**
  144586. * Makes a duplicate of the current material.
  144587. * @param name - name to use for the new material.
  144588. */
  144589. clone(name: string): PBRMetallicRoughnessMaterial;
  144590. /**
  144591. * Serialize the material to a parsable JSON object.
  144592. */
  144593. serialize(): any;
  144594. /**
  144595. * Parses a JSON object correponding to the serialize function.
  144596. */
  144597. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144598. }
  144599. }
  144600. declare module BABYLON {
  144601. /**
  144602. * The PBR material of BJS following the specular glossiness convention.
  144603. *
  144604. * This fits to the PBR convention in the GLTF definition:
  144605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144606. */
  144607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144608. /**
  144609. * Specifies the diffuse color of the material.
  144610. */
  144611. diffuseColor: Color3;
  144612. /**
  144613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144614. * channel.
  144615. */
  144616. diffuseTexture: BaseTexture;
  144617. /**
  144618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144619. */
  144620. specularColor: Color3;
  144621. /**
  144622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144623. */
  144624. glossiness: number;
  144625. /**
  144626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144627. */
  144628. specularGlossinessTexture: BaseTexture;
  144629. /**
  144630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144631. *
  144632. * @param name The material name
  144633. * @param scene The scene the material will be use in.
  144634. */
  144635. constructor(name: string, scene: Scene);
  144636. /**
  144637. * Return the currrent class name of the material.
  144638. */
  144639. getClassName(): string;
  144640. /**
  144641. * Makes a duplicate of the current material.
  144642. * @param name - name to use for the new material.
  144643. */
  144644. clone(name: string): PBRSpecularGlossinessMaterial;
  144645. /**
  144646. * Serialize the material to a parsable JSON object.
  144647. */
  144648. serialize(): any;
  144649. /**
  144650. * Parses a JSON object correponding to the serialize function.
  144651. */
  144652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144653. }
  144654. }
  144655. declare module BABYLON {
  144656. /**
  144657. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144658. * It can help converting any input color in a desired output one. This can then be used to create effects
  144659. * from sepia, black and white to sixties or futuristic rendering...
  144660. *
  144661. * The only supported format is currently 3dl.
  144662. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144663. */
  144664. export class ColorGradingTexture extends BaseTexture {
  144665. /**
  144666. * The texture URL.
  144667. */
  144668. url: string;
  144669. /**
  144670. * Empty line regex stored for GC.
  144671. */
  144672. private static _noneEmptyLineRegex;
  144673. private _textureMatrix;
  144674. private _onLoad;
  144675. /**
  144676. * Instantiates a ColorGradingTexture from the following parameters.
  144677. *
  144678. * @param url The location of the color gradind data (currently only supporting 3dl)
  144679. * @param sceneOrEngine The scene or engine the texture will be used in
  144680. * @param onLoad defines a callback triggered when the texture has been loaded
  144681. */
  144682. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144683. /**
  144684. * Fires the onload event from the constructor if requested.
  144685. */
  144686. private _triggerOnLoad;
  144687. /**
  144688. * Returns the texture matrix used in most of the material.
  144689. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144690. */
  144691. getTextureMatrix(): Matrix;
  144692. /**
  144693. * Occurs when the file being loaded is a .3dl LUT file.
  144694. */
  144695. private load3dlTexture;
  144696. /**
  144697. * Starts the loading process of the texture.
  144698. */
  144699. private loadTexture;
  144700. /**
  144701. * Clones the color gradind texture.
  144702. */
  144703. clone(): ColorGradingTexture;
  144704. /**
  144705. * Called during delayed load for textures.
  144706. */
  144707. delayLoad(): void;
  144708. /**
  144709. * Parses a color grading texture serialized by Babylon.
  144710. * @param parsedTexture The texture information being parsedTexture
  144711. * @param scene The scene to load the texture in
  144712. * @param rootUrl The root url of the data assets to load
  144713. * @return A color gradind texture
  144714. */
  144715. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144716. /**
  144717. * Serializes the LUT texture to json format.
  144718. */
  144719. serialize(): any;
  144720. }
  144721. }
  144722. declare module BABYLON {
  144723. /**
  144724. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144725. */
  144726. export class EquiRectangularCubeTexture extends BaseTexture {
  144727. /** The six faces of the cube. */
  144728. private static _FacesMapping;
  144729. private _noMipmap;
  144730. private _onLoad;
  144731. private _onError;
  144732. /** The size of the cubemap. */
  144733. private _size;
  144734. /** The buffer of the image. */
  144735. private _buffer;
  144736. /** The width of the input image. */
  144737. private _width;
  144738. /** The height of the input image. */
  144739. private _height;
  144740. /** The URL to the image. */
  144741. url: string;
  144742. /**
  144743. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144744. * @param url The location of the image
  144745. * @param scene The scene the texture will be used in
  144746. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144747. * @param noMipmap Forces to not generate the mipmap if true
  144748. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144749. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144750. * @param onLoad — defines a callback called when texture is loaded
  144751. * @param onError — defines a callback called if there is an error
  144752. */
  144753. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144754. /**
  144755. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144756. */
  144757. private loadImage;
  144758. /**
  144759. * Convert the image buffer into a cubemap and create a CubeTexture.
  144760. */
  144761. private loadTexture;
  144762. /**
  144763. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144764. * @param buffer The ArrayBuffer that should be converted.
  144765. * @returns The buffer as Float32Array.
  144766. */
  144767. private getFloat32ArrayFromArrayBuffer;
  144768. /**
  144769. * Get the current class name of the texture useful for serialization or dynamic coding.
  144770. * @returns "EquiRectangularCubeTexture"
  144771. */
  144772. getClassName(): string;
  144773. /**
  144774. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144775. * @returns A clone of the current EquiRectangularCubeTexture.
  144776. */
  144777. clone(): EquiRectangularCubeTexture;
  144778. }
  144779. }
  144780. declare module BABYLON {
  144781. /**
  144782. * Defines the options related to the creation of an HtmlElementTexture
  144783. */
  144784. export interface IHtmlElementTextureOptions {
  144785. /**
  144786. * Defines wether mip maps should be created or not.
  144787. */
  144788. generateMipMaps?: boolean;
  144789. /**
  144790. * Defines the sampling mode of the texture.
  144791. */
  144792. samplingMode?: number;
  144793. /**
  144794. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144795. */
  144796. engine: Nullable<ThinEngine>;
  144797. /**
  144798. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144799. */
  144800. scene: Nullable<Scene>;
  144801. }
  144802. /**
  144803. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144804. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144805. * is automatically managed.
  144806. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144807. * in your application.
  144808. *
  144809. * As the update is not automatic, you need to call them manually.
  144810. */
  144811. export class HtmlElementTexture extends BaseTexture {
  144812. /**
  144813. * The texture URL.
  144814. */
  144815. element: HTMLVideoElement | HTMLCanvasElement;
  144816. private static readonly DefaultOptions;
  144817. private _textureMatrix;
  144818. private _isVideo;
  144819. private _generateMipMaps;
  144820. private _samplingMode;
  144821. /**
  144822. * Instantiates a HtmlElementTexture from the following parameters.
  144823. *
  144824. * @param name Defines the name of the texture
  144825. * @param element Defines the video or canvas the texture is filled with
  144826. * @param options Defines the other none mandatory texture creation options
  144827. */
  144828. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144829. private _createInternalTexture;
  144830. /**
  144831. * Returns the texture matrix used in most of the material.
  144832. */
  144833. getTextureMatrix(): Matrix;
  144834. /**
  144835. * Updates the content of the texture.
  144836. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144837. */
  144838. update(invertY?: Nullable<boolean>): void;
  144839. }
  144840. }
  144841. declare module BABYLON {
  144842. /**
  144843. * Based on jsTGALoader - Javascript loader for TGA file
  144844. * By Vincent Thibault
  144845. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144846. */
  144847. export class TGATools {
  144848. private static _TYPE_INDEXED;
  144849. private static _TYPE_RGB;
  144850. private static _TYPE_GREY;
  144851. private static _TYPE_RLE_INDEXED;
  144852. private static _TYPE_RLE_RGB;
  144853. private static _TYPE_RLE_GREY;
  144854. private static _ORIGIN_MASK;
  144855. private static _ORIGIN_SHIFT;
  144856. private static _ORIGIN_BL;
  144857. private static _ORIGIN_BR;
  144858. private static _ORIGIN_UL;
  144859. private static _ORIGIN_UR;
  144860. /**
  144861. * Gets the header of a TGA file
  144862. * @param data defines the TGA data
  144863. * @returns the header
  144864. */
  144865. static GetTGAHeader(data: Uint8Array): any;
  144866. /**
  144867. * Uploads TGA content to a Babylon Texture
  144868. * @hidden
  144869. */
  144870. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144871. /** @hidden */
  144872. 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;
  144873. /** @hidden */
  144874. 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;
  144875. /** @hidden */
  144876. 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;
  144877. /** @hidden */
  144878. 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;
  144879. /** @hidden */
  144880. 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;
  144881. /** @hidden */
  144882. 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;
  144883. }
  144884. }
  144885. declare module BABYLON {
  144886. /**
  144887. * Implementation of the TGA Texture Loader.
  144888. * @hidden
  144889. */
  144890. export class _TGATextureLoader implements IInternalTextureLoader {
  144891. /**
  144892. * Defines wether the loader supports cascade loading the different faces.
  144893. */
  144894. readonly supportCascades: boolean;
  144895. /**
  144896. * This returns if the loader support the current file information.
  144897. * @param extension defines the file extension of the file being loaded
  144898. * @returns true if the loader can load the specified file
  144899. */
  144900. canLoad(extension: string): boolean;
  144901. /**
  144902. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144903. * @param data contains the texture data
  144904. * @param texture defines the BabylonJS internal texture
  144905. * @param createPolynomials will be true if polynomials have been requested
  144906. * @param onLoad defines the callback to trigger once the texture is ready
  144907. * @param onError defines the callback to trigger in case of error
  144908. */
  144909. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144910. /**
  144911. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144912. * @param data contains the texture data
  144913. * @param texture defines the BabylonJS internal texture
  144914. * @param callback defines the method to call once ready to upload
  144915. */
  144916. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144917. }
  144918. }
  144919. declare module BABYLON {
  144920. /**
  144921. * Info about the .basis files
  144922. */
  144923. class BasisFileInfo {
  144924. /**
  144925. * If the file has alpha
  144926. */
  144927. hasAlpha: boolean;
  144928. /**
  144929. * Info about each image of the basis file
  144930. */
  144931. images: Array<{
  144932. levels: Array<{
  144933. width: number;
  144934. height: number;
  144935. transcodedPixels: ArrayBufferView;
  144936. }>;
  144937. }>;
  144938. }
  144939. /**
  144940. * Result of transcoding a basis file
  144941. */
  144942. class TranscodeResult {
  144943. /**
  144944. * Info about the .basis file
  144945. */
  144946. fileInfo: BasisFileInfo;
  144947. /**
  144948. * Format to use when loading the file
  144949. */
  144950. format: number;
  144951. }
  144952. /**
  144953. * Configuration options for the Basis transcoder
  144954. */
  144955. export class BasisTranscodeConfiguration {
  144956. /**
  144957. * Supported compression formats used to determine the supported output format of the transcoder
  144958. */
  144959. supportedCompressionFormats?: {
  144960. /**
  144961. * etc1 compression format
  144962. */
  144963. etc1?: boolean;
  144964. /**
  144965. * s3tc compression format
  144966. */
  144967. s3tc?: boolean;
  144968. /**
  144969. * pvrtc compression format
  144970. */
  144971. pvrtc?: boolean;
  144972. /**
  144973. * etc2 compression format
  144974. */
  144975. etc2?: boolean;
  144976. };
  144977. /**
  144978. * If mipmap levels should be loaded for transcoded images (Default: true)
  144979. */
  144980. loadMipmapLevels?: boolean;
  144981. /**
  144982. * Index of a single image to load (Default: all images)
  144983. */
  144984. loadSingleImage?: number;
  144985. }
  144986. /**
  144987. * Used to load .Basis files
  144988. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144989. */
  144990. export class BasisTools {
  144991. private static _IgnoreSupportedFormats;
  144992. /**
  144993. * URL to use when loading the basis transcoder
  144994. */
  144995. static JSModuleURL: string;
  144996. /**
  144997. * URL to use when loading the wasm module for the transcoder
  144998. */
  144999. static WasmModuleURL: string;
  145000. /**
  145001. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  145002. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  145003. * @returns internal format corresponding to the Basis format
  145004. */
  145005. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  145006. private static _WorkerPromise;
  145007. private static _Worker;
  145008. private static _actionId;
  145009. private static _CreateWorkerAsync;
  145010. /**
  145011. * Transcodes a loaded image file to compressed pixel data
  145012. * @param data image data to transcode
  145013. * @param config configuration options for the transcoding
  145014. * @returns a promise resulting in the transcoded image
  145015. */
  145016. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  145017. /**
  145018. * Loads a texture from the transcode result
  145019. * @param texture texture load to
  145020. * @param transcodeResult the result of transcoding the basis file to load from
  145021. */
  145022. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  145023. }
  145024. }
  145025. declare module BABYLON {
  145026. /**
  145027. * Loader for .basis file format
  145028. */
  145029. export class _BasisTextureLoader implements IInternalTextureLoader {
  145030. /**
  145031. * Defines whether the loader supports cascade loading the different faces.
  145032. */
  145033. readonly supportCascades: boolean;
  145034. /**
  145035. * This returns if the loader support the current file information.
  145036. * @param extension defines the file extension of the file being loaded
  145037. * @returns true if the loader can load the specified file
  145038. */
  145039. canLoad(extension: string): boolean;
  145040. /**
  145041. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  145042. * @param data contains the texture data
  145043. * @param texture defines the BabylonJS internal texture
  145044. * @param createPolynomials will be true if polynomials have been requested
  145045. * @param onLoad defines the callback to trigger once the texture is ready
  145046. * @param onError defines the callback to trigger in case of error
  145047. */
  145048. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  145049. /**
  145050. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  145051. * @param data contains the texture data
  145052. * @param texture defines the BabylonJS internal texture
  145053. * @param callback defines the method to call once ready to upload
  145054. */
  145055. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  145056. }
  145057. }
  145058. declare module BABYLON {
  145059. /**
  145060. * Defines the basic options interface of a TexturePacker Frame
  145061. */
  145062. export interface ITexturePackerFrame {
  145063. /**
  145064. * The frame ID
  145065. */
  145066. id: number;
  145067. /**
  145068. * The frames Scale
  145069. */
  145070. scale: Vector2;
  145071. /**
  145072. * The Frames offset
  145073. */
  145074. offset: Vector2;
  145075. }
  145076. /**
  145077. * This is a support class for frame Data on texture packer sets.
  145078. */
  145079. export class TexturePackerFrame implements ITexturePackerFrame {
  145080. /**
  145081. * The frame ID
  145082. */
  145083. id: number;
  145084. /**
  145085. * The frames Scale
  145086. */
  145087. scale: Vector2;
  145088. /**
  145089. * The Frames offset
  145090. */
  145091. offset: Vector2;
  145092. /**
  145093. * Initializes a texture package frame.
  145094. * @param id The numerical frame identifier
  145095. * @param scale Scalar Vector2 for UV frame
  145096. * @param offset Vector2 for the frame position in UV units.
  145097. * @returns TexturePackerFrame
  145098. */
  145099. constructor(id: number, scale: Vector2, offset: Vector2);
  145100. }
  145101. }
  145102. declare module BABYLON {
  145103. /**
  145104. * Defines the basic options interface of a TexturePacker
  145105. */
  145106. export interface ITexturePackerOptions {
  145107. /**
  145108. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  145109. */
  145110. map?: string[];
  145111. /**
  145112. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145113. */
  145114. uvsIn?: string;
  145115. /**
  145116. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145117. */
  145118. uvsOut?: string;
  145119. /**
  145120. * number representing the layout style. Defaults to LAYOUT_STRIP
  145121. */
  145122. layout?: number;
  145123. /**
  145124. * number of columns if using custom column count layout(2). This defaults to 4.
  145125. */
  145126. colnum?: number;
  145127. /**
  145128. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  145129. */
  145130. updateInputMeshes?: boolean;
  145131. /**
  145132. * boolean flag to dispose all the source textures. Defaults to true.
  145133. */
  145134. disposeSources?: boolean;
  145135. /**
  145136. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  145137. */
  145138. fillBlanks?: boolean;
  145139. /**
  145140. * string value representing the context fill style color. Defaults to 'black'.
  145141. */
  145142. customFillColor?: string;
  145143. /**
  145144. * Width and Height Value of each Frame in the TexturePacker Sets
  145145. */
  145146. frameSize?: number;
  145147. /**
  145148. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  145149. */
  145150. paddingRatio?: number;
  145151. /**
  145152. * Number that declares the fill method for the padding gutter.
  145153. */
  145154. paddingMode?: number;
  145155. /**
  145156. * If in SUBUV_COLOR padding mode what color to use.
  145157. */
  145158. paddingColor?: Color3 | Color4;
  145159. }
  145160. /**
  145161. * Defines the basic interface of a TexturePacker JSON File
  145162. */
  145163. export interface ITexturePackerJSON {
  145164. /**
  145165. * The frame ID
  145166. */
  145167. name: string;
  145168. /**
  145169. * The base64 channel data
  145170. */
  145171. sets: any;
  145172. /**
  145173. * The options of the Packer
  145174. */
  145175. options: ITexturePackerOptions;
  145176. /**
  145177. * The frame data of the Packer
  145178. */
  145179. frames: Array<number>;
  145180. }
  145181. /**
  145182. * This is a support class that generates a series of packed texture sets.
  145183. * @see https://doc.babylonjs.com/babylon101/materials
  145184. */
  145185. export class TexturePacker {
  145186. /** Packer Layout Constant 0 */
  145187. static readonly LAYOUT_STRIP: number;
  145188. /** Packer Layout Constant 1 */
  145189. static readonly LAYOUT_POWER2: number;
  145190. /** Packer Layout Constant 2 */
  145191. static readonly LAYOUT_COLNUM: number;
  145192. /** Packer Layout Constant 0 */
  145193. static readonly SUBUV_WRAP: number;
  145194. /** Packer Layout Constant 1 */
  145195. static readonly SUBUV_EXTEND: number;
  145196. /** Packer Layout Constant 2 */
  145197. static readonly SUBUV_COLOR: number;
  145198. /** The Name of the Texture Package */
  145199. name: string;
  145200. /** The scene scope of the TexturePacker */
  145201. scene: Scene;
  145202. /** The Meshes to target */
  145203. meshes: AbstractMesh[];
  145204. /** Arguments passed with the Constructor */
  145205. options: ITexturePackerOptions;
  145206. /** The promise that is started upon initialization */
  145207. promise: Nullable<Promise<TexturePacker | string>>;
  145208. /** The Container object for the channel sets that are generated */
  145209. sets: object;
  145210. /** The Container array for the frames that are generated */
  145211. frames: TexturePackerFrame[];
  145212. /** The expected number of textures the system is parsing. */
  145213. private _expecting;
  145214. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  145215. private _paddingValue;
  145216. /**
  145217. * Initializes a texture package series from an array of meshes or a single mesh.
  145218. * @param name The name of the package
  145219. * @param meshes The target meshes to compose the package from
  145220. * @param options The arguments that texture packer should follow while building.
  145221. * @param scene The scene which the textures are scoped to.
  145222. * @returns TexturePacker
  145223. */
  145224. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  145225. /**
  145226. * Starts the package process
  145227. * @param resolve The promises resolution function
  145228. * @returns TexturePacker
  145229. */
  145230. private _createFrames;
  145231. /**
  145232. * Calculates the Size of the Channel Sets
  145233. * @returns Vector2
  145234. */
  145235. private _calculateSize;
  145236. /**
  145237. * Calculates the UV data for the frames.
  145238. * @param baseSize the base frameSize
  145239. * @param padding the base frame padding
  145240. * @param dtSize size of the Dynamic Texture for that channel
  145241. * @param dtUnits is 1/dtSize
  145242. * @param update flag to update the input meshes
  145243. */
  145244. private _calculateMeshUVFrames;
  145245. /**
  145246. * Calculates the frames Offset.
  145247. * @param index of the frame
  145248. * @returns Vector2
  145249. */
  145250. private _getFrameOffset;
  145251. /**
  145252. * Updates a Mesh to the frame data
  145253. * @param mesh that is the target
  145254. * @param frameID or the frame index
  145255. */
  145256. private _updateMeshUV;
  145257. /**
  145258. * Updates a Meshes materials to use the texture packer channels
  145259. * @param m is the mesh to target
  145260. * @param force all channels on the packer to be set.
  145261. */
  145262. private _updateTextureReferences;
  145263. /**
  145264. * Public method to set a Mesh to a frame
  145265. * @param m that is the target
  145266. * @param frameID or the frame index
  145267. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  145268. */
  145269. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  145270. /**
  145271. * Starts the async promise to compile the texture packer.
  145272. * @returns Promise<void>
  145273. */
  145274. processAsync(): Promise<void>;
  145275. /**
  145276. * Disposes all textures associated with this packer
  145277. */
  145278. dispose(): void;
  145279. /**
  145280. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  145281. * @param imageType is the image type to use.
  145282. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  145283. */
  145284. download(imageType?: string, quality?: number): void;
  145285. /**
  145286. * Public method to load a texturePacker JSON file.
  145287. * @param data of the JSON file in string format.
  145288. */
  145289. updateFromJSON(data: string): void;
  145290. }
  145291. }
  145292. declare module BABYLON {
  145293. /**
  145294. * 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.
  145295. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145296. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145297. */
  145298. export class CustomProceduralTexture extends ProceduralTexture {
  145299. private _animate;
  145300. private _time;
  145301. private _config;
  145302. private _texturePath;
  145303. /**
  145304. * Instantiates a new Custom Procedural Texture.
  145305. * 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.
  145306. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145307. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145308. * @param name Define the name of the texture
  145309. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  145310. * @param size Define the size of the texture to create
  145311. * @param scene Define the scene the texture belongs to
  145312. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  145313. * @param generateMipMaps Define if the texture should creates mip maps or not
  145314. */
  145315. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145316. private _loadJson;
  145317. /**
  145318. * Is the texture ready to be used ? (rendered at least once)
  145319. * @returns true if ready, otherwise, false.
  145320. */
  145321. isReady(): boolean;
  145322. /**
  145323. * Render the texture to its associated render target.
  145324. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  145325. */
  145326. render(useCameraPostProcess?: boolean): void;
  145327. /**
  145328. * Update the list of dependant textures samplers in the shader.
  145329. */
  145330. updateTextures(): void;
  145331. /**
  145332. * Update the uniform values of the procedural texture in the shader.
  145333. */
  145334. updateShaderUniforms(): void;
  145335. /**
  145336. * Define if the texture animates or not.
  145337. */
  145338. get animate(): boolean;
  145339. set animate(value: boolean);
  145340. }
  145341. }
  145342. declare module BABYLON {
  145343. /** @hidden */
  145344. export var noisePixelShader: {
  145345. name: string;
  145346. shader: string;
  145347. };
  145348. }
  145349. declare module BABYLON {
  145350. /**
  145351. * Class used to generate noise procedural textures
  145352. */
  145353. export class NoiseProceduralTexture extends ProceduralTexture {
  145354. /** Gets or sets the start time (default is 0) */
  145355. time: number;
  145356. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145357. brightness: number;
  145358. /** Defines the number of octaves to process */
  145359. octaves: number;
  145360. /** Defines the level of persistence (0.8 by default) */
  145361. persistence: number;
  145362. /** Gets or sets animation speed factor (default is 1) */
  145363. animationSpeedFactor: number;
  145364. /**
  145365. * Creates a new NoiseProceduralTexture
  145366. * @param name defines the name fo the texture
  145367. * @param size defines the size of the texture (default is 256)
  145368. * @param scene defines the hosting scene
  145369. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145370. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145371. */
  145372. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145373. private _updateShaderUniforms;
  145374. protected _getDefines(): string;
  145375. /** Generate the current state of the procedural texture */
  145376. render(useCameraPostProcess?: boolean): void;
  145377. /**
  145378. * Serializes this noise procedural texture
  145379. * @returns a serialized noise procedural texture object
  145380. */
  145381. serialize(): any;
  145382. /**
  145383. * Clone the texture.
  145384. * @returns the cloned texture
  145385. */
  145386. clone(): NoiseProceduralTexture;
  145387. /**
  145388. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145389. * @param parsedTexture defines parsed texture data
  145390. * @param scene defines the current scene
  145391. * @param rootUrl defines the root URL containing noise procedural texture information
  145392. * @returns a parsed NoiseProceduralTexture
  145393. */
  145394. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145395. }
  145396. }
  145397. declare module BABYLON {
  145398. /**
  145399. * Raw cube texture where the raw buffers are passed in
  145400. */
  145401. export class RawCubeTexture extends CubeTexture {
  145402. /**
  145403. * Creates a cube texture where the raw buffers are passed in.
  145404. * @param scene defines the scene the texture is attached to
  145405. * @param data defines the array of data to use to create each face
  145406. * @param size defines the size of the textures
  145407. * @param format defines the format of the data
  145408. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145409. * @param generateMipMaps defines if the engine should generate the mip levels
  145410. * @param invertY defines if data must be stored with Y axis inverted
  145411. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145412. * @param compression defines the compression used (null by default)
  145413. */
  145414. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145415. /**
  145416. * Updates the raw cube texture.
  145417. * @param data defines the data to store
  145418. * @param format defines the data format
  145419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145420. * @param invertY defines if data must be stored with Y axis inverted
  145421. * @param compression defines the compression used (null by default)
  145422. * @param level defines which level of the texture to update
  145423. */
  145424. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145425. /**
  145426. * Updates a raw cube texture with RGBD encoded data.
  145427. * @param data defines the array of data [mipmap][face] to use to create each face
  145428. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145431. * @returns a promsie that resolves when the operation is complete
  145432. */
  145433. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145434. /**
  145435. * Clones the raw cube texture.
  145436. * @return a new cube texture
  145437. */
  145438. clone(): CubeTexture;
  145439. /** @hidden */
  145440. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145441. }
  145442. }
  145443. declare module BABYLON {
  145444. /**
  145445. * Class used to store 2D array textures containing user data
  145446. */
  145447. export class RawTexture2DArray extends Texture {
  145448. /** Gets or sets the texture format to use */
  145449. format: number;
  145450. /**
  145451. * Create a new RawTexture2DArray
  145452. * @param data defines the data of the texture
  145453. * @param width defines the width of the texture
  145454. * @param height defines the height of the texture
  145455. * @param depth defines the number of layers of the texture
  145456. * @param format defines the texture format to use
  145457. * @param scene defines the hosting scene
  145458. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145459. * @param invertY defines if texture must be stored with Y axis inverted
  145460. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145461. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145462. */
  145463. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145464. /** Gets or sets the texture format to use */
  145465. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145466. /**
  145467. * Update the texture with new data
  145468. * @param data defines the data to store in the texture
  145469. */
  145470. update(data: ArrayBufferView): void;
  145471. }
  145472. }
  145473. declare module BABYLON {
  145474. /**
  145475. * Class used to store 3D textures containing user data
  145476. */
  145477. export class RawTexture3D extends Texture {
  145478. /** Gets or sets the texture format to use */
  145479. format: number;
  145480. /**
  145481. * Create a new RawTexture3D
  145482. * @param data defines the data of the texture
  145483. * @param width defines the width of the texture
  145484. * @param height defines the height of the texture
  145485. * @param depth defines the depth of the texture
  145486. * @param format defines the texture format to use
  145487. * @param scene defines the hosting scene
  145488. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145489. * @param invertY defines if texture must be stored with Y axis inverted
  145490. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145491. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145492. */
  145493. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145494. /** Gets or sets the texture format to use */
  145495. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145496. /**
  145497. * Update the texture with new data
  145498. * @param data defines the data to store in the texture
  145499. */
  145500. update(data: ArrayBufferView): void;
  145501. }
  145502. }
  145503. declare module BABYLON {
  145504. /**
  145505. * Creates a refraction texture used by refraction channel of the standard material.
  145506. * It is like a mirror but to see through a material.
  145507. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145508. */
  145509. export class RefractionTexture extends RenderTargetTexture {
  145510. /**
  145511. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145512. * 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.
  145513. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145514. */
  145515. refractionPlane: Plane;
  145516. /**
  145517. * Define how deep under the surface we should see.
  145518. */
  145519. depth: number;
  145520. /**
  145521. * Creates a refraction texture used by refraction channel of the standard material.
  145522. * It is like a mirror but to see through a material.
  145523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145524. * @param name Define the texture name
  145525. * @param size Define the size of the underlying texture
  145526. * @param scene Define the scene the refraction belongs to
  145527. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145528. */
  145529. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145530. /**
  145531. * Clone the refraction texture.
  145532. * @returns the cloned texture
  145533. */
  145534. clone(): RefractionTexture;
  145535. /**
  145536. * Serialize the texture to a JSON representation you could use in Parse later on
  145537. * @returns the serialized JSON representation
  145538. */
  145539. serialize(): any;
  145540. }
  145541. }
  145542. declare module BABYLON {
  145543. /**
  145544. * Block used to add support for vertex skinning (bones)
  145545. */
  145546. export class BonesBlock extends NodeMaterialBlock {
  145547. /**
  145548. * Creates a new BonesBlock
  145549. * @param name defines the block name
  145550. */
  145551. constructor(name: string);
  145552. /**
  145553. * Initialize the block and prepare the context for build
  145554. * @param state defines the state that will be used for the build
  145555. */
  145556. initialize(state: NodeMaterialBuildState): void;
  145557. /**
  145558. * Gets the current class name
  145559. * @returns the class name
  145560. */
  145561. getClassName(): string;
  145562. /**
  145563. * Gets the matrix indices input component
  145564. */
  145565. get matricesIndices(): NodeMaterialConnectionPoint;
  145566. /**
  145567. * Gets the matrix weights input component
  145568. */
  145569. get matricesWeights(): NodeMaterialConnectionPoint;
  145570. /**
  145571. * Gets the extra matrix indices input component
  145572. */
  145573. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145574. /**
  145575. * Gets the extra matrix weights input component
  145576. */
  145577. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145578. /**
  145579. * Gets the world input component
  145580. */
  145581. get world(): NodeMaterialConnectionPoint;
  145582. /**
  145583. * Gets the output component
  145584. */
  145585. get output(): NodeMaterialConnectionPoint;
  145586. autoConfigure(material: NodeMaterial): void;
  145587. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145590. protected _buildBlock(state: NodeMaterialBuildState): this;
  145591. }
  145592. }
  145593. declare module BABYLON {
  145594. /**
  145595. * Block used to add support for instances
  145596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145597. */
  145598. export class InstancesBlock extends NodeMaterialBlock {
  145599. /**
  145600. * Creates a new InstancesBlock
  145601. * @param name defines the block name
  145602. */
  145603. constructor(name: string);
  145604. /**
  145605. * Gets the current class name
  145606. * @returns the class name
  145607. */
  145608. getClassName(): string;
  145609. /**
  145610. * Gets the first world row input component
  145611. */
  145612. get world0(): NodeMaterialConnectionPoint;
  145613. /**
  145614. * Gets the second world row input component
  145615. */
  145616. get world1(): NodeMaterialConnectionPoint;
  145617. /**
  145618. * Gets the third world row input component
  145619. */
  145620. get world2(): NodeMaterialConnectionPoint;
  145621. /**
  145622. * Gets the forth world row input component
  145623. */
  145624. get world3(): NodeMaterialConnectionPoint;
  145625. /**
  145626. * Gets the world input component
  145627. */
  145628. get world(): NodeMaterialConnectionPoint;
  145629. /**
  145630. * Gets the output component
  145631. */
  145632. get output(): NodeMaterialConnectionPoint;
  145633. /**
  145634. * Gets the isntanceID component
  145635. */
  145636. get instanceID(): NodeMaterialConnectionPoint;
  145637. autoConfigure(material: NodeMaterial): void;
  145638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145639. protected _buildBlock(state: NodeMaterialBuildState): this;
  145640. }
  145641. }
  145642. declare module BABYLON {
  145643. /**
  145644. * Block used to add morph targets support to vertex shader
  145645. */
  145646. export class MorphTargetsBlock extends NodeMaterialBlock {
  145647. private _repeatableContentAnchor;
  145648. /**
  145649. * Create a new MorphTargetsBlock
  145650. * @param name defines the block name
  145651. */
  145652. constructor(name: string);
  145653. /**
  145654. * Gets the current class name
  145655. * @returns the class name
  145656. */
  145657. getClassName(): string;
  145658. /**
  145659. * Gets the position input component
  145660. */
  145661. get position(): NodeMaterialConnectionPoint;
  145662. /**
  145663. * Gets the normal input component
  145664. */
  145665. get normal(): NodeMaterialConnectionPoint;
  145666. /**
  145667. * Gets the tangent input component
  145668. */
  145669. get tangent(): NodeMaterialConnectionPoint;
  145670. /**
  145671. * Gets the tangent input component
  145672. */
  145673. get uv(): NodeMaterialConnectionPoint;
  145674. /**
  145675. * Gets the position output component
  145676. */
  145677. get positionOutput(): NodeMaterialConnectionPoint;
  145678. /**
  145679. * Gets the normal output component
  145680. */
  145681. get normalOutput(): NodeMaterialConnectionPoint;
  145682. /**
  145683. * Gets the tangent output component
  145684. */
  145685. get tangentOutput(): NodeMaterialConnectionPoint;
  145686. /**
  145687. * Gets the tangent output component
  145688. */
  145689. get uvOutput(): NodeMaterialConnectionPoint;
  145690. initialize(state: NodeMaterialBuildState): void;
  145691. autoConfigure(material: NodeMaterial): void;
  145692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145694. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145695. protected _buildBlock(state: NodeMaterialBuildState): this;
  145696. }
  145697. }
  145698. declare module BABYLON {
  145699. /**
  145700. * Block used to get data information from a light
  145701. */
  145702. export class LightInformationBlock extends NodeMaterialBlock {
  145703. private _lightDataUniformName;
  145704. private _lightColorUniformName;
  145705. private _lightTypeDefineName;
  145706. /**
  145707. * Gets or sets the light associated with this block
  145708. */
  145709. light: Nullable<Light>;
  145710. /**
  145711. * Creates a new LightInformationBlock
  145712. * @param name defines the block name
  145713. */
  145714. constructor(name: string);
  145715. /**
  145716. * Gets the current class name
  145717. * @returns the class name
  145718. */
  145719. getClassName(): string;
  145720. /**
  145721. * Gets the world position input component
  145722. */
  145723. get worldPosition(): NodeMaterialConnectionPoint;
  145724. /**
  145725. * Gets the direction output component
  145726. */
  145727. get direction(): NodeMaterialConnectionPoint;
  145728. /**
  145729. * Gets the direction output component
  145730. */
  145731. get color(): NodeMaterialConnectionPoint;
  145732. /**
  145733. * Gets the direction output component
  145734. */
  145735. get intensity(): NodeMaterialConnectionPoint;
  145736. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145738. protected _buildBlock(state: NodeMaterialBuildState): this;
  145739. serialize(): any;
  145740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145741. }
  145742. }
  145743. declare module BABYLON {
  145744. /**
  145745. * Block used to add image processing support to fragment shader
  145746. */
  145747. export class ImageProcessingBlock extends NodeMaterialBlock {
  145748. /**
  145749. * Create a new ImageProcessingBlock
  145750. * @param name defines the block name
  145751. */
  145752. constructor(name: string);
  145753. /**
  145754. * Gets the current class name
  145755. * @returns the class name
  145756. */
  145757. getClassName(): string;
  145758. /**
  145759. * Gets the color input component
  145760. */
  145761. get color(): NodeMaterialConnectionPoint;
  145762. /**
  145763. * Gets the output component
  145764. */
  145765. get output(): NodeMaterialConnectionPoint;
  145766. /**
  145767. * Initialize the block and prepare the context for build
  145768. * @param state defines the state that will be used for the build
  145769. */
  145770. initialize(state: NodeMaterialBuildState): void;
  145771. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145773. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145774. protected _buildBlock(state: NodeMaterialBuildState): this;
  145775. }
  145776. }
  145777. declare module BABYLON {
  145778. /**
  145779. * Block used to pertub normals based on a normal map
  145780. */
  145781. export class PerturbNormalBlock extends NodeMaterialBlock {
  145782. private _tangentSpaceParameterName;
  145783. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145784. invertX: boolean;
  145785. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145786. invertY: boolean;
  145787. /**
  145788. * Create a new PerturbNormalBlock
  145789. * @param name defines the block name
  145790. */
  145791. constructor(name: string);
  145792. /**
  145793. * Gets the current class name
  145794. * @returns the class name
  145795. */
  145796. getClassName(): string;
  145797. /**
  145798. * Gets the world position input component
  145799. */
  145800. get worldPosition(): NodeMaterialConnectionPoint;
  145801. /**
  145802. * Gets the world normal input component
  145803. */
  145804. get worldNormal(): NodeMaterialConnectionPoint;
  145805. /**
  145806. * Gets the world tangent input component
  145807. */
  145808. get worldTangent(): NodeMaterialConnectionPoint;
  145809. /**
  145810. * Gets the uv input component
  145811. */
  145812. get uv(): NodeMaterialConnectionPoint;
  145813. /**
  145814. * Gets the normal map color input component
  145815. */
  145816. get normalMapColor(): NodeMaterialConnectionPoint;
  145817. /**
  145818. * Gets the strength input component
  145819. */
  145820. get strength(): NodeMaterialConnectionPoint;
  145821. /**
  145822. * Gets the output component
  145823. */
  145824. get output(): NodeMaterialConnectionPoint;
  145825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145827. autoConfigure(material: NodeMaterial): void;
  145828. protected _buildBlock(state: NodeMaterialBuildState): this;
  145829. protected _dumpPropertiesCode(): string;
  145830. serialize(): any;
  145831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145832. }
  145833. }
  145834. declare module BABYLON {
  145835. /**
  145836. * Block used to discard a pixel if a value is smaller than a cutoff
  145837. */
  145838. export class DiscardBlock extends NodeMaterialBlock {
  145839. /**
  145840. * Create a new DiscardBlock
  145841. * @param name defines the block name
  145842. */
  145843. constructor(name: string);
  145844. /**
  145845. * Gets the current class name
  145846. * @returns the class name
  145847. */
  145848. getClassName(): string;
  145849. /**
  145850. * Gets the color input component
  145851. */
  145852. get value(): NodeMaterialConnectionPoint;
  145853. /**
  145854. * Gets the cutoff input component
  145855. */
  145856. get cutoff(): NodeMaterialConnectionPoint;
  145857. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145858. }
  145859. }
  145860. declare module BABYLON {
  145861. /**
  145862. * Block used to test if the fragment shader is front facing
  145863. */
  145864. export class FrontFacingBlock extends NodeMaterialBlock {
  145865. /**
  145866. * Creates a new FrontFacingBlock
  145867. * @param name defines the block name
  145868. */
  145869. constructor(name: string);
  145870. /**
  145871. * Gets the current class name
  145872. * @returns the class name
  145873. */
  145874. getClassName(): string;
  145875. /**
  145876. * Gets the output component
  145877. */
  145878. get output(): NodeMaterialConnectionPoint;
  145879. protected _buildBlock(state: NodeMaterialBuildState): this;
  145880. }
  145881. }
  145882. declare module BABYLON {
  145883. /**
  145884. * Block used to get the derivative value on x and y of a given input
  145885. */
  145886. export class DerivativeBlock extends NodeMaterialBlock {
  145887. /**
  145888. * Create a new DerivativeBlock
  145889. * @param name defines the block name
  145890. */
  145891. constructor(name: string);
  145892. /**
  145893. * Gets the current class name
  145894. * @returns the class name
  145895. */
  145896. getClassName(): string;
  145897. /**
  145898. * Gets the input component
  145899. */
  145900. get input(): NodeMaterialConnectionPoint;
  145901. /**
  145902. * Gets the derivative output on x
  145903. */
  145904. get dx(): NodeMaterialConnectionPoint;
  145905. /**
  145906. * Gets the derivative output on y
  145907. */
  145908. get dy(): NodeMaterialConnectionPoint;
  145909. protected _buildBlock(state: NodeMaterialBuildState): this;
  145910. }
  145911. }
  145912. declare module BABYLON {
  145913. /**
  145914. * Block used to make gl_FragCoord available
  145915. */
  145916. export class FragCoordBlock extends NodeMaterialBlock {
  145917. /**
  145918. * Creates a new FragCoordBlock
  145919. * @param name defines the block name
  145920. */
  145921. constructor(name: string);
  145922. /**
  145923. * Gets the current class name
  145924. * @returns the class name
  145925. */
  145926. getClassName(): string;
  145927. /**
  145928. * Gets the xy component
  145929. */
  145930. get xy(): NodeMaterialConnectionPoint;
  145931. /**
  145932. * Gets the xyz component
  145933. */
  145934. get xyz(): NodeMaterialConnectionPoint;
  145935. /**
  145936. * Gets the xyzw component
  145937. */
  145938. get xyzw(): NodeMaterialConnectionPoint;
  145939. /**
  145940. * Gets the x component
  145941. */
  145942. get x(): NodeMaterialConnectionPoint;
  145943. /**
  145944. * Gets the y component
  145945. */
  145946. get y(): NodeMaterialConnectionPoint;
  145947. /**
  145948. * Gets the z component
  145949. */
  145950. get z(): NodeMaterialConnectionPoint;
  145951. /**
  145952. * Gets the w component
  145953. */
  145954. get output(): NodeMaterialConnectionPoint;
  145955. protected writeOutputs(state: NodeMaterialBuildState): string;
  145956. protected _buildBlock(state: NodeMaterialBuildState): this;
  145957. }
  145958. }
  145959. declare module BABYLON {
  145960. /**
  145961. * Block used to get the screen sizes
  145962. */
  145963. export class ScreenSizeBlock extends NodeMaterialBlock {
  145964. private _varName;
  145965. private _scene;
  145966. /**
  145967. * Creates a new ScreenSizeBlock
  145968. * @param name defines the block name
  145969. */
  145970. constructor(name: string);
  145971. /**
  145972. * Gets the current class name
  145973. * @returns the class name
  145974. */
  145975. getClassName(): string;
  145976. /**
  145977. * Gets the xy component
  145978. */
  145979. get xy(): NodeMaterialConnectionPoint;
  145980. /**
  145981. * Gets the x component
  145982. */
  145983. get x(): NodeMaterialConnectionPoint;
  145984. /**
  145985. * Gets the y component
  145986. */
  145987. get y(): NodeMaterialConnectionPoint;
  145988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145989. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145990. protected _buildBlock(state: NodeMaterialBuildState): this;
  145991. }
  145992. }
  145993. declare module BABYLON {
  145994. /**
  145995. * Block used to add support for scene fog
  145996. */
  145997. export class FogBlock extends NodeMaterialBlock {
  145998. private _fogDistanceName;
  145999. private _fogParameters;
  146000. /**
  146001. * Create a new FogBlock
  146002. * @param name defines the block name
  146003. */
  146004. constructor(name: string);
  146005. /**
  146006. * Gets the current class name
  146007. * @returns the class name
  146008. */
  146009. getClassName(): string;
  146010. /**
  146011. * Gets the world position input component
  146012. */
  146013. get worldPosition(): NodeMaterialConnectionPoint;
  146014. /**
  146015. * Gets the view input component
  146016. */
  146017. get view(): NodeMaterialConnectionPoint;
  146018. /**
  146019. * Gets the color input component
  146020. */
  146021. get input(): NodeMaterialConnectionPoint;
  146022. /**
  146023. * Gets the fog color input component
  146024. */
  146025. get fogColor(): NodeMaterialConnectionPoint;
  146026. /**
  146027. * Gets the output component
  146028. */
  146029. get output(): NodeMaterialConnectionPoint;
  146030. autoConfigure(material: NodeMaterial): void;
  146031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146033. protected _buildBlock(state: NodeMaterialBuildState): this;
  146034. }
  146035. }
  146036. declare module BABYLON {
  146037. /**
  146038. * Block used to add light in the fragment shader
  146039. */
  146040. export class LightBlock extends NodeMaterialBlock {
  146041. private _lightId;
  146042. /**
  146043. * Gets or sets the light associated with this block
  146044. */
  146045. light: Nullable<Light>;
  146046. /**
  146047. * Create a new LightBlock
  146048. * @param name defines the block name
  146049. */
  146050. constructor(name: string);
  146051. /**
  146052. * Gets the current class name
  146053. * @returns the class name
  146054. */
  146055. getClassName(): string;
  146056. /**
  146057. * Gets the world position input component
  146058. */
  146059. get worldPosition(): NodeMaterialConnectionPoint;
  146060. /**
  146061. * Gets the world normal input component
  146062. */
  146063. get worldNormal(): NodeMaterialConnectionPoint;
  146064. /**
  146065. * Gets the camera (or eye) position component
  146066. */
  146067. get cameraPosition(): NodeMaterialConnectionPoint;
  146068. /**
  146069. * Gets the glossiness component
  146070. */
  146071. get glossiness(): NodeMaterialConnectionPoint;
  146072. /**
  146073. * Gets the glossinness power component
  146074. */
  146075. get glossPower(): NodeMaterialConnectionPoint;
  146076. /**
  146077. * Gets the diffuse color component
  146078. */
  146079. get diffuseColor(): NodeMaterialConnectionPoint;
  146080. /**
  146081. * Gets the specular color component
  146082. */
  146083. get specularColor(): NodeMaterialConnectionPoint;
  146084. /**
  146085. * Gets the view matrix component
  146086. */
  146087. get view(): NodeMaterialConnectionPoint;
  146088. /**
  146089. * Gets the diffuse output component
  146090. */
  146091. get diffuseOutput(): NodeMaterialConnectionPoint;
  146092. /**
  146093. * Gets the specular output component
  146094. */
  146095. get specularOutput(): NodeMaterialConnectionPoint;
  146096. /**
  146097. * Gets the shadow output component
  146098. */
  146099. get shadow(): NodeMaterialConnectionPoint;
  146100. autoConfigure(material: NodeMaterial): void;
  146101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146102. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146104. private _injectVertexCode;
  146105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146106. serialize(): any;
  146107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146108. }
  146109. }
  146110. declare module BABYLON {
  146111. /**
  146112. * Block used to read a reflection texture from a sampler
  146113. */
  146114. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  146115. /**
  146116. * Create a new ReflectionTextureBlock
  146117. * @param name defines the block name
  146118. */
  146119. constructor(name: string);
  146120. /**
  146121. * Gets the current class name
  146122. * @returns the class name
  146123. */
  146124. getClassName(): string;
  146125. /**
  146126. * Gets the world position input component
  146127. */
  146128. get position(): NodeMaterialConnectionPoint;
  146129. /**
  146130. * Gets the world position input component
  146131. */
  146132. get worldPosition(): NodeMaterialConnectionPoint;
  146133. /**
  146134. * Gets the world normal input component
  146135. */
  146136. get worldNormal(): NodeMaterialConnectionPoint;
  146137. /**
  146138. * Gets the world input component
  146139. */
  146140. get world(): NodeMaterialConnectionPoint;
  146141. /**
  146142. * Gets the camera (or eye) position component
  146143. */
  146144. get cameraPosition(): NodeMaterialConnectionPoint;
  146145. /**
  146146. * Gets the view input component
  146147. */
  146148. get view(): NodeMaterialConnectionPoint;
  146149. /**
  146150. * Gets the rgb output component
  146151. */
  146152. get rgb(): NodeMaterialConnectionPoint;
  146153. /**
  146154. * Gets the rgba output component
  146155. */
  146156. get rgba(): NodeMaterialConnectionPoint;
  146157. /**
  146158. * Gets the r output component
  146159. */
  146160. get r(): NodeMaterialConnectionPoint;
  146161. /**
  146162. * Gets the g output component
  146163. */
  146164. get g(): NodeMaterialConnectionPoint;
  146165. /**
  146166. * Gets the b output component
  146167. */
  146168. get b(): NodeMaterialConnectionPoint;
  146169. /**
  146170. * Gets the a output component
  146171. */
  146172. get a(): NodeMaterialConnectionPoint;
  146173. autoConfigure(material: NodeMaterial): void;
  146174. protected _buildBlock(state: NodeMaterialBuildState): this;
  146175. }
  146176. }
  146177. declare module BABYLON {
  146178. /**
  146179. * Block used to add 2 vectors
  146180. */
  146181. export class AddBlock extends NodeMaterialBlock {
  146182. /**
  146183. * Creates a new AddBlock
  146184. * @param name defines the block name
  146185. */
  146186. constructor(name: string);
  146187. /**
  146188. * Gets the current class name
  146189. * @returns the class name
  146190. */
  146191. getClassName(): string;
  146192. /**
  146193. * Gets the left operand input component
  146194. */
  146195. get left(): NodeMaterialConnectionPoint;
  146196. /**
  146197. * Gets the right operand input component
  146198. */
  146199. get right(): NodeMaterialConnectionPoint;
  146200. /**
  146201. * Gets the output component
  146202. */
  146203. get output(): NodeMaterialConnectionPoint;
  146204. protected _buildBlock(state: NodeMaterialBuildState): this;
  146205. }
  146206. }
  146207. declare module BABYLON {
  146208. /**
  146209. * Block used to scale a vector by a float
  146210. */
  146211. export class ScaleBlock extends NodeMaterialBlock {
  146212. /**
  146213. * Creates a new ScaleBlock
  146214. * @param name defines the block name
  146215. */
  146216. constructor(name: string);
  146217. /**
  146218. * Gets the current class name
  146219. * @returns the class name
  146220. */
  146221. getClassName(): string;
  146222. /**
  146223. * Gets the input component
  146224. */
  146225. get input(): NodeMaterialConnectionPoint;
  146226. /**
  146227. * Gets the factor input component
  146228. */
  146229. get factor(): NodeMaterialConnectionPoint;
  146230. /**
  146231. * Gets the output component
  146232. */
  146233. get output(): NodeMaterialConnectionPoint;
  146234. protected _buildBlock(state: NodeMaterialBuildState): this;
  146235. }
  146236. }
  146237. declare module BABYLON {
  146238. /**
  146239. * Block used to clamp a float
  146240. */
  146241. export class ClampBlock extends NodeMaterialBlock {
  146242. /** Gets or sets the minimum range */
  146243. minimum: number;
  146244. /** Gets or sets the maximum range */
  146245. maximum: number;
  146246. /**
  146247. * Creates a new ClampBlock
  146248. * @param name defines the block name
  146249. */
  146250. constructor(name: string);
  146251. /**
  146252. * Gets the current class name
  146253. * @returns the class name
  146254. */
  146255. getClassName(): string;
  146256. /**
  146257. * Gets the value input component
  146258. */
  146259. get value(): NodeMaterialConnectionPoint;
  146260. /**
  146261. * Gets the output component
  146262. */
  146263. get output(): NodeMaterialConnectionPoint;
  146264. protected _buildBlock(state: NodeMaterialBuildState): this;
  146265. protected _dumpPropertiesCode(): string;
  146266. serialize(): any;
  146267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146268. }
  146269. }
  146270. declare module BABYLON {
  146271. /**
  146272. * Block used to apply a cross product between 2 vectors
  146273. */
  146274. export class CrossBlock extends NodeMaterialBlock {
  146275. /**
  146276. * Creates a new CrossBlock
  146277. * @param name defines the block name
  146278. */
  146279. constructor(name: string);
  146280. /**
  146281. * Gets the current class name
  146282. * @returns the class name
  146283. */
  146284. getClassName(): string;
  146285. /**
  146286. * Gets the left operand input component
  146287. */
  146288. get left(): NodeMaterialConnectionPoint;
  146289. /**
  146290. * Gets the right operand input component
  146291. */
  146292. get right(): NodeMaterialConnectionPoint;
  146293. /**
  146294. * Gets the output component
  146295. */
  146296. get output(): NodeMaterialConnectionPoint;
  146297. protected _buildBlock(state: NodeMaterialBuildState): this;
  146298. }
  146299. }
  146300. declare module BABYLON {
  146301. /**
  146302. * Block used to apply a dot product between 2 vectors
  146303. */
  146304. export class DotBlock extends NodeMaterialBlock {
  146305. /**
  146306. * Creates a new DotBlock
  146307. * @param name defines the block name
  146308. */
  146309. constructor(name: string);
  146310. /**
  146311. * Gets the current class name
  146312. * @returns the class name
  146313. */
  146314. getClassName(): string;
  146315. /**
  146316. * Gets the left operand input component
  146317. */
  146318. get left(): NodeMaterialConnectionPoint;
  146319. /**
  146320. * Gets the right operand input component
  146321. */
  146322. get right(): NodeMaterialConnectionPoint;
  146323. /**
  146324. * Gets the output component
  146325. */
  146326. get output(): NodeMaterialConnectionPoint;
  146327. protected _buildBlock(state: NodeMaterialBuildState): this;
  146328. }
  146329. }
  146330. declare module BABYLON {
  146331. /**
  146332. * Block used to normalize a vector
  146333. */
  146334. export class NormalizeBlock extends NodeMaterialBlock {
  146335. /**
  146336. * Creates a new NormalizeBlock
  146337. * @param name defines the block name
  146338. */
  146339. constructor(name: string);
  146340. /**
  146341. * Gets the current class name
  146342. * @returns the class name
  146343. */
  146344. getClassName(): string;
  146345. /**
  146346. * Gets the input component
  146347. */
  146348. get input(): NodeMaterialConnectionPoint;
  146349. /**
  146350. * Gets the output component
  146351. */
  146352. get output(): NodeMaterialConnectionPoint;
  146353. protected _buildBlock(state: NodeMaterialBuildState): this;
  146354. }
  146355. }
  146356. declare module BABYLON {
  146357. /**
  146358. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146359. */
  146360. export class ColorMergerBlock extends NodeMaterialBlock {
  146361. /**
  146362. * Create a new ColorMergerBlock
  146363. * @param name defines the block name
  146364. */
  146365. constructor(name: string);
  146366. /**
  146367. * Gets the current class name
  146368. * @returns the class name
  146369. */
  146370. getClassName(): string;
  146371. /**
  146372. * Gets the rgb component (input)
  146373. */
  146374. get rgbIn(): NodeMaterialConnectionPoint;
  146375. /**
  146376. * Gets the r component (input)
  146377. */
  146378. get r(): NodeMaterialConnectionPoint;
  146379. /**
  146380. * Gets the g component (input)
  146381. */
  146382. get g(): NodeMaterialConnectionPoint;
  146383. /**
  146384. * Gets the b component (input)
  146385. */
  146386. get b(): NodeMaterialConnectionPoint;
  146387. /**
  146388. * Gets the a component (input)
  146389. */
  146390. get a(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the rgba component (output)
  146393. */
  146394. get rgba(): NodeMaterialConnectionPoint;
  146395. /**
  146396. * Gets the rgb component (output)
  146397. */
  146398. get rgbOut(): NodeMaterialConnectionPoint;
  146399. /**
  146400. * Gets the rgb component (output)
  146401. * @deprecated Please use rgbOut instead.
  146402. */
  146403. get rgb(): NodeMaterialConnectionPoint;
  146404. protected _buildBlock(state: NodeMaterialBuildState): this;
  146405. }
  146406. }
  146407. declare module BABYLON {
  146408. /**
  146409. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146410. */
  146411. export class VectorSplitterBlock extends NodeMaterialBlock {
  146412. /**
  146413. * Create a new VectorSplitterBlock
  146414. * @param name defines the block name
  146415. */
  146416. constructor(name: string);
  146417. /**
  146418. * Gets the current class name
  146419. * @returns the class name
  146420. */
  146421. getClassName(): string;
  146422. /**
  146423. * Gets the xyzw component (input)
  146424. */
  146425. get xyzw(): NodeMaterialConnectionPoint;
  146426. /**
  146427. * Gets the xyz component (input)
  146428. */
  146429. get xyzIn(): NodeMaterialConnectionPoint;
  146430. /**
  146431. * Gets the xy component (input)
  146432. */
  146433. get xyIn(): NodeMaterialConnectionPoint;
  146434. /**
  146435. * Gets the xyz component (output)
  146436. */
  146437. get xyzOut(): NodeMaterialConnectionPoint;
  146438. /**
  146439. * Gets the xy component (output)
  146440. */
  146441. get xyOut(): NodeMaterialConnectionPoint;
  146442. /**
  146443. * Gets the x component (output)
  146444. */
  146445. get x(): NodeMaterialConnectionPoint;
  146446. /**
  146447. * Gets the y component (output)
  146448. */
  146449. get y(): NodeMaterialConnectionPoint;
  146450. /**
  146451. * Gets the z component (output)
  146452. */
  146453. get z(): NodeMaterialConnectionPoint;
  146454. /**
  146455. * Gets the w component (output)
  146456. */
  146457. get w(): NodeMaterialConnectionPoint;
  146458. protected _inputRename(name: string): string;
  146459. protected _outputRename(name: string): string;
  146460. protected _buildBlock(state: NodeMaterialBuildState): this;
  146461. }
  146462. }
  146463. declare module BABYLON {
  146464. /**
  146465. * Block used to lerp between 2 values
  146466. */
  146467. export class LerpBlock extends NodeMaterialBlock {
  146468. /**
  146469. * Creates a new LerpBlock
  146470. * @param name defines the block name
  146471. */
  146472. constructor(name: string);
  146473. /**
  146474. * Gets the current class name
  146475. * @returns the class name
  146476. */
  146477. getClassName(): string;
  146478. /**
  146479. * Gets the left operand input component
  146480. */
  146481. get left(): NodeMaterialConnectionPoint;
  146482. /**
  146483. * Gets the right operand input component
  146484. */
  146485. get right(): NodeMaterialConnectionPoint;
  146486. /**
  146487. * Gets the gradient operand input component
  146488. */
  146489. get gradient(): NodeMaterialConnectionPoint;
  146490. /**
  146491. * Gets the output component
  146492. */
  146493. get output(): NodeMaterialConnectionPoint;
  146494. protected _buildBlock(state: NodeMaterialBuildState): this;
  146495. }
  146496. }
  146497. declare module BABYLON {
  146498. /**
  146499. * Block used to divide 2 vectors
  146500. */
  146501. export class DivideBlock extends NodeMaterialBlock {
  146502. /**
  146503. * Creates a new DivideBlock
  146504. * @param name defines the block name
  146505. */
  146506. constructor(name: string);
  146507. /**
  146508. * Gets the current class name
  146509. * @returns the class name
  146510. */
  146511. getClassName(): string;
  146512. /**
  146513. * Gets the left operand input component
  146514. */
  146515. get left(): NodeMaterialConnectionPoint;
  146516. /**
  146517. * Gets the right operand input component
  146518. */
  146519. get right(): NodeMaterialConnectionPoint;
  146520. /**
  146521. * Gets the output component
  146522. */
  146523. get output(): NodeMaterialConnectionPoint;
  146524. protected _buildBlock(state: NodeMaterialBuildState): this;
  146525. }
  146526. }
  146527. declare module BABYLON {
  146528. /**
  146529. * Block used to subtract 2 vectors
  146530. */
  146531. export class SubtractBlock extends NodeMaterialBlock {
  146532. /**
  146533. * Creates a new SubtractBlock
  146534. * @param name defines the block name
  146535. */
  146536. constructor(name: string);
  146537. /**
  146538. * Gets the current class name
  146539. * @returns the class name
  146540. */
  146541. getClassName(): string;
  146542. /**
  146543. * Gets the left operand input component
  146544. */
  146545. get left(): NodeMaterialConnectionPoint;
  146546. /**
  146547. * Gets the right operand input component
  146548. */
  146549. get right(): NodeMaterialConnectionPoint;
  146550. /**
  146551. * Gets the output component
  146552. */
  146553. get output(): NodeMaterialConnectionPoint;
  146554. protected _buildBlock(state: NodeMaterialBuildState): this;
  146555. }
  146556. }
  146557. declare module BABYLON {
  146558. /**
  146559. * Block used to step a value
  146560. */
  146561. export class StepBlock extends NodeMaterialBlock {
  146562. /**
  146563. * Creates a new StepBlock
  146564. * @param name defines the block name
  146565. */
  146566. constructor(name: string);
  146567. /**
  146568. * Gets the current class name
  146569. * @returns the class name
  146570. */
  146571. getClassName(): string;
  146572. /**
  146573. * Gets the value operand input component
  146574. */
  146575. get value(): NodeMaterialConnectionPoint;
  146576. /**
  146577. * Gets the edge operand input component
  146578. */
  146579. get edge(): NodeMaterialConnectionPoint;
  146580. /**
  146581. * Gets the output component
  146582. */
  146583. get output(): NodeMaterialConnectionPoint;
  146584. protected _buildBlock(state: NodeMaterialBuildState): this;
  146585. }
  146586. }
  146587. declare module BABYLON {
  146588. /**
  146589. * Block used to get the opposite (1 - x) of a value
  146590. */
  146591. export class OneMinusBlock extends NodeMaterialBlock {
  146592. /**
  146593. * Creates a new OneMinusBlock
  146594. * @param name defines the block name
  146595. */
  146596. constructor(name: string);
  146597. /**
  146598. * Gets the current class name
  146599. * @returns the class name
  146600. */
  146601. getClassName(): string;
  146602. /**
  146603. * Gets the input component
  146604. */
  146605. get input(): NodeMaterialConnectionPoint;
  146606. /**
  146607. * Gets the output component
  146608. */
  146609. get output(): NodeMaterialConnectionPoint;
  146610. protected _buildBlock(state: NodeMaterialBuildState): this;
  146611. }
  146612. }
  146613. declare module BABYLON {
  146614. /**
  146615. * Block used to get the view direction
  146616. */
  146617. export class ViewDirectionBlock extends NodeMaterialBlock {
  146618. /**
  146619. * Creates a new ViewDirectionBlock
  146620. * @param name defines the block name
  146621. */
  146622. constructor(name: string);
  146623. /**
  146624. * Gets the current class name
  146625. * @returns the class name
  146626. */
  146627. getClassName(): string;
  146628. /**
  146629. * Gets the world position component
  146630. */
  146631. get worldPosition(): NodeMaterialConnectionPoint;
  146632. /**
  146633. * Gets the camera position component
  146634. */
  146635. get cameraPosition(): NodeMaterialConnectionPoint;
  146636. /**
  146637. * Gets the output component
  146638. */
  146639. get output(): NodeMaterialConnectionPoint;
  146640. autoConfigure(material: NodeMaterial): void;
  146641. protected _buildBlock(state: NodeMaterialBuildState): this;
  146642. }
  146643. }
  146644. declare module BABYLON {
  146645. /**
  146646. * Block used to compute fresnel value
  146647. */
  146648. export class FresnelBlock extends NodeMaterialBlock {
  146649. /**
  146650. * Create a new FresnelBlock
  146651. * @param name defines the block name
  146652. */
  146653. constructor(name: string);
  146654. /**
  146655. * Gets the current class name
  146656. * @returns the class name
  146657. */
  146658. getClassName(): string;
  146659. /**
  146660. * Gets the world normal input component
  146661. */
  146662. get worldNormal(): NodeMaterialConnectionPoint;
  146663. /**
  146664. * Gets the view direction input component
  146665. */
  146666. get viewDirection(): NodeMaterialConnectionPoint;
  146667. /**
  146668. * Gets the bias input component
  146669. */
  146670. get bias(): NodeMaterialConnectionPoint;
  146671. /**
  146672. * Gets the camera (or eye) position component
  146673. */
  146674. get power(): NodeMaterialConnectionPoint;
  146675. /**
  146676. * Gets the fresnel output component
  146677. */
  146678. get fresnel(): NodeMaterialConnectionPoint;
  146679. autoConfigure(material: NodeMaterial): void;
  146680. protected _buildBlock(state: NodeMaterialBuildState): this;
  146681. }
  146682. }
  146683. declare module BABYLON {
  146684. /**
  146685. * Block used to get the max of 2 values
  146686. */
  146687. export class MaxBlock extends NodeMaterialBlock {
  146688. /**
  146689. * Creates a new MaxBlock
  146690. * @param name defines the block name
  146691. */
  146692. constructor(name: string);
  146693. /**
  146694. * Gets the current class name
  146695. * @returns the class name
  146696. */
  146697. getClassName(): string;
  146698. /**
  146699. * Gets the left operand input component
  146700. */
  146701. get left(): NodeMaterialConnectionPoint;
  146702. /**
  146703. * Gets the right operand input component
  146704. */
  146705. get right(): NodeMaterialConnectionPoint;
  146706. /**
  146707. * Gets the output component
  146708. */
  146709. get output(): NodeMaterialConnectionPoint;
  146710. protected _buildBlock(state: NodeMaterialBuildState): this;
  146711. }
  146712. }
  146713. declare module BABYLON {
  146714. /**
  146715. * Block used to get the min of 2 values
  146716. */
  146717. export class MinBlock extends NodeMaterialBlock {
  146718. /**
  146719. * Creates a new MinBlock
  146720. * @param name defines the block name
  146721. */
  146722. constructor(name: string);
  146723. /**
  146724. * Gets the current class name
  146725. * @returns the class name
  146726. */
  146727. getClassName(): string;
  146728. /**
  146729. * Gets the left operand input component
  146730. */
  146731. get left(): NodeMaterialConnectionPoint;
  146732. /**
  146733. * Gets the right operand input component
  146734. */
  146735. get right(): NodeMaterialConnectionPoint;
  146736. /**
  146737. * Gets the output component
  146738. */
  146739. get output(): NodeMaterialConnectionPoint;
  146740. protected _buildBlock(state: NodeMaterialBuildState): this;
  146741. }
  146742. }
  146743. declare module BABYLON {
  146744. /**
  146745. * Block used to get the distance between 2 values
  146746. */
  146747. export class DistanceBlock extends NodeMaterialBlock {
  146748. /**
  146749. * Creates a new DistanceBlock
  146750. * @param name defines the block name
  146751. */
  146752. constructor(name: string);
  146753. /**
  146754. * Gets the current class name
  146755. * @returns the class name
  146756. */
  146757. getClassName(): string;
  146758. /**
  146759. * Gets the left operand input component
  146760. */
  146761. get left(): NodeMaterialConnectionPoint;
  146762. /**
  146763. * Gets the right operand input component
  146764. */
  146765. get right(): NodeMaterialConnectionPoint;
  146766. /**
  146767. * Gets the output component
  146768. */
  146769. get output(): NodeMaterialConnectionPoint;
  146770. protected _buildBlock(state: NodeMaterialBuildState): this;
  146771. }
  146772. }
  146773. declare module BABYLON {
  146774. /**
  146775. * Block used to get the length of a vector
  146776. */
  146777. export class LengthBlock extends NodeMaterialBlock {
  146778. /**
  146779. * Creates a new LengthBlock
  146780. * @param name defines the block name
  146781. */
  146782. constructor(name: string);
  146783. /**
  146784. * Gets the current class name
  146785. * @returns the class name
  146786. */
  146787. getClassName(): string;
  146788. /**
  146789. * Gets the value input component
  146790. */
  146791. get value(): NodeMaterialConnectionPoint;
  146792. /**
  146793. * Gets the output component
  146794. */
  146795. get output(): NodeMaterialConnectionPoint;
  146796. protected _buildBlock(state: NodeMaterialBuildState): this;
  146797. }
  146798. }
  146799. declare module BABYLON {
  146800. /**
  146801. * Block used to get negative version of a value (i.e. x * -1)
  146802. */
  146803. export class NegateBlock extends NodeMaterialBlock {
  146804. /**
  146805. * Creates a new NegateBlock
  146806. * @param name defines the block name
  146807. */
  146808. constructor(name: string);
  146809. /**
  146810. * Gets the current class name
  146811. * @returns the class name
  146812. */
  146813. getClassName(): string;
  146814. /**
  146815. * Gets the value input component
  146816. */
  146817. get value(): NodeMaterialConnectionPoint;
  146818. /**
  146819. * Gets the output component
  146820. */
  146821. get output(): NodeMaterialConnectionPoint;
  146822. protected _buildBlock(state: NodeMaterialBuildState): this;
  146823. }
  146824. }
  146825. declare module BABYLON {
  146826. /**
  146827. * Block used to get the value of the first parameter raised to the power of the second
  146828. */
  146829. export class PowBlock extends NodeMaterialBlock {
  146830. /**
  146831. * Creates a new PowBlock
  146832. * @param name defines the block name
  146833. */
  146834. constructor(name: string);
  146835. /**
  146836. * Gets the current class name
  146837. * @returns the class name
  146838. */
  146839. getClassName(): string;
  146840. /**
  146841. * Gets the value operand input component
  146842. */
  146843. get value(): NodeMaterialConnectionPoint;
  146844. /**
  146845. * Gets the power operand input component
  146846. */
  146847. get power(): NodeMaterialConnectionPoint;
  146848. /**
  146849. * Gets the output component
  146850. */
  146851. get output(): NodeMaterialConnectionPoint;
  146852. protected _buildBlock(state: NodeMaterialBuildState): this;
  146853. }
  146854. }
  146855. declare module BABYLON {
  146856. /**
  146857. * Block used to get a random number
  146858. */
  146859. export class RandomNumberBlock extends NodeMaterialBlock {
  146860. /**
  146861. * Creates a new RandomNumberBlock
  146862. * @param name defines the block name
  146863. */
  146864. constructor(name: string);
  146865. /**
  146866. * Gets the current class name
  146867. * @returns the class name
  146868. */
  146869. getClassName(): string;
  146870. /**
  146871. * Gets the seed input component
  146872. */
  146873. get seed(): NodeMaterialConnectionPoint;
  146874. /**
  146875. * Gets the output component
  146876. */
  146877. get output(): NodeMaterialConnectionPoint;
  146878. protected _buildBlock(state: NodeMaterialBuildState): this;
  146879. }
  146880. }
  146881. declare module BABYLON {
  146882. /**
  146883. * Block used to compute arc tangent of 2 values
  146884. */
  146885. export class ArcTan2Block extends NodeMaterialBlock {
  146886. /**
  146887. * Creates a new ArcTan2Block
  146888. * @param name defines the block name
  146889. */
  146890. constructor(name: string);
  146891. /**
  146892. * Gets the current class name
  146893. * @returns the class name
  146894. */
  146895. getClassName(): string;
  146896. /**
  146897. * Gets the x operand input component
  146898. */
  146899. get x(): NodeMaterialConnectionPoint;
  146900. /**
  146901. * Gets the y operand input component
  146902. */
  146903. get y(): NodeMaterialConnectionPoint;
  146904. /**
  146905. * Gets the output component
  146906. */
  146907. get output(): NodeMaterialConnectionPoint;
  146908. protected _buildBlock(state: NodeMaterialBuildState): this;
  146909. }
  146910. }
  146911. declare module BABYLON {
  146912. /**
  146913. * Block used to smooth step a value
  146914. */
  146915. export class SmoothStepBlock extends NodeMaterialBlock {
  146916. /**
  146917. * Creates a new SmoothStepBlock
  146918. * @param name defines the block name
  146919. */
  146920. constructor(name: string);
  146921. /**
  146922. * Gets the current class name
  146923. * @returns the class name
  146924. */
  146925. getClassName(): string;
  146926. /**
  146927. * Gets the value operand input component
  146928. */
  146929. get value(): NodeMaterialConnectionPoint;
  146930. /**
  146931. * Gets the first edge operand input component
  146932. */
  146933. get edge0(): NodeMaterialConnectionPoint;
  146934. /**
  146935. * Gets the second edge operand input component
  146936. */
  146937. get edge1(): NodeMaterialConnectionPoint;
  146938. /**
  146939. * Gets the output component
  146940. */
  146941. get output(): NodeMaterialConnectionPoint;
  146942. protected _buildBlock(state: NodeMaterialBuildState): this;
  146943. }
  146944. }
  146945. declare module BABYLON {
  146946. /**
  146947. * Block used to get the reciprocal (1 / x) of a value
  146948. */
  146949. export class ReciprocalBlock extends NodeMaterialBlock {
  146950. /**
  146951. * Creates a new ReciprocalBlock
  146952. * @param name defines the block name
  146953. */
  146954. constructor(name: string);
  146955. /**
  146956. * Gets the current class name
  146957. * @returns the class name
  146958. */
  146959. getClassName(): string;
  146960. /**
  146961. * Gets the input component
  146962. */
  146963. get input(): NodeMaterialConnectionPoint;
  146964. /**
  146965. * Gets the output component
  146966. */
  146967. get output(): NodeMaterialConnectionPoint;
  146968. protected _buildBlock(state: NodeMaterialBuildState): this;
  146969. }
  146970. }
  146971. declare module BABYLON {
  146972. /**
  146973. * Block used to replace a color by another one
  146974. */
  146975. export class ReplaceColorBlock extends NodeMaterialBlock {
  146976. /**
  146977. * Creates a new ReplaceColorBlock
  146978. * @param name defines the block name
  146979. */
  146980. constructor(name: string);
  146981. /**
  146982. * Gets the current class name
  146983. * @returns the class name
  146984. */
  146985. getClassName(): string;
  146986. /**
  146987. * Gets the value input component
  146988. */
  146989. get value(): NodeMaterialConnectionPoint;
  146990. /**
  146991. * Gets the reference input component
  146992. */
  146993. get reference(): NodeMaterialConnectionPoint;
  146994. /**
  146995. * Gets the distance input component
  146996. */
  146997. get distance(): NodeMaterialConnectionPoint;
  146998. /**
  146999. * Gets the replacement input component
  147000. */
  147001. get replacement(): NodeMaterialConnectionPoint;
  147002. /**
  147003. * Gets the output component
  147004. */
  147005. get output(): NodeMaterialConnectionPoint;
  147006. protected _buildBlock(state: NodeMaterialBuildState): this;
  147007. }
  147008. }
  147009. declare module BABYLON {
  147010. /**
  147011. * Block used to posterize a value
  147012. * @see https://en.wikipedia.org/wiki/Posterization
  147013. */
  147014. export class PosterizeBlock extends NodeMaterialBlock {
  147015. /**
  147016. * Creates a new PosterizeBlock
  147017. * @param name defines the block name
  147018. */
  147019. constructor(name: string);
  147020. /**
  147021. * Gets the current class name
  147022. * @returns the class name
  147023. */
  147024. getClassName(): string;
  147025. /**
  147026. * Gets the value input component
  147027. */
  147028. get value(): NodeMaterialConnectionPoint;
  147029. /**
  147030. * Gets the steps input component
  147031. */
  147032. get steps(): NodeMaterialConnectionPoint;
  147033. /**
  147034. * Gets the output component
  147035. */
  147036. get output(): NodeMaterialConnectionPoint;
  147037. protected _buildBlock(state: NodeMaterialBuildState): this;
  147038. }
  147039. }
  147040. declare module BABYLON {
  147041. /**
  147042. * Operations supported by the Wave block
  147043. */
  147044. export enum WaveBlockKind {
  147045. /** SawTooth */
  147046. SawTooth = 0,
  147047. /** Square */
  147048. Square = 1,
  147049. /** Triangle */
  147050. Triangle = 2
  147051. }
  147052. /**
  147053. * Block used to apply wave operation to floats
  147054. */
  147055. export class WaveBlock extends NodeMaterialBlock {
  147056. /**
  147057. * Gets or sets the kibnd of wave to be applied by the block
  147058. */
  147059. kind: WaveBlockKind;
  147060. /**
  147061. * Creates a new WaveBlock
  147062. * @param name defines the block name
  147063. */
  147064. constructor(name: string);
  147065. /**
  147066. * Gets the current class name
  147067. * @returns the class name
  147068. */
  147069. getClassName(): string;
  147070. /**
  147071. * Gets the input component
  147072. */
  147073. get input(): NodeMaterialConnectionPoint;
  147074. /**
  147075. * Gets the output component
  147076. */
  147077. get output(): NodeMaterialConnectionPoint;
  147078. protected _buildBlock(state: NodeMaterialBuildState): this;
  147079. serialize(): any;
  147080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147081. }
  147082. }
  147083. declare module BABYLON {
  147084. /**
  147085. * Class used to store a color step for the GradientBlock
  147086. */
  147087. export class GradientBlockColorStep {
  147088. private _step;
  147089. /**
  147090. * Gets value indicating which step this color is associated with (between 0 and 1)
  147091. */
  147092. get step(): number;
  147093. /**
  147094. * Sets a value indicating which step this color is associated with (between 0 and 1)
  147095. */
  147096. set step(val: number);
  147097. private _color;
  147098. /**
  147099. * Gets the color associated with this step
  147100. */
  147101. get color(): Color3;
  147102. /**
  147103. * Sets the color associated with this step
  147104. */
  147105. set color(val: Color3);
  147106. /**
  147107. * Creates a new GradientBlockColorStep
  147108. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  147109. * @param color defines the color associated with this step
  147110. */
  147111. constructor(step: number, color: Color3);
  147112. }
  147113. /**
  147114. * Block used to return a color from a gradient based on an input value between 0 and 1
  147115. */
  147116. export class GradientBlock extends NodeMaterialBlock {
  147117. /**
  147118. * Gets or sets the list of color steps
  147119. */
  147120. colorSteps: GradientBlockColorStep[];
  147121. /** Gets an observable raised when the value is changed */
  147122. onValueChangedObservable: Observable<GradientBlock>;
  147123. /** calls observable when the value is changed*/
  147124. colorStepsUpdated(): void;
  147125. /**
  147126. * Creates a new GradientBlock
  147127. * @param name defines the block name
  147128. */
  147129. constructor(name: string);
  147130. /**
  147131. * Gets the current class name
  147132. * @returns the class name
  147133. */
  147134. getClassName(): string;
  147135. /**
  147136. * Gets the gradient input component
  147137. */
  147138. get gradient(): NodeMaterialConnectionPoint;
  147139. /**
  147140. * Gets the output component
  147141. */
  147142. get output(): NodeMaterialConnectionPoint;
  147143. private _writeColorConstant;
  147144. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147145. serialize(): any;
  147146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147147. protected _dumpPropertiesCode(): string;
  147148. }
  147149. }
  147150. declare module BABYLON {
  147151. /**
  147152. * Block used to normalize lerp between 2 values
  147153. */
  147154. export class NLerpBlock extends NodeMaterialBlock {
  147155. /**
  147156. * Creates a new NLerpBlock
  147157. * @param name defines the block name
  147158. */
  147159. constructor(name: string);
  147160. /**
  147161. * Gets the current class name
  147162. * @returns the class name
  147163. */
  147164. getClassName(): string;
  147165. /**
  147166. * Gets the left operand input component
  147167. */
  147168. get left(): NodeMaterialConnectionPoint;
  147169. /**
  147170. * Gets the right operand input component
  147171. */
  147172. get right(): NodeMaterialConnectionPoint;
  147173. /**
  147174. * Gets the gradient operand input component
  147175. */
  147176. get gradient(): NodeMaterialConnectionPoint;
  147177. /**
  147178. * Gets the output component
  147179. */
  147180. get output(): NodeMaterialConnectionPoint;
  147181. protected _buildBlock(state: NodeMaterialBuildState): this;
  147182. }
  147183. }
  147184. declare module BABYLON {
  147185. /**
  147186. * block used to Generate a Worley Noise 3D Noise Pattern
  147187. */
  147188. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  147189. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  147190. manhattanDistance: boolean;
  147191. /**
  147192. * Creates a new WorleyNoise3DBlock
  147193. * @param name defines the block name
  147194. */
  147195. constructor(name: string);
  147196. /**
  147197. * Gets the current class name
  147198. * @returns the class name
  147199. */
  147200. getClassName(): string;
  147201. /**
  147202. * Gets the seed input component
  147203. */
  147204. get seed(): NodeMaterialConnectionPoint;
  147205. /**
  147206. * Gets the jitter input component
  147207. */
  147208. get jitter(): NodeMaterialConnectionPoint;
  147209. /**
  147210. * Gets the output component
  147211. */
  147212. get output(): NodeMaterialConnectionPoint;
  147213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147214. /**
  147215. * Exposes the properties to the UI?
  147216. */
  147217. protected _dumpPropertiesCode(): string;
  147218. /**
  147219. * Exposes the properties to the Seralize?
  147220. */
  147221. serialize(): any;
  147222. /**
  147223. * Exposes the properties to the deseralize?
  147224. */
  147225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147226. }
  147227. }
  147228. declare module BABYLON {
  147229. /**
  147230. * block used to Generate a Simplex Perlin 3d Noise Pattern
  147231. */
  147232. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  147233. /**
  147234. * Creates a new SimplexPerlin3DBlock
  147235. * @param name defines the block name
  147236. */
  147237. constructor(name: string);
  147238. /**
  147239. * Gets the current class name
  147240. * @returns the class name
  147241. */
  147242. getClassName(): string;
  147243. /**
  147244. * Gets the seed operand input component
  147245. */
  147246. get seed(): NodeMaterialConnectionPoint;
  147247. /**
  147248. * Gets the output component
  147249. */
  147250. get output(): NodeMaterialConnectionPoint;
  147251. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147252. }
  147253. }
  147254. declare module BABYLON {
  147255. /**
  147256. * Block used to blend normals
  147257. */
  147258. export class NormalBlendBlock extends NodeMaterialBlock {
  147259. /**
  147260. * Creates a new NormalBlendBlock
  147261. * @param name defines the block name
  147262. */
  147263. constructor(name: string);
  147264. /**
  147265. * Gets the current class name
  147266. * @returns the class name
  147267. */
  147268. getClassName(): string;
  147269. /**
  147270. * Gets the first input component
  147271. */
  147272. get normalMap0(): NodeMaterialConnectionPoint;
  147273. /**
  147274. * Gets the second input component
  147275. */
  147276. get normalMap1(): NodeMaterialConnectionPoint;
  147277. /**
  147278. * Gets the output component
  147279. */
  147280. get output(): NodeMaterialConnectionPoint;
  147281. protected _buildBlock(state: NodeMaterialBuildState): this;
  147282. }
  147283. }
  147284. declare module BABYLON {
  147285. /**
  147286. * Block used to rotate a 2d vector by a given angle
  147287. */
  147288. export class Rotate2dBlock extends NodeMaterialBlock {
  147289. /**
  147290. * Creates a new Rotate2dBlock
  147291. * @param name defines the block name
  147292. */
  147293. constructor(name: string);
  147294. /**
  147295. * Gets the current class name
  147296. * @returns the class name
  147297. */
  147298. getClassName(): string;
  147299. /**
  147300. * Gets the input vector
  147301. */
  147302. get input(): NodeMaterialConnectionPoint;
  147303. /**
  147304. * Gets the input angle
  147305. */
  147306. get angle(): NodeMaterialConnectionPoint;
  147307. /**
  147308. * Gets the output component
  147309. */
  147310. get output(): NodeMaterialConnectionPoint;
  147311. autoConfigure(material: NodeMaterial): void;
  147312. protected _buildBlock(state: NodeMaterialBuildState): this;
  147313. }
  147314. }
  147315. declare module BABYLON {
  147316. /**
  147317. * Block used to get the reflected vector from a direction and a normal
  147318. */
  147319. export class ReflectBlock extends NodeMaterialBlock {
  147320. /**
  147321. * Creates a new ReflectBlock
  147322. * @param name defines the block name
  147323. */
  147324. constructor(name: string);
  147325. /**
  147326. * Gets the current class name
  147327. * @returns the class name
  147328. */
  147329. getClassName(): string;
  147330. /**
  147331. * Gets the incident component
  147332. */
  147333. get incident(): NodeMaterialConnectionPoint;
  147334. /**
  147335. * Gets the normal component
  147336. */
  147337. get normal(): NodeMaterialConnectionPoint;
  147338. /**
  147339. * Gets the output component
  147340. */
  147341. get output(): NodeMaterialConnectionPoint;
  147342. protected _buildBlock(state: NodeMaterialBuildState): this;
  147343. }
  147344. }
  147345. declare module BABYLON {
  147346. /**
  147347. * Block used to get the refracted vector from a direction and a normal
  147348. */
  147349. export class RefractBlock extends NodeMaterialBlock {
  147350. /**
  147351. * Creates a new RefractBlock
  147352. * @param name defines the block name
  147353. */
  147354. constructor(name: string);
  147355. /**
  147356. * Gets the current class name
  147357. * @returns the class name
  147358. */
  147359. getClassName(): string;
  147360. /**
  147361. * Gets the incident component
  147362. */
  147363. get incident(): NodeMaterialConnectionPoint;
  147364. /**
  147365. * Gets the normal component
  147366. */
  147367. get normal(): NodeMaterialConnectionPoint;
  147368. /**
  147369. * Gets the index of refraction component
  147370. */
  147371. get ior(): NodeMaterialConnectionPoint;
  147372. /**
  147373. * Gets the output component
  147374. */
  147375. get output(): NodeMaterialConnectionPoint;
  147376. protected _buildBlock(state: NodeMaterialBuildState): this;
  147377. }
  147378. }
  147379. declare module BABYLON {
  147380. /**
  147381. * Block used to desaturate a color
  147382. */
  147383. export class DesaturateBlock extends NodeMaterialBlock {
  147384. /**
  147385. * Creates a new DesaturateBlock
  147386. * @param name defines the block name
  147387. */
  147388. constructor(name: string);
  147389. /**
  147390. * Gets the current class name
  147391. * @returns the class name
  147392. */
  147393. getClassName(): string;
  147394. /**
  147395. * Gets the color operand input component
  147396. */
  147397. get color(): NodeMaterialConnectionPoint;
  147398. /**
  147399. * Gets the level operand input component
  147400. */
  147401. get level(): NodeMaterialConnectionPoint;
  147402. /**
  147403. * Gets the output component
  147404. */
  147405. get output(): NodeMaterialConnectionPoint;
  147406. protected _buildBlock(state: NodeMaterialBuildState): this;
  147407. }
  147408. }
  147409. declare module BABYLON {
  147410. /**
  147411. * Block used to implement the reflection module of the PBR material
  147412. */
  147413. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147414. /** @hidden */
  147415. _defineLODReflectionAlpha: string;
  147416. /** @hidden */
  147417. _defineLinearSpecularReflection: string;
  147418. private _vEnvironmentIrradianceName;
  147419. /** @hidden */
  147420. _vReflectionMicrosurfaceInfosName: string;
  147421. /** @hidden */
  147422. _vReflectionInfosName: string;
  147423. /** @hidden */
  147424. _vReflectionFilteringInfoName: string;
  147425. private _scene;
  147426. /**
  147427. * The properties below are set by the main PBR block prior to calling methods of this class.
  147428. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147429. * It's less burden on the user side in the editor part.
  147430. */
  147431. /** @hidden */
  147432. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147433. /** @hidden */
  147434. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147435. /** @hidden */
  147436. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147437. /** @hidden */
  147438. viewConnectionPoint: NodeMaterialConnectionPoint;
  147439. /**
  147440. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147441. * diffuse part of the IBL.
  147442. */
  147443. useSphericalHarmonics: boolean;
  147444. /**
  147445. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147446. */
  147447. forceIrradianceInFragment: boolean;
  147448. /**
  147449. * Create a new ReflectionBlock
  147450. * @param name defines the block name
  147451. */
  147452. constructor(name: string);
  147453. /**
  147454. * Gets the current class name
  147455. * @returns the class name
  147456. */
  147457. getClassName(): string;
  147458. /**
  147459. * Gets the position input component
  147460. */
  147461. get position(): NodeMaterialConnectionPoint;
  147462. /**
  147463. * Gets the world position input component
  147464. */
  147465. get worldPosition(): NodeMaterialConnectionPoint;
  147466. /**
  147467. * Gets the world normal input component
  147468. */
  147469. get worldNormal(): NodeMaterialConnectionPoint;
  147470. /**
  147471. * Gets the world input component
  147472. */
  147473. get world(): NodeMaterialConnectionPoint;
  147474. /**
  147475. * Gets the camera (or eye) position component
  147476. */
  147477. get cameraPosition(): NodeMaterialConnectionPoint;
  147478. /**
  147479. * Gets the view input component
  147480. */
  147481. get view(): NodeMaterialConnectionPoint;
  147482. /**
  147483. * Gets the color input component
  147484. */
  147485. get color(): NodeMaterialConnectionPoint;
  147486. /**
  147487. * Gets the reflection object output component
  147488. */
  147489. get reflection(): NodeMaterialConnectionPoint;
  147490. /**
  147491. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147492. */
  147493. get hasTexture(): boolean;
  147494. /**
  147495. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147496. */
  147497. get reflectionColor(): string;
  147498. protected _getTexture(): Nullable<BaseTexture>;
  147499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147501. /**
  147502. * Gets the code to inject in the vertex shader
  147503. * @param state current state of the node material building
  147504. * @returns the shader code
  147505. */
  147506. handleVertexSide(state: NodeMaterialBuildState): string;
  147507. /**
  147508. * Gets the main code of the block (fragment side)
  147509. * @param state current state of the node material building
  147510. * @param normalVarName name of the existing variable corresponding to the normal
  147511. * @returns the shader code
  147512. */
  147513. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147514. protected _buildBlock(state: NodeMaterialBuildState): this;
  147515. protected _dumpPropertiesCode(): string;
  147516. serialize(): any;
  147517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147518. }
  147519. }
  147520. declare module BABYLON {
  147521. /**
  147522. * Block used to implement the sheen module of the PBR material
  147523. */
  147524. export class SheenBlock extends NodeMaterialBlock {
  147525. /**
  147526. * Create a new SheenBlock
  147527. * @param name defines the block name
  147528. */
  147529. constructor(name: string);
  147530. /**
  147531. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147532. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147533. * making it easier to setup and tweak the effect
  147534. */
  147535. albedoScaling: boolean;
  147536. /**
  147537. * Defines if the sheen is linked to the sheen color.
  147538. */
  147539. linkSheenWithAlbedo: boolean;
  147540. /**
  147541. * Initialize the block and prepare the context for build
  147542. * @param state defines the state that will be used for the build
  147543. */
  147544. initialize(state: NodeMaterialBuildState): void;
  147545. /**
  147546. * Gets the current class name
  147547. * @returns the class name
  147548. */
  147549. getClassName(): string;
  147550. /**
  147551. * Gets the intensity input component
  147552. */
  147553. get intensity(): NodeMaterialConnectionPoint;
  147554. /**
  147555. * Gets the color input component
  147556. */
  147557. get color(): NodeMaterialConnectionPoint;
  147558. /**
  147559. * Gets the roughness input component
  147560. */
  147561. get roughness(): NodeMaterialConnectionPoint;
  147562. /**
  147563. * Gets the sheen object output component
  147564. */
  147565. get sheen(): NodeMaterialConnectionPoint;
  147566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147567. /**
  147568. * Gets the main code of the block (fragment side)
  147569. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147570. * @returns the shader code
  147571. */
  147572. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147573. protected _buildBlock(state: NodeMaterialBuildState): this;
  147574. protected _dumpPropertiesCode(): string;
  147575. serialize(): any;
  147576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147577. }
  147578. }
  147579. declare module BABYLON {
  147580. /**
  147581. * Block used to implement the anisotropy module of the PBR material
  147582. */
  147583. export class AnisotropyBlock extends NodeMaterialBlock {
  147584. /**
  147585. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147586. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147587. * It's less burden on the user side in the editor part.
  147588. */
  147589. /** @hidden */
  147590. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147591. /** @hidden */
  147592. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147593. /**
  147594. * Create a new AnisotropyBlock
  147595. * @param name defines the block name
  147596. */
  147597. constructor(name: string);
  147598. /**
  147599. * Initialize the block and prepare the context for build
  147600. * @param state defines the state that will be used for the build
  147601. */
  147602. initialize(state: NodeMaterialBuildState): void;
  147603. /**
  147604. * Gets the current class name
  147605. * @returns the class name
  147606. */
  147607. getClassName(): string;
  147608. /**
  147609. * Gets the intensity input component
  147610. */
  147611. get intensity(): NodeMaterialConnectionPoint;
  147612. /**
  147613. * Gets the direction input component
  147614. */
  147615. get direction(): NodeMaterialConnectionPoint;
  147616. /**
  147617. * Gets the uv input component
  147618. */
  147619. get uv(): NodeMaterialConnectionPoint;
  147620. /**
  147621. * Gets the worldTangent input component
  147622. */
  147623. get worldTangent(): NodeMaterialConnectionPoint;
  147624. /**
  147625. * Gets the anisotropy object output component
  147626. */
  147627. get anisotropy(): NodeMaterialConnectionPoint;
  147628. private _generateTBNSpace;
  147629. /**
  147630. * Gets the main code of the block (fragment side)
  147631. * @param state current state of the node material building
  147632. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147633. * @returns the shader code
  147634. */
  147635. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147637. protected _buildBlock(state: NodeMaterialBuildState): this;
  147638. }
  147639. }
  147640. declare module BABYLON {
  147641. /**
  147642. * Block used to implement the clear coat module of the PBR material
  147643. */
  147644. export class ClearCoatBlock extends NodeMaterialBlock {
  147645. private _scene;
  147646. /**
  147647. * Create a new ClearCoatBlock
  147648. * @param name defines the block name
  147649. */
  147650. constructor(name: string);
  147651. /**
  147652. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147653. */
  147654. remapF0OnInterfaceChange: boolean;
  147655. /**
  147656. * Initialize the block and prepare the context for build
  147657. * @param state defines the state that will be used for the build
  147658. */
  147659. initialize(state: NodeMaterialBuildState): void;
  147660. /**
  147661. * Gets the current class name
  147662. * @returns the class name
  147663. */
  147664. getClassName(): string;
  147665. /**
  147666. * Gets the intensity input component
  147667. */
  147668. get intensity(): NodeMaterialConnectionPoint;
  147669. /**
  147670. * Gets the roughness input component
  147671. */
  147672. get roughness(): NodeMaterialConnectionPoint;
  147673. /**
  147674. * Gets the ior input component
  147675. */
  147676. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147677. /**
  147678. * Gets the bump texture input component
  147679. */
  147680. get normalMapColor(): NodeMaterialConnectionPoint;
  147681. /**
  147682. * Gets the uv input component
  147683. */
  147684. get uv(): NodeMaterialConnectionPoint;
  147685. /**
  147686. * Gets the tint color input component
  147687. */
  147688. get tintColor(): NodeMaterialConnectionPoint;
  147689. /**
  147690. * Gets the tint "at distance" input component
  147691. */
  147692. get tintAtDistance(): NodeMaterialConnectionPoint;
  147693. /**
  147694. * Gets the tint thickness input component
  147695. */
  147696. get tintThickness(): NodeMaterialConnectionPoint;
  147697. /**
  147698. * Gets the world tangent input component
  147699. */
  147700. get worldTangent(): NodeMaterialConnectionPoint;
  147701. /**
  147702. * Gets the clear coat object output component
  147703. */
  147704. get clearcoat(): NodeMaterialConnectionPoint;
  147705. autoConfigure(material: NodeMaterial): void;
  147706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147708. private _generateTBNSpace;
  147709. /**
  147710. * Gets the main code of the block (fragment side)
  147711. * @param state current state of the node material building
  147712. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147713. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147714. * @param worldPosVarName name of the variable holding the world position
  147715. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147716. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147717. * @param worldNormalVarName name of the variable holding the world normal
  147718. * @returns the shader code
  147719. */
  147720. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147721. protected _buildBlock(state: NodeMaterialBuildState): this;
  147722. protected _dumpPropertiesCode(): string;
  147723. serialize(): any;
  147724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147725. }
  147726. }
  147727. declare module BABYLON {
  147728. /**
  147729. * Block used to implement the sub surface module of the PBR material
  147730. */
  147731. export class SubSurfaceBlock extends NodeMaterialBlock {
  147732. /**
  147733. * Create a new SubSurfaceBlock
  147734. * @param name defines the block name
  147735. */
  147736. constructor(name: string);
  147737. /**
  147738. * Initialize the block and prepare the context for build
  147739. * @param state defines the state that will be used for the build
  147740. */
  147741. initialize(state: NodeMaterialBuildState): void;
  147742. /**
  147743. * Gets the current class name
  147744. * @returns the class name
  147745. */
  147746. getClassName(): string;
  147747. /**
  147748. * Gets the thickness component
  147749. */
  147750. get thickness(): NodeMaterialConnectionPoint;
  147751. /**
  147752. * Gets the tint color input component
  147753. */
  147754. get tintColor(): NodeMaterialConnectionPoint;
  147755. /**
  147756. * Gets the translucency intensity input component
  147757. */
  147758. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147759. /**
  147760. * Gets the translucency diffusion distance input component
  147761. */
  147762. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147763. /**
  147764. * Gets the refraction object parameters
  147765. */
  147766. get refraction(): NodeMaterialConnectionPoint;
  147767. /**
  147768. * Gets the sub surface object output component
  147769. */
  147770. get subsurface(): NodeMaterialConnectionPoint;
  147771. autoConfigure(material: NodeMaterial): void;
  147772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147773. /**
  147774. * Gets the main code of the block (fragment side)
  147775. * @param state current state of the node material building
  147776. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147777. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147778. * @param worldPosVarName name of the variable holding the world position
  147779. * @returns the shader code
  147780. */
  147781. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147782. protected _buildBlock(state: NodeMaterialBuildState): this;
  147783. }
  147784. }
  147785. declare module BABYLON {
  147786. /**
  147787. * Block used to implement the PBR metallic/roughness model
  147788. */
  147789. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147790. /**
  147791. * Gets or sets the light associated with this block
  147792. */
  147793. light: Nullable<Light>;
  147794. private _lightId;
  147795. private _scene;
  147796. private _environmentBRDFTexture;
  147797. private _environmentBrdfSamplerName;
  147798. private _vNormalWName;
  147799. private _invertNormalName;
  147800. private _metallicReflectanceColor;
  147801. private _metallicF0Factor;
  147802. private _vMetallicReflectanceFactorsName;
  147803. /**
  147804. * Create a new ReflectionBlock
  147805. * @param name defines the block name
  147806. */
  147807. constructor(name: string);
  147808. /**
  147809. * Intensity of the direct lights e.g. the four lights available in your scene.
  147810. * This impacts both the direct diffuse and specular highlights.
  147811. */
  147812. directIntensity: number;
  147813. /**
  147814. * Intensity of the environment e.g. how much the environment will light the object
  147815. * either through harmonics for rough material or through the refelction for shiny ones.
  147816. */
  147817. environmentIntensity: number;
  147818. /**
  147819. * This is a special control allowing the reduction of the specular highlights coming from the
  147820. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147821. */
  147822. specularIntensity: number;
  147823. /**
  147824. * Defines the falloff type used in this material.
  147825. * It by default is Physical.
  147826. */
  147827. lightFalloff: number;
  147828. /**
  147829. * Specifies that alpha test should be used
  147830. */
  147831. useAlphaTest: boolean;
  147832. /**
  147833. * Defines the alpha limits in alpha test mode.
  147834. */
  147835. alphaTestCutoff: number;
  147836. /**
  147837. * Specifies that alpha blending should be used
  147838. */
  147839. useAlphaBlending: boolean;
  147840. /**
  147841. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147842. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147843. */
  147844. useRadianceOverAlpha: boolean;
  147845. /**
  147846. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147847. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147848. */
  147849. useSpecularOverAlpha: boolean;
  147850. /**
  147851. * Enables specular anti aliasing in the PBR shader.
  147852. * It will both interacts on the Geometry for analytical and IBL lighting.
  147853. * It also prefilter the roughness map based on the bump values.
  147854. */
  147855. enableSpecularAntiAliasing: boolean;
  147856. /**
  147857. * Enables realtime filtering on the texture.
  147858. */
  147859. realTimeFiltering: boolean;
  147860. /**
  147861. * Quality switch for realtime filtering
  147862. */
  147863. realTimeFilteringQuality: number;
  147864. /**
  147865. * Defines if the material uses energy conservation.
  147866. */
  147867. useEnergyConservation: boolean;
  147868. /**
  147869. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147870. * too much the area relying on ambient texture to define their ambient occlusion.
  147871. */
  147872. useRadianceOcclusion: boolean;
  147873. /**
  147874. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147875. * makes the reflect vector face the model (under horizon).
  147876. */
  147877. useHorizonOcclusion: boolean;
  147878. /**
  147879. * If set to true, no lighting calculations will be applied.
  147880. */
  147881. unlit: boolean;
  147882. /**
  147883. * Force normal to face away from face.
  147884. */
  147885. forceNormalForward: boolean;
  147886. /**
  147887. * Defines the material debug mode.
  147888. * It helps seeing only some components of the material while troubleshooting.
  147889. */
  147890. debugMode: number;
  147891. /**
  147892. * Specify from where on screen the debug mode should start.
  147893. * The value goes from -1 (full screen) to 1 (not visible)
  147894. * It helps with side by side comparison against the final render
  147895. * This defaults to 0
  147896. */
  147897. debugLimit: number;
  147898. /**
  147899. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147900. * You can use the factor to better multiply the final value.
  147901. */
  147902. debugFactor: number;
  147903. /**
  147904. * Initialize the block and prepare the context for build
  147905. * @param state defines the state that will be used for the build
  147906. */
  147907. initialize(state: NodeMaterialBuildState): void;
  147908. /**
  147909. * Gets the current class name
  147910. * @returns the class name
  147911. */
  147912. getClassName(): string;
  147913. /**
  147914. * Gets the world position input component
  147915. */
  147916. get worldPosition(): NodeMaterialConnectionPoint;
  147917. /**
  147918. * Gets the world normal input component
  147919. */
  147920. get worldNormal(): NodeMaterialConnectionPoint;
  147921. /**
  147922. * Gets the view matrix parameter
  147923. */
  147924. get view(): NodeMaterialConnectionPoint;
  147925. /**
  147926. * Gets the camera position input component
  147927. */
  147928. get cameraPosition(): NodeMaterialConnectionPoint;
  147929. /**
  147930. * Gets the perturbed normal input component
  147931. */
  147932. get perturbedNormal(): NodeMaterialConnectionPoint;
  147933. /**
  147934. * Gets the base color input component
  147935. */
  147936. get baseColor(): NodeMaterialConnectionPoint;
  147937. /**
  147938. * Gets the metallic input component
  147939. */
  147940. get metallic(): NodeMaterialConnectionPoint;
  147941. /**
  147942. * Gets the roughness input component
  147943. */
  147944. get roughness(): NodeMaterialConnectionPoint;
  147945. /**
  147946. * Gets the ambient occlusion input component
  147947. */
  147948. get ambientOcc(): NodeMaterialConnectionPoint;
  147949. /**
  147950. * Gets the opacity input component
  147951. */
  147952. get opacity(): NodeMaterialConnectionPoint;
  147953. /**
  147954. * Gets the index of refraction input component
  147955. */
  147956. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147957. /**
  147958. * Gets the ambient color input component
  147959. */
  147960. get ambientColor(): NodeMaterialConnectionPoint;
  147961. /**
  147962. * Gets the reflection object parameters
  147963. */
  147964. get reflection(): NodeMaterialConnectionPoint;
  147965. /**
  147966. * Gets the clear coat object parameters
  147967. */
  147968. get clearcoat(): NodeMaterialConnectionPoint;
  147969. /**
  147970. * Gets the sheen object parameters
  147971. */
  147972. get sheen(): NodeMaterialConnectionPoint;
  147973. /**
  147974. * Gets the sub surface object parameters
  147975. */
  147976. get subsurface(): NodeMaterialConnectionPoint;
  147977. /**
  147978. * Gets the anisotropy object parameters
  147979. */
  147980. get anisotropy(): NodeMaterialConnectionPoint;
  147981. /**
  147982. * Gets the ambient output component
  147983. */
  147984. get ambientClr(): NodeMaterialConnectionPoint;
  147985. /**
  147986. * Gets the diffuse output component
  147987. */
  147988. get diffuseDir(): NodeMaterialConnectionPoint;
  147989. /**
  147990. * Gets the specular output component
  147991. */
  147992. get specularDir(): NodeMaterialConnectionPoint;
  147993. /**
  147994. * Gets the clear coat output component
  147995. */
  147996. get clearcoatDir(): NodeMaterialConnectionPoint;
  147997. /**
  147998. * Gets the sheen output component
  147999. */
  148000. get sheenDir(): NodeMaterialConnectionPoint;
  148001. /**
  148002. * Gets the indirect diffuse output component
  148003. */
  148004. get diffuseIndirect(): NodeMaterialConnectionPoint;
  148005. /**
  148006. * Gets the indirect specular output component
  148007. */
  148008. get specularIndirect(): NodeMaterialConnectionPoint;
  148009. /**
  148010. * Gets the indirect clear coat output component
  148011. */
  148012. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  148013. /**
  148014. * Gets the indirect sheen output component
  148015. */
  148016. get sheenIndirect(): NodeMaterialConnectionPoint;
  148017. /**
  148018. * Gets the refraction output component
  148019. */
  148020. get refraction(): NodeMaterialConnectionPoint;
  148021. /**
  148022. * Gets the global lighting output component
  148023. */
  148024. get lighting(): NodeMaterialConnectionPoint;
  148025. /**
  148026. * Gets the shadow output component
  148027. */
  148028. get shadow(): NodeMaterialConnectionPoint;
  148029. /**
  148030. * Gets the alpha output component
  148031. */
  148032. get alpha(): NodeMaterialConnectionPoint;
  148033. autoConfigure(material: NodeMaterial): void;
  148034. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  148035. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  148036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  148037. private _injectVertexCode;
  148038. private _getAlbedoOpacityCode;
  148039. private _getAmbientOcclusionCode;
  148040. private _getReflectivityCode;
  148041. protected _buildBlock(state: NodeMaterialBuildState): this;
  148042. protected _dumpPropertiesCode(): string;
  148043. serialize(): any;
  148044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  148045. }
  148046. }
  148047. declare module BABYLON {
  148048. /**
  148049. * Block used to compute value of one parameter modulo another
  148050. */
  148051. export class ModBlock extends NodeMaterialBlock {
  148052. /**
  148053. * Creates a new ModBlock
  148054. * @param name defines the block name
  148055. */
  148056. constructor(name: string);
  148057. /**
  148058. * Gets the current class name
  148059. * @returns the class name
  148060. */
  148061. getClassName(): string;
  148062. /**
  148063. * Gets the left operand input component
  148064. */
  148065. get left(): NodeMaterialConnectionPoint;
  148066. /**
  148067. * Gets the right operand input component
  148068. */
  148069. get right(): NodeMaterialConnectionPoint;
  148070. /**
  148071. * Gets the output component
  148072. */
  148073. get output(): NodeMaterialConnectionPoint;
  148074. protected _buildBlock(state: NodeMaterialBuildState): this;
  148075. }
  148076. }
  148077. declare module BABYLON {
  148078. /**
  148079. * Configuration for Draco compression
  148080. */
  148081. export interface IDracoCompressionConfiguration {
  148082. /**
  148083. * Configuration for the decoder.
  148084. */
  148085. decoder: {
  148086. /**
  148087. * The url to the WebAssembly module.
  148088. */
  148089. wasmUrl?: string;
  148090. /**
  148091. * The url to the WebAssembly binary.
  148092. */
  148093. wasmBinaryUrl?: string;
  148094. /**
  148095. * The url to the fallback JavaScript module.
  148096. */
  148097. fallbackUrl?: string;
  148098. };
  148099. }
  148100. /**
  148101. * Draco compression (https://google.github.io/draco/)
  148102. *
  148103. * This class wraps the Draco module.
  148104. *
  148105. * **Encoder**
  148106. *
  148107. * The encoder is not currently implemented.
  148108. *
  148109. * **Decoder**
  148110. *
  148111. * 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.
  148112. *
  148113. * To update the configuration, use the following code:
  148114. * ```javascript
  148115. * DracoCompression.Configuration = {
  148116. * decoder: {
  148117. * wasmUrl: "<url to the WebAssembly library>",
  148118. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  148119. * fallbackUrl: "<url to the fallback JavaScript library>",
  148120. * }
  148121. * };
  148122. * ```
  148123. *
  148124. * 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.
  148125. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  148126. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  148127. *
  148128. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  148129. * ```javascript
  148130. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  148131. * ```
  148132. *
  148133. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  148134. */
  148135. export class DracoCompression implements IDisposable {
  148136. private _workerPoolPromise?;
  148137. private _decoderModulePromise?;
  148138. /**
  148139. * The configuration. Defaults to the following urls:
  148140. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  148141. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  148142. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  148143. */
  148144. static Configuration: IDracoCompressionConfiguration;
  148145. /**
  148146. * Returns true if the decoder configuration is available.
  148147. */
  148148. static get DecoderAvailable(): boolean;
  148149. /**
  148150. * Default number of workers to create when creating the draco compression object.
  148151. */
  148152. static DefaultNumWorkers: number;
  148153. private static GetDefaultNumWorkers;
  148154. private static _Default;
  148155. /**
  148156. * Default instance for the draco compression object.
  148157. */
  148158. static get Default(): DracoCompression;
  148159. /**
  148160. * Constructor
  148161. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  148162. */
  148163. constructor(numWorkers?: number);
  148164. /**
  148165. * Stop all async operations and release resources.
  148166. */
  148167. dispose(): void;
  148168. /**
  148169. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  148170. * @returns a promise that resolves when ready
  148171. */
  148172. whenReadyAsync(): Promise<void>;
  148173. /**
  148174. * Decode Draco compressed mesh data to vertex data.
  148175. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  148176. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  148177. * @returns A promise that resolves with the decoded vertex data
  148178. */
  148179. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  148180. [kind: string]: number;
  148181. }): Promise<VertexData>;
  148182. }
  148183. }
  148184. declare module BABYLON {
  148185. /**
  148186. * Class for building Constructive Solid Geometry
  148187. */
  148188. export class CSG {
  148189. private polygons;
  148190. /**
  148191. * The world matrix
  148192. */
  148193. matrix: Matrix;
  148194. /**
  148195. * Stores the position
  148196. */
  148197. position: Vector3;
  148198. /**
  148199. * Stores the rotation
  148200. */
  148201. rotation: Vector3;
  148202. /**
  148203. * Stores the rotation quaternion
  148204. */
  148205. rotationQuaternion: Nullable<Quaternion>;
  148206. /**
  148207. * Stores the scaling vector
  148208. */
  148209. scaling: Vector3;
  148210. /**
  148211. * Convert the Mesh to CSG
  148212. * @param mesh The Mesh to convert to CSG
  148213. * @returns A new CSG from the Mesh
  148214. */
  148215. static FromMesh(mesh: Mesh): CSG;
  148216. /**
  148217. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  148218. * @param polygons Polygons used to construct a CSG solid
  148219. */
  148220. private static FromPolygons;
  148221. /**
  148222. * Clones, or makes a deep copy, of the CSG
  148223. * @returns A new CSG
  148224. */
  148225. clone(): CSG;
  148226. /**
  148227. * Unions this CSG with another CSG
  148228. * @param csg The CSG to union against this CSG
  148229. * @returns The unioned CSG
  148230. */
  148231. union(csg: CSG): CSG;
  148232. /**
  148233. * Unions this CSG with another CSG in place
  148234. * @param csg The CSG to union against this CSG
  148235. */
  148236. unionInPlace(csg: CSG): void;
  148237. /**
  148238. * Subtracts this CSG with another CSG
  148239. * @param csg The CSG to subtract against this CSG
  148240. * @returns A new CSG
  148241. */
  148242. subtract(csg: CSG): CSG;
  148243. /**
  148244. * Subtracts this CSG with another CSG in place
  148245. * @param csg The CSG to subtact against this CSG
  148246. */
  148247. subtractInPlace(csg: CSG): void;
  148248. /**
  148249. * Intersect this CSG with another CSG
  148250. * @param csg The CSG to intersect against this CSG
  148251. * @returns A new CSG
  148252. */
  148253. intersect(csg: CSG): CSG;
  148254. /**
  148255. * Intersects this CSG with another CSG in place
  148256. * @param csg The CSG to intersect against this CSG
  148257. */
  148258. intersectInPlace(csg: CSG): void;
  148259. /**
  148260. * Return a new CSG solid with solid and empty space switched. This solid is
  148261. * not modified.
  148262. * @returns A new CSG solid with solid and empty space switched
  148263. */
  148264. inverse(): CSG;
  148265. /**
  148266. * Inverses the CSG in place
  148267. */
  148268. inverseInPlace(): void;
  148269. /**
  148270. * This is used to keep meshes transformations so they can be restored
  148271. * when we build back a Babylon Mesh
  148272. * NB : All CSG operations are performed in world coordinates
  148273. * @param csg The CSG to copy the transform attributes from
  148274. * @returns This CSG
  148275. */
  148276. copyTransformAttributes(csg: CSG): CSG;
  148277. /**
  148278. * Build Raw mesh from CSG
  148279. * Coordinates here are in world space
  148280. * @param name The name of the mesh geometry
  148281. * @param scene The Scene
  148282. * @param keepSubMeshes Specifies if the submeshes should be kept
  148283. * @returns A new Mesh
  148284. */
  148285. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148286. /**
  148287. * Build Mesh from CSG taking material and transforms into account
  148288. * @param name The name of the Mesh
  148289. * @param material The material of the Mesh
  148290. * @param scene The Scene
  148291. * @param keepSubMeshes Specifies if submeshes should be kept
  148292. * @returns The new Mesh
  148293. */
  148294. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148295. }
  148296. }
  148297. declare module BABYLON {
  148298. /**
  148299. * Class used to create a trail following a mesh
  148300. */
  148301. export class TrailMesh extends Mesh {
  148302. private _generator;
  148303. private _autoStart;
  148304. private _running;
  148305. private _diameter;
  148306. private _length;
  148307. private _sectionPolygonPointsCount;
  148308. private _sectionVectors;
  148309. private _sectionNormalVectors;
  148310. private _beforeRenderObserver;
  148311. /**
  148312. * @constructor
  148313. * @param name The value used by scene.getMeshByName() to do a lookup.
  148314. * @param generator The mesh or transform node to generate a trail.
  148315. * @param scene The scene to add this mesh to.
  148316. * @param diameter Diameter of trailing mesh. Default is 1.
  148317. * @param length Length of trailing mesh. Default is 60.
  148318. * @param autoStart Automatically start trailing mesh. Default true.
  148319. */
  148320. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  148321. /**
  148322. * "TrailMesh"
  148323. * @returns "TrailMesh"
  148324. */
  148325. getClassName(): string;
  148326. private _createMesh;
  148327. /**
  148328. * Start trailing mesh.
  148329. */
  148330. start(): void;
  148331. /**
  148332. * Stop trailing mesh.
  148333. */
  148334. stop(): void;
  148335. /**
  148336. * Update trailing mesh geometry.
  148337. */
  148338. update(): void;
  148339. /**
  148340. * Returns a new TrailMesh object.
  148341. * @param name is a string, the name given to the new mesh
  148342. * @param newGenerator use new generator object for cloned trail mesh
  148343. * @returns a new mesh
  148344. */
  148345. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148346. /**
  148347. * Serializes this trail mesh
  148348. * @param serializationObject object to write serialization to
  148349. */
  148350. serialize(serializationObject: any): void;
  148351. /**
  148352. * Parses a serialized trail mesh
  148353. * @param parsedMesh the serialized mesh
  148354. * @param scene the scene to create the trail mesh in
  148355. * @returns the created trail mesh
  148356. */
  148357. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148358. }
  148359. }
  148360. declare module BABYLON {
  148361. /**
  148362. * Class containing static functions to help procedurally build meshes
  148363. */
  148364. export class TiledBoxBuilder {
  148365. /**
  148366. * Creates a box mesh
  148367. * 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)
  148368. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148372. * @param name defines the name of the mesh
  148373. * @param options defines the options used to create the mesh
  148374. * @param scene defines the hosting scene
  148375. * @returns the box mesh
  148376. */
  148377. static CreateTiledBox(name: string, options: {
  148378. pattern?: number;
  148379. width?: number;
  148380. height?: number;
  148381. depth?: number;
  148382. tileSize?: number;
  148383. tileWidth?: number;
  148384. tileHeight?: number;
  148385. alignHorizontal?: number;
  148386. alignVertical?: number;
  148387. faceUV?: Vector4[];
  148388. faceColors?: Color4[];
  148389. sideOrientation?: number;
  148390. updatable?: boolean;
  148391. }, scene?: Nullable<Scene>): Mesh;
  148392. }
  148393. }
  148394. declare module BABYLON {
  148395. /**
  148396. * Class containing static functions to help procedurally build meshes
  148397. */
  148398. export class TorusKnotBuilder {
  148399. /**
  148400. * Creates a torus knot mesh
  148401. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148402. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148403. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148404. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148408. * @param name defines the name of the mesh
  148409. * @param options defines the options used to create the mesh
  148410. * @param scene defines the hosting scene
  148411. * @returns the torus knot mesh
  148412. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148413. */
  148414. static CreateTorusKnot(name: string, options: {
  148415. radius?: number;
  148416. tube?: number;
  148417. radialSegments?: number;
  148418. tubularSegments?: number;
  148419. p?: number;
  148420. q?: number;
  148421. updatable?: boolean;
  148422. sideOrientation?: number;
  148423. frontUVs?: Vector4;
  148424. backUVs?: Vector4;
  148425. }, scene: any): Mesh;
  148426. }
  148427. }
  148428. declare module BABYLON {
  148429. /**
  148430. * Polygon
  148431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148432. */
  148433. export class Polygon {
  148434. /**
  148435. * Creates a rectangle
  148436. * @param xmin bottom X coord
  148437. * @param ymin bottom Y coord
  148438. * @param xmax top X coord
  148439. * @param ymax top Y coord
  148440. * @returns points that make the resulting rectation
  148441. */
  148442. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148443. /**
  148444. * Creates a circle
  148445. * @param radius radius of circle
  148446. * @param cx scale in x
  148447. * @param cy scale in y
  148448. * @param numberOfSides number of sides that make up the circle
  148449. * @returns points that make the resulting circle
  148450. */
  148451. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148452. /**
  148453. * Creates a polygon from input string
  148454. * @param input Input polygon data
  148455. * @returns the parsed points
  148456. */
  148457. static Parse(input: string): Vector2[];
  148458. /**
  148459. * Starts building a polygon from x and y coordinates
  148460. * @param x x coordinate
  148461. * @param y y coordinate
  148462. * @returns the started path2
  148463. */
  148464. static StartingAt(x: number, y: number): Path2;
  148465. }
  148466. /**
  148467. * Builds a polygon
  148468. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148469. */
  148470. export class PolygonMeshBuilder {
  148471. private _points;
  148472. private _outlinepoints;
  148473. private _holes;
  148474. private _name;
  148475. private _scene;
  148476. private _epoints;
  148477. private _eholes;
  148478. private _addToepoint;
  148479. /**
  148480. * Babylon reference to the earcut plugin.
  148481. */
  148482. bjsEarcut: any;
  148483. /**
  148484. * Creates a PolygonMeshBuilder
  148485. * @param name name of the builder
  148486. * @param contours Path of the polygon
  148487. * @param scene scene to add to when creating the mesh
  148488. * @param earcutInjection can be used to inject your own earcut reference
  148489. */
  148490. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148491. /**
  148492. * Adds a whole within the polygon
  148493. * @param hole Array of points defining the hole
  148494. * @returns this
  148495. */
  148496. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148497. /**
  148498. * Creates the polygon
  148499. * @param updatable If the mesh should be updatable
  148500. * @param depth The depth of the mesh created
  148501. * @returns the created mesh
  148502. */
  148503. build(updatable?: boolean, depth?: number): Mesh;
  148504. /**
  148505. * Creates the polygon
  148506. * @param depth The depth of the mesh created
  148507. * @returns the created VertexData
  148508. */
  148509. buildVertexData(depth?: number): VertexData;
  148510. /**
  148511. * Adds a side to the polygon
  148512. * @param positions points that make the polygon
  148513. * @param normals normals of the polygon
  148514. * @param uvs uvs of the polygon
  148515. * @param indices indices of the polygon
  148516. * @param bounds bounds of the polygon
  148517. * @param points points of the polygon
  148518. * @param depth depth of the polygon
  148519. * @param flip flip of the polygon
  148520. */
  148521. private addSide;
  148522. }
  148523. }
  148524. declare module BABYLON {
  148525. /**
  148526. * Class containing static functions to help procedurally build meshes
  148527. */
  148528. export class PolygonBuilder {
  148529. /**
  148530. * Creates a polygon mesh
  148531. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148532. * * 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
  148533. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148536. * * Remember you can only change the shape positions, not their number when updating a polygon
  148537. * @param name defines the name of the mesh
  148538. * @param options defines the options used to create the mesh
  148539. * @param scene defines the hosting scene
  148540. * @param earcutInjection can be used to inject your own earcut reference
  148541. * @returns the polygon mesh
  148542. */
  148543. static CreatePolygon(name: string, options: {
  148544. shape: Vector3[];
  148545. holes?: Vector3[][];
  148546. depth?: number;
  148547. faceUV?: Vector4[];
  148548. faceColors?: Color4[];
  148549. updatable?: boolean;
  148550. sideOrientation?: number;
  148551. frontUVs?: Vector4;
  148552. backUVs?: Vector4;
  148553. wrap?: boolean;
  148554. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148555. /**
  148556. * Creates an extruded polygon mesh, with depth in the Y direction.
  148557. * * 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)
  148558. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148559. * @param name defines the name of the mesh
  148560. * @param options defines the options used to create the mesh
  148561. * @param scene defines the hosting scene
  148562. * @param earcutInjection can be used to inject your own earcut reference
  148563. * @returns the polygon mesh
  148564. */
  148565. static ExtrudePolygon(name: string, options: {
  148566. shape: Vector3[];
  148567. holes?: Vector3[][];
  148568. depth?: number;
  148569. faceUV?: Vector4[];
  148570. faceColors?: Color4[];
  148571. updatable?: boolean;
  148572. sideOrientation?: number;
  148573. frontUVs?: Vector4;
  148574. backUVs?: Vector4;
  148575. wrap?: boolean;
  148576. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148577. }
  148578. }
  148579. declare module BABYLON {
  148580. /**
  148581. * Class containing static functions to help procedurally build meshes
  148582. */
  148583. export class LatheBuilder {
  148584. /**
  148585. * Creates lathe mesh.
  148586. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148587. * * 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
  148588. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148589. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148590. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148591. * * 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
  148592. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148593. * * 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
  148594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148598. * @param name defines the name of the mesh
  148599. * @param options defines the options used to create the mesh
  148600. * @param scene defines the hosting scene
  148601. * @returns the lathe mesh
  148602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148603. */
  148604. static CreateLathe(name: string, options: {
  148605. shape: Vector3[];
  148606. radius?: number;
  148607. tessellation?: number;
  148608. clip?: number;
  148609. arc?: number;
  148610. closed?: boolean;
  148611. updatable?: boolean;
  148612. sideOrientation?: number;
  148613. frontUVs?: Vector4;
  148614. backUVs?: Vector4;
  148615. cap?: number;
  148616. invertUV?: boolean;
  148617. }, scene?: Nullable<Scene>): Mesh;
  148618. }
  148619. }
  148620. declare module BABYLON {
  148621. /**
  148622. * Class containing static functions to help procedurally build meshes
  148623. */
  148624. export class TiledPlaneBuilder {
  148625. /**
  148626. * Creates a tiled plane mesh
  148627. * * The parameter `pattern` will, depending on value, do nothing or
  148628. * * * flip (reflect about central vertical) alternate tiles across and up
  148629. * * * flip every tile on alternate rows
  148630. * * * rotate (180 degs) alternate tiles across and up
  148631. * * * rotate every tile on alternate rows
  148632. * * * flip and rotate alternate tiles across and up
  148633. * * * flip and rotate every tile on alternate rows
  148634. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148635. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148638. * * 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)
  148639. * * 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)
  148640. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148641. * @param name defines the name of the mesh
  148642. * @param options defines the options used to create the mesh
  148643. * @param scene defines the hosting scene
  148644. * @returns the box mesh
  148645. */
  148646. static CreateTiledPlane(name: string, options: {
  148647. pattern?: number;
  148648. tileSize?: number;
  148649. tileWidth?: number;
  148650. tileHeight?: number;
  148651. size?: number;
  148652. width?: number;
  148653. height?: number;
  148654. alignHorizontal?: number;
  148655. alignVertical?: number;
  148656. sideOrientation?: number;
  148657. frontUVs?: Vector4;
  148658. backUVs?: Vector4;
  148659. updatable?: boolean;
  148660. }, scene?: Nullable<Scene>): Mesh;
  148661. }
  148662. }
  148663. declare module BABYLON {
  148664. /**
  148665. * Class containing static functions to help procedurally build meshes
  148666. */
  148667. export class TubeBuilder {
  148668. /**
  148669. * Creates a tube mesh.
  148670. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148671. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148672. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148673. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148674. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148675. * * 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)
  148676. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148677. * * 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
  148678. * * 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
  148679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148683. * @param name defines the name of the mesh
  148684. * @param options defines the options used to create the mesh
  148685. * @param scene defines the hosting scene
  148686. * @returns the tube mesh
  148687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148688. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148689. */
  148690. static CreateTube(name: string, options: {
  148691. path: Vector3[];
  148692. radius?: number;
  148693. tessellation?: number;
  148694. radiusFunction?: {
  148695. (i: number, distance: number): number;
  148696. };
  148697. cap?: number;
  148698. arc?: number;
  148699. updatable?: boolean;
  148700. sideOrientation?: number;
  148701. frontUVs?: Vector4;
  148702. backUVs?: Vector4;
  148703. instance?: Mesh;
  148704. invertUV?: boolean;
  148705. }, scene?: Nullable<Scene>): Mesh;
  148706. }
  148707. }
  148708. declare module BABYLON {
  148709. /**
  148710. * Class containing static functions to help procedurally build meshes
  148711. */
  148712. export class IcoSphereBuilder {
  148713. /**
  148714. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148715. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148716. * * 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`)
  148717. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148718. * * 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
  148719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148722. * @param name defines the name of the mesh
  148723. * @param options defines the options used to create the mesh
  148724. * @param scene defines the hosting scene
  148725. * @returns the icosahedron mesh
  148726. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148727. */
  148728. static CreateIcoSphere(name: string, options: {
  148729. radius?: number;
  148730. radiusX?: number;
  148731. radiusY?: number;
  148732. radiusZ?: number;
  148733. flat?: boolean;
  148734. subdivisions?: number;
  148735. sideOrientation?: number;
  148736. frontUVs?: Vector4;
  148737. backUVs?: Vector4;
  148738. updatable?: boolean;
  148739. }, scene?: Nullable<Scene>): Mesh;
  148740. }
  148741. }
  148742. declare module BABYLON {
  148743. /**
  148744. * Class containing static functions to help procedurally build meshes
  148745. */
  148746. export class DecalBuilder {
  148747. /**
  148748. * Creates a decal mesh.
  148749. * 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
  148750. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148751. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148752. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148753. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148754. * @param name defines the name of the mesh
  148755. * @param sourceMesh defines the mesh where the decal must be applied
  148756. * @param options defines the options used to create the mesh
  148757. * @param scene defines the hosting scene
  148758. * @returns the decal mesh
  148759. * @see https://doc.babylonjs.com/how_to/decals
  148760. */
  148761. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148762. position?: Vector3;
  148763. normal?: Vector3;
  148764. size?: Vector3;
  148765. angle?: number;
  148766. }): Mesh;
  148767. }
  148768. }
  148769. declare module BABYLON {
  148770. /**
  148771. * Class containing static functions to help procedurally build meshes
  148772. */
  148773. export class MeshBuilder {
  148774. /**
  148775. * Creates a box mesh
  148776. * * The parameter `size` sets the size (float) of each box side (default 1)
  148777. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148778. * * 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)
  148779. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148783. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148784. * @param name defines the name of the mesh
  148785. * @param options defines the options used to create the mesh
  148786. * @param scene defines the hosting scene
  148787. * @returns the box mesh
  148788. */
  148789. static CreateBox(name: string, options: {
  148790. size?: number;
  148791. width?: number;
  148792. height?: number;
  148793. depth?: number;
  148794. faceUV?: Vector4[];
  148795. faceColors?: Color4[];
  148796. sideOrientation?: number;
  148797. frontUVs?: Vector4;
  148798. backUVs?: Vector4;
  148799. wrap?: boolean;
  148800. topBaseAt?: number;
  148801. bottomBaseAt?: number;
  148802. updatable?: boolean;
  148803. }, scene?: Nullable<Scene>): Mesh;
  148804. /**
  148805. * Creates a tiled box mesh
  148806. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148808. * @param name defines the name of the mesh
  148809. * @param options defines the options used to create the mesh
  148810. * @param scene defines the hosting scene
  148811. * @returns the tiled box mesh
  148812. */
  148813. static CreateTiledBox(name: string, options: {
  148814. pattern?: number;
  148815. size?: number;
  148816. width?: number;
  148817. height?: number;
  148818. depth: number;
  148819. tileSize?: number;
  148820. tileWidth?: number;
  148821. tileHeight?: number;
  148822. faceUV?: Vector4[];
  148823. faceColors?: Color4[];
  148824. alignHorizontal?: number;
  148825. alignVertical?: number;
  148826. sideOrientation?: number;
  148827. updatable?: boolean;
  148828. }, scene?: Nullable<Scene>): Mesh;
  148829. /**
  148830. * Creates a sphere mesh
  148831. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148832. * * 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`)
  148833. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148834. * * 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
  148835. * * 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)
  148836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148839. * @param name defines the name of the mesh
  148840. * @param options defines the options used to create the mesh
  148841. * @param scene defines the hosting scene
  148842. * @returns the sphere mesh
  148843. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148844. */
  148845. static CreateSphere(name: string, options: {
  148846. segments?: number;
  148847. diameter?: number;
  148848. diameterX?: number;
  148849. diameterY?: number;
  148850. diameterZ?: number;
  148851. arc?: number;
  148852. slice?: number;
  148853. sideOrientation?: number;
  148854. frontUVs?: Vector4;
  148855. backUVs?: Vector4;
  148856. updatable?: boolean;
  148857. }, scene?: Nullable<Scene>): Mesh;
  148858. /**
  148859. * Creates a plane polygonal mesh. By default, this is a disc
  148860. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148861. * * 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
  148862. * * 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
  148863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148866. * @param name defines the name of the mesh
  148867. * @param options defines the options used to create the mesh
  148868. * @param scene defines the hosting scene
  148869. * @returns the plane polygonal mesh
  148870. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148871. */
  148872. static CreateDisc(name: string, options: {
  148873. radius?: number;
  148874. tessellation?: number;
  148875. arc?: number;
  148876. updatable?: boolean;
  148877. sideOrientation?: number;
  148878. frontUVs?: Vector4;
  148879. backUVs?: Vector4;
  148880. }, scene?: Nullable<Scene>): Mesh;
  148881. /**
  148882. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148883. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148884. * * 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`)
  148885. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148886. * * 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
  148887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148890. * @param name defines the name of the mesh
  148891. * @param options defines the options used to create the mesh
  148892. * @param scene defines the hosting scene
  148893. * @returns the icosahedron mesh
  148894. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148895. */
  148896. static CreateIcoSphere(name: string, options: {
  148897. radius?: number;
  148898. radiusX?: number;
  148899. radiusY?: number;
  148900. radiusZ?: number;
  148901. flat?: boolean;
  148902. subdivisions?: number;
  148903. sideOrientation?: number;
  148904. frontUVs?: Vector4;
  148905. backUVs?: Vector4;
  148906. updatable?: boolean;
  148907. }, scene?: Nullable<Scene>): Mesh;
  148908. /**
  148909. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148910. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148911. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148912. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148913. * * 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
  148914. * * 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
  148915. * * 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
  148916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148919. * * The 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
  148920. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148921. * * 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
  148922. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148924. * @param name defines the name of the mesh
  148925. * @param options defines the options used to create the mesh
  148926. * @param scene defines the hosting scene
  148927. * @returns the ribbon mesh
  148928. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148930. */
  148931. static CreateRibbon(name: string, options: {
  148932. pathArray: Vector3[][];
  148933. closeArray?: boolean;
  148934. closePath?: boolean;
  148935. offset?: number;
  148936. updatable?: boolean;
  148937. sideOrientation?: number;
  148938. frontUVs?: Vector4;
  148939. backUVs?: Vector4;
  148940. instance?: Mesh;
  148941. invertUV?: boolean;
  148942. uvs?: Vector2[];
  148943. colors?: Color4[];
  148944. }, scene?: Nullable<Scene>): Mesh;
  148945. /**
  148946. * Creates a cylinder or a cone mesh
  148947. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148948. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148949. * * 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.
  148950. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148951. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148952. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148953. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148954. * * 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).
  148955. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148956. * * 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).
  148957. * * 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
  148958. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148959. * * 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
  148960. * * 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.
  148961. * * If `enclose` is false, a ring surface is one element.
  148962. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148963. * * 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
  148964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148967. * @param name defines the name of the mesh
  148968. * @param options defines the options used to create the mesh
  148969. * @param scene defines the hosting scene
  148970. * @returns the cylinder mesh
  148971. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148972. */
  148973. static CreateCylinder(name: string, options: {
  148974. height?: number;
  148975. diameterTop?: number;
  148976. diameterBottom?: number;
  148977. diameter?: number;
  148978. tessellation?: number;
  148979. subdivisions?: number;
  148980. arc?: number;
  148981. faceColors?: Color4[];
  148982. faceUV?: Vector4[];
  148983. updatable?: boolean;
  148984. hasRings?: boolean;
  148985. enclose?: boolean;
  148986. cap?: number;
  148987. sideOrientation?: number;
  148988. frontUVs?: Vector4;
  148989. backUVs?: Vector4;
  148990. }, scene?: Nullable<Scene>): Mesh;
  148991. /**
  148992. * Creates a torus mesh
  148993. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148994. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148995. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148999. * @param name defines the name of the mesh
  149000. * @param options defines the options used to create the mesh
  149001. * @param scene defines the hosting scene
  149002. * @returns the torus mesh
  149003. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  149004. */
  149005. static CreateTorus(name: string, options: {
  149006. diameter?: number;
  149007. thickness?: number;
  149008. tessellation?: number;
  149009. updatable?: boolean;
  149010. sideOrientation?: number;
  149011. frontUVs?: Vector4;
  149012. backUVs?: Vector4;
  149013. }, scene?: Nullable<Scene>): Mesh;
  149014. /**
  149015. * Creates a torus knot mesh
  149016. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  149017. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  149018. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  149019. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  149020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149023. * @param name defines the name of the mesh
  149024. * @param options defines the options used to create the mesh
  149025. * @param scene defines the hosting scene
  149026. * @returns the torus knot mesh
  149027. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  149028. */
  149029. static CreateTorusKnot(name: string, options: {
  149030. radius?: number;
  149031. tube?: number;
  149032. radialSegments?: number;
  149033. tubularSegments?: number;
  149034. p?: number;
  149035. q?: number;
  149036. updatable?: boolean;
  149037. sideOrientation?: number;
  149038. frontUVs?: Vector4;
  149039. backUVs?: Vector4;
  149040. }, scene?: Nullable<Scene>): Mesh;
  149041. /**
  149042. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  149043. * * 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
  149044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  149045. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  149046. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  149047. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  149048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  149049. * * 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
  149050. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  149051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  149053. * @param name defines the name of the new line system
  149054. * @param options defines the options used to create the line system
  149055. * @param scene defines the hosting scene
  149056. * @returns a new line system mesh
  149057. */
  149058. static CreateLineSystem(name: string, options: {
  149059. lines: Vector3[][];
  149060. updatable?: boolean;
  149061. instance?: Nullable<LinesMesh>;
  149062. colors?: Nullable<Color4[][]>;
  149063. useVertexAlpha?: boolean;
  149064. }, scene: Nullable<Scene>): LinesMesh;
  149065. /**
  149066. * Creates a line mesh
  149067. * 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
  149068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149069. * * The parameter `points` is an array successive Vector3
  149070. * * 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
  149071. * * The optional parameter `colors` is an array of successive Color4, one per line point
  149072. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  149073. * * When updating an instance, remember that only point positions can change, not the number of points
  149074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  149076. * @param name defines the name of the new line system
  149077. * @param options defines the options used to create the line system
  149078. * @param scene defines the hosting scene
  149079. * @returns a new line mesh
  149080. */
  149081. static CreateLines(name: string, options: {
  149082. points: Vector3[];
  149083. updatable?: boolean;
  149084. instance?: Nullable<LinesMesh>;
  149085. colors?: Color4[];
  149086. useVertexAlpha?: boolean;
  149087. }, scene?: Nullable<Scene>): LinesMesh;
  149088. /**
  149089. * Creates a dashed line mesh
  149090. * * 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
  149091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149092. * * The parameter `points` is an array successive Vector3
  149093. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  149094. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  149095. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  149096. * * 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
  149097. * * When updating an instance, remember that only point positions can change, not the number of points
  149098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149099. * @param name defines the name of the mesh
  149100. * @param options defines the options used to create the mesh
  149101. * @param scene defines the hosting scene
  149102. * @returns the dashed line mesh
  149103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  149104. */
  149105. static CreateDashedLines(name: string, options: {
  149106. points: Vector3[];
  149107. dashSize?: number;
  149108. gapSize?: number;
  149109. dashNb?: number;
  149110. updatable?: boolean;
  149111. instance?: LinesMesh;
  149112. }, scene?: Nullable<Scene>): LinesMesh;
  149113. /**
  149114. * 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.
  149115. * * 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.
  149116. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149117. * * 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.
  149118. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  149119. * * 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
  149120. * * 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
  149121. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  149122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  149125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149126. * @param name defines the name of the mesh
  149127. * @param options defines the options used to create the mesh
  149128. * @param scene defines the hosting scene
  149129. * @returns the extruded shape mesh
  149130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149132. */
  149133. static ExtrudeShape(name: string, options: {
  149134. shape: Vector3[];
  149135. path: Vector3[];
  149136. scale?: number;
  149137. rotation?: number;
  149138. cap?: number;
  149139. updatable?: boolean;
  149140. sideOrientation?: number;
  149141. frontUVs?: Vector4;
  149142. backUVs?: Vector4;
  149143. instance?: Mesh;
  149144. invertUV?: boolean;
  149145. }, scene?: Nullable<Scene>): Mesh;
  149146. /**
  149147. * Creates an custom extruded shape mesh.
  149148. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  149149. * * 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.
  149150. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149151. * * 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
  149152. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  149153. * * 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
  149154. * * It must returns a float value that will be the scale value applied to the shape on each path point
  149155. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  149156. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  149157. * * 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
  149158. * * 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
  149159. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  149160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149164. * @param name defines the name of the mesh
  149165. * @param options defines the options used to create the mesh
  149166. * @param scene defines the hosting scene
  149167. * @returns the custom extruded shape mesh
  149168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  149169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149171. */
  149172. static ExtrudeShapeCustom(name: string, options: {
  149173. shape: Vector3[];
  149174. path: Vector3[];
  149175. scaleFunction?: any;
  149176. rotationFunction?: any;
  149177. ribbonCloseArray?: boolean;
  149178. ribbonClosePath?: boolean;
  149179. cap?: number;
  149180. updatable?: boolean;
  149181. sideOrientation?: number;
  149182. frontUVs?: Vector4;
  149183. backUVs?: Vector4;
  149184. instance?: Mesh;
  149185. invertUV?: boolean;
  149186. }, scene?: Nullable<Scene>): Mesh;
  149187. /**
  149188. * Creates lathe mesh.
  149189. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  149190. * * 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
  149191. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  149192. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  149193. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  149194. * * 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
  149195. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  149196. * * 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
  149197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149201. * @param name defines the name of the mesh
  149202. * @param options defines the options used to create the mesh
  149203. * @param scene defines the hosting scene
  149204. * @returns the lathe mesh
  149205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  149206. */
  149207. static CreateLathe(name: string, options: {
  149208. shape: Vector3[];
  149209. radius?: number;
  149210. tessellation?: number;
  149211. clip?: number;
  149212. arc?: number;
  149213. closed?: boolean;
  149214. updatable?: boolean;
  149215. sideOrientation?: number;
  149216. frontUVs?: Vector4;
  149217. backUVs?: Vector4;
  149218. cap?: number;
  149219. invertUV?: boolean;
  149220. }, scene?: Nullable<Scene>): Mesh;
  149221. /**
  149222. * Creates a tiled plane mesh
  149223. * * You can set a limited pattern arrangement with the tiles
  149224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149227. * @param name defines the name of the mesh
  149228. * @param options defines the options used to create the mesh
  149229. * @param scene defines the hosting scene
  149230. * @returns the plane mesh
  149231. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149232. */
  149233. static CreateTiledPlane(name: string, options: {
  149234. pattern?: number;
  149235. tileSize?: number;
  149236. tileWidth?: number;
  149237. tileHeight?: number;
  149238. size?: number;
  149239. width?: number;
  149240. height?: number;
  149241. alignHorizontal?: number;
  149242. alignVertical?: number;
  149243. sideOrientation?: number;
  149244. frontUVs?: Vector4;
  149245. backUVs?: Vector4;
  149246. updatable?: boolean;
  149247. }, scene?: Nullable<Scene>): Mesh;
  149248. /**
  149249. * Creates a plane mesh
  149250. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  149251. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  149252. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  149253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149256. * @param name defines the name of the mesh
  149257. * @param options defines the options used to create the mesh
  149258. * @param scene defines the hosting scene
  149259. * @returns the plane mesh
  149260. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149261. */
  149262. static CreatePlane(name: string, options: {
  149263. size?: number;
  149264. width?: number;
  149265. height?: number;
  149266. sideOrientation?: number;
  149267. frontUVs?: Vector4;
  149268. backUVs?: Vector4;
  149269. updatable?: boolean;
  149270. sourcePlane?: Plane;
  149271. }, scene?: Nullable<Scene>): Mesh;
  149272. /**
  149273. * Creates a ground mesh
  149274. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  149275. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  149276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149277. * @param name defines the name of the mesh
  149278. * @param options defines the options used to create the mesh
  149279. * @param scene defines the hosting scene
  149280. * @returns the ground mesh
  149281. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  149282. */
  149283. static CreateGround(name: string, options: {
  149284. width?: number;
  149285. height?: number;
  149286. subdivisions?: number;
  149287. subdivisionsX?: number;
  149288. subdivisionsY?: number;
  149289. updatable?: boolean;
  149290. }, scene?: Nullable<Scene>): Mesh;
  149291. /**
  149292. * Creates a tiled ground mesh
  149293. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  149294. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  149295. * * 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
  149296. * * 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
  149297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149298. * @param name defines the name of the mesh
  149299. * @param options defines the options used to create the mesh
  149300. * @param scene defines the hosting scene
  149301. * @returns the tiled ground mesh
  149302. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  149303. */
  149304. static CreateTiledGround(name: string, options: {
  149305. xmin: number;
  149306. zmin: number;
  149307. xmax: number;
  149308. zmax: number;
  149309. subdivisions?: {
  149310. w: number;
  149311. h: number;
  149312. };
  149313. precision?: {
  149314. w: number;
  149315. h: number;
  149316. };
  149317. updatable?: boolean;
  149318. }, scene?: Nullable<Scene>): Mesh;
  149319. /**
  149320. * Creates a ground mesh from a height map
  149321. * * The parameter `url` sets the URL of the height map image resource.
  149322. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  149323. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  149324. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  149325. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  149326. * * 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.
  149327. * * 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).
  149328. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  149329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149330. * @param name defines the name of the mesh
  149331. * @param url defines the url to the height map
  149332. * @param options defines the options used to create the mesh
  149333. * @param scene defines the hosting scene
  149334. * @returns the ground mesh
  149335. * @see https://doc.babylonjs.com/babylon101/height_map
  149336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  149337. */
  149338. static CreateGroundFromHeightMap(name: string, url: string, options: {
  149339. width?: number;
  149340. height?: number;
  149341. subdivisions?: number;
  149342. minHeight?: number;
  149343. maxHeight?: number;
  149344. colorFilter?: Color3;
  149345. alphaFilter?: number;
  149346. updatable?: boolean;
  149347. onReady?: (mesh: GroundMesh) => void;
  149348. }, scene?: Nullable<Scene>): GroundMesh;
  149349. /**
  149350. * Creates a polygon mesh
  149351. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149352. * * 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
  149353. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149356. * * Remember you can only change the shape positions, not their number when updating a polygon
  149357. * @param name defines the name of the mesh
  149358. * @param options defines the options used to create the mesh
  149359. * @param scene defines the hosting scene
  149360. * @param earcutInjection can be used to inject your own earcut reference
  149361. * @returns the polygon mesh
  149362. */
  149363. static CreatePolygon(name: string, options: {
  149364. shape: Vector3[];
  149365. holes?: Vector3[][];
  149366. depth?: number;
  149367. faceUV?: Vector4[];
  149368. faceColors?: Color4[];
  149369. updatable?: boolean;
  149370. sideOrientation?: number;
  149371. frontUVs?: Vector4;
  149372. backUVs?: Vector4;
  149373. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149374. /**
  149375. * Creates an extruded polygon mesh, with depth in the Y direction.
  149376. * * 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)
  149377. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149378. * @param name defines the name of the mesh
  149379. * @param options defines the options used to create the mesh
  149380. * @param scene defines the hosting scene
  149381. * @param earcutInjection can be used to inject your own earcut reference
  149382. * @returns the polygon mesh
  149383. */
  149384. static ExtrudePolygon(name: string, options: {
  149385. shape: Vector3[];
  149386. holes?: Vector3[][];
  149387. depth?: number;
  149388. faceUV?: Vector4[];
  149389. faceColors?: Color4[];
  149390. updatable?: boolean;
  149391. sideOrientation?: number;
  149392. frontUVs?: Vector4;
  149393. backUVs?: Vector4;
  149394. wrap?: boolean;
  149395. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149396. /**
  149397. * Creates a tube mesh.
  149398. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149399. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149400. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149401. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149402. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149403. * * 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)
  149404. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149405. * * 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
  149406. * * 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
  149407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149411. * @param name defines the name of the mesh
  149412. * @param options defines the options used to create the mesh
  149413. * @param scene defines the hosting scene
  149414. * @returns the tube mesh
  149415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149416. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149417. */
  149418. static CreateTube(name: string, options: {
  149419. path: Vector3[];
  149420. radius?: number;
  149421. tessellation?: number;
  149422. radiusFunction?: {
  149423. (i: number, distance: number): number;
  149424. };
  149425. cap?: number;
  149426. arc?: number;
  149427. updatable?: boolean;
  149428. sideOrientation?: number;
  149429. frontUVs?: Vector4;
  149430. backUVs?: Vector4;
  149431. instance?: Mesh;
  149432. invertUV?: boolean;
  149433. }, scene?: Nullable<Scene>): Mesh;
  149434. /**
  149435. * Creates a polyhedron mesh
  149436. * * 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
  149437. * * The parameter `size` (positive float, default 1) sets the polygon size
  149438. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149439. * * 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`
  149440. * * 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
  149441. * * 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)`)
  149442. * * 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
  149443. * * 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
  149444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149447. * @param name defines the name of the mesh
  149448. * @param options defines the options used to create the mesh
  149449. * @param scene defines the hosting scene
  149450. * @returns the polyhedron mesh
  149451. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149452. */
  149453. static CreatePolyhedron(name: string, options: {
  149454. type?: number;
  149455. size?: number;
  149456. sizeX?: number;
  149457. sizeY?: number;
  149458. sizeZ?: number;
  149459. custom?: any;
  149460. faceUV?: Vector4[];
  149461. faceColors?: Color4[];
  149462. flat?: boolean;
  149463. updatable?: boolean;
  149464. sideOrientation?: number;
  149465. frontUVs?: Vector4;
  149466. backUVs?: Vector4;
  149467. }, scene?: Nullable<Scene>): Mesh;
  149468. /**
  149469. * Creates a decal mesh.
  149470. * 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
  149471. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149472. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149473. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149474. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149475. * @param name defines the name of the mesh
  149476. * @param sourceMesh defines the mesh where the decal must be applied
  149477. * @param options defines the options used to create the mesh
  149478. * @param scene defines the hosting scene
  149479. * @returns the decal mesh
  149480. * @see https://doc.babylonjs.com/how_to/decals
  149481. */
  149482. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149483. position?: Vector3;
  149484. normal?: Vector3;
  149485. size?: Vector3;
  149486. angle?: number;
  149487. }): Mesh;
  149488. /**
  149489. * Creates a Capsule Mesh
  149490. * @param name defines the name of the mesh.
  149491. * @param options the constructors options used to shape the mesh.
  149492. * @param scene defines the scene the mesh is scoped to.
  149493. * @returns the capsule mesh
  149494. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149495. */
  149496. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149497. }
  149498. }
  149499. declare module BABYLON {
  149500. /**
  149501. * A simplifier interface for future simplification implementations
  149502. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149503. */
  149504. export interface ISimplifier {
  149505. /**
  149506. * Simplification of a given mesh according to the given settings.
  149507. * Since this requires computation, it is assumed that the function runs async.
  149508. * @param settings The settings of the simplification, including quality and distance
  149509. * @param successCallback A callback that will be called after the mesh was simplified.
  149510. * @param errorCallback in case of an error, this callback will be called. optional.
  149511. */
  149512. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149513. }
  149514. /**
  149515. * Expected simplification settings.
  149516. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149517. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149518. */
  149519. export interface ISimplificationSettings {
  149520. /**
  149521. * Gets or sets the expected quality
  149522. */
  149523. quality: number;
  149524. /**
  149525. * Gets or sets the distance when this optimized version should be used
  149526. */
  149527. distance: number;
  149528. /**
  149529. * Gets an already optimized mesh
  149530. */
  149531. optimizeMesh?: boolean;
  149532. }
  149533. /**
  149534. * Class used to specify simplification options
  149535. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149536. */
  149537. export class SimplificationSettings implements ISimplificationSettings {
  149538. /** expected quality */
  149539. quality: number;
  149540. /** distance when this optimized version should be used */
  149541. distance: number;
  149542. /** already optimized mesh */
  149543. optimizeMesh?: boolean | undefined;
  149544. /**
  149545. * Creates a SimplificationSettings
  149546. * @param quality expected quality
  149547. * @param distance distance when this optimized version should be used
  149548. * @param optimizeMesh already optimized mesh
  149549. */
  149550. constructor(
  149551. /** expected quality */
  149552. quality: number,
  149553. /** distance when this optimized version should be used */
  149554. distance: number,
  149555. /** already optimized mesh */
  149556. optimizeMesh?: boolean | undefined);
  149557. }
  149558. /**
  149559. * Interface used to define a simplification task
  149560. */
  149561. export interface ISimplificationTask {
  149562. /**
  149563. * Array of settings
  149564. */
  149565. settings: Array<ISimplificationSettings>;
  149566. /**
  149567. * Simplification type
  149568. */
  149569. simplificationType: SimplificationType;
  149570. /**
  149571. * Mesh to simplify
  149572. */
  149573. mesh: Mesh;
  149574. /**
  149575. * Callback called on success
  149576. */
  149577. successCallback?: () => void;
  149578. /**
  149579. * Defines if parallel processing can be used
  149580. */
  149581. parallelProcessing: boolean;
  149582. }
  149583. /**
  149584. * Queue used to order the simplification tasks
  149585. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149586. */
  149587. export class SimplificationQueue {
  149588. private _simplificationArray;
  149589. /**
  149590. * Gets a boolean indicating that the process is still running
  149591. */
  149592. running: boolean;
  149593. /**
  149594. * Creates a new queue
  149595. */
  149596. constructor();
  149597. /**
  149598. * Adds a new simplification task
  149599. * @param task defines a task to add
  149600. */
  149601. addTask(task: ISimplificationTask): void;
  149602. /**
  149603. * Execute next task
  149604. */
  149605. executeNext(): void;
  149606. /**
  149607. * Execute a simplification task
  149608. * @param task defines the task to run
  149609. */
  149610. runSimplification(task: ISimplificationTask): void;
  149611. private getSimplifier;
  149612. }
  149613. /**
  149614. * The implemented types of simplification
  149615. * At the moment only Quadratic Error Decimation is implemented
  149616. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149617. */
  149618. export enum SimplificationType {
  149619. /** Quadratic error decimation */
  149620. QUADRATIC = 0
  149621. }
  149622. /**
  149623. * An implementation of the Quadratic Error simplification algorithm.
  149624. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149625. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149626. * @author RaananW
  149627. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149628. */
  149629. export class QuadraticErrorSimplification implements ISimplifier {
  149630. private _mesh;
  149631. private triangles;
  149632. private vertices;
  149633. private references;
  149634. private _reconstructedMesh;
  149635. /** Gets or sets the number pf sync interations */
  149636. syncIterations: number;
  149637. /** Gets or sets the aggressiveness of the simplifier */
  149638. aggressiveness: number;
  149639. /** Gets or sets the number of allowed iterations for decimation */
  149640. decimationIterations: number;
  149641. /** Gets or sets the espilon to use for bounding box computation */
  149642. boundingBoxEpsilon: number;
  149643. /**
  149644. * Creates a new QuadraticErrorSimplification
  149645. * @param _mesh defines the target mesh
  149646. */
  149647. constructor(_mesh: Mesh);
  149648. /**
  149649. * Simplification of a given mesh according to the given settings.
  149650. * Since this requires computation, it is assumed that the function runs async.
  149651. * @param settings The settings of the simplification, including quality and distance
  149652. * @param successCallback A callback that will be called after the mesh was simplified.
  149653. */
  149654. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149655. private runDecimation;
  149656. private initWithMesh;
  149657. private init;
  149658. private reconstructMesh;
  149659. private initDecimatedMesh;
  149660. private isFlipped;
  149661. private updateTriangles;
  149662. private identifyBorder;
  149663. private updateMesh;
  149664. private vertexError;
  149665. private calculateError;
  149666. }
  149667. }
  149668. declare module BABYLON {
  149669. interface Scene {
  149670. /** @hidden (Backing field) */
  149671. _simplificationQueue: SimplificationQueue;
  149672. /**
  149673. * Gets or sets the simplification queue attached to the scene
  149674. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149675. */
  149676. simplificationQueue: SimplificationQueue;
  149677. }
  149678. interface Mesh {
  149679. /**
  149680. * Simplify the mesh according to the given array of settings.
  149681. * Function will return immediately and will simplify async
  149682. * @param settings a collection of simplification settings
  149683. * @param parallelProcessing should all levels calculate parallel or one after the other
  149684. * @param simplificationType the type of simplification to run
  149685. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149686. * @returns the current mesh
  149687. */
  149688. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149689. }
  149690. /**
  149691. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149692. * created in a scene
  149693. */
  149694. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149695. /**
  149696. * The component name helpfull to identify the component in the list of scene components.
  149697. */
  149698. readonly name: string;
  149699. /**
  149700. * The scene the component belongs to.
  149701. */
  149702. scene: Scene;
  149703. /**
  149704. * Creates a new instance of the component for the given scene
  149705. * @param scene Defines the scene to register the component in
  149706. */
  149707. constructor(scene: Scene);
  149708. /**
  149709. * Registers the component in a given scene
  149710. */
  149711. register(): void;
  149712. /**
  149713. * Rebuilds the elements related to this component in case of
  149714. * context lost for instance.
  149715. */
  149716. rebuild(): void;
  149717. /**
  149718. * Disposes the component and the associated ressources
  149719. */
  149720. dispose(): void;
  149721. private _beforeCameraUpdate;
  149722. }
  149723. }
  149724. declare module BABYLON {
  149725. interface Mesh {
  149726. /**
  149727. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149728. */
  149729. thinInstanceEnablePicking: boolean;
  149730. /**
  149731. * Creates a new thin instance
  149732. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149733. * @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
  149734. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149735. */
  149736. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149737. /**
  149738. * Adds the transformation (matrix) of the current mesh as a thin instance
  149739. * @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
  149740. * @returns the thin instance index number
  149741. */
  149742. thinInstanceAddSelf(refresh: boolean): number;
  149743. /**
  149744. * Registers a custom attribute to be used with thin instances
  149745. * @param kind name of the attribute
  149746. * @param stride size in floats of the attribute
  149747. */
  149748. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149749. /**
  149750. * Sets the matrix of a thin instance
  149751. * @param index index of the thin instance
  149752. * @param matrix matrix to set
  149753. * @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
  149754. */
  149755. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149756. /**
  149757. * Sets the value of a custom attribute for a thin instance
  149758. * @param kind name of the attribute
  149759. * @param index index of the thin instance
  149760. * @param value value to set
  149761. * @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
  149762. */
  149763. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149764. /**
  149765. * 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.
  149766. */
  149767. thinInstanceCount: number;
  149768. /**
  149769. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149770. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149771. * @param buffer buffer to set
  149772. * @param stride size in floats of each value of the buffer
  149773. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149774. */
  149775. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149776. /**
  149777. * Gets the list of world matrices
  149778. * @return an array containing all the world matrices from the thin instances
  149779. */
  149780. thinInstanceGetWorldMatrices(): Matrix[];
  149781. /**
  149782. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149783. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149784. */
  149785. thinInstanceBufferUpdated(kind: string): void;
  149786. /**
  149787. * Applies a partial update to a buffer directly on the GPU
  149788. * 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
  149789. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149790. * @param data the data to set in the GPU buffer
  149791. * @param offset the offset in the GPU buffer where to update the data
  149792. */
  149793. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149794. /**
  149795. * Refreshes the bounding info, taking into account all the thin instances defined
  149796. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149797. */
  149798. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149799. /** @hidden */
  149800. _thinInstanceInitializeUserStorage(): void;
  149801. /** @hidden */
  149802. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149803. /** @hidden */
  149804. _userThinInstanceBuffersStorage: {
  149805. data: {
  149806. [key: string]: Float32Array;
  149807. };
  149808. sizes: {
  149809. [key: string]: number;
  149810. };
  149811. vertexBuffers: {
  149812. [key: string]: Nullable<VertexBuffer>;
  149813. };
  149814. strides: {
  149815. [key: string]: number;
  149816. };
  149817. };
  149818. }
  149819. }
  149820. declare module BABYLON {
  149821. /**
  149822. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149823. */
  149824. export interface INavigationEnginePlugin {
  149825. /**
  149826. * plugin name
  149827. */
  149828. name: string;
  149829. /**
  149830. * Creates a navigation mesh
  149831. * @param meshes array of all the geometry used to compute the navigatio mesh
  149832. * @param parameters bunch of parameters used to filter geometry
  149833. */
  149834. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149835. /**
  149836. * Create a navigation mesh debug mesh
  149837. * @param scene is where the mesh will be added
  149838. * @returns debug display mesh
  149839. */
  149840. createDebugNavMesh(scene: Scene): Mesh;
  149841. /**
  149842. * Get a navigation mesh constrained position, closest to the parameter position
  149843. * @param position world position
  149844. * @returns the closest point to position constrained by the navigation mesh
  149845. */
  149846. getClosestPoint(position: Vector3): Vector3;
  149847. /**
  149848. * Get a navigation mesh constrained position, closest to the parameter position
  149849. * @param position world position
  149850. * @param result output the closest point to position constrained by the navigation mesh
  149851. */
  149852. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149853. /**
  149854. * Get a navigation mesh constrained position, within a particular radius
  149855. * @param position world position
  149856. * @param maxRadius the maximum distance to the constrained world position
  149857. * @returns the closest point to position constrained by the navigation mesh
  149858. */
  149859. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149860. /**
  149861. * Get a navigation mesh constrained position, within a particular radius
  149862. * @param position world position
  149863. * @param maxRadius the maximum distance to the constrained world position
  149864. * @param result output the closest point to position constrained by the navigation mesh
  149865. */
  149866. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149867. /**
  149868. * Compute the final position from a segment made of destination-position
  149869. * @param position world position
  149870. * @param destination world position
  149871. * @returns the resulting point along the navmesh
  149872. */
  149873. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149874. /**
  149875. * Compute the final position from a segment made of destination-position
  149876. * @param position world position
  149877. * @param destination world position
  149878. * @param result output the resulting point along the navmesh
  149879. */
  149880. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149881. /**
  149882. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149883. * @param start world position
  149884. * @param end world position
  149885. * @returns array containing world position composing the path
  149886. */
  149887. computePath(start: Vector3, end: Vector3): Vector3[];
  149888. /**
  149889. * If this plugin is supported
  149890. * @returns true if plugin is supported
  149891. */
  149892. isSupported(): boolean;
  149893. /**
  149894. * Create a new Crowd so you can add agents
  149895. * @param maxAgents the maximum agent count in the crowd
  149896. * @param maxAgentRadius the maximum radius an agent can have
  149897. * @param scene to attach the crowd to
  149898. * @returns the crowd you can add agents to
  149899. */
  149900. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149901. /**
  149902. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149903. * The queries will try to find a solution within those bounds
  149904. * default is (1,1,1)
  149905. * @param extent x,y,z value that define the extent around the queries point of reference
  149906. */
  149907. setDefaultQueryExtent(extent: Vector3): void;
  149908. /**
  149909. * Get the Bounding box extent specified by setDefaultQueryExtent
  149910. * @returns the box extent values
  149911. */
  149912. getDefaultQueryExtent(): Vector3;
  149913. /**
  149914. * build the navmesh from a previously saved state using getNavmeshData
  149915. * @param data the Uint8Array returned by getNavmeshData
  149916. */
  149917. buildFromNavmeshData(data: Uint8Array): void;
  149918. /**
  149919. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149920. * @returns data the Uint8Array that can be saved and reused
  149921. */
  149922. getNavmeshData(): Uint8Array;
  149923. /**
  149924. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149925. * @param result output the box extent values
  149926. */
  149927. getDefaultQueryExtentToRef(result: Vector3): void;
  149928. /**
  149929. * Set the time step of the navigation tick update.
  149930. * Default is 1/60.
  149931. * A value of 0 will disable fixed time update
  149932. * @param newTimeStep the new timestep to apply to this world.
  149933. */
  149934. setTimeStep(newTimeStep: number): void;
  149935. /**
  149936. * Get the time step of the navigation tick update.
  149937. * @returns the current time step
  149938. */
  149939. getTimeStep(): number;
  149940. /**
  149941. * If delta time in navigation tick update is greater than the time step
  149942. * a number of sub iterations are done. If more iterations are need to reach deltatime
  149943. * they will be discarded.
  149944. * A value of 0 will set to no maximum and update will use as many substeps as needed
  149945. * @param newStepCount the maximum number of iterations
  149946. */
  149947. setMaximumSubStepCount(newStepCount: number): void;
  149948. /**
  149949. * Get the maximum number of iterations per navigation tick update
  149950. * @returns the maximum number of iterations
  149951. */
  149952. getMaximumSubStepCount(): number;
  149953. /**
  149954. * Release all resources
  149955. */
  149956. dispose(): void;
  149957. }
  149958. /**
  149959. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149960. */
  149961. export interface ICrowd {
  149962. /**
  149963. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149964. * You can attach anything to that node. The node position is updated in the scene update tick.
  149965. * @param pos world position that will be constrained by the navigation mesh
  149966. * @param parameters agent parameters
  149967. * @param transform hooked to the agent that will be update by the scene
  149968. * @returns agent index
  149969. */
  149970. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149971. /**
  149972. * Returns the agent position in world space
  149973. * @param index agent index returned by addAgent
  149974. * @returns world space position
  149975. */
  149976. getAgentPosition(index: number): Vector3;
  149977. /**
  149978. * Gets the agent position result in world space
  149979. * @param index agent index returned by addAgent
  149980. * @param result output world space position
  149981. */
  149982. getAgentPositionToRef(index: number, result: Vector3): void;
  149983. /**
  149984. * Gets the agent velocity in world space
  149985. * @param index agent index returned by addAgent
  149986. * @returns world space velocity
  149987. */
  149988. getAgentVelocity(index: number): Vector3;
  149989. /**
  149990. * Gets the agent velocity result in world space
  149991. * @param index agent index returned by addAgent
  149992. * @param result output world space velocity
  149993. */
  149994. getAgentVelocityToRef(index: number, result: Vector3): void;
  149995. /**
  149996. * Gets the agent next target point on the path
  149997. * @param index agent index returned by addAgent
  149998. * @returns world space position
  149999. */
  150000. getAgentNextTargetPath(index: number): Vector3;
  150001. /**
  150002. * Gets the agent state
  150003. * @param index agent index returned by addAgent
  150004. * @returns agent state
  150005. */
  150006. getAgentState(index: number): number;
  150007. /**
  150008. * returns true if the agent in over an off mesh link connection
  150009. * @param index agent index returned by addAgent
  150010. * @returns true if over an off mesh link connection
  150011. */
  150012. overOffmeshConnection(index: number): boolean;
  150013. /**
  150014. * Gets the agent next target point on the path
  150015. * @param index agent index returned by addAgent
  150016. * @param result output world space position
  150017. */
  150018. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150019. /**
  150020. * remove a particular agent previously created
  150021. * @param index agent index returned by addAgent
  150022. */
  150023. removeAgent(index: number): void;
  150024. /**
  150025. * get the list of all agents attached to this crowd
  150026. * @returns list of agent indices
  150027. */
  150028. getAgents(): number[];
  150029. /**
  150030. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150031. * @param deltaTime in seconds
  150032. */
  150033. update(deltaTime: number): void;
  150034. /**
  150035. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150036. * @param index agent index returned by addAgent
  150037. * @param destination targeted world position
  150038. */
  150039. agentGoto(index: number, destination: Vector3): void;
  150040. /**
  150041. * Teleport the agent to a new position
  150042. * @param index agent index returned by addAgent
  150043. * @param destination targeted world position
  150044. */
  150045. agentTeleport(index: number, destination: Vector3): void;
  150046. /**
  150047. * Update agent parameters
  150048. * @param index agent index returned by addAgent
  150049. * @param parameters agent parameters
  150050. */
  150051. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150052. /**
  150053. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150054. * The queries will try to find a solution within those bounds
  150055. * default is (1,1,1)
  150056. * @param extent x,y,z value that define the extent around the queries point of reference
  150057. */
  150058. setDefaultQueryExtent(extent: Vector3): void;
  150059. /**
  150060. * Get the Bounding box extent specified by setDefaultQueryExtent
  150061. * @returns the box extent values
  150062. */
  150063. getDefaultQueryExtent(): Vector3;
  150064. /**
  150065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150066. * @param result output the box extent values
  150067. */
  150068. getDefaultQueryExtentToRef(result: Vector3): void;
  150069. /**
  150070. * Release all resources
  150071. */
  150072. dispose(): void;
  150073. }
  150074. /**
  150075. * Configures an agent
  150076. */
  150077. export interface IAgentParameters {
  150078. /**
  150079. * Agent radius. [Limit: >= 0]
  150080. */
  150081. radius: number;
  150082. /**
  150083. * Agent height. [Limit: > 0]
  150084. */
  150085. height: number;
  150086. /**
  150087. * Maximum allowed acceleration. [Limit: >= 0]
  150088. */
  150089. maxAcceleration: number;
  150090. /**
  150091. * Maximum allowed speed. [Limit: >= 0]
  150092. */
  150093. maxSpeed: number;
  150094. /**
  150095. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  150096. */
  150097. collisionQueryRange: number;
  150098. /**
  150099. * The path visibility optimization range. [Limit: > 0]
  150100. */
  150101. pathOptimizationRange: number;
  150102. /**
  150103. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  150104. */
  150105. separationWeight: number;
  150106. }
  150107. /**
  150108. * Configures the navigation mesh creation
  150109. */
  150110. export interface INavMeshParameters {
  150111. /**
  150112. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  150113. */
  150114. cs: number;
  150115. /**
  150116. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  150117. */
  150118. ch: number;
  150119. /**
  150120. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  150121. */
  150122. walkableSlopeAngle: number;
  150123. /**
  150124. * Minimum floor to 'ceiling' height that will still allow the floor area to
  150125. * be considered walkable. [Limit: >= 3] [Units: vx]
  150126. */
  150127. walkableHeight: number;
  150128. /**
  150129. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  150130. */
  150131. walkableClimb: number;
  150132. /**
  150133. * The distance to erode/shrink the walkable area of the heightfield away from
  150134. * obstructions. [Limit: >=0] [Units: vx]
  150135. */
  150136. walkableRadius: number;
  150137. /**
  150138. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  150139. */
  150140. maxEdgeLen: number;
  150141. /**
  150142. * The maximum distance a simplfied contour's border edges should deviate
  150143. * the original raw contour. [Limit: >=0] [Units: vx]
  150144. */
  150145. maxSimplificationError: number;
  150146. /**
  150147. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  150148. */
  150149. minRegionArea: number;
  150150. /**
  150151. * Any regions with a span count smaller than this value will, if possible,
  150152. * be merged with larger regions. [Limit: >=0] [Units: vx]
  150153. */
  150154. mergeRegionArea: number;
  150155. /**
  150156. * The maximum number of vertices allowed for polygons generated during the
  150157. * contour to polygon conversion process. [Limit: >= 3]
  150158. */
  150159. maxVertsPerPoly: number;
  150160. /**
  150161. * Sets the sampling distance to use when generating the detail mesh.
  150162. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  150163. */
  150164. detailSampleDist: number;
  150165. /**
  150166. * The maximum distance the detail mesh surface should deviate from heightfield
  150167. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  150168. */
  150169. detailSampleMaxError: number;
  150170. }
  150171. }
  150172. declare module BABYLON {
  150173. /**
  150174. * RecastJS navigation plugin
  150175. */
  150176. export class RecastJSPlugin implements INavigationEnginePlugin {
  150177. /**
  150178. * Reference to the Recast library
  150179. */
  150180. bjsRECAST: any;
  150181. /**
  150182. * plugin name
  150183. */
  150184. name: string;
  150185. /**
  150186. * the first navmesh created. We might extend this to support multiple navmeshes
  150187. */
  150188. navMesh: any;
  150189. private _maximumSubStepCount;
  150190. private _timeStep;
  150191. /**
  150192. * Initializes the recastJS plugin
  150193. * @param recastInjection can be used to inject your own recast reference
  150194. */
  150195. constructor(recastInjection?: any);
  150196. /**
  150197. * Set the time step of the navigation tick update.
  150198. * Default is 1/60.
  150199. * A value of 0 will disable fixed time update
  150200. * @param newTimeStep the new timestep to apply to this world.
  150201. */
  150202. setTimeStep(newTimeStep?: number): void;
  150203. /**
  150204. * Get the time step of the navigation tick update.
  150205. * @returns the current time step
  150206. */
  150207. getTimeStep(): number;
  150208. /**
  150209. * If delta time in navigation tick update is greater than the time step
  150210. * a number of sub iterations are done. If more iterations are need to reach deltatime
  150211. * they will be discarded.
  150212. * A value of 0 will set to no maximum and update will use as many substeps as needed
  150213. * @param newStepCount the maximum number of iterations
  150214. */
  150215. setMaximumSubStepCount(newStepCount?: number): void;
  150216. /**
  150217. * Get the maximum number of iterations per navigation tick update
  150218. * @returns the maximum number of iterations
  150219. */
  150220. getMaximumSubStepCount(): number;
  150221. /**
  150222. * Creates a navigation mesh
  150223. * @param meshes array of all the geometry used to compute the navigatio mesh
  150224. * @param parameters bunch of parameters used to filter geometry
  150225. */
  150226. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  150227. /**
  150228. * Create a navigation mesh debug mesh
  150229. * @param scene is where the mesh will be added
  150230. * @returns debug display mesh
  150231. */
  150232. createDebugNavMesh(scene: Scene): Mesh;
  150233. /**
  150234. * Get a navigation mesh constrained position, closest to the parameter position
  150235. * @param position world position
  150236. * @returns the closest point to position constrained by the navigation mesh
  150237. */
  150238. getClosestPoint(position: Vector3): Vector3;
  150239. /**
  150240. * Get a navigation mesh constrained position, closest to the parameter position
  150241. * @param position world position
  150242. * @param result output the closest point to position constrained by the navigation mesh
  150243. */
  150244. getClosestPointToRef(position: Vector3, result: Vector3): void;
  150245. /**
  150246. * Get a navigation mesh constrained position, within a particular radius
  150247. * @param position world position
  150248. * @param maxRadius the maximum distance to the constrained world position
  150249. * @returns the closest point to position constrained by the navigation mesh
  150250. */
  150251. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  150252. /**
  150253. * Get a navigation mesh constrained position, within a particular radius
  150254. * @param position world position
  150255. * @param maxRadius the maximum distance to the constrained world position
  150256. * @param result output the closest point to position constrained by the navigation mesh
  150257. */
  150258. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  150259. /**
  150260. * Compute the final position from a segment made of destination-position
  150261. * @param position world position
  150262. * @param destination world position
  150263. * @returns the resulting point along the navmesh
  150264. */
  150265. moveAlong(position: Vector3, destination: Vector3): Vector3;
  150266. /**
  150267. * Compute the final position from a segment made of destination-position
  150268. * @param position world position
  150269. * @param destination world position
  150270. * @param result output the resulting point along the navmesh
  150271. */
  150272. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  150273. /**
  150274. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  150275. * @param start world position
  150276. * @param end world position
  150277. * @returns array containing world position composing the path
  150278. */
  150279. computePath(start: Vector3, end: Vector3): Vector3[];
  150280. /**
  150281. * Create a new Crowd so you can add agents
  150282. * @param maxAgents the maximum agent count in the crowd
  150283. * @param maxAgentRadius the maximum radius an agent can have
  150284. * @param scene to attach the crowd to
  150285. * @returns the crowd you can add agents to
  150286. */
  150287. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  150288. /**
  150289. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150290. * The queries will try to find a solution within those bounds
  150291. * default is (1,1,1)
  150292. * @param extent x,y,z value that define the extent around the queries point of reference
  150293. */
  150294. setDefaultQueryExtent(extent: Vector3): void;
  150295. /**
  150296. * Get the Bounding box extent specified by setDefaultQueryExtent
  150297. * @returns the box extent values
  150298. */
  150299. getDefaultQueryExtent(): Vector3;
  150300. /**
  150301. * build the navmesh from a previously saved state using getNavmeshData
  150302. * @param data the Uint8Array returned by getNavmeshData
  150303. */
  150304. buildFromNavmeshData(data: Uint8Array): void;
  150305. /**
  150306. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  150307. * @returns data the Uint8Array that can be saved and reused
  150308. */
  150309. getNavmeshData(): Uint8Array;
  150310. /**
  150311. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150312. * @param result output the box extent values
  150313. */
  150314. getDefaultQueryExtentToRef(result: Vector3): void;
  150315. /**
  150316. * Disposes
  150317. */
  150318. dispose(): void;
  150319. /**
  150320. * If this plugin is supported
  150321. * @returns true if plugin is supported
  150322. */
  150323. isSupported(): boolean;
  150324. }
  150325. /**
  150326. * Recast detour crowd implementation
  150327. */
  150328. export class RecastJSCrowd implements ICrowd {
  150329. /**
  150330. * Recast/detour plugin
  150331. */
  150332. bjsRECASTPlugin: RecastJSPlugin;
  150333. /**
  150334. * Link to the detour crowd
  150335. */
  150336. recastCrowd: any;
  150337. /**
  150338. * One transform per agent
  150339. */
  150340. transforms: TransformNode[];
  150341. /**
  150342. * All agents created
  150343. */
  150344. agents: number[];
  150345. /**
  150346. * Link to the scene is kept to unregister the crowd from the scene
  150347. */
  150348. private _scene;
  150349. /**
  150350. * Observer for crowd updates
  150351. */
  150352. private _onBeforeAnimationsObserver;
  150353. /**
  150354. * Constructor
  150355. * @param plugin recastJS plugin
  150356. * @param maxAgents the maximum agent count in the crowd
  150357. * @param maxAgentRadius the maximum radius an agent can have
  150358. * @param scene to attach the crowd to
  150359. * @returns the crowd you can add agents to
  150360. */
  150361. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  150362. /**
  150363. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150364. * You can attach anything to that node. The node position is updated in the scene update tick.
  150365. * @param pos world position that will be constrained by the navigation mesh
  150366. * @param parameters agent parameters
  150367. * @param transform hooked to the agent that will be update by the scene
  150368. * @returns agent index
  150369. */
  150370. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150371. /**
  150372. * Returns the agent position in world space
  150373. * @param index agent index returned by addAgent
  150374. * @returns world space position
  150375. */
  150376. getAgentPosition(index: number): Vector3;
  150377. /**
  150378. * Returns the agent position result in world space
  150379. * @param index agent index returned by addAgent
  150380. * @param result output world space position
  150381. */
  150382. getAgentPositionToRef(index: number, result: Vector3): void;
  150383. /**
  150384. * Returns the agent velocity in world space
  150385. * @param index agent index returned by addAgent
  150386. * @returns world space velocity
  150387. */
  150388. getAgentVelocity(index: number): Vector3;
  150389. /**
  150390. * Returns the agent velocity result in world space
  150391. * @param index agent index returned by addAgent
  150392. * @param result output world space velocity
  150393. */
  150394. getAgentVelocityToRef(index: number, result: Vector3): void;
  150395. /**
  150396. * Returns the agent next target point on the path
  150397. * @param index agent index returned by addAgent
  150398. * @returns world space position
  150399. */
  150400. getAgentNextTargetPath(index: number): Vector3;
  150401. /**
  150402. * Returns the agent next target point on the path
  150403. * @param index agent index returned by addAgent
  150404. * @param result output world space position
  150405. */
  150406. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150407. /**
  150408. * Gets the agent state
  150409. * @param index agent index returned by addAgent
  150410. * @returns agent state
  150411. */
  150412. getAgentState(index: number): number;
  150413. /**
  150414. * returns true if the agent in over an off mesh link connection
  150415. * @param index agent index returned by addAgent
  150416. * @returns true if over an off mesh link connection
  150417. */
  150418. overOffmeshConnection(index: number): boolean;
  150419. /**
  150420. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150421. * @param index agent index returned by addAgent
  150422. * @param destination targeted world position
  150423. */
  150424. agentGoto(index: number, destination: Vector3): void;
  150425. /**
  150426. * Teleport the agent to a new position
  150427. * @param index agent index returned by addAgent
  150428. * @param destination targeted world position
  150429. */
  150430. agentTeleport(index: number, destination: Vector3): void;
  150431. /**
  150432. * Update agent parameters
  150433. * @param index agent index returned by addAgent
  150434. * @param parameters agent parameters
  150435. */
  150436. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150437. /**
  150438. * remove a particular agent previously created
  150439. * @param index agent index returned by addAgent
  150440. */
  150441. removeAgent(index: number): void;
  150442. /**
  150443. * get the list of all agents attached to this crowd
  150444. * @returns list of agent indices
  150445. */
  150446. getAgents(): number[];
  150447. /**
  150448. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150449. * @param deltaTime in seconds
  150450. */
  150451. update(deltaTime: number): void;
  150452. /**
  150453. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150454. * The queries will try to find a solution within those bounds
  150455. * default is (1,1,1)
  150456. * @param extent x,y,z value that define the extent around the queries point of reference
  150457. */
  150458. setDefaultQueryExtent(extent: Vector3): void;
  150459. /**
  150460. * Get the Bounding box extent specified by setDefaultQueryExtent
  150461. * @returns the box extent values
  150462. */
  150463. getDefaultQueryExtent(): Vector3;
  150464. /**
  150465. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150466. * @param result output the box extent values
  150467. */
  150468. getDefaultQueryExtentToRef(result: Vector3): void;
  150469. /**
  150470. * Release all resources
  150471. */
  150472. dispose(): void;
  150473. }
  150474. }
  150475. declare module BABYLON {
  150476. /**
  150477. * Class used to enable access to IndexedDB
  150478. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150479. */
  150480. export class Database implements IOfflineProvider {
  150481. private _callbackManifestChecked;
  150482. private _currentSceneUrl;
  150483. private _db;
  150484. private _enableSceneOffline;
  150485. private _enableTexturesOffline;
  150486. private _manifestVersionFound;
  150487. private _mustUpdateRessources;
  150488. private _hasReachedQuota;
  150489. private _isSupported;
  150490. private _idbFactory;
  150491. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150492. private static IsUASupportingBlobStorage;
  150493. /**
  150494. * Gets a boolean indicating if Database storate is enabled (off by default)
  150495. */
  150496. static IDBStorageEnabled: boolean;
  150497. /**
  150498. * Gets a boolean indicating if scene must be saved in the database
  150499. */
  150500. get enableSceneOffline(): boolean;
  150501. /**
  150502. * Gets a boolean indicating if textures must be saved in the database
  150503. */
  150504. get enableTexturesOffline(): boolean;
  150505. /**
  150506. * Creates a new Database
  150507. * @param urlToScene defines the url to load the scene
  150508. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150509. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150510. */
  150511. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150512. private static _ParseURL;
  150513. private static _ReturnFullUrlLocation;
  150514. private _checkManifestFile;
  150515. /**
  150516. * Open the database and make it available
  150517. * @param successCallback defines the callback to call on success
  150518. * @param errorCallback defines the callback to call on error
  150519. */
  150520. open(successCallback: () => void, errorCallback: () => void): void;
  150521. /**
  150522. * Loads an image from the database
  150523. * @param url defines the url to load from
  150524. * @param image defines the target DOM image
  150525. */
  150526. loadImage(url: string, image: HTMLImageElement): void;
  150527. private _loadImageFromDBAsync;
  150528. private _saveImageIntoDBAsync;
  150529. private _checkVersionFromDB;
  150530. private _loadVersionFromDBAsync;
  150531. private _saveVersionIntoDBAsync;
  150532. /**
  150533. * Loads a file from database
  150534. * @param url defines the URL to load from
  150535. * @param sceneLoaded defines a callback to call on success
  150536. * @param progressCallBack defines a callback to call when progress changed
  150537. * @param errorCallback defines a callback to call on error
  150538. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150539. */
  150540. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150541. private _loadFileAsync;
  150542. private _saveFileAsync;
  150543. /**
  150544. * Validates if xhr data is correct
  150545. * @param xhr defines the request to validate
  150546. * @param dataType defines the expected data type
  150547. * @returns true if data is correct
  150548. */
  150549. private static _ValidateXHRData;
  150550. }
  150551. }
  150552. declare module BABYLON {
  150553. /** @hidden */
  150554. export var gpuUpdateParticlesPixelShader: {
  150555. name: string;
  150556. shader: string;
  150557. };
  150558. }
  150559. declare module BABYLON {
  150560. /** @hidden */
  150561. export var gpuUpdateParticlesVertexShader: {
  150562. name: string;
  150563. shader: string;
  150564. };
  150565. }
  150566. declare module BABYLON {
  150567. /** @hidden */
  150568. export var clipPlaneFragmentDeclaration2: {
  150569. name: string;
  150570. shader: string;
  150571. };
  150572. }
  150573. declare module BABYLON {
  150574. /** @hidden */
  150575. export var gpuRenderParticlesPixelShader: {
  150576. name: string;
  150577. shader: string;
  150578. };
  150579. }
  150580. declare module BABYLON {
  150581. /** @hidden */
  150582. export var clipPlaneVertexDeclaration2: {
  150583. name: string;
  150584. shader: string;
  150585. };
  150586. }
  150587. declare module BABYLON {
  150588. /** @hidden */
  150589. export var gpuRenderParticlesVertexShader: {
  150590. name: string;
  150591. shader: string;
  150592. };
  150593. }
  150594. declare module BABYLON {
  150595. /**
  150596. * This represents a GPU particle system in Babylon
  150597. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150598. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150599. */
  150600. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150601. /**
  150602. * The layer mask we are rendering the particles through.
  150603. */
  150604. layerMask: number;
  150605. private _capacity;
  150606. private _activeCount;
  150607. private _currentActiveCount;
  150608. private _accumulatedCount;
  150609. private _renderEffect;
  150610. private _updateEffect;
  150611. private _buffer0;
  150612. private _buffer1;
  150613. private _spriteBuffer;
  150614. private _updateVAO;
  150615. private _renderVAO;
  150616. private _targetIndex;
  150617. private _sourceBuffer;
  150618. private _targetBuffer;
  150619. private _currentRenderId;
  150620. private _started;
  150621. private _stopped;
  150622. private _timeDelta;
  150623. private _randomTexture;
  150624. private _randomTexture2;
  150625. private _attributesStrideSize;
  150626. private _updateEffectOptions;
  150627. private _randomTextureSize;
  150628. private _actualFrame;
  150629. private _customEffect;
  150630. private readonly _rawTextureWidth;
  150631. /**
  150632. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150633. */
  150634. static get IsSupported(): boolean;
  150635. /**
  150636. * An event triggered when the system is disposed.
  150637. */
  150638. onDisposeObservable: Observable<IParticleSystem>;
  150639. /**
  150640. * An event triggered when the system is stopped
  150641. */
  150642. onStoppedObservable: Observable<IParticleSystem>;
  150643. /**
  150644. * Gets the maximum number of particles active at the same time.
  150645. * @returns The max number of active particles.
  150646. */
  150647. getCapacity(): number;
  150648. /**
  150649. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150650. * to override the particles.
  150651. */
  150652. forceDepthWrite: boolean;
  150653. /**
  150654. * Gets or set the number of active particles
  150655. */
  150656. get activeParticleCount(): number;
  150657. set activeParticleCount(value: number);
  150658. private _preWarmDone;
  150659. /**
  150660. * Specifies if the particles are updated in emitter local space or world space.
  150661. */
  150662. isLocal: boolean;
  150663. /** Gets or sets a matrix to use to compute projection */
  150664. defaultProjectionMatrix: Matrix;
  150665. /**
  150666. * Is this system ready to be used/rendered
  150667. * @return true if the system is ready
  150668. */
  150669. isReady(): boolean;
  150670. /**
  150671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150672. * @returns True if it has been started, otherwise false.
  150673. */
  150674. isStarted(): boolean;
  150675. /**
  150676. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150677. * @returns True if it has been stopped, otherwise false.
  150678. */
  150679. isStopped(): boolean;
  150680. /**
  150681. * Gets a boolean indicating that the system is stopping
  150682. * @returns true if the system is currently stopping
  150683. */
  150684. isStopping(): boolean;
  150685. /**
  150686. * Gets the number of particles active at the same time.
  150687. * @returns The number of active particles.
  150688. */
  150689. getActiveCount(): number;
  150690. /**
  150691. * Starts the particle system and begins to emit
  150692. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150693. */
  150694. start(delay?: number): void;
  150695. /**
  150696. * Stops the particle system.
  150697. */
  150698. stop(): void;
  150699. /**
  150700. * Remove all active particles
  150701. */
  150702. reset(): void;
  150703. /**
  150704. * Returns the string "GPUParticleSystem"
  150705. * @returns a string containing the class name
  150706. */
  150707. getClassName(): string;
  150708. /**
  150709. * Gets the custom effect used to render the particles
  150710. * @param blendMode Blend mode for which the effect should be retrieved
  150711. * @returns The effect
  150712. */
  150713. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150714. /**
  150715. * Sets the custom effect used to render the particles
  150716. * @param effect The effect to set
  150717. * @param blendMode Blend mode for which the effect should be set
  150718. */
  150719. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150720. /** @hidden */
  150721. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150722. /**
  150723. * Observable that will be called just before the particles are drawn
  150724. */
  150725. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150726. /**
  150727. * Gets the name of the particle vertex shader
  150728. */
  150729. get vertexShaderName(): string;
  150730. private _colorGradientsTexture;
  150731. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150732. /**
  150733. * Adds a new color gradient
  150734. * @param gradient defines the gradient to use (between 0 and 1)
  150735. * @param color1 defines the color to affect to the specified gradient
  150736. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150737. * @returns the current particle system
  150738. */
  150739. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150740. private _refreshColorGradient;
  150741. /** Force the system to rebuild all gradients that need to be resync */
  150742. forceRefreshGradients(): void;
  150743. /**
  150744. * Remove a specific color gradient
  150745. * @param gradient defines the gradient to remove
  150746. * @returns the current particle system
  150747. */
  150748. removeColorGradient(gradient: number): GPUParticleSystem;
  150749. private _angularSpeedGradientsTexture;
  150750. private _sizeGradientsTexture;
  150751. private _velocityGradientsTexture;
  150752. private _limitVelocityGradientsTexture;
  150753. private _dragGradientsTexture;
  150754. private _addFactorGradient;
  150755. /**
  150756. * Adds a new size gradient
  150757. * @param gradient defines the gradient to use (between 0 and 1)
  150758. * @param factor defines the size factor to affect to the specified gradient
  150759. * @returns the current particle system
  150760. */
  150761. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150762. /**
  150763. * Remove a specific size gradient
  150764. * @param gradient defines the gradient to remove
  150765. * @returns the current particle system
  150766. */
  150767. removeSizeGradient(gradient: number): GPUParticleSystem;
  150768. private _refreshFactorGradient;
  150769. /**
  150770. * Adds a new angular speed gradient
  150771. * @param gradient defines the gradient to use (between 0 and 1)
  150772. * @param factor defines the angular speed to affect to the specified gradient
  150773. * @returns the current particle system
  150774. */
  150775. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150776. /**
  150777. * Remove a specific angular speed gradient
  150778. * @param gradient defines the gradient to remove
  150779. * @returns the current particle system
  150780. */
  150781. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150782. /**
  150783. * Adds a new velocity gradient
  150784. * @param gradient defines the gradient to use (between 0 and 1)
  150785. * @param factor defines the velocity to affect to the specified gradient
  150786. * @returns the current particle system
  150787. */
  150788. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150789. /**
  150790. * Remove a specific velocity gradient
  150791. * @param gradient defines the gradient to remove
  150792. * @returns the current particle system
  150793. */
  150794. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150795. /**
  150796. * Adds a new limit velocity gradient
  150797. * @param gradient defines the gradient to use (between 0 and 1)
  150798. * @param factor defines the limit velocity value to affect to the specified gradient
  150799. * @returns the current particle system
  150800. */
  150801. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150802. /**
  150803. * Remove a specific limit velocity gradient
  150804. * @param gradient defines the gradient to remove
  150805. * @returns the current particle system
  150806. */
  150807. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150808. /**
  150809. * Adds a new drag gradient
  150810. * @param gradient defines the gradient to use (between 0 and 1)
  150811. * @param factor defines the drag value to affect to the specified gradient
  150812. * @returns the current particle system
  150813. */
  150814. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150815. /**
  150816. * Remove a specific drag gradient
  150817. * @param gradient defines the gradient to remove
  150818. * @returns the current particle system
  150819. */
  150820. removeDragGradient(gradient: number): GPUParticleSystem;
  150821. /**
  150822. * Not supported by GPUParticleSystem
  150823. * @param gradient defines the gradient to use (between 0 and 1)
  150824. * @param factor defines the emit rate value to affect to the specified gradient
  150825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150826. * @returns the current particle system
  150827. */
  150828. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150829. /**
  150830. * Not supported by GPUParticleSystem
  150831. * @param gradient defines the gradient to remove
  150832. * @returns the current particle system
  150833. */
  150834. removeEmitRateGradient(gradient: number): IParticleSystem;
  150835. /**
  150836. * Not supported by GPUParticleSystem
  150837. * @param gradient defines the gradient to use (between 0 and 1)
  150838. * @param factor defines the start size value to affect to the specified gradient
  150839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150840. * @returns the current particle system
  150841. */
  150842. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150843. /**
  150844. * Not supported by GPUParticleSystem
  150845. * @param gradient defines the gradient to remove
  150846. * @returns the current particle system
  150847. */
  150848. removeStartSizeGradient(gradient: number): IParticleSystem;
  150849. /**
  150850. * Not supported by GPUParticleSystem
  150851. * @param gradient defines the gradient to use (between 0 and 1)
  150852. * @param min defines the color remap minimal range
  150853. * @param max defines the color remap maximal range
  150854. * @returns the current particle system
  150855. */
  150856. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150857. /**
  150858. * Not supported by GPUParticleSystem
  150859. * @param gradient defines the gradient to remove
  150860. * @returns the current particle system
  150861. */
  150862. removeColorRemapGradient(): IParticleSystem;
  150863. /**
  150864. * Not supported by GPUParticleSystem
  150865. * @param gradient defines the gradient to use (between 0 and 1)
  150866. * @param min defines the alpha remap minimal range
  150867. * @param max defines the alpha remap maximal range
  150868. * @returns the current particle system
  150869. */
  150870. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150871. /**
  150872. * Not supported by GPUParticleSystem
  150873. * @param gradient defines the gradient to remove
  150874. * @returns the current particle system
  150875. */
  150876. removeAlphaRemapGradient(): IParticleSystem;
  150877. /**
  150878. * Not supported by GPUParticleSystem
  150879. * @param gradient defines the gradient to use (between 0 and 1)
  150880. * @param color defines the color to affect to the specified gradient
  150881. * @returns the current particle system
  150882. */
  150883. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150884. /**
  150885. * Not supported by GPUParticleSystem
  150886. * @param gradient defines the gradient to remove
  150887. * @returns the current particle system
  150888. */
  150889. removeRampGradient(): IParticleSystem;
  150890. /**
  150891. * Not supported by GPUParticleSystem
  150892. * @returns the list of ramp gradients
  150893. */
  150894. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150895. /**
  150896. * Not supported by GPUParticleSystem
  150897. * Gets or sets a boolean indicating that ramp gradients must be used
  150898. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150899. */
  150900. get useRampGradients(): boolean;
  150901. set useRampGradients(value: boolean);
  150902. /**
  150903. * Not supported by GPUParticleSystem
  150904. * @param gradient defines the gradient to use (between 0 and 1)
  150905. * @param factor defines the life time factor to affect to the specified gradient
  150906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150907. * @returns the current particle system
  150908. */
  150909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150910. /**
  150911. * Not supported by GPUParticleSystem
  150912. * @param gradient defines the gradient to remove
  150913. * @returns the current particle system
  150914. */
  150915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150916. /**
  150917. * Instantiates a GPU particle system.
  150918. * 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.
  150919. * @param name The name of the particle system
  150920. * @param options The options used to create the system
  150921. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150923. * @param customEffect a custom effect used to change the way particles are rendered by default
  150924. */
  150925. constructor(name: string, options: Partial<{
  150926. capacity: number;
  150927. randomTextureSize: number;
  150928. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150929. protected _reset(): void;
  150930. private _createUpdateVAO;
  150931. private _createRenderVAO;
  150932. private _initialize;
  150933. /** @hidden */
  150934. _recreateUpdateEffect(): void;
  150935. private _getEffect;
  150936. /**
  150937. * Fill the defines array according to the current settings of the particle system
  150938. * @param defines Array to be updated
  150939. * @param blendMode blend mode to take into account when updating the array
  150940. */
  150941. fillDefines(defines: Array<string>, blendMode?: number): void;
  150942. /**
  150943. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150944. * @param uniforms Uniforms array to fill
  150945. * @param attributes Attributes array to fill
  150946. * @param samplers Samplers array to fill
  150947. */
  150948. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150949. /** @hidden */
  150950. _recreateRenderEffect(): Effect;
  150951. /**
  150952. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150953. * @param preWarm defines if we are in the pre-warmimg phase
  150954. */
  150955. animate(preWarm?: boolean): void;
  150956. private _createFactorGradientTexture;
  150957. private _createSizeGradientTexture;
  150958. private _createAngularSpeedGradientTexture;
  150959. private _createVelocityGradientTexture;
  150960. private _createLimitVelocityGradientTexture;
  150961. private _createDragGradientTexture;
  150962. private _createColorGradientTexture;
  150963. /**
  150964. * Renders the particle system in its current state
  150965. * @param preWarm defines if the system should only update the particles but not render them
  150966. * @returns the current number of particles
  150967. */
  150968. render(preWarm?: boolean): number;
  150969. /**
  150970. * Rebuilds the particle system
  150971. */
  150972. rebuild(): void;
  150973. private _releaseBuffers;
  150974. private _releaseVAOs;
  150975. /**
  150976. * Disposes the particle system and free the associated resources
  150977. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150978. */
  150979. dispose(disposeTexture?: boolean): void;
  150980. /**
  150981. * Clones the particle system.
  150982. * @param name The name of the cloned object
  150983. * @param newEmitter The new emitter to use
  150984. * @returns the cloned particle system
  150985. */
  150986. clone(name: string, newEmitter: any): GPUParticleSystem;
  150987. /**
  150988. * Serializes the particle system to a JSON object
  150989. * @param serializeTexture defines if the texture must be serialized as well
  150990. * @returns the JSON object
  150991. */
  150992. serialize(serializeTexture?: boolean): any;
  150993. /**
  150994. * Parses a JSON object to create a GPU particle system.
  150995. * @param parsedParticleSystem The JSON object to parse
  150996. * @param sceneOrEngine The scene or the engine to create the particle system in
  150997. * @param rootUrl The root url to use to load external dependencies like texture
  150998. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150999. * @returns the parsed GPU particle system
  151000. */
  151001. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  151002. }
  151003. }
  151004. declare module BABYLON {
  151005. /**
  151006. * Represents a set of particle systems working together to create a specific effect
  151007. */
  151008. export class ParticleSystemSet implements IDisposable {
  151009. /**
  151010. * Gets or sets base Assets URL
  151011. */
  151012. static BaseAssetsUrl: string;
  151013. private _emitterCreationOptions;
  151014. private _emitterNode;
  151015. /**
  151016. * Gets the particle system list
  151017. */
  151018. systems: IParticleSystem[];
  151019. /**
  151020. * Gets the emitter node used with this set
  151021. */
  151022. get emitterNode(): Nullable<TransformNode>;
  151023. /**
  151024. * Creates a new emitter mesh as a sphere
  151025. * @param options defines the options used to create the sphere
  151026. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  151027. * @param scene defines the hosting scene
  151028. */
  151029. setEmitterAsSphere(options: {
  151030. diameter: number;
  151031. segments: number;
  151032. color: Color3;
  151033. }, renderingGroupId: number, scene: Scene): void;
  151034. /**
  151035. * Starts all particle systems of the set
  151036. * @param emitter defines an optional mesh to use as emitter for the particle systems
  151037. */
  151038. start(emitter?: AbstractMesh): void;
  151039. /**
  151040. * Release all associated resources
  151041. */
  151042. dispose(): void;
  151043. /**
  151044. * Serialize the set into a JSON compatible object
  151045. * @param serializeTexture defines if the texture must be serialized as well
  151046. * @returns a JSON compatible representation of the set
  151047. */
  151048. serialize(serializeTexture?: boolean): any;
  151049. /**
  151050. * Parse a new ParticleSystemSet from a serialized source
  151051. * @param data defines a JSON compatible representation of the set
  151052. * @param scene defines the hosting scene
  151053. * @param gpu defines if we want GPU particles or CPU particles
  151054. * @returns a new ParticleSystemSet
  151055. */
  151056. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  151057. }
  151058. }
  151059. declare module BABYLON {
  151060. /**
  151061. * This class is made for on one-liner static method to help creating particle system set.
  151062. */
  151063. export class ParticleHelper {
  151064. /**
  151065. * Gets or sets base Assets URL
  151066. */
  151067. static BaseAssetsUrl: string;
  151068. /** Define the Url to load snippets */
  151069. static SnippetUrl: string;
  151070. /**
  151071. * Create a default particle system that you can tweak
  151072. * @param emitter defines the emitter to use
  151073. * @param capacity defines the system capacity (default is 500 particles)
  151074. * @param scene defines the hosting scene
  151075. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  151076. * @returns the new Particle system
  151077. */
  151078. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  151079. /**
  151080. * This is the main static method (one-liner) of this helper to create different particle systems
  151081. * @param type This string represents the type to the particle system to create
  151082. * @param scene The scene where the particle system should live
  151083. * @param gpu If the system will use gpu
  151084. * @returns the ParticleSystemSet created
  151085. */
  151086. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  151087. /**
  151088. * Static function used to export a particle system to a ParticleSystemSet variable.
  151089. * Please note that the emitter shape is not exported
  151090. * @param systems defines the particle systems to export
  151091. * @returns the created particle system set
  151092. */
  151093. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  151094. /**
  151095. * Creates a particle system from a snippet saved in a remote file
  151096. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  151097. * @param url defines the url to load from
  151098. * @param scene defines the hosting scene
  151099. * @param gpu If the system will use gpu
  151100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151101. * @returns a promise that will resolve to the new particle system
  151102. */
  151103. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151104. /**
  151105. * Creates a particle system from a snippet saved by the particle system editor
  151106. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  151107. * @param scene defines the hosting scene
  151108. * @param gpu If the system will use gpu
  151109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151110. * @returns a promise that will resolve to the new particle system
  151111. */
  151112. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151113. }
  151114. }
  151115. declare module BABYLON {
  151116. interface Engine {
  151117. /**
  151118. * Create an effect to use with particle systems.
  151119. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  151120. * the particle system for which you want to create a custom effect in the last parameter
  151121. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  151122. * @param uniformsNames defines a list of attribute names
  151123. * @param samplers defines an array of string used to represent textures
  151124. * @param defines defines the string containing the defines to use to compile the shaders
  151125. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  151126. * @param onCompiled defines a function to call when the effect creation is successful
  151127. * @param onError defines a function to call when the effect creation has failed
  151128. * @param particleSystem the particle system you want to create the effect for
  151129. * @returns the new Effect
  151130. */
  151131. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  151132. }
  151133. interface Mesh {
  151134. /**
  151135. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  151136. * @returns an array of IParticleSystem
  151137. */
  151138. getEmittedParticleSystems(): IParticleSystem[];
  151139. /**
  151140. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  151141. * @returns an array of IParticleSystem
  151142. */
  151143. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  151144. }
  151145. }
  151146. declare module BABYLON {
  151147. /** Defines the 4 color options */
  151148. export enum PointColor {
  151149. /** color value */
  151150. Color = 2,
  151151. /** uv value */
  151152. UV = 1,
  151153. /** random value */
  151154. Random = 0,
  151155. /** stated value */
  151156. Stated = 3
  151157. }
  151158. /**
  151159. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  151160. * 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.
  151161. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  151162. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  151163. *
  151164. * Full documentation here : TO BE ENTERED
  151165. */
  151166. export class PointsCloudSystem implements IDisposable {
  151167. /**
  151168. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  151169. * Example : var p = SPS.particles[i];
  151170. */
  151171. particles: CloudPoint[];
  151172. /**
  151173. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  151174. */
  151175. nbParticles: number;
  151176. /**
  151177. * This a counter for your own usage. It's not set by any SPS functions.
  151178. */
  151179. counter: number;
  151180. /**
  151181. * The PCS name. This name is also given to the underlying mesh.
  151182. */
  151183. name: string;
  151184. /**
  151185. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  151186. */
  151187. mesh: Mesh;
  151188. /**
  151189. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  151190. * Please read :
  151191. */
  151192. vars: any;
  151193. /**
  151194. * @hidden
  151195. */
  151196. _size: number;
  151197. private _scene;
  151198. private _promises;
  151199. private _positions;
  151200. private _indices;
  151201. private _normals;
  151202. private _colors;
  151203. private _uvs;
  151204. private _indices32;
  151205. private _positions32;
  151206. private _colors32;
  151207. private _uvs32;
  151208. private _updatable;
  151209. private _isVisibilityBoxLocked;
  151210. private _alwaysVisible;
  151211. private _groups;
  151212. private _groupCounter;
  151213. private _computeParticleColor;
  151214. private _computeParticleTexture;
  151215. private _computeParticleRotation;
  151216. private _computeBoundingBox;
  151217. private _isReady;
  151218. /**
  151219. * Creates a PCS (Points Cloud System) object
  151220. * @param name (String) is the PCS name, this will be the underlying mesh name
  151221. * @param pointSize (number) is the size for each point
  151222. * @param scene (Scene) is the scene in which the PCS is added
  151223. * @param options defines the options of the PCS e.g.
  151224. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  151225. */
  151226. constructor(name: string, pointSize: number, scene: Scene, options?: {
  151227. updatable?: boolean;
  151228. });
  151229. /**
  151230. * Builds the PCS underlying mesh. Returns a standard Mesh.
  151231. * If no points were added to the PCS, the returned mesh is just a single point.
  151232. * @returns a promise for the created mesh
  151233. */
  151234. buildMeshAsync(): Promise<Mesh>;
  151235. /**
  151236. * @hidden
  151237. */
  151238. private _buildMesh;
  151239. private _addParticle;
  151240. private _randomUnitVector;
  151241. private _getColorIndicesForCoord;
  151242. private _setPointsColorOrUV;
  151243. private _colorFromTexture;
  151244. private _calculateDensity;
  151245. /**
  151246. * Adds points to the PCS in random positions within a unit sphere
  151247. * @param nb (positive integer) the number of particles to be created from this model
  151248. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  151249. * @returns the number of groups in the system
  151250. */
  151251. addPoints(nb: number, pointFunction?: any): number;
  151252. /**
  151253. * Adds points to the PCS from the surface of the model shape
  151254. * @param mesh is any Mesh object that will be used as a surface model for the points
  151255. * @param nb (positive integer) the number of particles to be created from this model
  151256. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151257. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151258. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151259. * @returns the number of groups in the system
  151260. */
  151261. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151262. /**
  151263. * Adds points to the PCS inside the model shape
  151264. * @param mesh is any Mesh object that will be used as a surface model for the points
  151265. * @param nb (positive integer) the number of particles to be created from this model
  151266. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151267. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151268. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151269. * @returns the number of groups in the system
  151270. */
  151271. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151272. /**
  151273. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  151274. * This method calls `updateParticle()` for each particle of the SPS.
  151275. * For an animated SPS, it is usually called within the render loop.
  151276. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  151277. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  151278. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  151279. * @returns the PCS.
  151280. */
  151281. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  151282. /**
  151283. * Disposes the PCS.
  151284. */
  151285. dispose(): void;
  151286. /**
  151287. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  151288. * doc :
  151289. * @returns the PCS.
  151290. */
  151291. refreshVisibleSize(): PointsCloudSystem;
  151292. /**
  151293. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  151294. * @param size the size (float) of the visibility box
  151295. * note : this doesn't lock the PCS mesh bounding box.
  151296. * doc :
  151297. */
  151298. setVisibilityBox(size: number): void;
  151299. /**
  151300. * Gets whether the PCS is always visible or not
  151301. * doc :
  151302. */
  151303. get isAlwaysVisible(): boolean;
  151304. /**
  151305. * Sets the PCS as always visible or not
  151306. * doc :
  151307. */
  151308. set isAlwaysVisible(val: boolean);
  151309. /**
  151310. * Tells to `setParticles()` to compute the particle rotations or not
  151311. * Default value : false. The PCS is faster when it's set to false
  151312. * Note : particle rotations are only applied to parent particles
  151313. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  151314. */
  151315. set computeParticleRotation(val: boolean);
  151316. /**
  151317. * Tells to `setParticles()` to compute the particle colors or not.
  151318. * Default value : true. The PCS is faster when it's set to false.
  151319. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151320. */
  151321. set computeParticleColor(val: boolean);
  151322. set computeParticleTexture(val: boolean);
  151323. /**
  151324. * Gets if `setParticles()` computes the particle colors or not.
  151325. * Default value : false. The PCS is faster when it's set to false.
  151326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151327. */
  151328. get computeParticleColor(): boolean;
  151329. /**
  151330. * Gets if `setParticles()` computes the particle textures or not.
  151331. * Default value : false. The PCS is faster when it's set to false.
  151332. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  151333. */
  151334. get computeParticleTexture(): boolean;
  151335. /**
  151336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  151337. */
  151338. set computeBoundingBox(val: boolean);
  151339. /**
  151340. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  151341. */
  151342. get computeBoundingBox(): boolean;
  151343. /**
  151344. * This function does nothing. It may be overwritten to set all the particle first values.
  151345. * The PCS doesn't call this function, you may have to call it by your own.
  151346. * doc :
  151347. */
  151348. initParticles(): void;
  151349. /**
  151350. * This function does nothing. It may be overwritten to recycle a particle
  151351. * The PCS doesn't call this function, you can to call it
  151352. * doc :
  151353. * @param particle The particle to recycle
  151354. * @returns the recycled particle
  151355. */
  151356. recycleParticle(particle: CloudPoint): CloudPoint;
  151357. /**
  151358. * Updates a particle : this function should be overwritten by the user.
  151359. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  151360. * doc :
  151361. * @example : just set a particle position or velocity and recycle conditions
  151362. * @param particle The particle to update
  151363. * @returns the updated particle
  151364. */
  151365. updateParticle(particle: CloudPoint): CloudPoint;
  151366. /**
  151367. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  151368. * This does nothing and may be overwritten by the user.
  151369. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151370. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151371. * @param update the boolean update value actually passed to setParticles()
  151372. */
  151373. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151374. /**
  151375. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  151376. * This will be passed three parameters.
  151377. * This does nothing and may be overwritten by the user.
  151378. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151379. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151380. * @param update the boolean update value actually passed to setParticles()
  151381. */
  151382. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151383. }
  151384. }
  151385. declare module BABYLON {
  151386. /**
  151387. * Represents one particle of a points cloud system.
  151388. */
  151389. export class CloudPoint {
  151390. /**
  151391. * particle global index
  151392. */
  151393. idx: number;
  151394. /**
  151395. * The color of the particle
  151396. */
  151397. color: Nullable<Color4>;
  151398. /**
  151399. * The world space position of the particle.
  151400. */
  151401. position: Vector3;
  151402. /**
  151403. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151404. */
  151405. rotation: Vector3;
  151406. /**
  151407. * The world space rotation quaternion of the particle.
  151408. */
  151409. rotationQuaternion: Nullable<Quaternion>;
  151410. /**
  151411. * The uv of the particle.
  151412. */
  151413. uv: Nullable<Vector2>;
  151414. /**
  151415. * The current speed of the particle.
  151416. */
  151417. velocity: Vector3;
  151418. /**
  151419. * The pivot point in the particle local space.
  151420. */
  151421. pivot: Vector3;
  151422. /**
  151423. * Must the particle be translated from its pivot point in its local space ?
  151424. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151425. * Default : false
  151426. */
  151427. translateFromPivot: boolean;
  151428. /**
  151429. * Index of this particle in the global "positions" array (Internal use)
  151430. * @hidden
  151431. */
  151432. _pos: number;
  151433. /**
  151434. * @hidden Index of this particle in the global "indices" array (Internal use)
  151435. */
  151436. _ind: number;
  151437. /**
  151438. * Group this particle belongs to
  151439. */
  151440. _group: PointsGroup;
  151441. /**
  151442. * Group id of this particle
  151443. */
  151444. groupId: number;
  151445. /**
  151446. * Index of the particle in its group id (Internal use)
  151447. */
  151448. idxInGroup: number;
  151449. /**
  151450. * @hidden Particle BoundingInfo object (Internal use)
  151451. */
  151452. _boundingInfo: BoundingInfo;
  151453. /**
  151454. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151455. */
  151456. _pcs: PointsCloudSystem;
  151457. /**
  151458. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151459. */
  151460. _stillInvisible: boolean;
  151461. /**
  151462. * @hidden Last computed particle rotation matrix
  151463. */
  151464. _rotationMatrix: number[];
  151465. /**
  151466. * Parent particle Id, if any.
  151467. * Default null.
  151468. */
  151469. parentId: Nullable<number>;
  151470. /**
  151471. * @hidden Internal global position in the PCS.
  151472. */
  151473. _globalPosition: Vector3;
  151474. /**
  151475. * Creates a Point Cloud object.
  151476. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151477. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151478. * @param group (PointsGroup) is the group the particle belongs to
  151479. * @param groupId (integer) is the group identifier in the PCS.
  151480. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151481. * @param pcs defines the PCS it is associated to
  151482. */
  151483. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151484. /**
  151485. * get point size
  151486. */
  151487. get size(): Vector3;
  151488. /**
  151489. * Set point size
  151490. */
  151491. set size(scale: Vector3);
  151492. /**
  151493. * Legacy support, changed quaternion to rotationQuaternion
  151494. */
  151495. get quaternion(): Nullable<Quaternion>;
  151496. /**
  151497. * Legacy support, changed quaternion to rotationQuaternion
  151498. */
  151499. set quaternion(q: Nullable<Quaternion>);
  151500. /**
  151501. * Returns a boolean. True if the particle intersects a mesh, else false
  151502. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151503. * @param target is the object (point or mesh) what the intersection is computed against
  151504. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151505. * @returns true if it intersects
  151506. */
  151507. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151508. /**
  151509. * get the rotation matrix of the particle
  151510. * @hidden
  151511. */
  151512. getRotationMatrix(m: Matrix): void;
  151513. }
  151514. /**
  151515. * Represents a group of points in a points cloud system
  151516. * * PCS internal tool, don't use it manually.
  151517. */
  151518. export class PointsGroup {
  151519. /**
  151520. * The group id
  151521. * @hidden
  151522. */
  151523. groupID: number;
  151524. /**
  151525. * image data for group (internal use)
  151526. * @hidden
  151527. */
  151528. _groupImageData: Nullable<ArrayBufferView>;
  151529. /**
  151530. * Image Width (internal use)
  151531. * @hidden
  151532. */
  151533. _groupImgWidth: number;
  151534. /**
  151535. * Image Height (internal use)
  151536. * @hidden
  151537. */
  151538. _groupImgHeight: number;
  151539. /**
  151540. * Custom position function (internal use)
  151541. * @hidden
  151542. */
  151543. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151544. /**
  151545. * density per facet for surface points
  151546. * @hidden
  151547. */
  151548. _groupDensity: number[];
  151549. /**
  151550. * Only when points are colored by texture carries pointer to texture list array
  151551. * @hidden
  151552. */
  151553. _textureNb: number;
  151554. /**
  151555. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151556. * PCS internal tool, don't use it manually.
  151557. * @hidden
  151558. */
  151559. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151560. }
  151561. }
  151562. declare module BABYLON {
  151563. interface Scene {
  151564. /** @hidden (Backing field) */
  151565. _physicsEngine: Nullable<IPhysicsEngine>;
  151566. /** @hidden */
  151567. _physicsTimeAccumulator: number;
  151568. /**
  151569. * Gets the current physics engine
  151570. * @returns a IPhysicsEngine or null if none attached
  151571. */
  151572. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151573. /**
  151574. * Enables physics to the current scene
  151575. * @param gravity defines the scene's gravity for the physics engine
  151576. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151577. * @return a boolean indicating if the physics engine was initialized
  151578. */
  151579. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151580. /**
  151581. * Disables and disposes the physics engine associated with the scene
  151582. */
  151583. disablePhysicsEngine(): void;
  151584. /**
  151585. * Gets a boolean indicating if there is an active physics engine
  151586. * @returns a boolean indicating if there is an active physics engine
  151587. */
  151588. isPhysicsEnabled(): boolean;
  151589. /**
  151590. * Deletes a physics compound impostor
  151591. * @param compound defines the compound to delete
  151592. */
  151593. deleteCompoundImpostor(compound: any): void;
  151594. /**
  151595. * An event triggered when physic simulation is about to be run
  151596. */
  151597. onBeforePhysicsObservable: Observable<Scene>;
  151598. /**
  151599. * An event triggered when physic simulation has been done
  151600. */
  151601. onAfterPhysicsObservable: Observable<Scene>;
  151602. }
  151603. interface AbstractMesh {
  151604. /** @hidden */
  151605. _physicsImpostor: Nullable<PhysicsImpostor>;
  151606. /**
  151607. * Gets or sets impostor used for physic simulation
  151608. * @see https://doc.babylonjs.com/features/physics_engine
  151609. */
  151610. physicsImpostor: Nullable<PhysicsImpostor>;
  151611. /**
  151612. * Gets the current physics impostor
  151613. * @see https://doc.babylonjs.com/features/physics_engine
  151614. * @returns a physics impostor or null
  151615. */
  151616. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151617. /** Apply a physic impulse to the mesh
  151618. * @param force defines the force to apply
  151619. * @param contactPoint defines where to apply the force
  151620. * @returns the current mesh
  151621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151622. */
  151623. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151624. /**
  151625. * Creates a physic joint between two meshes
  151626. * @param otherMesh defines the other mesh to use
  151627. * @param pivot1 defines the pivot to use on this mesh
  151628. * @param pivot2 defines the pivot to use on the other mesh
  151629. * @param options defines additional options (can be plugin dependent)
  151630. * @returns the current mesh
  151631. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151632. */
  151633. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151634. /** @hidden */
  151635. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151636. }
  151637. /**
  151638. * Defines the physics engine scene component responsible to manage a physics engine
  151639. */
  151640. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151641. /**
  151642. * The component name helpful to identify the component in the list of scene components.
  151643. */
  151644. readonly name: string;
  151645. /**
  151646. * The scene the component belongs to.
  151647. */
  151648. scene: Scene;
  151649. /**
  151650. * Creates a new instance of the component for the given scene
  151651. * @param scene Defines the scene to register the component in
  151652. */
  151653. constructor(scene: Scene);
  151654. /**
  151655. * Registers the component in a given scene
  151656. */
  151657. register(): void;
  151658. /**
  151659. * Rebuilds the elements related to this component in case of
  151660. * context lost for instance.
  151661. */
  151662. rebuild(): void;
  151663. /**
  151664. * Disposes the component and the associated ressources
  151665. */
  151666. dispose(): void;
  151667. }
  151668. }
  151669. declare module BABYLON {
  151670. /**
  151671. * A helper for physics simulations
  151672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151673. */
  151674. export class PhysicsHelper {
  151675. private _scene;
  151676. private _physicsEngine;
  151677. /**
  151678. * Initializes the Physics helper
  151679. * @param scene Babylon.js scene
  151680. */
  151681. constructor(scene: Scene);
  151682. /**
  151683. * Applies a radial explosion impulse
  151684. * @param origin the origin of the explosion
  151685. * @param radiusOrEventOptions the radius or the options of radial explosion
  151686. * @param strength the explosion strength
  151687. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151688. * @returns A physics radial explosion event, or null
  151689. */
  151690. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151691. /**
  151692. * Applies a radial explosion force
  151693. * @param origin the origin of the explosion
  151694. * @param radiusOrEventOptions the radius or the options of radial explosion
  151695. * @param strength the explosion strength
  151696. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151697. * @returns A physics radial explosion event, or null
  151698. */
  151699. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151700. /**
  151701. * Creates a gravitational field
  151702. * @param origin the origin of the explosion
  151703. * @param radiusOrEventOptions the radius or the options of radial explosion
  151704. * @param strength the explosion strength
  151705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151706. * @returns A physics gravitational field event, or null
  151707. */
  151708. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151709. /**
  151710. * Creates a physics updraft event
  151711. * @param origin the origin of the updraft
  151712. * @param radiusOrEventOptions the radius or the options of the updraft
  151713. * @param strength the strength of the updraft
  151714. * @param height the height of the updraft
  151715. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151716. * @returns A physics updraft event, or null
  151717. */
  151718. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151719. /**
  151720. * Creates a physics vortex event
  151721. * @param origin the of the vortex
  151722. * @param radiusOrEventOptions the radius or the options of the vortex
  151723. * @param strength the strength of the vortex
  151724. * @param height the height of the vortex
  151725. * @returns a Physics vortex event, or null
  151726. * A physics vortex event or null
  151727. */
  151728. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151729. }
  151730. /**
  151731. * Represents a physics radial explosion event
  151732. */
  151733. class PhysicsRadialExplosionEvent {
  151734. private _scene;
  151735. private _options;
  151736. private _sphere;
  151737. private _dataFetched;
  151738. /**
  151739. * Initializes a radial explosioin event
  151740. * @param _scene BabylonJS scene
  151741. * @param _options The options for the vortex event
  151742. */
  151743. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151744. /**
  151745. * Returns the data related to the radial explosion event (sphere).
  151746. * @returns The radial explosion event data
  151747. */
  151748. getData(): PhysicsRadialExplosionEventData;
  151749. /**
  151750. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151751. * @param impostor A physics imposter
  151752. * @param origin the origin of the explosion
  151753. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151754. */
  151755. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151756. /**
  151757. * Triggers affecterd impostors callbacks
  151758. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151759. */
  151760. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151761. /**
  151762. * Disposes the sphere.
  151763. * @param force Specifies if the sphere should be disposed by force
  151764. */
  151765. dispose(force?: boolean): void;
  151766. /*** Helpers ***/
  151767. private _prepareSphere;
  151768. private _intersectsWithSphere;
  151769. }
  151770. /**
  151771. * Represents a gravitational field event
  151772. */
  151773. class PhysicsGravitationalFieldEvent {
  151774. private _physicsHelper;
  151775. private _scene;
  151776. private _origin;
  151777. private _options;
  151778. private _tickCallback;
  151779. private _sphere;
  151780. private _dataFetched;
  151781. /**
  151782. * Initializes the physics gravitational field event
  151783. * @param _physicsHelper A physics helper
  151784. * @param _scene BabylonJS scene
  151785. * @param _origin The origin position of the gravitational field event
  151786. * @param _options The options for the vortex event
  151787. */
  151788. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151789. /**
  151790. * Returns the data related to the gravitational field event (sphere).
  151791. * @returns A gravitational field event
  151792. */
  151793. getData(): PhysicsGravitationalFieldEventData;
  151794. /**
  151795. * Enables the gravitational field.
  151796. */
  151797. enable(): void;
  151798. /**
  151799. * Disables the gravitational field.
  151800. */
  151801. disable(): void;
  151802. /**
  151803. * Disposes the sphere.
  151804. * @param force The force to dispose from the gravitational field event
  151805. */
  151806. dispose(force?: boolean): void;
  151807. private _tick;
  151808. }
  151809. /**
  151810. * Represents a physics updraft event
  151811. */
  151812. class PhysicsUpdraftEvent {
  151813. private _scene;
  151814. private _origin;
  151815. private _options;
  151816. private _physicsEngine;
  151817. private _originTop;
  151818. private _originDirection;
  151819. private _tickCallback;
  151820. private _cylinder;
  151821. private _cylinderPosition;
  151822. private _dataFetched;
  151823. /**
  151824. * Initializes the physics updraft event
  151825. * @param _scene BabylonJS scene
  151826. * @param _origin The origin position of the updraft
  151827. * @param _options The options for the updraft event
  151828. */
  151829. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151830. /**
  151831. * Returns the data related to the updraft event (cylinder).
  151832. * @returns A physics updraft event
  151833. */
  151834. getData(): PhysicsUpdraftEventData;
  151835. /**
  151836. * Enables the updraft.
  151837. */
  151838. enable(): void;
  151839. /**
  151840. * Disables the updraft.
  151841. */
  151842. disable(): void;
  151843. /**
  151844. * Disposes the cylinder.
  151845. * @param force Specifies if the updraft should be disposed by force
  151846. */
  151847. dispose(force?: boolean): void;
  151848. private getImpostorHitData;
  151849. private _tick;
  151850. /*** Helpers ***/
  151851. private _prepareCylinder;
  151852. private _intersectsWithCylinder;
  151853. }
  151854. /**
  151855. * Represents a physics vortex event
  151856. */
  151857. class PhysicsVortexEvent {
  151858. private _scene;
  151859. private _origin;
  151860. private _options;
  151861. private _physicsEngine;
  151862. private _originTop;
  151863. private _tickCallback;
  151864. private _cylinder;
  151865. private _cylinderPosition;
  151866. private _dataFetched;
  151867. /**
  151868. * Initializes the physics vortex event
  151869. * @param _scene The BabylonJS scene
  151870. * @param _origin The origin position of the vortex
  151871. * @param _options The options for the vortex event
  151872. */
  151873. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151874. /**
  151875. * Returns the data related to the vortex event (cylinder).
  151876. * @returns The physics vortex event data
  151877. */
  151878. getData(): PhysicsVortexEventData;
  151879. /**
  151880. * Enables the vortex.
  151881. */
  151882. enable(): void;
  151883. /**
  151884. * Disables the cortex.
  151885. */
  151886. disable(): void;
  151887. /**
  151888. * Disposes the sphere.
  151889. * @param force
  151890. */
  151891. dispose(force?: boolean): void;
  151892. private getImpostorHitData;
  151893. private _tick;
  151894. /*** Helpers ***/
  151895. private _prepareCylinder;
  151896. private _intersectsWithCylinder;
  151897. }
  151898. /**
  151899. * Options fot the radial explosion event
  151900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151901. */
  151902. export class PhysicsRadialExplosionEventOptions {
  151903. /**
  151904. * The radius of the sphere for the radial explosion.
  151905. */
  151906. radius: number;
  151907. /**
  151908. * The strenth of the explosion.
  151909. */
  151910. strength: number;
  151911. /**
  151912. * The strenght of the force in correspondence to the distance of the affected object
  151913. */
  151914. falloff: PhysicsRadialImpulseFalloff;
  151915. /**
  151916. * Sphere options for the radial explosion.
  151917. */
  151918. sphere: {
  151919. segments: number;
  151920. diameter: number;
  151921. };
  151922. /**
  151923. * Sphere options for the radial explosion.
  151924. */
  151925. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151926. }
  151927. /**
  151928. * Options fot the updraft event
  151929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151930. */
  151931. export class PhysicsUpdraftEventOptions {
  151932. /**
  151933. * The radius of the cylinder for the vortex
  151934. */
  151935. radius: number;
  151936. /**
  151937. * The strenth of the updraft.
  151938. */
  151939. strength: number;
  151940. /**
  151941. * The height of the cylinder for the updraft.
  151942. */
  151943. height: number;
  151944. /**
  151945. * The mode for the the updraft.
  151946. */
  151947. updraftMode: PhysicsUpdraftMode;
  151948. }
  151949. /**
  151950. * Options fot the vortex event
  151951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151952. */
  151953. export class PhysicsVortexEventOptions {
  151954. /**
  151955. * The radius of the cylinder for the vortex
  151956. */
  151957. radius: number;
  151958. /**
  151959. * The strenth of the vortex.
  151960. */
  151961. strength: number;
  151962. /**
  151963. * The height of the cylinder for the vortex.
  151964. */
  151965. height: number;
  151966. /**
  151967. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151968. */
  151969. centripetalForceThreshold: number;
  151970. /**
  151971. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151972. */
  151973. centripetalForceMultiplier: number;
  151974. /**
  151975. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151976. */
  151977. centrifugalForceMultiplier: number;
  151978. /**
  151979. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151980. */
  151981. updraftForceMultiplier: number;
  151982. }
  151983. /**
  151984. * The strenght of the force in correspondence to the distance of the affected object
  151985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151986. */
  151987. export enum PhysicsRadialImpulseFalloff {
  151988. /** Defines that impulse is constant in strength across it's whole radius */
  151989. Constant = 0,
  151990. /** Defines that impulse gets weaker if it's further from the origin */
  151991. Linear = 1
  151992. }
  151993. /**
  151994. * The strength of the force in correspondence to the distance of the affected object
  151995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151996. */
  151997. export enum PhysicsUpdraftMode {
  151998. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151999. Center = 0,
  152000. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  152001. Perpendicular = 1
  152002. }
  152003. /**
  152004. * Interface for a physics hit data
  152005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152006. */
  152007. export interface PhysicsHitData {
  152008. /**
  152009. * The force applied at the contact point
  152010. */
  152011. force: Vector3;
  152012. /**
  152013. * The contact point
  152014. */
  152015. contactPoint: Vector3;
  152016. /**
  152017. * The distance from the origin to the contact point
  152018. */
  152019. distanceFromOrigin: number;
  152020. }
  152021. /**
  152022. * Interface for radial explosion event data
  152023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152024. */
  152025. export interface PhysicsRadialExplosionEventData {
  152026. /**
  152027. * A sphere used for the radial explosion event
  152028. */
  152029. sphere: Mesh;
  152030. }
  152031. /**
  152032. * Interface for gravitational field event data
  152033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152034. */
  152035. export interface PhysicsGravitationalFieldEventData {
  152036. /**
  152037. * A sphere mesh used for the gravitational field event
  152038. */
  152039. sphere: Mesh;
  152040. }
  152041. /**
  152042. * Interface for updraft event data
  152043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152044. */
  152045. export interface PhysicsUpdraftEventData {
  152046. /**
  152047. * A cylinder used for the updraft event
  152048. */
  152049. cylinder: Mesh;
  152050. }
  152051. /**
  152052. * Interface for vortex event data
  152053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152054. */
  152055. export interface PhysicsVortexEventData {
  152056. /**
  152057. * A cylinder used for the vortex event
  152058. */
  152059. cylinder: Mesh;
  152060. }
  152061. /**
  152062. * Interface for an affected physics impostor
  152063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152064. */
  152065. export interface PhysicsAffectedImpostorWithData {
  152066. /**
  152067. * The impostor affected by the effect
  152068. */
  152069. impostor: PhysicsImpostor;
  152070. /**
  152071. * The data about the hit/horce from the explosion
  152072. */
  152073. hitData: PhysicsHitData;
  152074. }
  152075. }
  152076. declare module BABYLON {
  152077. /** @hidden */
  152078. export var blackAndWhitePixelShader: {
  152079. name: string;
  152080. shader: string;
  152081. };
  152082. }
  152083. declare module BABYLON {
  152084. /**
  152085. * Post process used to render in black and white
  152086. */
  152087. export class BlackAndWhitePostProcess extends PostProcess {
  152088. /**
  152089. * Linear about to convert he result to black and white (default: 1)
  152090. */
  152091. degree: number;
  152092. /**
  152093. * Gets a string identifying the name of the class
  152094. * @returns "BlackAndWhitePostProcess" string
  152095. */
  152096. getClassName(): string;
  152097. /**
  152098. * Creates a black and white post process
  152099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  152100. * @param name The name of the effect.
  152101. * @param options The required width/height ratio to downsize to before computing the render pass.
  152102. * @param camera The camera to apply the render pass to.
  152103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152104. * @param engine The engine which the post process will be applied. (default: current engine)
  152105. * @param reusable If the post process can be reused on the same frame. (default: false)
  152106. */
  152107. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152108. /** @hidden */
  152109. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  152110. }
  152111. }
  152112. declare module BABYLON {
  152113. /**
  152114. * This represents a set of one or more post processes in Babylon.
  152115. * A post process can be used to apply a shader to a texture after it is rendered.
  152116. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152117. */
  152118. export class PostProcessRenderEffect {
  152119. private _postProcesses;
  152120. private _getPostProcesses;
  152121. private _singleInstance;
  152122. private _cameras;
  152123. private _indicesForCamera;
  152124. /**
  152125. * Name of the effect
  152126. * @hidden
  152127. */
  152128. _name: string;
  152129. /**
  152130. * Instantiates a post process render effect.
  152131. * A post process can be used to apply a shader to a texture after it is rendered.
  152132. * @param engine The engine the effect is tied to
  152133. * @param name The name of the effect
  152134. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  152135. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  152136. */
  152137. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  152138. /**
  152139. * Checks if all the post processes in the effect are supported.
  152140. */
  152141. get isSupported(): boolean;
  152142. /**
  152143. * Updates the current state of the effect
  152144. * @hidden
  152145. */
  152146. _update(): void;
  152147. /**
  152148. * Attaches the effect on cameras
  152149. * @param cameras The camera to attach to.
  152150. * @hidden
  152151. */
  152152. _attachCameras(cameras: Camera): void;
  152153. /**
  152154. * Attaches the effect on cameras
  152155. * @param cameras The camera to attach to.
  152156. * @hidden
  152157. */
  152158. _attachCameras(cameras: Camera[]): void;
  152159. /**
  152160. * Detaches the effect on cameras
  152161. * @param cameras The camera to detatch from.
  152162. * @hidden
  152163. */
  152164. _detachCameras(cameras: Camera): void;
  152165. /**
  152166. * Detatches the effect on cameras
  152167. * @param cameras The camera to detatch from.
  152168. * @hidden
  152169. */
  152170. _detachCameras(cameras: Camera[]): void;
  152171. /**
  152172. * Enables the effect on given cameras
  152173. * @param cameras The camera to enable.
  152174. * @hidden
  152175. */
  152176. _enable(cameras: Camera): void;
  152177. /**
  152178. * Enables the effect on given cameras
  152179. * @param cameras The camera to enable.
  152180. * @hidden
  152181. */
  152182. _enable(cameras: Nullable<Camera[]>): void;
  152183. /**
  152184. * Disables the effect on the given cameras
  152185. * @param cameras The camera to disable.
  152186. * @hidden
  152187. */
  152188. _disable(cameras: Camera): void;
  152189. /**
  152190. * Disables the effect on the given cameras
  152191. * @param cameras The camera to disable.
  152192. * @hidden
  152193. */
  152194. _disable(cameras: Nullable<Camera[]>): void;
  152195. /**
  152196. * Gets a list of the post processes contained in the effect.
  152197. * @param camera The camera to get the post processes on.
  152198. * @returns The list of the post processes in the effect.
  152199. */
  152200. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  152201. }
  152202. }
  152203. declare module BABYLON {
  152204. /** @hidden */
  152205. export var extractHighlightsPixelShader: {
  152206. name: string;
  152207. shader: string;
  152208. };
  152209. }
  152210. declare module BABYLON {
  152211. /**
  152212. * 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.
  152213. */
  152214. export class ExtractHighlightsPostProcess extends PostProcess {
  152215. /**
  152216. * The luminance threshold, pixels below this value will be set to black.
  152217. */
  152218. threshold: number;
  152219. /** @hidden */
  152220. _exposure: number;
  152221. /**
  152222. * Post process which has the input texture to be used when performing highlight extraction
  152223. * @hidden
  152224. */
  152225. _inputPostProcess: Nullable<PostProcess>;
  152226. /**
  152227. * Gets a string identifying the name of the class
  152228. * @returns "ExtractHighlightsPostProcess" string
  152229. */
  152230. getClassName(): string;
  152231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152232. }
  152233. }
  152234. declare module BABYLON {
  152235. /** @hidden */
  152236. export var bloomMergePixelShader: {
  152237. name: string;
  152238. shader: string;
  152239. };
  152240. }
  152241. declare module BABYLON {
  152242. /**
  152243. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152244. */
  152245. export class BloomMergePostProcess extends PostProcess {
  152246. /** Weight of the bloom to be added to the original input. */
  152247. weight: number;
  152248. /**
  152249. * Gets a string identifying the name of the class
  152250. * @returns "BloomMergePostProcess" string
  152251. */
  152252. getClassName(): string;
  152253. /**
  152254. * Creates a new instance of @see BloomMergePostProcess
  152255. * @param name The name of the effect.
  152256. * @param originalFromInput Post process which's input will be used for the merge.
  152257. * @param blurred Blurred highlights post process which's output will be used.
  152258. * @param weight Weight of the bloom to be added to the original input.
  152259. * @param options The required width/height ratio to downsize to before computing the render pass.
  152260. * @param camera The camera to apply the render pass to.
  152261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152262. * @param engine The engine which the post process will be applied. (default: current engine)
  152263. * @param reusable If the post process can be reused on the same frame. (default: false)
  152264. * @param textureType Type of textures used when performing the post process. (default: 0)
  152265. * @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)
  152266. */
  152267. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  152268. /** Weight of the bloom to be added to the original input. */
  152269. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152270. }
  152271. }
  152272. declare module BABYLON {
  152273. /**
  152274. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  152275. */
  152276. export class BloomEffect extends PostProcessRenderEffect {
  152277. private bloomScale;
  152278. /**
  152279. * @hidden Internal
  152280. */
  152281. _effects: Array<PostProcess>;
  152282. /**
  152283. * @hidden Internal
  152284. */
  152285. _downscale: ExtractHighlightsPostProcess;
  152286. private _blurX;
  152287. private _blurY;
  152288. private _merge;
  152289. /**
  152290. * The luminance threshold to find bright areas of the image to bloom.
  152291. */
  152292. get threshold(): number;
  152293. set threshold(value: number);
  152294. /**
  152295. * The strength of the bloom.
  152296. */
  152297. get weight(): number;
  152298. set weight(value: number);
  152299. /**
  152300. * Specifies the size of the bloom blur kernel, relative to the final output size
  152301. */
  152302. get kernel(): number;
  152303. set kernel(value: number);
  152304. /**
  152305. * Creates a new instance of @see BloomEffect
  152306. * @param scene The scene the effect belongs to.
  152307. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  152308. * @param bloomKernel The size of the kernel to be used when applying the blur.
  152309. * @param bloomWeight The the strength of bloom.
  152310. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152311. * @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)
  152312. */
  152313. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  152314. /**
  152315. * Disposes each of the internal effects for a given camera.
  152316. * @param camera The camera to dispose the effect on.
  152317. */
  152318. disposeEffects(camera: Camera): void;
  152319. /**
  152320. * @hidden Internal
  152321. */
  152322. _updateEffects(): void;
  152323. /**
  152324. * Internal
  152325. * @returns if all the contained post processes are ready.
  152326. * @hidden
  152327. */
  152328. _isReady(): boolean;
  152329. }
  152330. }
  152331. declare module BABYLON {
  152332. /** @hidden */
  152333. export var chromaticAberrationPixelShader: {
  152334. name: string;
  152335. shader: string;
  152336. };
  152337. }
  152338. declare module BABYLON {
  152339. /**
  152340. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  152341. */
  152342. export class ChromaticAberrationPostProcess extends PostProcess {
  152343. /**
  152344. * The amount of seperation of rgb channels (default: 30)
  152345. */
  152346. aberrationAmount: number;
  152347. /**
  152348. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  152349. */
  152350. radialIntensity: number;
  152351. /**
  152352. * 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))
  152353. */
  152354. direction: Vector2;
  152355. /**
  152356. * 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))
  152357. */
  152358. centerPosition: Vector2;
  152359. /** The width of the screen to apply the effect on */
  152360. screenWidth: number;
  152361. /** The height of the screen to apply the effect on */
  152362. screenHeight: number;
  152363. /**
  152364. * Gets a string identifying the name of the class
  152365. * @returns "ChromaticAberrationPostProcess" string
  152366. */
  152367. getClassName(): string;
  152368. /**
  152369. * Creates a new instance ChromaticAberrationPostProcess
  152370. * @param name The name of the effect.
  152371. * @param screenWidth The width of the screen to apply the effect on.
  152372. * @param screenHeight The height of the screen to apply the effect on.
  152373. * @param options The required width/height ratio to downsize to before computing the render pass.
  152374. * @param camera The camera to apply the render pass to.
  152375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152376. * @param engine The engine which the post process will be applied. (default: current engine)
  152377. * @param reusable If the post process can be reused on the same frame. (default: false)
  152378. * @param textureType Type of textures used when performing the post process. (default: 0)
  152379. * @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)
  152380. */
  152381. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152382. /** @hidden */
  152383. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  152384. }
  152385. }
  152386. declare module BABYLON {
  152387. /** @hidden */
  152388. export var circleOfConfusionPixelShader: {
  152389. name: string;
  152390. shader: string;
  152391. };
  152392. }
  152393. declare module BABYLON {
  152394. /**
  152395. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  152396. */
  152397. export class CircleOfConfusionPostProcess extends PostProcess {
  152398. /**
  152399. * 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.
  152400. */
  152401. lensSize: number;
  152402. /**
  152403. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152404. */
  152405. fStop: number;
  152406. /**
  152407. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152408. */
  152409. focusDistance: number;
  152410. /**
  152411. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152412. */
  152413. focalLength: number;
  152414. /**
  152415. * Gets a string identifying the name of the class
  152416. * @returns "CircleOfConfusionPostProcess" string
  152417. */
  152418. getClassName(): string;
  152419. private _depthTexture;
  152420. /**
  152421. * Creates a new instance CircleOfConfusionPostProcess
  152422. * @param name The name of the effect.
  152423. * @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.
  152424. * @param options The required width/height ratio to downsize to before computing the render pass.
  152425. * @param camera The camera to apply the render pass to.
  152426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152427. * @param engine The engine which the post process will be applied. (default: current engine)
  152428. * @param reusable If the post process can be reused on the same frame. (default: false)
  152429. * @param textureType Type of textures used when performing the post process. (default: 0)
  152430. * @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)
  152431. */
  152432. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152433. /**
  152434. * 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.
  152435. */
  152436. set depthTexture(value: RenderTargetTexture);
  152437. }
  152438. }
  152439. declare module BABYLON {
  152440. /** @hidden */
  152441. export var colorCorrectionPixelShader: {
  152442. name: string;
  152443. shader: string;
  152444. };
  152445. }
  152446. declare module BABYLON {
  152447. /**
  152448. *
  152449. * This post-process allows the modification of rendered colors by using
  152450. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152451. *
  152452. * The object needs to be provided an url to a texture containing the color
  152453. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152454. * Use an image editing software to tweak the LUT to match your needs.
  152455. *
  152456. * For an example of a color LUT, see here:
  152457. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152458. * For explanations on color grading, see here:
  152459. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152460. *
  152461. */
  152462. export class ColorCorrectionPostProcess extends PostProcess {
  152463. private _colorTableTexture;
  152464. /**
  152465. * Gets the color table url used to create the LUT texture
  152466. */
  152467. colorTableUrl: string;
  152468. /**
  152469. * Gets a string identifying the name of the class
  152470. * @returns "ColorCorrectionPostProcess" string
  152471. */
  152472. getClassName(): string;
  152473. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152474. /** @hidden */
  152475. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152476. }
  152477. }
  152478. declare module BABYLON {
  152479. /** @hidden */
  152480. export var convolutionPixelShader: {
  152481. name: string;
  152482. shader: string;
  152483. };
  152484. }
  152485. declare module BABYLON {
  152486. /**
  152487. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152488. * input texture to perform effects such as edge detection or sharpening
  152489. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152490. */
  152491. export class ConvolutionPostProcess extends PostProcess {
  152492. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152493. kernel: number[];
  152494. /**
  152495. * Gets a string identifying the name of the class
  152496. * @returns "ConvolutionPostProcess" string
  152497. */
  152498. getClassName(): string;
  152499. /**
  152500. * Creates a new instance ConvolutionPostProcess
  152501. * @param name The name of the effect.
  152502. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152503. * @param options The required width/height ratio to downsize to before computing the render pass.
  152504. * @param camera The camera to apply the render pass to.
  152505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152506. * @param engine The engine which the post process will be applied. (default: current engine)
  152507. * @param reusable If the post process can be reused on the same frame. (default: false)
  152508. * @param textureType Type of textures used when performing the post process. (default: 0)
  152509. */
  152510. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152511. /** @hidden */
  152512. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152513. /**
  152514. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152515. */
  152516. static EdgeDetect0Kernel: number[];
  152517. /**
  152518. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152519. */
  152520. static EdgeDetect1Kernel: number[];
  152521. /**
  152522. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152523. */
  152524. static EdgeDetect2Kernel: number[];
  152525. /**
  152526. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152527. */
  152528. static SharpenKernel: number[];
  152529. /**
  152530. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152531. */
  152532. static EmbossKernel: number[];
  152533. /**
  152534. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152535. */
  152536. static GaussianKernel: number[];
  152537. }
  152538. }
  152539. declare module BABYLON {
  152540. /**
  152541. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152542. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152543. * based on samples that have a large difference in distance than the center pixel.
  152544. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152545. */
  152546. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152547. /**
  152548. * The direction the blur should be applied
  152549. */
  152550. direction: Vector2;
  152551. /**
  152552. * Gets a string identifying the name of the class
  152553. * @returns "DepthOfFieldBlurPostProcess" string
  152554. */
  152555. getClassName(): string;
  152556. /**
  152557. * Creates a new instance CircleOfConfusionPostProcess
  152558. * @param name The name of the effect.
  152559. * @param scene The scene the effect belongs to.
  152560. * @param direction The direction the blur should be applied.
  152561. * @param kernel The size of the kernel used to blur.
  152562. * @param options The required width/height ratio to downsize to before computing the render pass.
  152563. * @param camera The camera to apply the render pass to.
  152564. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152565. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152567. * @param engine The engine which the post process will be applied. (default: current engine)
  152568. * @param reusable If the post process can be reused on the same frame. (default: false)
  152569. * @param textureType Type of textures used when performing the post process. (default: 0)
  152570. * @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)
  152571. */
  152572. 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);
  152573. }
  152574. }
  152575. declare module BABYLON {
  152576. /** @hidden */
  152577. export var depthOfFieldMergePixelShader: {
  152578. name: string;
  152579. shader: string;
  152580. };
  152581. }
  152582. declare module BABYLON {
  152583. /**
  152584. * Options to be set when merging outputs from the default pipeline.
  152585. */
  152586. export class DepthOfFieldMergePostProcessOptions {
  152587. /**
  152588. * The original image to merge on top of
  152589. */
  152590. originalFromInput: PostProcess;
  152591. /**
  152592. * Parameters to perform the merge of the depth of field effect
  152593. */
  152594. depthOfField?: {
  152595. circleOfConfusion: PostProcess;
  152596. blurSteps: Array<PostProcess>;
  152597. };
  152598. /**
  152599. * Parameters to perform the merge of bloom effect
  152600. */
  152601. bloom?: {
  152602. blurred: PostProcess;
  152603. weight: number;
  152604. };
  152605. }
  152606. /**
  152607. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152608. */
  152609. export class DepthOfFieldMergePostProcess extends PostProcess {
  152610. private blurSteps;
  152611. /**
  152612. * Gets a string identifying the name of the class
  152613. * @returns "DepthOfFieldMergePostProcess" string
  152614. */
  152615. getClassName(): string;
  152616. /**
  152617. * Creates a new instance of DepthOfFieldMergePostProcess
  152618. * @param name The name of the effect.
  152619. * @param originalFromInput Post process which's input will be used for the merge.
  152620. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152621. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152622. * @param options The required width/height ratio to downsize to before computing the render pass.
  152623. * @param camera The camera to apply the render pass to.
  152624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152625. * @param engine The engine which the post process will be applied. (default: current engine)
  152626. * @param reusable If the post process can be reused on the same frame. (default: false)
  152627. * @param textureType Type of textures used when performing the post process. (default: 0)
  152628. * @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)
  152629. */
  152630. 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);
  152631. /**
  152632. * Updates the effect with the current post process compile time values and recompiles the shader.
  152633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152636. * @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
  152637. * @param onCompiled Called when the shader has been compiled.
  152638. * @param onError Called if there is an error when compiling a shader.
  152639. */
  152640. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152641. }
  152642. }
  152643. declare module BABYLON {
  152644. /**
  152645. * Specifies the level of max blur that should be applied when using the depth of field effect
  152646. */
  152647. export enum DepthOfFieldEffectBlurLevel {
  152648. /**
  152649. * Subtle blur
  152650. */
  152651. Low = 0,
  152652. /**
  152653. * Medium blur
  152654. */
  152655. Medium = 1,
  152656. /**
  152657. * Large blur
  152658. */
  152659. High = 2
  152660. }
  152661. /**
  152662. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152663. */
  152664. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152665. private _circleOfConfusion;
  152666. /**
  152667. * @hidden Internal, blurs from high to low
  152668. */
  152669. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152670. private _depthOfFieldBlurY;
  152671. private _dofMerge;
  152672. /**
  152673. * @hidden Internal post processes in depth of field effect
  152674. */
  152675. _effects: Array<PostProcess>;
  152676. /**
  152677. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152678. */
  152679. set focalLength(value: number);
  152680. get focalLength(): number;
  152681. /**
  152682. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152683. */
  152684. set fStop(value: number);
  152685. get fStop(): number;
  152686. /**
  152687. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152688. */
  152689. set focusDistance(value: number);
  152690. get focusDistance(): number;
  152691. /**
  152692. * 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.
  152693. */
  152694. set lensSize(value: number);
  152695. get lensSize(): number;
  152696. /**
  152697. * Creates a new instance DepthOfFieldEffect
  152698. * @param scene The scene the effect belongs to.
  152699. * @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.
  152700. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152701. * @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)
  152702. */
  152703. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152704. /**
  152705. * Get the current class name of the current effet
  152706. * @returns "DepthOfFieldEffect"
  152707. */
  152708. getClassName(): string;
  152709. /**
  152710. * 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.
  152711. */
  152712. set depthTexture(value: RenderTargetTexture);
  152713. /**
  152714. * Disposes each of the internal effects for a given camera.
  152715. * @param camera The camera to dispose the effect on.
  152716. */
  152717. disposeEffects(camera: Camera): void;
  152718. /**
  152719. * @hidden Internal
  152720. */
  152721. _updateEffects(): void;
  152722. /**
  152723. * Internal
  152724. * @returns if all the contained post processes are ready.
  152725. * @hidden
  152726. */
  152727. _isReady(): boolean;
  152728. }
  152729. }
  152730. declare module BABYLON {
  152731. /** @hidden */
  152732. export var displayPassPixelShader: {
  152733. name: string;
  152734. shader: string;
  152735. };
  152736. }
  152737. declare module BABYLON {
  152738. /**
  152739. * DisplayPassPostProcess which produces an output the same as it's input
  152740. */
  152741. export class DisplayPassPostProcess extends PostProcess {
  152742. /**
  152743. * Gets a string identifying the name of the class
  152744. * @returns "DisplayPassPostProcess" string
  152745. */
  152746. getClassName(): string;
  152747. /**
  152748. * Creates the DisplayPassPostProcess
  152749. * @param name The name of the effect.
  152750. * @param options The required width/height ratio to downsize to before computing the render pass.
  152751. * @param camera The camera to apply the render pass to.
  152752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152753. * @param engine The engine which the post process will be applied. (default: current engine)
  152754. * @param reusable If the post process can be reused on the same frame. (default: false)
  152755. */
  152756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152757. /** @hidden */
  152758. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152759. }
  152760. }
  152761. declare module BABYLON {
  152762. /** @hidden */
  152763. export var filterPixelShader: {
  152764. name: string;
  152765. shader: string;
  152766. };
  152767. }
  152768. declare module BABYLON {
  152769. /**
  152770. * Applies a kernel filter to the image
  152771. */
  152772. export class FilterPostProcess extends PostProcess {
  152773. /** The matrix to be applied to the image */
  152774. kernelMatrix: Matrix;
  152775. /**
  152776. * Gets a string identifying the name of the class
  152777. * @returns "FilterPostProcess" string
  152778. */
  152779. getClassName(): string;
  152780. /**
  152781. *
  152782. * @param name The name of the effect.
  152783. * @param kernelMatrix The matrix to be applied to the image
  152784. * @param options The required width/height ratio to downsize to before computing the render pass.
  152785. * @param camera The camera to apply the render pass to.
  152786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152787. * @param engine The engine which the post process will be applied. (default: current engine)
  152788. * @param reusable If the post process can be reused on the same frame. (default: false)
  152789. */
  152790. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152791. /** @hidden */
  152792. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152793. }
  152794. }
  152795. declare module BABYLON {
  152796. /** @hidden */
  152797. export var fxaaPixelShader: {
  152798. name: string;
  152799. shader: string;
  152800. };
  152801. }
  152802. declare module BABYLON {
  152803. /** @hidden */
  152804. export var fxaaVertexShader: {
  152805. name: string;
  152806. shader: string;
  152807. };
  152808. }
  152809. declare module BABYLON {
  152810. /**
  152811. * Fxaa post process
  152812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152813. */
  152814. export class FxaaPostProcess extends PostProcess {
  152815. /**
  152816. * Gets a string identifying the name of the class
  152817. * @returns "FxaaPostProcess" string
  152818. */
  152819. getClassName(): string;
  152820. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152821. private _getDefines;
  152822. /** @hidden */
  152823. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152824. }
  152825. }
  152826. declare module BABYLON {
  152827. /** @hidden */
  152828. export var grainPixelShader: {
  152829. name: string;
  152830. shader: string;
  152831. };
  152832. }
  152833. declare module BABYLON {
  152834. /**
  152835. * The GrainPostProcess adds noise to the image at mid luminance levels
  152836. */
  152837. export class GrainPostProcess extends PostProcess {
  152838. /**
  152839. * The intensity of the grain added (default: 30)
  152840. */
  152841. intensity: number;
  152842. /**
  152843. * If the grain should be randomized on every frame
  152844. */
  152845. animated: boolean;
  152846. /**
  152847. * Gets a string identifying the name of the class
  152848. * @returns "GrainPostProcess" string
  152849. */
  152850. getClassName(): string;
  152851. /**
  152852. * Creates a new instance of @see GrainPostProcess
  152853. * @param name The name of the effect.
  152854. * @param options The required width/height ratio to downsize to before computing the render pass.
  152855. * @param camera The camera to apply the render pass to.
  152856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152857. * @param engine The engine which the post process will be applied. (default: current engine)
  152858. * @param reusable If the post process can be reused on the same frame. (default: false)
  152859. * @param textureType Type of textures used when performing the post process. (default: 0)
  152860. * @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)
  152861. */
  152862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152863. /** @hidden */
  152864. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152865. }
  152866. }
  152867. declare module BABYLON {
  152868. /** @hidden */
  152869. export var highlightsPixelShader: {
  152870. name: string;
  152871. shader: string;
  152872. };
  152873. }
  152874. declare module BABYLON {
  152875. /**
  152876. * Extracts highlights from the image
  152877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152878. */
  152879. export class HighlightsPostProcess extends PostProcess {
  152880. /**
  152881. * Gets a string identifying the name of the class
  152882. * @returns "HighlightsPostProcess" string
  152883. */
  152884. getClassName(): string;
  152885. /**
  152886. * Extracts highlights from the image
  152887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152888. * @param name The name of the effect.
  152889. * @param options The required width/height ratio to downsize to before computing the render pass.
  152890. * @param camera The camera to apply the render pass to.
  152891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152892. * @param engine The engine which the post process will be applied. (default: current engine)
  152893. * @param reusable If the post process can be reused on the same frame. (default: false)
  152894. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152895. */
  152896. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152897. }
  152898. }
  152899. declare module BABYLON {
  152900. /**
  152901. * Contains all parameters needed for the prepass to perform
  152902. * motion blur
  152903. */
  152904. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152905. /**
  152906. * Is motion blur enabled
  152907. */
  152908. enabled: boolean;
  152909. /**
  152910. * Name of the configuration
  152911. */
  152912. name: string;
  152913. /**
  152914. * Textures that should be present in the MRT for this effect to work
  152915. */
  152916. readonly texturesRequired: number[];
  152917. }
  152918. }
  152919. declare module BABYLON {
  152920. interface Scene {
  152921. /** @hidden (Backing field) */
  152922. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152923. /**
  152924. * Gets or Sets the current geometry buffer associated to the scene.
  152925. */
  152926. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152927. /**
  152928. * Enables a GeometryBufferRender and associates it with the scene
  152929. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152930. * @returns the GeometryBufferRenderer
  152931. */
  152932. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152933. /**
  152934. * Disables the GeometryBufferRender associated with the scene
  152935. */
  152936. disableGeometryBufferRenderer(): void;
  152937. }
  152938. /**
  152939. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152940. * in several rendering techniques.
  152941. */
  152942. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152943. /**
  152944. * The component name helpful to identify the component in the list of scene components.
  152945. */
  152946. readonly name: string;
  152947. /**
  152948. * The scene the component belongs to.
  152949. */
  152950. scene: Scene;
  152951. /**
  152952. * Creates a new instance of the component for the given scene
  152953. * @param scene Defines the scene to register the component in
  152954. */
  152955. constructor(scene: Scene);
  152956. /**
  152957. * Registers the component in a given scene
  152958. */
  152959. register(): void;
  152960. /**
  152961. * Rebuilds the elements related to this component in case of
  152962. * context lost for instance.
  152963. */
  152964. rebuild(): void;
  152965. /**
  152966. * Disposes the component and the associated ressources
  152967. */
  152968. dispose(): void;
  152969. private _gatherRenderTargets;
  152970. }
  152971. }
  152972. declare module BABYLON {
  152973. /** @hidden */
  152974. export var motionBlurPixelShader: {
  152975. name: string;
  152976. shader: string;
  152977. };
  152978. }
  152979. declare module BABYLON {
  152980. /**
  152981. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152982. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152983. * As an example, all you have to do is to create the post-process:
  152984. * var mb = new BABYLON.MotionBlurPostProcess(
  152985. * 'mb', // The name of the effect.
  152986. * scene, // The scene containing the objects to blur according to their velocity.
  152987. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152988. * camera // The camera to apply the render pass to.
  152989. * );
  152990. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152991. */
  152992. export class MotionBlurPostProcess extends PostProcess {
  152993. /**
  152994. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152995. */
  152996. motionStrength: number;
  152997. /**
  152998. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152999. */
  153000. get motionBlurSamples(): number;
  153001. /**
  153002. * Sets the number of iterations to be used for motion blur quality
  153003. */
  153004. set motionBlurSamples(samples: number);
  153005. private _motionBlurSamples;
  153006. /**
  153007. * Gets wether or not the motion blur post-process is in object based mode.
  153008. */
  153009. get isObjectBased(): boolean;
  153010. /**
  153011. * Sets wether or not the motion blur post-process is in object based mode.
  153012. */
  153013. set isObjectBased(value: boolean);
  153014. private _isObjectBased;
  153015. private _forceGeometryBuffer;
  153016. private _geometryBufferRenderer;
  153017. private _prePassRenderer;
  153018. private _invViewProjection;
  153019. private _previousViewProjection;
  153020. /**
  153021. * Gets a string identifying the name of the class
  153022. * @returns "MotionBlurPostProcess" string
  153023. */
  153024. getClassName(): string;
  153025. /**
  153026. * Creates a new instance MotionBlurPostProcess
  153027. * @param name The name of the effect.
  153028. * @param scene The scene containing the objects to blur according to their velocity.
  153029. * @param options The required width/height ratio to downsize to before computing the render pass.
  153030. * @param camera The camera to apply the render pass to.
  153031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153032. * @param engine The engine which the post process will be applied. (default: current engine)
  153033. * @param reusable If the post process can be reused on the same frame. (default: false)
  153034. * @param textureType Type of textures used when performing the post process. (default: 0)
  153035. * @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)
  153036. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153037. */
  153038. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153039. /**
  153040. * Excludes the given skinned mesh from computing bones velocities.
  153041. * 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.
  153042. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  153043. */
  153044. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153045. /**
  153046. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  153047. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  153048. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  153049. */
  153050. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153051. /**
  153052. * Disposes the post process.
  153053. * @param camera The camera to dispose the post process on.
  153054. */
  153055. dispose(camera?: Camera): void;
  153056. /**
  153057. * Called on the mode changed (object based or screen based).
  153058. */
  153059. private _applyMode;
  153060. /**
  153061. * Called on the effect is applied when the motion blur post-process is in object based mode.
  153062. */
  153063. private _onApplyObjectBased;
  153064. /**
  153065. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  153066. */
  153067. private _onApplyScreenBased;
  153068. /**
  153069. * Called on the effect must be updated (changed mode, samples count, etc.).
  153070. */
  153071. private _updateEffect;
  153072. /** @hidden */
  153073. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  153074. }
  153075. }
  153076. declare module BABYLON {
  153077. /** @hidden */
  153078. export var refractionPixelShader: {
  153079. name: string;
  153080. shader: string;
  153081. };
  153082. }
  153083. declare module BABYLON {
  153084. /**
  153085. * Post process which applies a refractin texture
  153086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153087. */
  153088. export class RefractionPostProcess extends PostProcess {
  153089. private _refTexture;
  153090. private _ownRefractionTexture;
  153091. /** the base color of the refraction (used to taint the rendering) */
  153092. color: Color3;
  153093. /** simulated refraction depth */
  153094. depth: number;
  153095. /** the coefficient of the base color (0 to remove base color tainting) */
  153096. colorLevel: number;
  153097. /** Gets the url used to load the refraction texture */
  153098. refractionTextureUrl: string;
  153099. /**
  153100. * Gets or sets the refraction texture
  153101. * Please note that you are responsible for disposing the texture if you set it manually
  153102. */
  153103. get refractionTexture(): Texture;
  153104. set refractionTexture(value: Texture);
  153105. /**
  153106. * Gets a string identifying the name of the class
  153107. * @returns "RefractionPostProcess" string
  153108. */
  153109. getClassName(): string;
  153110. /**
  153111. * Initializes the RefractionPostProcess
  153112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153113. * @param name The name of the effect.
  153114. * @param refractionTextureUrl Url of the refraction texture to use
  153115. * @param color the base color of the refraction (used to taint the rendering)
  153116. * @param depth simulated refraction depth
  153117. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  153118. * @param camera The camera to apply the render pass to.
  153119. * @param options The required width/height ratio to downsize to before computing the render pass.
  153120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153121. * @param engine The engine which the post process will be applied. (default: current engine)
  153122. * @param reusable If the post process can be reused on the same frame. (default: false)
  153123. */
  153124. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153125. /**
  153126. * Disposes of the post process
  153127. * @param camera Camera to dispose post process on
  153128. */
  153129. dispose(camera: Camera): void;
  153130. /** @hidden */
  153131. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  153132. }
  153133. }
  153134. declare module BABYLON {
  153135. /** @hidden */
  153136. export var sharpenPixelShader: {
  153137. name: string;
  153138. shader: string;
  153139. };
  153140. }
  153141. declare module BABYLON {
  153142. /**
  153143. * The SharpenPostProcess applies a sharpen kernel to every pixel
  153144. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  153145. */
  153146. export class SharpenPostProcess extends PostProcess {
  153147. /**
  153148. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  153149. */
  153150. colorAmount: number;
  153151. /**
  153152. * How much sharpness should be applied (default: 0.3)
  153153. */
  153154. edgeAmount: number;
  153155. /**
  153156. * Gets a string identifying the name of the class
  153157. * @returns "SharpenPostProcess" string
  153158. */
  153159. getClassName(): string;
  153160. /**
  153161. * Creates a new instance ConvolutionPostProcess
  153162. * @param name The name of the effect.
  153163. * @param options The required width/height ratio to downsize to before computing the render pass.
  153164. * @param camera The camera to apply the render pass to.
  153165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153166. * @param engine The engine which the post process will be applied. (default: current engine)
  153167. * @param reusable If the post process can be reused on the same frame. (default: false)
  153168. * @param textureType Type of textures used when performing the post process. (default: 0)
  153169. * @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)
  153170. */
  153171. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153172. /** @hidden */
  153173. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  153174. }
  153175. }
  153176. declare module BABYLON {
  153177. /**
  153178. * PostProcessRenderPipeline
  153179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153180. */
  153181. export class PostProcessRenderPipeline {
  153182. private engine;
  153183. private _renderEffects;
  153184. private _renderEffectsForIsolatedPass;
  153185. /**
  153186. * List of inspectable custom properties (used by the Inspector)
  153187. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  153188. */
  153189. inspectableCustomProperties: IInspectable[];
  153190. /**
  153191. * @hidden
  153192. */
  153193. protected _cameras: Camera[];
  153194. /** @hidden */
  153195. _name: string;
  153196. /**
  153197. * Gets pipeline name
  153198. */
  153199. get name(): string;
  153200. /** Gets the list of attached cameras */
  153201. get cameras(): Camera[];
  153202. /**
  153203. * Initializes a PostProcessRenderPipeline
  153204. * @param engine engine to add the pipeline to
  153205. * @param name name of the pipeline
  153206. */
  153207. constructor(engine: Engine, name: string);
  153208. /**
  153209. * Gets the class name
  153210. * @returns "PostProcessRenderPipeline"
  153211. */
  153212. getClassName(): string;
  153213. /**
  153214. * If all the render effects in the pipeline are supported
  153215. */
  153216. get isSupported(): boolean;
  153217. /**
  153218. * Adds an effect to the pipeline
  153219. * @param renderEffect the effect to add
  153220. */
  153221. addEffect(renderEffect: PostProcessRenderEffect): void;
  153222. /** @hidden */
  153223. _rebuild(): void;
  153224. /** @hidden */
  153225. _enableEffect(renderEffectName: string, cameras: Camera): void;
  153226. /** @hidden */
  153227. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  153228. /** @hidden */
  153229. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153230. /** @hidden */
  153231. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153232. /** @hidden */
  153233. _attachCameras(cameras: Camera, unique: boolean): void;
  153234. /** @hidden */
  153235. _attachCameras(cameras: Camera[], unique: boolean): void;
  153236. /** @hidden */
  153237. _detachCameras(cameras: Camera): void;
  153238. /** @hidden */
  153239. _detachCameras(cameras: Nullable<Camera[]>): void;
  153240. /** @hidden */
  153241. _update(): void;
  153242. /** @hidden */
  153243. _reset(): void;
  153244. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  153245. /**
  153246. * Sets the required values to the prepass renderer.
  153247. * @param prePassRenderer defines the prepass renderer to setup.
  153248. * @returns true if the pre pass is needed.
  153249. */
  153250. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  153251. /**
  153252. * Disposes of the pipeline
  153253. */
  153254. dispose(): void;
  153255. }
  153256. }
  153257. declare module BABYLON {
  153258. /**
  153259. * PostProcessRenderPipelineManager class
  153260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153261. */
  153262. export class PostProcessRenderPipelineManager {
  153263. private _renderPipelines;
  153264. /**
  153265. * Initializes a PostProcessRenderPipelineManager
  153266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153267. */
  153268. constructor();
  153269. /**
  153270. * Gets the list of supported render pipelines
  153271. */
  153272. get supportedPipelines(): PostProcessRenderPipeline[];
  153273. /**
  153274. * Adds a pipeline to the manager
  153275. * @param renderPipeline The pipeline to add
  153276. */
  153277. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  153278. /**
  153279. * Attaches a camera to the pipeline
  153280. * @param renderPipelineName The name of the pipeline to attach to
  153281. * @param cameras the camera to attach
  153282. * @param unique if the camera can be attached multiple times to the pipeline
  153283. */
  153284. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  153285. /**
  153286. * Detaches a camera from the pipeline
  153287. * @param renderPipelineName The name of the pipeline to detach from
  153288. * @param cameras the camera to detach
  153289. */
  153290. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  153291. /**
  153292. * Enables an effect by name on a pipeline
  153293. * @param renderPipelineName the name of the pipeline to enable the effect in
  153294. * @param renderEffectName the name of the effect to enable
  153295. * @param cameras the cameras that the effect should be enabled on
  153296. */
  153297. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153298. /**
  153299. * Disables an effect by name on a pipeline
  153300. * @param renderPipelineName the name of the pipeline to disable the effect in
  153301. * @param renderEffectName the name of the effect to disable
  153302. * @param cameras the cameras that the effect should be disabled on
  153303. */
  153304. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153305. /**
  153306. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  153307. */
  153308. update(): void;
  153309. /** @hidden */
  153310. _rebuild(): void;
  153311. /**
  153312. * Disposes of the manager and pipelines
  153313. */
  153314. dispose(): void;
  153315. }
  153316. }
  153317. declare module BABYLON {
  153318. interface Scene {
  153319. /** @hidden (Backing field) */
  153320. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153321. /**
  153322. * Gets the postprocess render pipeline manager
  153323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153324. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153325. */
  153326. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153327. }
  153328. /**
  153329. * Defines the Render Pipeline scene component responsible to rendering pipelines
  153330. */
  153331. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  153332. /**
  153333. * The component name helpfull to identify the component in the list of scene components.
  153334. */
  153335. readonly name: string;
  153336. /**
  153337. * The scene the component belongs to.
  153338. */
  153339. scene: Scene;
  153340. /**
  153341. * Creates a new instance of the component for the given scene
  153342. * @param scene Defines the scene to register the component in
  153343. */
  153344. constructor(scene: Scene);
  153345. /**
  153346. * Registers the component in a given scene
  153347. */
  153348. register(): void;
  153349. /**
  153350. * Rebuilds the elements related to this component in case of
  153351. * context lost for instance.
  153352. */
  153353. rebuild(): void;
  153354. /**
  153355. * Disposes the component and the associated ressources
  153356. */
  153357. dispose(): void;
  153358. private _gatherRenderTargets;
  153359. }
  153360. }
  153361. declare module BABYLON {
  153362. /**
  153363. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  153364. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153365. */
  153366. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153367. private _scene;
  153368. private _camerasToBeAttached;
  153369. /**
  153370. * ID of the sharpen post process,
  153371. */
  153372. private readonly SharpenPostProcessId;
  153373. /**
  153374. * @ignore
  153375. * ID of the image processing post process;
  153376. */
  153377. readonly ImageProcessingPostProcessId: string;
  153378. /**
  153379. * @ignore
  153380. * ID of the Fast Approximate Anti-Aliasing post process;
  153381. */
  153382. readonly FxaaPostProcessId: string;
  153383. /**
  153384. * ID of the chromatic aberration post process,
  153385. */
  153386. private readonly ChromaticAberrationPostProcessId;
  153387. /**
  153388. * ID of the grain post process
  153389. */
  153390. private readonly GrainPostProcessId;
  153391. /**
  153392. * Sharpen post process which will apply a sharpen convolution to enhance edges
  153393. */
  153394. sharpen: SharpenPostProcess;
  153395. private _sharpenEffect;
  153396. private bloom;
  153397. /**
  153398. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  153399. */
  153400. depthOfField: DepthOfFieldEffect;
  153401. /**
  153402. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153403. */
  153404. fxaa: FxaaPostProcess;
  153405. /**
  153406. * Image post processing pass used to perform operations such as tone mapping or color grading.
  153407. */
  153408. imageProcessing: ImageProcessingPostProcess;
  153409. /**
  153410. * Chromatic aberration post process which will shift rgb colors in the image
  153411. */
  153412. chromaticAberration: ChromaticAberrationPostProcess;
  153413. private _chromaticAberrationEffect;
  153414. /**
  153415. * Grain post process which add noise to the image
  153416. */
  153417. grain: GrainPostProcess;
  153418. private _grainEffect;
  153419. /**
  153420. * Glow post process which adds a glow to emissive areas of the image
  153421. */
  153422. private _glowLayer;
  153423. /**
  153424. * Animations which can be used to tweak settings over a period of time
  153425. */
  153426. animations: Animation[];
  153427. private _imageProcessingConfigurationObserver;
  153428. private _sharpenEnabled;
  153429. private _bloomEnabled;
  153430. private _depthOfFieldEnabled;
  153431. private _depthOfFieldBlurLevel;
  153432. private _fxaaEnabled;
  153433. private _imageProcessingEnabled;
  153434. private _defaultPipelineTextureType;
  153435. private _bloomScale;
  153436. private _chromaticAberrationEnabled;
  153437. private _grainEnabled;
  153438. private _buildAllowed;
  153439. /**
  153440. * This is triggered each time the pipeline has been built.
  153441. */
  153442. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153443. /**
  153444. * Gets active scene
  153445. */
  153446. get scene(): Scene;
  153447. /**
  153448. * Enable or disable the sharpen process from the pipeline
  153449. */
  153450. set sharpenEnabled(enabled: boolean);
  153451. get sharpenEnabled(): boolean;
  153452. private _resizeObserver;
  153453. private _hardwareScaleLevel;
  153454. private _bloomKernel;
  153455. /**
  153456. * Specifies the size of the bloom blur kernel, relative to the final output size
  153457. */
  153458. get bloomKernel(): number;
  153459. set bloomKernel(value: number);
  153460. /**
  153461. * Specifies the weight of the bloom in the final rendering
  153462. */
  153463. private _bloomWeight;
  153464. /**
  153465. * Specifies the luma threshold for the area that will be blurred by the bloom
  153466. */
  153467. private _bloomThreshold;
  153468. private _hdr;
  153469. /**
  153470. * The strength of the bloom.
  153471. */
  153472. set bloomWeight(value: number);
  153473. get bloomWeight(): number;
  153474. /**
  153475. * The strength of the bloom.
  153476. */
  153477. set bloomThreshold(value: number);
  153478. get bloomThreshold(): number;
  153479. /**
  153480. * The scale of the bloom, lower value will provide better performance.
  153481. */
  153482. set bloomScale(value: number);
  153483. get bloomScale(): number;
  153484. /**
  153485. * Enable or disable the bloom from the pipeline
  153486. */
  153487. set bloomEnabled(enabled: boolean);
  153488. get bloomEnabled(): boolean;
  153489. private _rebuildBloom;
  153490. /**
  153491. * If the depth of field is enabled.
  153492. */
  153493. get depthOfFieldEnabled(): boolean;
  153494. set depthOfFieldEnabled(enabled: boolean);
  153495. /**
  153496. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153497. */
  153498. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153499. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153500. /**
  153501. * If the anti aliasing is enabled.
  153502. */
  153503. set fxaaEnabled(enabled: boolean);
  153504. get fxaaEnabled(): boolean;
  153505. private _samples;
  153506. /**
  153507. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153508. */
  153509. set samples(sampleCount: number);
  153510. get samples(): number;
  153511. /**
  153512. * If image processing is enabled.
  153513. */
  153514. set imageProcessingEnabled(enabled: boolean);
  153515. get imageProcessingEnabled(): boolean;
  153516. /**
  153517. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153518. */
  153519. set glowLayerEnabled(enabled: boolean);
  153520. get glowLayerEnabled(): boolean;
  153521. /**
  153522. * Gets the glow layer (or null if not defined)
  153523. */
  153524. get glowLayer(): Nullable<GlowLayer>;
  153525. /**
  153526. * Enable or disable the chromaticAberration process from the pipeline
  153527. */
  153528. set chromaticAberrationEnabled(enabled: boolean);
  153529. get chromaticAberrationEnabled(): boolean;
  153530. /**
  153531. * Enable or disable the grain process from the pipeline
  153532. */
  153533. set grainEnabled(enabled: boolean);
  153534. get grainEnabled(): boolean;
  153535. /**
  153536. * @constructor
  153537. * @param name - The rendering pipeline name (default: "")
  153538. * @param hdr - If high dynamic range textures should be used (default: true)
  153539. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153540. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153541. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153542. */
  153543. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153544. /**
  153545. * Get the class name
  153546. * @returns "DefaultRenderingPipeline"
  153547. */
  153548. getClassName(): string;
  153549. /**
  153550. * Force the compilation of the entire pipeline.
  153551. */
  153552. prepare(): void;
  153553. private _hasCleared;
  153554. private _prevPostProcess;
  153555. private _prevPrevPostProcess;
  153556. private _setAutoClearAndTextureSharing;
  153557. private _depthOfFieldSceneObserver;
  153558. private _buildPipeline;
  153559. private _disposePostProcesses;
  153560. /**
  153561. * Adds a camera to the pipeline
  153562. * @param camera the camera to be added
  153563. */
  153564. addCamera(camera: Camera): void;
  153565. /**
  153566. * Removes a camera from the pipeline
  153567. * @param camera the camera to remove
  153568. */
  153569. removeCamera(camera: Camera): void;
  153570. /**
  153571. * Dispose of the pipeline and stop all post processes
  153572. */
  153573. dispose(): void;
  153574. /**
  153575. * Serialize the rendering pipeline (Used when exporting)
  153576. * @returns the serialized object
  153577. */
  153578. serialize(): any;
  153579. /**
  153580. * Parse the serialized pipeline
  153581. * @param source Source pipeline.
  153582. * @param scene The scene to load the pipeline to.
  153583. * @param rootUrl The URL of the serialized pipeline.
  153584. * @returns An instantiated pipeline from the serialized object.
  153585. */
  153586. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153587. }
  153588. }
  153589. declare module BABYLON {
  153590. /** @hidden */
  153591. export var lensHighlightsPixelShader: {
  153592. name: string;
  153593. shader: string;
  153594. };
  153595. }
  153596. declare module BABYLON {
  153597. /** @hidden */
  153598. export var depthOfFieldPixelShader: {
  153599. name: string;
  153600. shader: string;
  153601. };
  153602. }
  153603. declare module BABYLON {
  153604. /**
  153605. * BABYLON.JS Chromatic Aberration GLSL Shader
  153606. * Author: Olivier Guyot
  153607. * Separates very slightly R, G and B colors on the edges of the screen
  153608. * Inspired by Francois Tarlier & Martins Upitis
  153609. */
  153610. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153611. /**
  153612. * @ignore
  153613. * The chromatic aberration PostProcess id in the pipeline
  153614. */
  153615. LensChromaticAberrationEffect: string;
  153616. /**
  153617. * @ignore
  153618. * The highlights enhancing PostProcess id in the pipeline
  153619. */
  153620. HighlightsEnhancingEffect: string;
  153621. /**
  153622. * @ignore
  153623. * The depth-of-field PostProcess id in the pipeline
  153624. */
  153625. LensDepthOfFieldEffect: string;
  153626. private _scene;
  153627. private _depthTexture;
  153628. private _grainTexture;
  153629. private _chromaticAberrationPostProcess;
  153630. private _highlightsPostProcess;
  153631. private _depthOfFieldPostProcess;
  153632. private _edgeBlur;
  153633. private _grainAmount;
  153634. private _chromaticAberration;
  153635. private _distortion;
  153636. private _highlightsGain;
  153637. private _highlightsThreshold;
  153638. private _dofDistance;
  153639. private _dofAperture;
  153640. private _dofDarken;
  153641. private _dofPentagon;
  153642. private _blurNoise;
  153643. /**
  153644. * @constructor
  153645. *
  153646. * Effect parameters are as follow:
  153647. * {
  153648. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153649. * edge_blur: number; // from 0 to x (1 for realism)
  153650. * distortion: number; // from 0 to x (1 for realism)
  153651. * grain_amount: number; // from 0 to 1
  153652. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153653. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153654. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153655. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153656. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153657. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153658. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153659. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153660. * }
  153661. * Note: if an effect parameter is unset, effect is disabled
  153662. *
  153663. * @param name The rendering pipeline name
  153664. * @param parameters - An object containing all parameters (see above)
  153665. * @param scene The scene linked to this pipeline
  153666. * @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)
  153667. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153668. */
  153669. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153670. /**
  153671. * Get the class name
  153672. * @returns "LensRenderingPipeline"
  153673. */
  153674. getClassName(): string;
  153675. /**
  153676. * Gets associated scene
  153677. */
  153678. get scene(): Scene;
  153679. /**
  153680. * Gets or sets the edge blur
  153681. */
  153682. get edgeBlur(): number;
  153683. set edgeBlur(value: number);
  153684. /**
  153685. * Gets or sets the grain amount
  153686. */
  153687. get grainAmount(): number;
  153688. set grainAmount(value: number);
  153689. /**
  153690. * Gets or sets the chromatic aberration amount
  153691. */
  153692. get chromaticAberration(): number;
  153693. set chromaticAberration(value: number);
  153694. /**
  153695. * Gets or sets the depth of field aperture
  153696. */
  153697. get dofAperture(): number;
  153698. set dofAperture(value: number);
  153699. /**
  153700. * Gets or sets the edge distortion
  153701. */
  153702. get edgeDistortion(): number;
  153703. set edgeDistortion(value: number);
  153704. /**
  153705. * Gets or sets the depth of field distortion
  153706. */
  153707. get dofDistortion(): number;
  153708. set dofDistortion(value: number);
  153709. /**
  153710. * Gets or sets the darken out of focus amount
  153711. */
  153712. get darkenOutOfFocus(): number;
  153713. set darkenOutOfFocus(value: number);
  153714. /**
  153715. * Gets or sets a boolean indicating if blur noise is enabled
  153716. */
  153717. get blurNoise(): boolean;
  153718. set blurNoise(value: boolean);
  153719. /**
  153720. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153721. */
  153722. get pentagonBokeh(): boolean;
  153723. set pentagonBokeh(value: boolean);
  153724. /**
  153725. * Gets or sets the highlight grain amount
  153726. */
  153727. get highlightsGain(): number;
  153728. set highlightsGain(value: number);
  153729. /**
  153730. * Gets or sets the highlight threshold
  153731. */
  153732. get highlightsThreshold(): number;
  153733. set highlightsThreshold(value: number);
  153734. /**
  153735. * Sets the amount of blur at the edges
  153736. * @param amount blur amount
  153737. */
  153738. setEdgeBlur(amount: number): void;
  153739. /**
  153740. * Sets edge blur to 0
  153741. */
  153742. disableEdgeBlur(): void;
  153743. /**
  153744. * Sets the amout of grain
  153745. * @param amount Amount of grain
  153746. */
  153747. setGrainAmount(amount: number): void;
  153748. /**
  153749. * Set grain amount to 0
  153750. */
  153751. disableGrain(): void;
  153752. /**
  153753. * Sets the chromatic aberration amount
  153754. * @param amount amount of chromatic aberration
  153755. */
  153756. setChromaticAberration(amount: number): void;
  153757. /**
  153758. * Sets chromatic aberration amount to 0
  153759. */
  153760. disableChromaticAberration(): void;
  153761. /**
  153762. * Sets the EdgeDistortion amount
  153763. * @param amount amount of EdgeDistortion
  153764. */
  153765. setEdgeDistortion(amount: number): void;
  153766. /**
  153767. * Sets edge distortion to 0
  153768. */
  153769. disableEdgeDistortion(): void;
  153770. /**
  153771. * Sets the FocusDistance amount
  153772. * @param amount amount of FocusDistance
  153773. */
  153774. setFocusDistance(amount: number): void;
  153775. /**
  153776. * Disables depth of field
  153777. */
  153778. disableDepthOfField(): void;
  153779. /**
  153780. * Sets the Aperture amount
  153781. * @param amount amount of Aperture
  153782. */
  153783. setAperture(amount: number): void;
  153784. /**
  153785. * Sets the DarkenOutOfFocus amount
  153786. * @param amount amount of DarkenOutOfFocus
  153787. */
  153788. setDarkenOutOfFocus(amount: number): void;
  153789. private _pentagonBokehIsEnabled;
  153790. /**
  153791. * Creates a pentagon bokeh effect
  153792. */
  153793. enablePentagonBokeh(): void;
  153794. /**
  153795. * Disables the pentagon bokeh effect
  153796. */
  153797. disablePentagonBokeh(): void;
  153798. /**
  153799. * Enables noise blur
  153800. */
  153801. enableNoiseBlur(): void;
  153802. /**
  153803. * Disables noise blur
  153804. */
  153805. disableNoiseBlur(): void;
  153806. /**
  153807. * Sets the HighlightsGain amount
  153808. * @param amount amount of HighlightsGain
  153809. */
  153810. setHighlightsGain(amount: number): void;
  153811. /**
  153812. * Sets the HighlightsThreshold amount
  153813. * @param amount amount of HighlightsThreshold
  153814. */
  153815. setHighlightsThreshold(amount: number): void;
  153816. /**
  153817. * Disables highlights
  153818. */
  153819. disableHighlights(): void;
  153820. /**
  153821. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153822. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153823. */
  153824. dispose(disableDepthRender?: boolean): void;
  153825. private _createChromaticAberrationPostProcess;
  153826. private _createHighlightsPostProcess;
  153827. private _createDepthOfFieldPostProcess;
  153828. private _createGrainTexture;
  153829. }
  153830. }
  153831. declare module BABYLON {
  153832. /**
  153833. * Contains all parameters needed for the prepass to perform
  153834. * screen space subsurface scattering
  153835. */
  153836. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153837. /**
  153838. * Is subsurface enabled
  153839. */
  153840. enabled: boolean;
  153841. /**
  153842. * Name of the configuration
  153843. */
  153844. name: string;
  153845. /**
  153846. * Textures that should be present in the MRT for this effect to work
  153847. */
  153848. readonly texturesRequired: number[];
  153849. }
  153850. }
  153851. declare module BABYLON {
  153852. /** @hidden */
  153853. export var ssao2PixelShader: {
  153854. name: string;
  153855. shader: string;
  153856. };
  153857. }
  153858. declare module BABYLON {
  153859. /** @hidden */
  153860. export var ssaoCombinePixelShader: {
  153861. name: string;
  153862. shader: string;
  153863. };
  153864. }
  153865. declare module BABYLON {
  153866. /**
  153867. * Render pipeline to produce ssao effect
  153868. */
  153869. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153870. /**
  153871. * @ignore
  153872. * The PassPostProcess id in the pipeline that contains the original scene color
  153873. */
  153874. SSAOOriginalSceneColorEffect: string;
  153875. /**
  153876. * @ignore
  153877. * The SSAO PostProcess id in the pipeline
  153878. */
  153879. SSAORenderEffect: string;
  153880. /**
  153881. * @ignore
  153882. * The horizontal blur PostProcess id in the pipeline
  153883. */
  153884. SSAOBlurHRenderEffect: string;
  153885. /**
  153886. * @ignore
  153887. * The vertical blur PostProcess id in the pipeline
  153888. */
  153889. SSAOBlurVRenderEffect: string;
  153890. /**
  153891. * @ignore
  153892. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153893. */
  153894. SSAOCombineRenderEffect: string;
  153895. /**
  153896. * The output strength of the SSAO post-process. Default value is 1.0.
  153897. */
  153898. totalStrength: number;
  153899. /**
  153900. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153901. */
  153902. maxZ: number;
  153903. /**
  153904. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153905. */
  153906. minZAspect: number;
  153907. private _samples;
  153908. /**
  153909. * Number of samples used for the SSAO calculations. Default value is 8
  153910. */
  153911. set samples(n: number);
  153912. get samples(): number;
  153913. private _textureSamples;
  153914. /**
  153915. * Number of samples to use for antialiasing
  153916. */
  153917. set textureSamples(n: number);
  153918. get textureSamples(): number;
  153919. /**
  153920. * Force rendering the geometry through geometry buffer
  153921. */
  153922. private _forceGeometryBuffer;
  153923. /**
  153924. * Ratio object used for SSAO ratio and blur ratio
  153925. */
  153926. private _ratio;
  153927. /**
  153928. * Dynamically generated sphere sampler.
  153929. */
  153930. private _sampleSphere;
  153931. /**
  153932. * Blur filter offsets
  153933. */
  153934. private _samplerOffsets;
  153935. private _expensiveBlur;
  153936. /**
  153937. * If bilateral blur should be used
  153938. */
  153939. set expensiveBlur(b: boolean);
  153940. get expensiveBlur(): boolean;
  153941. /**
  153942. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153943. */
  153944. radius: number;
  153945. /**
  153946. * The base color of the SSAO post-process
  153947. * The final result is "base + ssao" between [0, 1]
  153948. */
  153949. base: number;
  153950. /**
  153951. * Support test.
  153952. */
  153953. static get IsSupported(): boolean;
  153954. private _scene;
  153955. private _randomTexture;
  153956. private _originalColorPostProcess;
  153957. private _ssaoPostProcess;
  153958. private _blurHPostProcess;
  153959. private _blurVPostProcess;
  153960. private _ssaoCombinePostProcess;
  153961. private _prePassRenderer;
  153962. /**
  153963. * Gets active scene
  153964. */
  153965. get scene(): Scene;
  153966. /**
  153967. * @constructor
  153968. * @param name The rendering pipeline name
  153969. * @param scene The scene linked to this pipeline
  153970. * @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 }
  153971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153972. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153973. */
  153974. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153975. /**
  153976. * Get the class name
  153977. * @returns "SSAO2RenderingPipeline"
  153978. */
  153979. getClassName(): string;
  153980. /**
  153981. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153982. */
  153983. dispose(disableGeometryBufferRenderer?: boolean): void;
  153984. private _createBlurPostProcess;
  153985. /** @hidden */
  153986. _rebuild(): void;
  153987. private _bits;
  153988. private _radicalInverse_VdC;
  153989. private _hammersley;
  153990. private _hemisphereSample_uniform;
  153991. private _generateHemisphere;
  153992. private _getDefinesForSSAO;
  153993. private _createSSAOPostProcess;
  153994. private _createSSAOCombinePostProcess;
  153995. private _createRandomTexture;
  153996. /**
  153997. * Serialize the rendering pipeline (Used when exporting)
  153998. * @returns the serialized object
  153999. */
  154000. serialize(): any;
  154001. /**
  154002. * Parse the serialized pipeline
  154003. * @param source Source pipeline.
  154004. * @param scene The scene to load the pipeline to.
  154005. * @param rootUrl The URL of the serialized pipeline.
  154006. * @returns An instantiated pipeline from the serialized object.
  154007. */
  154008. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  154009. }
  154010. }
  154011. declare module BABYLON {
  154012. /** @hidden */
  154013. export var ssaoPixelShader: {
  154014. name: string;
  154015. shader: string;
  154016. };
  154017. }
  154018. declare module BABYLON {
  154019. /**
  154020. * Render pipeline to produce ssao effect
  154021. */
  154022. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  154023. /**
  154024. * @ignore
  154025. * The PassPostProcess id in the pipeline that contains the original scene color
  154026. */
  154027. SSAOOriginalSceneColorEffect: string;
  154028. /**
  154029. * @ignore
  154030. * The SSAO PostProcess id in the pipeline
  154031. */
  154032. SSAORenderEffect: string;
  154033. /**
  154034. * @ignore
  154035. * The horizontal blur PostProcess id in the pipeline
  154036. */
  154037. SSAOBlurHRenderEffect: string;
  154038. /**
  154039. * @ignore
  154040. * The vertical blur PostProcess id in the pipeline
  154041. */
  154042. SSAOBlurVRenderEffect: string;
  154043. /**
  154044. * @ignore
  154045. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  154046. */
  154047. SSAOCombineRenderEffect: string;
  154048. /**
  154049. * The output strength of the SSAO post-process. Default value is 1.0.
  154050. */
  154051. totalStrength: number;
  154052. /**
  154053. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  154054. */
  154055. radius: number;
  154056. /**
  154057. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  154058. * Must not be equal to fallOff and superior to fallOff.
  154059. * Default value is 0.0075
  154060. */
  154061. area: number;
  154062. /**
  154063. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  154064. * Must not be equal to area and inferior to area.
  154065. * Default value is 0.000001
  154066. */
  154067. fallOff: number;
  154068. /**
  154069. * The base color of the SSAO post-process
  154070. * The final result is "base + ssao" between [0, 1]
  154071. */
  154072. base: number;
  154073. private _scene;
  154074. private _depthTexture;
  154075. private _randomTexture;
  154076. private _originalColorPostProcess;
  154077. private _ssaoPostProcess;
  154078. private _blurHPostProcess;
  154079. private _blurVPostProcess;
  154080. private _ssaoCombinePostProcess;
  154081. private _firstUpdate;
  154082. /**
  154083. * Gets active scene
  154084. */
  154085. get scene(): Scene;
  154086. /**
  154087. * @constructor
  154088. * @param name - The rendering pipeline name
  154089. * @param scene - The scene linked to this pipeline
  154090. * @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 }
  154091. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  154092. */
  154093. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  154094. /**
  154095. * Get the class name
  154096. * @returns "SSAORenderingPipeline"
  154097. */
  154098. getClassName(): string;
  154099. /**
  154100. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  154101. */
  154102. dispose(disableDepthRender?: boolean): void;
  154103. private _createBlurPostProcess;
  154104. /** @hidden */
  154105. _rebuild(): void;
  154106. private _createSSAOPostProcess;
  154107. private _createSSAOCombinePostProcess;
  154108. private _createRandomTexture;
  154109. }
  154110. }
  154111. declare module BABYLON {
  154112. /**
  154113. * Contains all parameters needed for the prepass to perform
  154114. * screen space reflections
  154115. */
  154116. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  154117. /**
  154118. * Is ssr enabled
  154119. */
  154120. enabled: boolean;
  154121. /**
  154122. * Name of the configuration
  154123. */
  154124. name: string;
  154125. /**
  154126. * Textures that should be present in the MRT for this effect to work
  154127. */
  154128. readonly texturesRequired: number[];
  154129. }
  154130. }
  154131. declare module BABYLON {
  154132. /** @hidden */
  154133. export var screenSpaceReflectionPixelShader: {
  154134. name: string;
  154135. shader: string;
  154136. };
  154137. }
  154138. declare module BABYLON {
  154139. /**
  154140. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  154141. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  154142. */
  154143. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  154144. /**
  154145. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  154146. */
  154147. threshold: number;
  154148. /**
  154149. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  154150. */
  154151. strength: number;
  154152. /**
  154153. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  154154. */
  154155. reflectionSpecularFalloffExponent: number;
  154156. /**
  154157. * 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]
  154158. */
  154159. step: number;
  154160. /**
  154161. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  154162. */
  154163. roughnessFactor: number;
  154164. private _forceGeometryBuffer;
  154165. private _geometryBufferRenderer;
  154166. private _prePassRenderer;
  154167. private _enableSmoothReflections;
  154168. private _reflectionSamples;
  154169. private _smoothSteps;
  154170. /**
  154171. * Gets a string identifying the name of the class
  154172. * @returns "ScreenSpaceReflectionPostProcess" string
  154173. */
  154174. getClassName(): string;
  154175. /**
  154176. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  154177. * @param name The name of the effect.
  154178. * @param scene The scene containing the objects to calculate reflections.
  154179. * @param options The required width/height ratio to downsize to before computing the render pass.
  154180. * @param camera The camera to apply the render pass to.
  154181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154182. * @param engine The engine which the post process will be applied. (default: current engine)
  154183. * @param reusable If the post process can be reused on the same frame. (default: false)
  154184. * @param textureType Type of textures used when performing the post process. (default: 0)
  154185. * @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)
  154186. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  154187. */
  154188. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  154189. /**
  154190. * Gets wether or not smoothing reflections is enabled.
  154191. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154192. */
  154193. get enableSmoothReflections(): boolean;
  154194. /**
  154195. * Sets wether or not smoothing reflections is enabled.
  154196. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154197. */
  154198. set enableSmoothReflections(enabled: boolean);
  154199. /**
  154200. * Gets the number of samples taken while computing reflections. More samples count is high,
  154201. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154202. */
  154203. get reflectionSamples(): number;
  154204. /**
  154205. * Sets the number of samples taken while computing reflections. More samples count is high,
  154206. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154207. */
  154208. set reflectionSamples(samples: number);
  154209. /**
  154210. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  154211. * more the post-process will require GPU power and can generate a drop in FPS.
  154212. * Default value (5.0) work pretty well in all cases but can be adjusted.
  154213. */
  154214. get smoothSteps(): number;
  154215. set smoothSteps(steps: number);
  154216. private _updateEffectDefines;
  154217. /** @hidden */
  154218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  154219. }
  154220. }
  154221. declare module BABYLON {
  154222. /** @hidden */
  154223. export var standardPixelShader: {
  154224. name: string;
  154225. shader: string;
  154226. };
  154227. }
  154228. declare module BABYLON {
  154229. /**
  154230. * Standard rendering pipeline
  154231. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154232. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  154233. */
  154234. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  154235. /**
  154236. * Public members
  154237. */
  154238. /**
  154239. * Post-process which contains the original scene color before the pipeline applies all the effects
  154240. */
  154241. originalPostProcess: Nullable<PostProcess>;
  154242. /**
  154243. * Post-process used to down scale an image x4
  154244. */
  154245. downSampleX4PostProcess: Nullable<PostProcess>;
  154246. /**
  154247. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  154248. */
  154249. brightPassPostProcess: Nullable<PostProcess>;
  154250. /**
  154251. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  154252. */
  154253. blurHPostProcesses: PostProcess[];
  154254. /**
  154255. * Post-process array storing all the vertical blur post-processes used by the pipeline
  154256. */
  154257. blurVPostProcesses: PostProcess[];
  154258. /**
  154259. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  154260. */
  154261. textureAdderPostProcess: Nullable<PostProcess>;
  154262. /**
  154263. * Post-process used to create volumetric lighting effect
  154264. */
  154265. volumetricLightPostProcess: Nullable<PostProcess>;
  154266. /**
  154267. * Post-process used to smooth the previous volumetric light post-process on the X axis
  154268. */
  154269. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  154270. /**
  154271. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  154272. */
  154273. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  154274. /**
  154275. * Post-process used to merge the volumetric light effect and the real scene color
  154276. */
  154277. volumetricLightMergePostProces: Nullable<PostProcess>;
  154278. /**
  154279. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  154280. */
  154281. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  154282. /**
  154283. * Base post-process used to calculate the average luminance of the final image for HDR
  154284. */
  154285. luminancePostProcess: Nullable<PostProcess>;
  154286. /**
  154287. * Post-processes used to create down sample post-processes in order to get
  154288. * the average luminance of the final image for HDR
  154289. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  154290. */
  154291. luminanceDownSamplePostProcesses: PostProcess[];
  154292. /**
  154293. * Post-process used to create a HDR effect (light adaptation)
  154294. */
  154295. hdrPostProcess: Nullable<PostProcess>;
  154296. /**
  154297. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  154298. */
  154299. textureAdderFinalPostProcess: Nullable<PostProcess>;
  154300. /**
  154301. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  154302. */
  154303. lensFlareFinalPostProcess: Nullable<PostProcess>;
  154304. /**
  154305. * Post-process used to merge the final HDR post-process and the real scene color
  154306. */
  154307. hdrFinalPostProcess: Nullable<PostProcess>;
  154308. /**
  154309. * Post-process used to create a lens flare effect
  154310. */
  154311. lensFlarePostProcess: Nullable<PostProcess>;
  154312. /**
  154313. * Post-process that merges the result of the lens flare post-process and the real scene color
  154314. */
  154315. lensFlareComposePostProcess: Nullable<PostProcess>;
  154316. /**
  154317. * Post-process used to create a motion blur effect
  154318. */
  154319. motionBlurPostProcess: Nullable<PostProcess>;
  154320. /**
  154321. * Post-process used to create a depth of field effect
  154322. */
  154323. depthOfFieldPostProcess: Nullable<PostProcess>;
  154324. /**
  154325. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  154326. */
  154327. fxaaPostProcess: Nullable<FxaaPostProcess>;
  154328. /**
  154329. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  154330. */
  154331. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  154332. /**
  154333. * Represents the brightness threshold in order to configure the illuminated surfaces
  154334. */
  154335. brightThreshold: number;
  154336. /**
  154337. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  154338. */
  154339. blurWidth: number;
  154340. /**
  154341. * Sets if the blur for highlighted surfaces must be only horizontal
  154342. */
  154343. horizontalBlur: boolean;
  154344. /**
  154345. * Gets the overall exposure used by the pipeline
  154346. */
  154347. get exposure(): number;
  154348. /**
  154349. * Sets the overall exposure used by the pipeline
  154350. */
  154351. set exposure(value: number);
  154352. /**
  154353. * Texture used typically to simulate "dirty" on camera lens
  154354. */
  154355. lensTexture: Nullable<Texture>;
  154356. /**
  154357. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  154358. */
  154359. volumetricLightCoefficient: number;
  154360. /**
  154361. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  154362. */
  154363. volumetricLightPower: number;
  154364. /**
  154365. * Used the set the blur intensity to smooth the volumetric lights
  154366. */
  154367. volumetricLightBlurScale: number;
  154368. /**
  154369. * Light (spot or directional) used to generate the volumetric lights rays
  154370. * The source light must have a shadow generate so the pipeline can get its
  154371. * depth map
  154372. */
  154373. sourceLight: Nullable<SpotLight | DirectionalLight>;
  154374. /**
  154375. * For eye adaptation, represents the minimum luminance the eye can see
  154376. */
  154377. hdrMinimumLuminance: number;
  154378. /**
  154379. * For eye adaptation, represents the decrease luminance speed
  154380. */
  154381. hdrDecreaseRate: number;
  154382. /**
  154383. * For eye adaptation, represents the increase luminance speed
  154384. */
  154385. hdrIncreaseRate: number;
  154386. /**
  154387. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154388. */
  154389. get hdrAutoExposure(): boolean;
  154390. /**
  154391. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154392. */
  154393. set hdrAutoExposure(value: boolean);
  154394. /**
  154395. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  154396. */
  154397. lensColorTexture: Nullable<Texture>;
  154398. /**
  154399. * The overall strengh for the lens flare effect
  154400. */
  154401. lensFlareStrength: number;
  154402. /**
  154403. * Dispersion coefficient for lens flare ghosts
  154404. */
  154405. lensFlareGhostDispersal: number;
  154406. /**
  154407. * Main lens flare halo width
  154408. */
  154409. lensFlareHaloWidth: number;
  154410. /**
  154411. * Based on the lens distortion effect, defines how much the lens flare result
  154412. * is distorted
  154413. */
  154414. lensFlareDistortionStrength: number;
  154415. /**
  154416. * Configures the blur intensity used for for lens flare (halo)
  154417. */
  154418. lensFlareBlurWidth: number;
  154419. /**
  154420. * Lens star texture must be used to simulate rays on the flares and is available
  154421. * in the documentation
  154422. */
  154423. lensStarTexture: Nullable<Texture>;
  154424. /**
  154425. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154426. * flare effect by taking account of the dirt texture
  154427. */
  154428. lensFlareDirtTexture: Nullable<Texture>;
  154429. /**
  154430. * Represents the focal length for the depth of field effect
  154431. */
  154432. depthOfFieldDistance: number;
  154433. /**
  154434. * Represents the blur intensity for the blurred part of the depth of field effect
  154435. */
  154436. depthOfFieldBlurWidth: number;
  154437. /**
  154438. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154439. */
  154440. get motionStrength(): number;
  154441. /**
  154442. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154443. */
  154444. set motionStrength(strength: number);
  154445. /**
  154446. * Gets wether or not the motion blur post-process is object based or screen based.
  154447. */
  154448. get objectBasedMotionBlur(): boolean;
  154449. /**
  154450. * Sets wether or not the motion blur post-process should be object based or screen based
  154451. */
  154452. set objectBasedMotionBlur(value: boolean);
  154453. /**
  154454. * List of animations for the pipeline (IAnimatable implementation)
  154455. */
  154456. animations: Animation[];
  154457. /**
  154458. * Private members
  154459. */
  154460. private _scene;
  154461. private _currentDepthOfFieldSource;
  154462. private _basePostProcess;
  154463. private _fixedExposure;
  154464. private _currentExposure;
  154465. private _hdrAutoExposure;
  154466. private _hdrCurrentLuminance;
  154467. private _motionStrength;
  154468. private _isObjectBasedMotionBlur;
  154469. private _floatTextureType;
  154470. private _camerasToBeAttached;
  154471. private _ratio;
  154472. private _bloomEnabled;
  154473. private _depthOfFieldEnabled;
  154474. private _vlsEnabled;
  154475. private _lensFlareEnabled;
  154476. private _hdrEnabled;
  154477. private _motionBlurEnabled;
  154478. private _fxaaEnabled;
  154479. private _screenSpaceReflectionsEnabled;
  154480. private _motionBlurSamples;
  154481. private _volumetricLightStepsCount;
  154482. private _samples;
  154483. /**
  154484. * @ignore
  154485. * Specifies if the bloom pipeline is enabled
  154486. */
  154487. get BloomEnabled(): boolean;
  154488. set BloomEnabled(enabled: boolean);
  154489. /**
  154490. * @ignore
  154491. * Specifies if the depth of field pipeline is enabed
  154492. */
  154493. get DepthOfFieldEnabled(): boolean;
  154494. set DepthOfFieldEnabled(enabled: boolean);
  154495. /**
  154496. * @ignore
  154497. * Specifies if the lens flare pipeline is enabed
  154498. */
  154499. get LensFlareEnabled(): boolean;
  154500. set LensFlareEnabled(enabled: boolean);
  154501. /**
  154502. * @ignore
  154503. * Specifies if the HDR pipeline is enabled
  154504. */
  154505. get HDREnabled(): boolean;
  154506. set HDREnabled(enabled: boolean);
  154507. /**
  154508. * @ignore
  154509. * Specifies if the volumetric lights scattering effect is enabled
  154510. */
  154511. get VLSEnabled(): boolean;
  154512. set VLSEnabled(enabled: boolean);
  154513. /**
  154514. * @ignore
  154515. * Specifies if the motion blur effect is enabled
  154516. */
  154517. get MotionBlurEnabled(): boolean;
  154518. set MotionBlurEnabled(enabled: boolean);
  154519. /**
  154520. * Specifies if anti-aliasing is enabled
  154521. */
  154522. get fxaaEnabled(): boolean;
  154523. set fxaaEnabled(enabled: boolean);
  154524. /**
  154525. * Specifies if screen space reflections are enabled.
  154526. */
  154527. get screenSpaceReflectionsEnabled(): boolean;
  154528. set screenSpaceReflectionsEnabled(enabled: boolean);
  154529. /**
  154530. * Specifies the number of steps used to calculate the volumetric lights
  154531. * Typically in interval [50, 200]
  154532. */
  154533. get volumetricLightStepsCount(): number;
  154534. set volumetricLightStepsCount(count: number);
  154535. /**
  154536. * Specifies the number of samples used for the motion blur effect
  154537. * Typically in interval [16, 64]
  154538. */
  154539. get motionBlurSamples(): number;
  154540. set motionBlurSamples(samples: number);
  154541. /**
  154542. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154543. */
  154544. get samples(): number;
  154545. set samples(sampleCount: number);
  154546. /**
  154547. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154548. * @constructor
  154549. * @param name The rendering pipeline name
  154550. * @param scene The scene linked to this pipeline
  154551. * @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)
  154552. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154553. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154554. */
  154555. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154556. private _buildPipeline;
  154557. private _createDownSampleX4PostProcess;
  154558. private _createBrightPassPostProcess;
  154559. private _createBlurPostProcesses;
  154560. private _createTextureAdderPostProcess;
  154561. private _createVolumetricLightPostProcess;
  154562. private _createLuminancePostProcesses;
  154563. private _createHdrPostProcess;
  154564. private _createLensFlarePostProcess;
  154565. private _createDepthOfFieldPostProcess;
  154566. private _createMotionBlurPostProcess;
  154567. private _getDepthTexture;
  154568. private _disposePostProcesses;
  154569. /**
  154570. * Dispose of the pipeline and stop all post processes
  154571. */
  154572. dispose(): void;
  154573. /**
  154574. * Serialize the rendering pipeline (Used when exporting)
  154575. * @returns the serialized object
  154576. */
  154577. serialize(): any;
  154578. /**
  154579. * Parse the serialized pipeline
  154580. * @param source Source pipeline.
  154581. * @param scene The scene to load the pipeline to.
  154582. * @param rootUrl The URL of the serialized pipeline.
  154583. * @returns An instantiated pipeline from the serialized object.
  154584. */
  154585. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154586. /**
  154587. * Luminance steps
  154588. */
  154589. static LuminanceSteps: number;
  154590. }
  154591. }
  154592. declare module BABYLON {
  154593. /** @hidden */
  154594. export var stereoscopicInterlacePixelShader: {
  154595. name: string;
  154596. shader: string;
  154597. };
  154598. }
  154599. declare module BABYLON {
  154600. /**
  154601. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154602. */
  154603. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154604. private _stepSize;
  154605. private _passedProcess;
  154606. /**
  154607. * Gets a string identifying the name of the class
  154608. * @returns "StereoscopicInterlacePostProcessI" string
  154609. */
  154610. getClassName(): string;
  154611. /**
  154612. * Initializes a StereoscopicInterlacePostProcessI
  154613. * @param name The name of the effect.
  154614. * @param rigCameras The rig cameras to be appled to the post process
  154615. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154616. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154618. * @param engine The engine which the post process will be applied. (default: current engine)
  154619. * @param reusable If the post process can be reused on the same frame. (default: false)
  154620. */
  154621. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154622. }
  154623. /**
  154624. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154625. */
  154626. export class StereoscopicInterlacePostProcess extends PostProcess {
  154627. private _stepSize;
  154628. private _passedProcess;
  154629. /**
  154630. * Gets a string identifying the name of the class
  154631. * @returns "StereoscopicInterlacePostProcess" string
  154632. */
  154633. getClassName(): string;
  154634. /**
  154635. * Initializes a StereoscopicInterlacePostProcess
  154636. * @param name The name of the effect.
  154637. * @param rigCameras The rig cameras to be appled to the post process
  154638. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154640. * @param engine The engine which the post process will be applied. (default: current engine)
  154641. * @param reusable If the post process can be reused on the same frame. (default: false)
  154642. */
  154643. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154644. }
  154645. }
  154646. declare module BABYLON {
  154647. /** @hidden */
  154648. export var tonemapPixelShader: {
  154649. name: string;
  154650. shader: string;
  154651. };
  154652. }
  154653. declare module BABYLON {
  154654. /** Defines operator used for tonemapping */
  154655. export enum TonemappingOperator {
  154656. /** Hable */
  154657. Hable = 0,
  154658. /** Reinhard */
  154659. Reinhard = 1,
  154660. /** HejiDawson */
  154661. HejiDawson = 2,
  154662. /** Photographic */
  154663. Photographic = 3
  154664. }
  154665. /**
  154666. * Defines a post process to apply tone mapping
  154667. */
  154668. export class TonemapPostProcess extends PostProcess {
  154669. private _operator;
  154670. /** Defines the required exposure adjustement */
  154671. exposureAdjustment: number;
  154672. /**
  154673. * Gets a string identifying the name of the class
  154674. * @returns "TonemapPostProcess" string
  154675. */
  154676. getClassName(): string;
  154677. /**
  154678. * Creates a new TonemapPostProcess
  154679. * @param name defines the name of the postprocess
  154680. * @param _operator defines the operator to use
  154681. * @param exposureAdjustment defines the required exposure adjustement
  154682. * @param camera defines the camera to use (can be null)
  154683. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154684. * @param engine defines the hosting engine (can be ignore if camera is set)
  154685. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154686. */
  154687. constructor(name: string, _operator: TonemappingOperator,
  154688. /** Defines the required exposure adjustement */
  154689. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154690. }
  154691. }
  154692. declare module BABYLON {
  154693. /** @hidden */
  154694. export var volumetricLightScatteringPixelShader: {
  154695. name: string;
  154696. shader: string;
  154697. };
  154698. }
  154699. declare module BABYLON {
  154700. /** @hidden */
  154701. export var volumetricLightScatteringPassVertexShader: {
  154702. name: string;
  154703. shader: string;
  154704. };
  154705. }
  154706. declare module BABYLON {
  154707. /** @hidden */
  154708. export var volumetricLightScatteringPassPixelShader: {
  154709. name: string;
  154710. shader: string;
  154711. };
  154712. }
  154713. declare module BABYLON {
  154714. /**
  154715. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154716. */
  154717. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154718. private _volumetricLightScatteringPass;
  154719. private _volumetricLightScatteringRTT;
  154720. private _viewPort;
  154721. private _screenCoordinates;
  154722. private _cachedDefines;
  154723. /**
  154724. * If not undefined, the mesh position is computed from the attached node position
  154725. */
  154726. attachedNode: {
  154727. position: Vector3;
  154728. };
  154729. /**
  154730. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154731. */
  154732. customMeshPosition: Vector3;
  154733. /**
  154734. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154735. */
  154736. useCustomMeshPosition: boolean;
  154737. /**
  154738. * If the post-process should inverse the light scattering direction
  154739. */
  154740. invert: boolean;
  154741. /**
  154742. * The internal mesh used by the post-process
  154743. */
  154744. mesh: Mesh;
  154745. /**
  154746. * @hidden
  154747. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154748. */
  154749. get useDiffuseColor(): boolean;
  154750. set useDiffuseColor(useDiffuseColor: boolean);
  154751. /**
  154752. * Array containing the excluded meshes not rendered in the internal pass
  154753. */
  154754. excludedMeshes: AbstractMesh[];
  154755. /**
  154756. * Controls the overall intensity of the post-process
  154757. */
  154758. exposure: number;
  154759. /**
  154760. * Dissipates each sample's contribution in range [0, 1]
  154761. */
  154762. decay: number;
  154763. /**
  154764. * Controls the overall intensity of each sample
  154765. */
  154766. weight: number;
  154767. /**
  154768. * Controls the density of each sample
  154769. */
  154770. density: number;
  154771. /**
  154772. * @constructor
  154773. * @param name The post-process name
  154774. * @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)
  154775. * @param camera The camera that the post-process will be attached to
  154776. * @param mesh The mesh used to create the light scattering
  154777. * @param samples The post-process quality, default 100
  154778. * @param samplingModeThe post-process filtering mode
  154779. * @param engine The babylon engine
  154780. * @param reusable If the post-process is reusable
  154781. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154782. */
  154783. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154784. /**
  154785. * Returns the string "VolumetricLightScatteringPostProcess"
  154786. * @returns "VolumetricLightScatteringPostProcess"
  154787. */
  154788. getClassName(): string;
  154789. private _isReady;
  154790. /**
  154791. * Sets the new light position for light scattering effect
  154792. * @param position The new custom light position
  154793. */
  154794. setCustomMeshPosition(position: Vector3): void;
  154795. /**
  154796. * Returns the light position for light scattering effect
  154797. * @return Vector3 The custom light position
  154798. */
  154799. getCustomMeshPosition(): Vector3;
  154800. /**
  154801. * Disposes the internal assets and detaches the post-process from the camera
  154802. */
  154803. dispose(camera: Camera): void;
  154804. /**
  154805. * Returns the render target texture used by the post-process
  154806. * @return the render target texture used by the post-process
  154807. */
  154808. getPass(): RenderTargetTexture;
  154809. private _meshExcluded;
  154810. private _createPass;
  154811. private _updateMeshScreenCoordinates;
  154812. /**
  154813. * Creates a default mesh for the Volumeric Light Scattering post-process
  154814. * @param name The mesh name
  154815. * @param scene The scene where to create the mesh
  154816. * @return the default mesh
  154817. */
  154818. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154819. }
  154820. }
  154821. declare module BABYLON {
  154822. /** @hidden */
  154823. export var screenSpaceCurvaturePixelShader: {
  154824. name: string;
  154825. shader: string;
  154826. };
  154827. }
  154828. declare module BABYLON {
  154829. /**
  154830. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154831. */
  154832. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154833. /**
  154834. * Defines how much ridge the curvature effect displays.
  154835. */
  154836. ridge: number;
  154837. /**
  154838. * Defines how much valley the curvature effect displays.
  154839. */
  154840. valley: number;
  154841. private _geometryBufferRenderer;
  154842. /**
  154843. * Gets a string identifying the name of the class
  154844. * @returns "ScreenSpaceCurvaturePostProcess" string
  154845. */
  154846. getClassName(): string;
  154847. /**
  154848. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154849. * @param name The name of the effect.
  154850. * @param scene The scene containing the objects to blur according to their velocity.
  154851. * @param options The required width/height ratio to downsize to before computing the render pass.
  154852. * @param camera The camera to apply the render pass to.
  154853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154854. * @param engine The engine which the post process will be applied. (default: current engine)
  154855. * @param reusable If the post process can be reused on the same frame. (default: false)
  154856. * @param textureType Type of textures used when performing the post process. (default: 0)
  154857. * @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)
  154858. */
  154859. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154860. /**
  154861. * Support test.
  154862. */
  154863. static get IsSupported(): boolean;
  154864. /** @hidden */
  154865. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154866. }
  154867. }
  154868. declare module BABYLON {
  154869. interface Scene {
  154870. /** @hidden (Backing field) */
  154871. _boundingBoxRenderer: BoundingBoxRenderer;
  154872. /** @hidden (Backing field) */
  154873. _forceShowBoundingBoxes: boolean;
  154874. /**
  154875. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154876. */
  154877. forceShowBoundingBoxes: boolean;
  154878. /**
  154879. * Gets the bounding box renderer associated with the scene
  154880. * @returns a BoundingBoxRenderer
  154881. */
  154882. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154883. }
  154884. interface AbstractMesh {
  154885. /** @hidden (Backing field) */
  154886. _showBoundingBox: boolean;
  154887. /**
  154888. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154889. */
  154890. showBoundingBox: boolean;
  154891. }
  154892. /**
  154893. * Component responsible of rendering the bounding box of the meshes in a scene.
  154894. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154895. */
  154896. export class BoundingBoxRenderer implements ISceneComponent {
  154897. /**
  154898. * The component name helpfull to identify the component in the list of scene components.
  154899. */
  154900. readonly name: string;
  154901. /**
  154902. * The scene the component belongs to.
  154903. */
  154904. scene: Scene;
  154905. /**
  154906. * Color of the bounding box lines placed in front of an object
  154907. */
  154908. frontColor: Color3;
  154909. /**
  154910. * Color of the bounding box lines placed behind an object
  154911. */
  154912. backColor: Color3;
  154913. /**
  154914. * Defines if the renderer should show the back lines or not
  154915. */
  154916. showBackLines: boolean;
  154917. /**
  154918. * Observable raised before rendering a bounding box
  154919. */
  154920. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154921. /**
  154922. * Observable raised after rendering a bounding box
  154923. */
  154924. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154925. /**
  154926. * Observable raised after resources are created
  154927. */
  154928. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154929. /**
  154930. * When false, no bounding boxes will be rendered
  154931. */
  154932. enabled: boolean;
  154933. /**
  154934. * @hidden
  154935. */
  154936. renderList: SmartArray<BoundingBox>;
  154937. private _colorShader;
  154938. private _vertexBuffers;
  154939. private _indexBuffer;
  154940. private _fillIndexBuffer;
  154941. private _fillIndexData;
  154942. /**
  154943. * Instantiates a new bounding box renderer in a scene.
  154944. * @param scene the scene the renderer renders in
  154945. */
  154946. constructor(scene: Scene);
  154947. /**
  154948. * Registers the component in a given scene
  154949. */
  154950. register(): void;
  154951. private _evaluateSubMesh;
  154952. private _preActiveMesh;
  154953. private _prepareResources;
  154954. private _createIndexBuffer;
  154955. /**
  154956. * Rebuilds the elements related to this component in case of
  154957. * context lost for instance.
  154958. */
  154959. rebuild(): void;
  154960. /**
  154961. * @hidden
  154962. */
  154963. reset(): void;
  154964. /**
  154965. * Render the bounding boxes of a specific rendering group
  154966. * @param renderingGroupId defines the rendering group to render
  154967. */
  154968. render(renderingGroupId: number): void;
  154969. /**
  154970. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154971. * @param mesh Define the mesh to render the occlusion bounding box for
  154972. */
  154973. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154974. /**
  154975. * Dispose and release the resources attached to this renderer.
  154976. */
  154977. dispose(): void;
  154978. }
  154979. }
  154980. declare module BABYLON {
  154981. interface Scene {
  154982. /** @hidden (Backing field) */
  154983. _depthRenderer: {
  154984. [id: string]: DepthRenderer;
  154985. };
  154986. /**
  154987. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154988. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154989. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154990. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154991. * @returns the created depth renderer
  154992. */
  154993. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154994. /**
  154995. * Disables a depth renderer for a given camera
  154996. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154997. */
  154998. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154999. }
  155000. /**
  155001. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  155002. * in several rendering techniques.
  155003. */
  155004. export class DepthRendererSceneComponent implements ISceneComponent {
  155005. /**
  155006. * The component name helpfull to identify the component in the list of scene components.
  155007. */
  155008. readonly name: string;
  155009. /**
  155010. * The scene the component belongs to.
  155011. */
  155012. scene: Scene;
  155013. /**
  155014. * Creates a new instance of the component for the given scene
  155015. * @param scene Defines the scene to register the component in
  155016. */
  155017. constructor(scene: Scene);
  155018. /**
  155019. * Registers the component in a given scene
  155020. */
  155021. register(): void;
  155022. /**
  155023. * Rebuilds the elements related to this component in case of
  155024. * context lost for instance.
  155025. */
  155026. rebuild(): void;
  155027. /**
  155028. * Disposes the component and the associated ressources
  155029. */
  155030. dispose(): void;
  155031. private _gatherRenderTargets;
  155032. private _gatherActiveCameraRenderTargets;
  155033. }
  155034. }
  155035. declare module BABYLON {
  155036. interface AbstractScene {
  155037. /** @hidden (Backing field) */
  155038. _prePassRenderer: Nullable<PrePassRenderer>;
  155039. /**
  155040. * Gets or Sets the current prepass renderer associated to the scene.
  155041. */
  155042. prePassRenderer: Nullable<PrePassRenderer>;
  155043. /**
  155044. * Enables the prepass and associates it with the scene
  155045. * @returns the PrePassRenderer
  155046. */
  155047. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  155048. /**
  155049. * Disables the prepass associated with the scene
  155050. */
  155051. disablePrePassRenderer(): void;
  155052. }
  155053. /**
  155054. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155055. * in several rendering techniques.
  155056. */
  155057. export class PrePassRendererSceneComponent implements ISceneComponent {
  155058. /**
  155059. * The component name helpful to identify the component in the list of scene components.
  155060. */
  155061. readonly name: string;
  155062. /**
  155063. * The scene the component belongs to.
  155064. */
  155065. scene: Scene;
  155066. /**
  155067. * Creates a new instance of the component for the given scene
  155068. * @param scene Defines the scene to register the component in
  155069. */
  155070. constructor(scene: Scene);
  155071. /**
  155072. * Registers the component in a given scene
  155073. */
  155074. register(): void;
  155075. private _beforeCameraDraw;
  155076. private _afterCameraDraw;
  155077. private _beforeClearStage;
  155078. private _beforeRenderingMeshStage;
  155079. private _afterRenderingMeshStage;
  155080. /**
  155081. * Rebuilds the elements related to this component in case of
  155082. * context lost for instance.
  155083. */
  155084. rebuild(): void;
  155085. /**
  155086. * Disposes the component and the associated ressources
  155087. */
  155088. dispose(): void;
  155089. }
  155090. }
  155091. declare module BABYLON {
  155092. /** @hidden */
  155093. export var fibonacci: {
  155094. name: string;
  155095. shader: string;
  155096. };
  155097. }
  155098. declare module BABYLON {
  155099. /** @hidden */
  155100. export var diffusionProfile: {
  155101. name: string;
  155102. shader: string;
  155103. };
  155104. }
  155105. declare module BABYLON {
  155106. /** @hidden */
  155107. export var subSurfaceScatteringPixelShader: {
  155108. name: string;
  155109. shader: string;
  155110. };
  155111. }
  155112. declare module BABYLON {
  155113. /**
  155114. * Sub surface scattering post process
  155115. */
  155116. export class SubSurfaceScatteringPostProcess extends PostProcess {
  155117. /**
  155118. * Gets a string identifying the name of the class
  155119. * @returns "SubSurfaceScatteringPostProcess" string
  155120. */
  155121. getClassName(): string;
  155122. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  155123. }
  155124. }
  155125. declare module BABYLON {
  155126. /**
  155127. * Contains all parameters needed for the prepass to perform
  155128. * screen space subsurface scattering
  155129. */
  155130. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  155131. /** @hidden */
  155132. static _SceneComponentInitialization: (scene: Scene) => void;
  155133. private _ssDiffusionS;
  155134. private _ssFilterRadii;
  155135. private _ssDiffusionD;
  155136. /**
  155137. * Post process to attach for screen space subsurface scattering
  155138. */
  155139. postProcess: SubSurfaceScatteringPostProcess;
  155140. /**
  155141. * Diffusion profile color for subsurface scattering
  155142. */
  155143. get ssDiffusionS(): number[];
  155144. /**
  155145. * Diffusion profile max color channel value for subsurface scattering
  155146. */
  155147. get ssDiffusionD(): number[];
  155148. /**
  155149. * Diffusion profile filter radius for subsurface scattering
  155150. */
  155151. get ssFilterRadii(): number[];
  155152. /**
  155153. * Is subsurface enabled
  155154. */
  155155. enabled: boolean;
  155156. /**
  155157. * Name of the configuration
  155158. */
  155159. name: string;
  155160. /**
  155161. * Diffusion profile colors for subsurface scattering
  155162. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  155163. * See ...
  155164. * Note that you can only store up to 5 of them
  155165. */
  155166. ssDiffusionProfileColors: Color3[];
  155167. /**
  155168. * Defines the ratio real world => scene units.
  155169. * Used for subsurface scattering
  155170. */
  155171. metersPerUnit: number;
  155172. /**
  155173. * Textures that should be present in the MRT for this effect to work
  155174. */
  155175. readonly texturesRequired: number[];
  155176. private _scene;
  155177. /**
  155178. * Builds a subsurface configuration object
  155179. * @param scene The scene
  155180. */
  155181. constructor(scene: Scene);
  155182. /**
  155183. * Adds a new diffusion profile.
  155184. * Useful for more realistic subsurface scattering on diverse materials.
  155185. * @param color The color of the diffusion profile. Should be the average color of the material.
  155186. * @return The index of the diffusion profile for the material subsurface configuration
  155187. */
  155188. addDiffusionProfile(color: Color3): number;
  155189. /**
  155190. * Creates the sss post process
  155191. * @return The created post process
  155192. */
  155193. createPostProcess(): SubSurfaceScatteringPostProcess;
  155194. /**
  155195. * Deletes all diffusion profiles.
  155196. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  155197. */
  155198. clearAllDiffusionProfiles(): void;
  155199. /**
  155200. * Disposes this object
  155201. */
  155202. dispose(): void;
  155203. /**
  155204. * @hidden
  155205. * https://zero-radiance.github.io/post/sampling-diffusion/
  155206. *
  155207. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  155208. * ------------------------------------------------------------------------------------
  155209. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  155210. * PDF[r, phi, s] = r * R[r, phi, s]
  155211. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  155212. * ------------------------------------------------------------------------------------
  155213. * We importance sample the color channel with the widest scattering distance.
  155214. */
  155215. getDiffusionProfileParameters(color: Color3): number;
  155216. /**
  155217. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  155218. * 'u' is the random number (the value of the CDF): [0, 1).
  155219. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  155220. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  155221. */
  155222. private _sampleBurleyDiffusionProfile;
  155223. }
  155224. }
  155225. declare module BABYLON {
  155226. interface AbstractScene {
  155227. /** @hidden (Backing field) */
  155228. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155229. /**
  155230. * Gets or Sets the current prepass renderer associated to the scene.
  155231. */
  155232. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155233. /**
  155234. * Enables the subsurface effect for prepass
  155235. * @returns the SubSurfaceConfiguration
  155236. */
  155237. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  155238. /**
  155239. * Disables the subsurface effect for prepass
  155240. */
  155241. disableSubSurfaceForPrePass(): void;
  155242. }
  155243. /**
  155244. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155245. * in several rendering techniques.
  155246. */
  155247. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  155248. /**
  155249. * The component name helpful to identify the component in the list of scene components.
  155250. */
  155251. readonly name: string;
  155252. /**
  155253. * The scene the component belongs to.
  155254. */
  155255. scene: Scene;
  155256. /**
  155257. * Creates a new instance of the component for the given scene
  155258. * @param scene Defines the scene to register the component in
  155259. */
  155260. constructor(scene: Scene);
  155261. /**
  155262. * Registers the component in a given scene
  155263. */
  155264. register(): void;
  155265. /**
  155266. * Serializes the component data to the specified json object
  155267. * @param serializationObject The object to serialize to
  155268. */
  155269. serialize(serializationObject: any): void;
  155270. /**
  155271. * Adds all the elements from the container to the scene
  155272. * @param container the container holding the elements
  155273. */
  155274. addFromContainer(container: AbstractScene): void;
  155275. /**
  155276. * Removes all the elements in the container from the scene
  155277. * @param container contains the elements to remove
  155278. * @param dispose if the removed element should be disposed (default: false)
  155279. */
  155280. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  155281. /**
  155282. * Rebuilds the elements related to this component in case of
  155283. * context lost for instance.
  155284. */
  155285. rebuild(): void;
  155286. /**
  155287. * Disposes the component and the associated ressources
  155288. */
  155289. dispose(): void;
  155290. }
  155291. }
  155292. declare module BABYLON {
  155293. /** @hidden */
  155294. export var outlinePixelShader: {
  155295. name: string;
  155296. shader: string;
  155297. };
  155298. }
  155299. declare module BABYLON {
  155300. /** @hidden */
  155301. export var outlineVertexShader: {
  155302. name: string;
  155303. shader: string;
  155304. };
  155305. }
  155306. declare module BABYLON {
  155307. interface Scene {
  155308. /** @hidden */
  155309. _outlineRenderer: OutlineRenderer;
  155310. /**
  155311. * Gets the outline renderer associated with the scene
  155312. * @returns a OutlineRenderer
  155313. */
  155314. getOutlineRenderer(): OutlineRenderer;
  155315. }
  155316. interface AbstractMesh {
  155317. /** @hidden (Backing field) */
  155318. _renderOutline: boolean;
  155319. /**
  155320. * Gets or sets a boolean indicating if the outline must be rendered as well
  155321. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  155322. */
  155323. renderOutline: boolean;
  155324. /** @hidden (Backing field) */
  155325. _renderOverlay: boolean;
  155326. /**
  155327. * Gets or sets a boolean indicating if the overlay must be rendered as well
  155328. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  155329. */
  155330. renderOverlay: boolean;
  155331. }
  155332. /**
  155333. * This class is responsible to draw bothe outline/overlay of meshes.
  155334. * It should not be used directly but through the available method on mesh.
  155335. */
  155336. export class OutlineRenderer implements ISceneComponent {
  155337. /**
  155338. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  155339. */
  155340. private static _StencilReference;
  155341. /**
  155342. * The name of the component. Each component must have a unique name.
  155343. */
  155344. name: string;
  155345. /**
  155346. * The scene the component belongs to.
  155347. */
  155348. scene: Scene;
  155349. /**
  155350. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  155351. */
  155352. zOffset: number;
  155353. private _engine;
  155354. private _effect;
  155355. private _cachedDefines;
  155356. private _savedDepthWrite;
  155357. /**
  155358. * Instantiates a new outline renderer. (There could be only one per scene).
  155359. * @param scene Defines the scene it belongs to
  155360. */
  155361. constructor(scene: Scene);
  155362. /**
  155363. * Register the component to one instance of a scene.
  155364. */
  155365. register(): void;
  155366. /**
  155367. * Rebuilds the elements related to this component in case of
  155368. * context lost for instance.
  155369. */
  155370. rebuild(): void;
  155371. /**
  155372. * Disposes the component and the associated ressources.
  155373. */
  155374. dispose(): void;
  155375. /**
  155376. * Renders the outline in the canvas.
  155377. * @param subMesh Defines the sumesh to render
  155378. * @param batch Defines the batch of meshes in case of instances
  155379. * @param useOverlay Defines if the rendering is for the overlay or the outline
  155380. */
  155381. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  155382. /**
  155383. * Returns whether or not the outline renderer is ready for a given submesh.
  155384. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  155385. * @param subMesh Defines the submesh to check readyness for
  155386. * @param useInstances Defines wheter wee are trying to render instances or not
  155387. * @returns true if ready otherwise false
  155388. */
  155389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  155390. private _beforeRenderingMesh;
  155391. private _afterRenderingMesh;
  155392. }
  155393. }
  155394. declare module BABYLON {
  155395. /**
  155396. * Defines the basic options interface of a Sprite Frame Source Size.
  155397. */
  155398. export interface ISpriteJSONSpriteSourceSize {
  155399. /**
  155400. * number of the original width of the Frame
  155401. */
  155402. w: number;
  155403. /**
  155404. * number of the original height of the Frame
  155405. */
  155406. h: number;
  155407. }
  155408. /**
  155409. * Defines the basic options interface of a Sprite Frame Data.
  155410. */
  155411. export interface ISpriteJSONSpriteFrameData {
  155412. /**
  155413. * number of the x offset of the Frame
  155414. */
  155415. x: number;
  155416. /**
  155417. * number of the y offset of the Frame
  155418. */
  155419. y: number;
  155420. /**
  155421. * number of the width of the Frame
  155422. */
  155423. w: number;
  155424. /**
  155425. * number of the height of the Frame
  155426. */
  155427. h: number;
  155428. }
  155429. /**
  155430. * Defines the basic options interface of a JSON Sprite.
  155431. */
  155432. export interface ISpriteJSONSprite {
  155433. /**
  155434. * string name of the Frame
  155435. */
  155436. filename: string;
  155437. /**
  155438. * ISpriteJSONSpriteFrame basic object of the frame data
  155439. */
  155440. frame: ISpriteJSONSpriteFrameData;
  155441. /**
  155442. * boolean to flag is the frame was rotated.
  155443. */
  155444. rotated: boolean;
  155445. /**
  155446. * boolean to flag is the frame was trimmed.
  155447. */
  155448. trimmed: boolean;
  155449. /**
  155450. * ISpriteJSONSpriteFrame basic object of the source data
  155451. */
  155452. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155453. /**
  155454. * ISpriteJSONSpriteFrame basic object of the source data
  155455. */
  155456. sourceSize: ISpriteJSONSpriteSourceSize;
  155457. }
  155458. /**
  155459. * Defines the basic options interface of a JSON atlas.
  155460. */
  155461. export interface ISpriteJSONAtlas {
  155462. /**
  155463. * Array of objects that contain the frame data.
  155464. */
  155465. frames: Array<ISpriteJSONSprite>;
  155466. /**
  155467. * object basic object containing the sprite meta data.
  155468. */
  155469. meta?: object;
  155470. }
  155471. }
  155472. declare module BABYLON {
  155473. /** @hidden */
  155474. export var spriteMapPixelShader: {
  155475. name: string;
  155476. shader: string;
  155477. };
  155478. }
  155479. declare module BABYLON {
  155480. /** @hidden */
  155481. export var spriteMapVertexShader: {
  155482. name: string;
  155483. shader: string;
  155484. };
  155485. }
  155486. declare module BABYLON {
  155487. /**
  155488. * Defines the basic options interface of a SpriteMap
  155489. */
  155490. export interface ISpriteMapOptions {
  155491. /**
  155492. * Vector2 of the number of cells in the grid.
  155493. */
  155494. stageSize?: Vector2;
  155495. /**
  155496. * Vector2 of the size of the output plane in World Units.
  155497. */
  155498. outputSize?: Vector2;
  155499. /**
  155500. * Vector3 of the position of the output plane in World Units.
  155501. */
  155502. outputPosition?: Vector3;
  155503. /**
  155504. * Vector3 of the rotation of the output plane.
  155505. */
  155506. outputRotation?: Vector3;
  155507. /**
  155508. * number of layers that the system will reserve in resources.
  155509. */
  155510. layerCount?: number;
  155511. /**
  155512. * number of max animation frames a single cell will reserve in resources.
  155513. */
  155514. maxAnimationFrames?: number;
  155515. /**
  155516. * number cell index of the base tile when the system compiles.
  155517. */
  155518. baseTile?: number;
  155519. /**
  155520. * boolean flip the sprite after its been repositioned by the framing data.
  155521. */
  155522. flipU?: boolean;
  155523. /**
  155524. * Vector3 scalar of the global RGB values of the SpriteMap.
  155525. */
  155526. colorMultiply?: Vector3;
  155527. }
  155528. /**
  155529. * Defines the IDisposable interface in order to be cleanable from resources.
  155530. */
  155531. export interface ISpriteMap extends IDisposable {
  155532. /**
  155533. * String name of the SpriteMap.
  155534. */
  155535. name: string;
  155536. /**
  155537. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155538. */
  155539. atlasJSON: ISpriteJSONAtlas;
  155540. /**
  155541. * Texture of the SpriteMap.
  155542. */
  155543. spriteSheet: Texture;
  155544. /**
  155545. * The parameters to initialize the SpriteMap with.
  155546. */
  155547. options: ISpriteMapOptions;
  155548. }
  155549. /**
  155550. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155551. */
  155552. export class SpriteMap implements ISpriteMap {
  155553. /** The Name of the spriteMap */
  155554. name: string;
  155555. /** The JSON file with the frame and meta data */
  155556. atlasJSON: ISpriteJSONAtlas;
  155557. /** The systems Sprite Sheet Texture */
  155558. spriteSheet: Texture;
  155559. /** Arguments passed with the Constructor */
  155560. options: ISpriteMapOptions;
  155561. /** Public Sprite Storage array, parsed from atlasJSON */
  155562. sprites: Array<ISpriteJSONSprite>;
  155563. /** Returns the Number of Sprites in the System */
  155564. get spriteCount(): number;
  155565. /** Returns the Position of Output Plane*/
  155566. get position(): Vector3;
  155567. /** Returns the Position of Output Plane*/
  155568. set position(v: Vector3);
  155569. /** Returns the Rotation of Output Plane*/
  155570. get rotation(): Vector3;
  155571. /** Returns the Rotation of Output Plane*/
  155572. set rotation(v: Vector3);
  155573. /** Sets the AnimationMap*/
  155574. get animationMap(): RawTexture;
  155575. /** Sets the AnimationMap*/
  155576. set animationMap(v: RawTexture);
  155577. /** Scene that the SpriteMap was created in */
  155578. private _scene;
  155579. /** Texture Buffer of Float32 that holds tile frame data*/
  155580. private _frameMap;
  155581. /** Texture Buffers of Float32 that holds tileMap data*/
  155582. private _tileMaps;
  155583. /** Texture Buffer of Float32 that holds Animation Data*/
  155584. private _animationMap;
  155585. /** Custom ShaderMaterial Central to the System*/
  155586. private _material;
  155587. /** Custom ShaderMaterial Central to the System*/
  155588. private _output;
  155589. /** Systems Time Ticker*/
  155590. private _time;
  155591. /**
  155592. * Creates a new SpriteMap
  155593. * @param name defines the SpriteMaps Name
  155594. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155595. * @param spriteSheet is the Texture that the Sprites are on.
  155596. * @param options a basic deployment configuration
  155597. * @param scene The Scene that the map is deployed on
  155598. */
  155599. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155600. /**
  155601. * Returns tileID location
  155602. * @returns Vector2 the cell position ID
  155603. */
  155604. getTileID(): Vector2;
  155605. /**
  155606. * Gets the UV location of the mouse over the SpriteMap.
  155607. * @returns Vector2 the UV position of the mouse interaction
  155608. */
  155609. getMousePosition(): Vector2;
  155610. /**
  155611. * Creates the "frame" texture Buffer
  155612. * -------------------------------------
  155613. * Structure of frames
  155614. * "filename": "Falling-Water-2.png",
  155615. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155616. * "rotated": true,
  155617. * "trimmed": true,
  155618. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155619. * "sourceSize": {"w":32,"h":32}
  155620. * @returns RawTexture of the frameMap
  155621. */
  155622. private _createFrameBuffer;
  155623. /**
  155624. * Creates the tileMap texture Buffer
  155625. * @param buffer normally and array of numbers, or a false to generate from scratch
  155626. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155627. * @returns RawTexture of the tileMap
  155628. */
  155629. private _createTileBuffer;
  155630. /**
  155631. * Modifies the data of the tileMaps
  155632. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155633. * @param pos is the iVector2 Coordinates of the Tile
  155634. * @param tile The SpriteIndex of the new Tile
  155635. */
  155636. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155637. /**
  155638. * Creates the animationMap texture Buffer
  155639. * @param buffer normally and array of numbers, or a false to generate from scratch
  155640. * @returns RawTexture of the animationMap
  155641. */
  155642. private _createTileAnimationBuffer;
  155643. /**
  155644. * Modifies the data of the animationMap
  155645. * @param cellID is the Index of the Sprite
  155646. * @param _frame is the target Animation frame
  155647. * @param toCell is the Target Index of the next frame of the animation
  155648. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155649. * @param speed is a global scalar of the time variable on the map.
  155650. */
  155651. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155652. /**
  155653. * Exports the .tilemaps file
  155654. */
  155655. saveTileMaps(): void;
  155656. /**
  155657. * Imports the .tilemaps file
  155658. * @param url of the .tilemaps file
  155659. */
  155660. loadTileMaps(url: string): void;
  155661. /**
  155662. * Release associated resources
  155663. */
  155664. dispose(): void;
  155665. }
  155666. }
  155667. declare module BABYLON {
  155668. /**
  155669. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155670. * @see https://doc.babylonjs.com/babylon101/sprites
  155671. */
  155672. export class SpritePackedManager extends SpriteManager {
  155673. /** defines the packed manager's name */
  155674. name: string;
  155675. /**
  155676. * Creates a new sprite manager from a packed sprite sheet
  155677. * @param name defines the manager's name
  155678. * @param imgUrl defines the sprite sheet url
  155679. * @param capacity defines the maximum allowed number of sprites
  155680. * @param scene defines the hosting scene
  155681. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155682. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155683. * @param samplingMode defines the smapling mode to use with spritesheet
  155684. * @param fromPacked set to true; do not alter
  155685. */
  155686. constructor(
  155687. /** defines the packed manager's name */
  155688. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155689. }
  155690. }
  155691. declare module BABYLON {
  155692. /**
  155693. * Defines the list of states available for a task inside a AssetsManager
  155694. */
  155695. export enum AssetTaskState {
  155696. /**
  155697. * Initialization
  155698. */
  155699. INIT = 0,
  155700. /**
  155701. * Running
  155702. */
  155703. RUNNING = 1,
  155704. /**
  155705. * Done
  155706. */
  155707. DONE = 2,
  155708. /**
  155709. * Error
  155710. */
  155711. ERROR = 3
  155712. }
  155713. /**
  155714. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155715. */
  155716. export abstract class AbstractAssetTask {
  155717. /**
  155718. * Task name
  155719. */ name: string;
  155720. /**
  155721. * Callback called when the task is successful
  155722. */
  155723. onSuccess: (task: any) => void;
  155724. /**
  155725. * Callback called when the task is not successful
  155726. */
  155727. onError: (task: any, message?: string, exception?: any) => void;
  155728. /**
  155729. * Creates a new AssetsManager
  155730. * @param name defines the name of the task
  155731. */
  155732. constructor(
  155733. /**
  155734. * Task name
  155735. */ name: string);
  155736. private _isCompleted;
  155737. private _taskState;
  155738. private _errorObject;
  155739. /**
  155740. * Get if the task is completed
  155741. */
  155742. get isCompleted(): boolean;
  155743. /**
  155744. * Gets the current state of the task
  155745. */
  155746. get taskState(): AssetTaskState;
  155747. /**
  155748. * Gets the current error object (if task is in error)
  155749. */
  155750. get errorObject(): {
  155751. message?: string;
  155752. exception?: any;
  155753. };
  155754. /**
  155755. * Internal only
  155756. * @hidden
  155757. */
  155758. _setErrorObject(message?: string, exception?: any): void;
  155759. /**
  155760. * Execute the current task
  155761. * @param scene defines the scene where you want your assets to be loaded
  155762. * @param onSuccess is a callback called when the task is successfully executed
  155763. * @param onError is a callback called if an error occurs
  155764. */
  155765. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155766. /**
  155767. * Execute the current task
  155768. * @param scene defines the scene where you want your assets to be loaded
  155769. * @param onSuccess is a callback called when the task is successfully executed
  155770. * @param onError is a callback called if an error occurs
  155771. */
  155772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155773. /**
  155774. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155775. * This can be used with failed tasks that have the reason for failure fixed.
  155776. */
  155777. reset(): void;
  155778. private onErrorCallback;
  155779. private onDoneCallback;
  155780. }
  155781. /**
  155782. * Define the interface used by progress events raised during assets loading
  155783. */
  155784. export interface IAssetsProgressEvent {
  155785. /**
  155786. * Defines the number of remaining tasks to process
  155787. */
  155788. remainingCount: number;
  155789. /**
  155790. * Defines the total number of tasks
  155791. */
  155792. totalCount: number;
  155793. /**
  155794. * Defines the task that was just processed
  155795. */
  155796. task: AbstractAssetTask;
  155797. }
  155798. /**
  155799. * Class used to share progress information about assets loading
  155800. */
  155801. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155802. /**
  155803. * Defines the number of remaining tasks to process
  155804. */
  155805. remainingCount: number;
  155806. /**
  155807. * Defines the total number of tasks
  155808. */
  155809. totalCount: number;
  155810. /**
  155811. * Defines the task that was just processed
  155812. */
  155813. task: AbstractAssetTask;
  155814. /**
  155815. * Creates a AssetsProgressEvent
  155816. * @param remainingCount defines the number of remaining tasks to process
  155817. * @param totalCount defines the total number of tasks
  155818. * @param task defines the task that was just processed
  155819. */
  155820. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155821. }
  155822. /**
  155823. * Define a task used by AssetsManager to load assets into a container
  155824. */
  155825. export class ContainerAssetTask extends AbstractAssetTask {
  155826. /**
  155827. * Defines the name of the task
  155828. */
  155829. name: string;
  155830. /**
  155831. * Defines the list of mesh's names you want to load
  155832. */
  155833. meshesNames: any;
  155834. /**
  155835. * Defines the root url to use as a base to load your meshes and associated resources
  155836. */
  155837. rootUrl: string;
  155838. /**
  155839. * Defines the filename or File of the scene to load from
  155840. */
  155841. sceneFilename: string | File;
  155842. /**
  155843. * Get the loaded asset container
  155844. */
  155845. loadedContainer: AssetContainer;
  155846. /**
  155847. * Gets the list of loaded meshes
  155848. */
  155849. loadedMeshes: Array<AbstractMesh>;
  155850. /**
  155851. * Gets the list of loaded particle systems
  155852. */
  155853. loadedParticleSystems: Array<IParticleSystem>;
  155854. /**
  155855. * Gets the list of loaded skeletons
  155856. */
  155857. loadedSkeletons: Array<Skeleton>;
  155858. /**
  155859. * Gets the list of loaded animation groups
  155860. */
  155861. loadedAnimationGroups: Array<AnimationGroup>;
  155862. /**
  155863. * Callback called when the task is successful
  155864. */
  155865. onSuccess: (task: ContainerAssetTask) => void;
  155866. /**
  155867. * Callback called when the task is successful
  155868. */
  155869. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155870. /**
  155871. * Creates a new ContainerAssetTask
  155872. * @param name defines the name of the task
  155873. * @param meshesNames defines the list of mesh's names you want to load
  155874. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155875. * @param sceneFilename defines the filename or File of the scene to load from
  155876. */
  155877. constructor(
  155878. /**
  155879. * Defines the name of the task
  155880. */
  155881. name: string,
  155882. /**
  155883. * Defines the list of mesh's names you want to load
  155884. */
  155885. meshesNames: any,
  155886. /**
  155887. * Defines the root url to use as a base to load your meshes and associated resources
  155888. */
  155889. rootUrl: string,
  155890. /**
  155891. * Defines the filename or File of the scene to load from
  155892. */
  155893. sceneFilename: string | File);
  155894. /**
  155895. * Execute the current task
  155896. * @param scene defines the scene where you want your assets to be loaded
  155897. * @param onSuccess is a callback called when the task is successfully executed
  155898. * @param onError is a callback called if an error occurs
  155899. */
  155900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155901. }
  155902. /**
  155903. * Define a task used by AssetsManager to load meshes
  155904. */
  155905. export class MeshAssetTask extends AbstractAssetTask {
  155906. /**
  155907. * Defines the name of the task
  155908. */
  155909. name: string;
  155910. /**
  155911. * Defines the list of mesh's names you want to load
  155912. */
  155913. meshesNames: any;
  155914. /**
  155915. * Defines the root url to use as a base to load your meshes and associated resources
  155916. */
  155917. rootUrl: string;
  155918. /**
  155919. * Defines the filename or File of the scene to load from
  155920. */
  155921. sceneFilename: string | File;
  155922. /**
  155923. * Gets the list of loaded meshes
  155924. */
  155925. loadedMeshes: Array<AbstractMesh>;
  155926. /**
  155927. * Gets the list of loaded particle systems
  155928. */
  155929. loadedParticleSystems: Array<IParticleSystem>;
  155930. /**
  155931. * Gets the list of loaded skeletons
  155932. */
  155933. loadedSkeletons: Array<Skeleton>;
  155934. /**
  155935. * Gets the list of loaded animation groups
  155936. */
  155937. loadedAnimationGroups: Array<AnimationGroup>;
  155938. /**
  155939. * Callback called when the task is successful
  155940. */
  155941. onSuccess: (task: MeshAssetTask) => void;
  155942. /**
  155943. * Callback called when the task is successful
  155944. */
  155945. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155946. /**
  155947. * Creates a new MeshAssetTask
  155948. * @param name defines the name of the task
  155949. * @param meshesNames defines the list of mesh's names you want to load
  155950. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155951. * @param sceneFilename defines the filename or File of the scene to load from
  155952. */
  155953. constructor(
  155954. /**
  155955. * Defines the name of the task
  155956. */
  155957. name: string,
  155958. /**
  155959. * Defines the list of mesh's names you want to load
  155960. */
  155961. meshesNames: any,
  155962. /**
  155963. * Defines the root url to use as a base to load your meshes and associated resources
  155964. */
  155965. rootUrl: string,
  155966. /**
  155967. * Defines the filename or File of the scene to load from
  155968. */
  155969. sceneFilename: string | File);
  155970. /**
  155971. * Execute the current task
  155972. * @param scene defines the scene where you want your assets to be loaded
  155973. * @param onSuccess is a callback called when the task is successfully executed
  155974. * @param onError is a callback called if an error occurs
  155975. */
  155976. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155977. }
  155978. /**
  155979. * Define a task used by AssetsManager to load text content
  155980. */
  155981. export class TextFileAssetTask extends AbstractAssetTask {
  155982. /**
  155983. * Defines the name of the task
  155984. */
  155985. name: string;
  155986. /**
  155987. * Defines the location of the file to load
  155988. */
  155989. url: string;
  155990. /**
  155991. * Gets the loaded text string
  155992. */
  155993. text: string;
  155994. /**
  155995. * Callback called when the task is successful
  155996. */
  155997. onSuccess: (task: TextFileAssetTask) => void;
  155998. /**
  155999. * Callback called when the task is successful
  156000. */
  156001. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  156002. /**
  156003. * Creates a new TextFileAssetTask object
  156004. * @param name defines the name of the task
  156005. * @param url defines the location of the file to load
  156006. */
  156007. constructor(
  156008. /**
  156009. * Defines the name of the task
  156010. */
  156011. name: string,
  156012. /**
  156013. * Defines the location of the file to load
  156014. */
  156015. url: string);
  156016. /**
  156017. * Execute the current task
  156018. * @param scene defines the scene where you want your assets to be loaded
  156019. * @param onSuccess is a callback called when the task is successfully executed
  156020. * @param onError is a callback called if an error occurs
  156021. */
  156022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156023. }
  156024. /**
  156025. * Define a task used by AssetsManager to load binary data
  156026. */
  156027. export class BinaryFileAssetTask extends AbstractAssetTask {
  156028. /**
  156029. * Defines the name of the task
  156030. */
  156031. name: string;
  156032. /**
  156033. * Defines the location of the file to load
  156034. */
  156035. url: string;
  156036. /**
  156037. * Gets the lodaded data (as an array buffer)
  156038. */
  156039. data: ArrayBuffer;
  156040. /**
  156041. * Callback called when the task is successful
  156042. */
  156043. onSuccess: (task: BinaryFileAssetTask) => void;
  156044. /**
  156045. * Callback called when the task is successful
  156046. */
  156047. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  156048. /**
  156049. * Creates a new BinaryFileAssetTask object
  156050. * @param name defines the name of the new task
  156051. * @param url defines the location of the file to load
  156052. */
  156053. constructor(
  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. * Execute the current task
  156064. * @param scene defines the scene where you want your assets to be loaded
  156065. * @param onSuccess is a callback called when the task is successfully executed
  156066. * @param onError is a callback called if an error occurs
  156067. */
  156068. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156069. }
  156070. /**
  156071. * Define a task used by AssetsManager to load images
  156072. */
  156073. export class ImageAssetTask extends AbstractAssetTask {
  156074. /**
  156075. * Defines the name of the task
  156076. */
  156077. name: string;
  156078. /**
  156079. * Defines the location of the image to load
  156080. */
  156081. url: string;
  156082. /**
  156083. * Gets the loaded images
  156084. */
  156085. image: HTMLImageElement;
  156086. /**
  156087. * Callback called when the task is successful
  156088. */
  156089. onSuccess: (task: ImageAssetTask) => void;
  156090. /**
  156091. * Callback called when the task is successful
  156092. */
  156093. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  156094. /**
  156095. * Creates a new ImageAssetTask
  156096. * @param name defines the name of the task
  156097. * @param url defines the location of the image to load
  156098. */
  156099. constructor(
  156100. /**
  156101. * Defines the name of the task
  156102. */
  156103. name: string,
  156104. /**
  156105. * Defines the location of the image to load
  156106. */
  156107. url: string);
  156108. /**
  156109. * Execute the current task
  156110. * @param scene defines the scene where you want your assets to be loaded
  156111. * @param onSuccess is a callback called when the task is successfully executed
  156112. * @param onError is a callback called if an error occurs
  156113. */
  156114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156115. }
  156116. /**
  156117. * Defines the interface used by texture loading tasks
  156118. */
  156119. export interface ITextureAssetTask<TEX extends BaseTexture> {
  156120. /**
  156121. * Gets the loaded texture
  156122. */
  156123. texture: TEX;
  156124. }
  156125. /**
  156126. * Define a task used by AssetsManager to load 2D textures
  156127. */
  156128. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  156129. /**
  156130. * Defines the name of the task
  156131. */
  156132. name: string;
  156133. /**
  156134. * Defines the location of the file to load
  156135. */
  156136. url: string;
  156137. /**
  156138. * Defines if mipmap should not be generated (default is false)
  156139. */
  156140. noMipmap?: boolean | undefined;
  156141. /**
  156142. * Defines if texture must be inverted on Y axis (default is true)
  156143. */
  156144. invertY: boolean;
  156145. /**
  156146. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156147. */
  156148. samplingMode: number;
  156149. /**
  156150. * Gets the loaded texture
  156151. */
  156152. texture: Texture;
  156153. /**
  156154. * Callback called when the task is successful
  156155. */
  156156. onSuccess: (task: TextureAssetTask) => void;
  156157. /**
  156158. * Callback called when the task is successful
  156159. */
  156160. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  156161. /**
  156162. * Creates a new TextureAssetTask object
  156163. * @param name defines the name of the task
  156164. * @param url defines the location of the file to load
  156165. * @param noMipmap defines if mipmap should not be generated (default is false)
  156166. * @param invertY defines if texture must be inverted on Y axis (default is true)
  156167. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156168. */
  156169. constructor(
  156170. /**
  156171. * Defines the name of the task
  156172. */
  156173. name: string,
  156174. /**
  156175. * Defines the location of the file to load
  156176. */
  156177. url: string,
  156178. /**
  156179. * Defines if mipmap should not be generated (default is false)
  156180. */
  156181. noMipmap?: boolean | undefined,
  156182. /**
  156183. * Defines if texture must be inverted on Y axis (default is true)
  156184. */
  156185. invertY?: boolean,
  156186. /**
  156187. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156188. */
  156189. samplingMode?: number);
  156190. /**
  156191. * Execute the current task
  156192. * @param scene defines the scene where you want your assets to be loaded
  156193. * @param onSuccess is a callback called when the task is successfully executed
  156194. * @param onError is a callback called if an error occurs
  156195. */
  156196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156197. }
  156198. /**
  156199. * Define a task used by AssetsManager to load cube textures
  156200. */
  156201. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  156202. /**
  156203. * Defines the name of the task
  156204. */
  156205. name: string;
  156206. /**
  156207. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156208. */
  156209. url: string;
  156210. /**
  156211. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156212. */
  156213. extensions?: string[] | undefined;
  156214. /**
  156215. * Defines if mipmaps should not be generated (default is false)
  156216. */
  156217. noMipmap?: boolean | undefined;
  156218. /**
  156219. * Defines the explicit list of files (undefined by default)
  156220. */
  156221. files?: string[] | undefined;
  156222. /**
  156223. * Gets the loaded texture
  156224. */
  156225. texture: CubeTexture;
  156226. /**
  156227. * Callback called when the task is successful
  156228. */
  156229. onSuccess: (task: CubeTextureAssetTask) => void;
  156230. /**
  156231. * Callback called when the task is successful
  156232. */
  156233. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  156234. /**
  156235. * Creates a new CubeTextureAssetTask
  156236. * @param name defines the name of the task
  156237. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156238. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156239. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156240. * @param files defines the explicit list of files (undefined by default)
  156241. */
  156242. constructor(
  156243. /**
  156244. * Defines the name of the task
  156245. */
  156246. name: string,
  156247. /**
  156248. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156249. */
  156250. url: string,
  156251. /**
  156252. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156253. */
  156254. extensions?: string[] | undefined,
  156255. /**
  156256. * Defines if mipmaps should not be generated (default is false)
  156257. */
  156258. noMipmap?: boolean | undefined,
  156259. /**
  156260. * Defines the explicit list of files (undefined by default)
  156261. */
  156262. files?: string[] | undefined);
  156263. /**
  156264. * Execute the current task
  156265. * @param scene defines the scene where you want your assets to be loaded
  156266. * @param onSuccess is a callback called when the task is successfully executed
  156267. * @param onError is a callback called if an error occurs
  156268. */
  156269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156270. }
  156271. /**
  156272. * Define a task used by AssetsManager to load HDR cube textures
  156273. */
  156274. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  156275. /**
  156276. * Defines the name of the task
  156277. */
  156278. name: string;
  156279. /**
  156280. * Defines the location of the file to load
  156281. */
  156282. url: string;
  156283. /**
  156284. * Defines the desired size (the more it increases the longer the generation will be)
  156285. */
  156286. size: number;
  156287. /**
  156288. * Defines if mipmaps should not be generated (default is false)
  156289. */
  156290. noMipmap: boolean;
  156291. /**
  156292. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156293. */
  156294. generateHarmonics: boolean;
  156295. /**
  156296. * 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)
  156297. */
  156298. gammaSpace: boolean;
  156299. /**
  156300. * Internal Use Only
  156301. */
  156302. reserved: boolean;
  156303. /**
  156304. * Gets the loaded texture
  156305. */
  156306. texture: HDRCubeTexture;
  156307. /**
  156308. * Callback called when the task is successful
  156309. */
  156310. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  156311. /**
  156312. * Callback called when the task is successful
  156313. */
  156314. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  156315. /**
  156316. * Creates a new HDRCubeTextureAssetTask object
  156317. * @param name defines the name of the task
  156318. * @param url defines the location of the file to load
  156319. * @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.
  156320. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156321. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156322. * @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)
  156323. * @param reserved Internal use only
  156324. */
  156325. constructor(
  156326. /**
  156327. * Defines the name of the task
  156328. */
  156329. name: string,
  156330. /**
  156331. * Defines the location of the file to load
  156332. */
  156333. url: string,
  156334. /**
  156335. * Defines the desired size (the more it increases the longer the generation will be)
  156336. */
  156337. size: number,
  156338. /**
  156339. * Defines if mipmaps should not be generated (default is false)
  156340. */
  156341. noMipmap?: boolean,
  156342. /**
  156343. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156344. */
  156345. generateHarmonics?: boolean,
  156346. /**
  156347. * 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)
  156348. */
  156349. gammaSpace?: boolean,
  156350. /**
  156351. * Internal Use Only
  156352. */
  156353. reserved?: boolean);
  156354. /**
  156355. * Execute the current task
  156356. * @param scene defines the scene where you want your assets to be loaded
  156357. * @param onSuccess is a callback called when the task is successfully executed
  156358. * @param onError is a callback called if an error occurs
  156359. */
  156360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156361. }
  156362. /**
  156363. * Define a task used by AssetsManager to load Equirectangular cube textures
  156364. */
  156365. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  156366. /**
  156367. * Defines the name of the task
  156368. */
  156369. name: string;
  156370. /**
  156371. * Defines the location of the file to load
  156372. */
  156373. url: string;
  156374. /**
  156375. * Defines the desired size (the more it increases the longer the generation will be)
  156376. */
  156377. size: number;
  156378. /**
  156379. * Defines if mipmaps should not be generated (default is false)
  156380. */
  156381. noMipmap: boolean;
  156382. /**
  156383. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156384. * but the standard material would require them in Gamma space) (default is true)
  156385. */
  156386. gammaSpace: boolean;
  156387. /**
  156388. * Gets the loaded texture
  156389. */
  156390. texture: EquiRectangularCubeTexture;
  156391. /**
  156392. * Callback called when the task is successful
  156393. */
  156394. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  156395. /**
  156396. * Callback called when the task is successful
  156397. */
  156398. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  156399. /**
  156400. * Creates a new EquiRectangularCubeTextureAssetTask object
  156401. * @param name defines the name of the task
  156402. * @param url defines the location of the file to load
  156403. * @param size defines the desired size (the more it increases the longer the generation will be)
  156404. * If the size is omitted this implies you are using a preprocessed cubemap.
  156405. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156406. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  156407. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  156408. * (default is true)
  156409. */
  156410. constructor(
  156411. /**
  156412. * Defines the name of the task
  156413. */
  156414. name: string,
  156415. /**
  156416. * Defines the location of the file to load
  156417. */
  156418. url: string,
  156419. /**
  156420. * Defines the desired size (the more it increases the longer the generation will be)
  156421. */
  156422. size: number,
  156423. /**
  156424. * Defines if mipmaps should not be generated (default is false)
  156425. */
  156426. noMipmap?: boolean,
  156427. /**
  156428. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156429. * but the standard material would require them in Gamma space) (default is true)
  156430. */
  156431. gammaSpace?: boolean);
  156432. /**
  156433. * Execute the current task
  156434. * @param scene defines the scene where you want your assets to be loaded
  156435. * @param onSuccess is a callback called when the task is successfully executed
  156436. * @param onError is a callback called if an error occurs
  156437. */
  156438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156439. }
  156440. /**
  156441. * This class can be used to easily import assets into a scene
  156442. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156443. */
  156444. export class AssetsManager {
  156445. private _scene;
  156446. private _isLoading;
  156447. protected _tasks: AbstractAssetTask[];
  156448. protected _waitingTasksCount: number;
  156449. protected _totalTasksCount: number;
  156450. /**
  156451. * Callback called when all tasks are processed
  156452. */
  156453. onFinish: (tasks: AbstractAssetTask[]) => void;
  156454. /**
  156455. * Callback called when a task is successful
  156456. */
  156457. onTaskSuccess: (task: AbstractAssetTask) => void;
  156458. /**
  156459. * Callback called when a task had an error
  156460. */
  156461. onTaskError: (task: AbstractAssetTask) => void;
  156462. /**
  156463. * Callback called when a task is done (whatever the result is)
  156464. */
  156465. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156466. /**
  156467. * Observable called when all tasks are processed
  156468. */
  156469. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156470. /**
  156471. * Observable called when a task had an error
  156472. */
  156473. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156474. /**
  156475. * Observable called when all tasks were executed
  156476. */
  156477. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156478. /**
  156479. * Observable called when a task is done (whatever the result is)
  156480. */
  156481. onProgressObservable: Observable<IAssetsProgressEvent>;
  156482. /**
  156483. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156484. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156485. */
  156486. useDefaultLoadingScreen: boolean;
  156487. /**
  156488. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156489. * when all assets have been downloaded.
  156490. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156491. */
  156492. autoHideLoadingUI: boolean;
  156493. /**
  156494. * Creates a new AssetsManager
  156495. * @param scene defines the scene to work on
  156496. */
  156497. constructor(scene: Scene);
  156498. /**
  156499. * Add a ContainerAssetTask to the list of active tasks
  156500. * @param taskName defines the name of the new task
  156501. * @param meshesNames defines the name of meshes to load
  156502. * @param rootUrl defines the root url to use to locate files
  156503. * @param sceneFilename defines the filename of the scene file
  156504. * @returns a new ContainerAssetTask object
  156505. */
  156506. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156507. /**
  156508. * Add a MeshAssetTask to the list of active tasks
  156509. * @param taskName defines the name of the new task
  156510. * @param meshesNames defines the name of meshes to load
  156511. * @param rootUrl defines the root url to use to locate files
  156512. * @param sceneFilename defines the filename of the scene file
  156513. * @returns a new MeshAssetTask object
  156514. */
  156515. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156516. /**
  156517. * Add a TextFileAssetTask to the list of active tasks
  156518. * @param taskName defines the name of the new task
  156519. * @param url defines the url of the file to load
  156520. * @returns a new TextFileAssetTask object
  156521. */
  156522. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156523. /**
  156524. * Add a BinaryFileAssetTask to the list of active tasks
  156525. * @param taskName defines the name of the new task
  156526. * @param url defines the url of the file to load
  156527. * @returns a new BinaryFileAssetTask object
  156528. */
  156529. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156530. /**
  156531. * Add a ImageAssetTask to the list of active tasks
  156532. * @param taskName defines the name of the new task
  156533. * @param url defines the url of the file to load
  156534. * @returns a new ImageAssetTask object
  156535. */
  156536. addImageTask(taskName: string, url: string): ImageAssetTask;
  156537. /**
  156538. * Add a TextureAssetTask to the list of active tasks
  156539. * @param taskName defines the name of the new task
  156540. * @param url defines the url of the file to load
  156541. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156542. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156543. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156544. * @returns a new TextureAssetTask object
  156545. */
  156546. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156547. /**
  156548. * Add a CubeTextureAssetTask to the list of active tasks
  156549. * @param taskName defines the name of the new task
  156550. * @param url defines the url of the file to load
  156551. * @param extensions defines the extension to use to load the cube map (can be null)
  156552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156553. * @param files defines the list of files to load (can be null)
  156554. * @returns a new CubeTextureAssetTask object
  156555. */
  156556. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156557. /**
  156558. *
  156559. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156560. * @param taskName defines the name of the new task
  156561. * @param url defines the url of the file to load
  156562. * @param size defines the size you want for the cubemap (can be null)
  156563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156564. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156565. * @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)
  156566. * @param reserved Internal use only
  156567. * @returns a new HDRCubeTextureAssetTask object
  156568. */
  156569. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156570. /**
  156571. *
  156572. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156573. * @param taskName defines the name of the new task
  156574. * @param url defines the url of the file to load
  156575. * @param size defines the size you want for the cubemap (can be null)
  156576. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156577. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156578. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156579. * @returns a new EquiRectangularCubeTextureAssetTask object
  156580. */
  156581. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156582. /**
  156583. * Remove a task from the assets manager.
  156584. * @param task the task to remove
  156585. */
  156586. removeTask(task: AbstractAssetTask): void;
  156587. private _decreaseWaitingTasksCount;
  156588. private _runTask;
  156589. /**
  156590. * Reset the AssetsManager and remove all tasks
  156591. * @return the current instance of the AssetsManager
  156592. */
  156593. reset(): AssetsManager;
  156594. /**
  156595. * Start the loading process
  156596. * @return the current instance of the AssetsManager
  156597. */
  156598. load(): AssetsManager;
  156599. /**
  156600. * Start the loading process as an async operation
  156601. * @return a promise returning the list of failed tasks
  156602. */
  156603. loadAsync(): Promise<void>;
  156604. }
  156605. }
  156606. declare module BABYLON {
  156607. /**
  156608. * Wrapper class for promise with external resolve and reject.
  156609. */
  156610. export class Deferred<T> {
  156611. /**
  156612. * The promise associated with this deferred object.
  156613. */
  156614. readonly promise: Promise<T>;
  156615. private _resolve;
  156616. private _reject;
  156617. /**
  156618. * The resolve method of the promise associated with this deferred object.
  156619. */
  156620. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156621. /**
  156622. * The reject method of the promise associated with this deferred object.
  156623. */
  156624. get reject(): (reason?: any) => void;
  156625. /**
  156626. * Constructor for this deferred object.
  156627. */
  156628. constructor();
  156629. }
  156630. }
  156631. declare module BABYLON {
  156632. /**
  156633. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156634. */
  156635. export class MeshExploder {
  156636. private _centerMesh;
  156637. private _meshes;
  156638. private _meshesOrigins;
  156639. private _toCenterVectors;
  156640. private _scaledDirection;
  156641. private _newPosition;
  156642. private _centerPosition;
  156643. /**
  156644. * Explodes meshes from a center mesh.
  156645. * @param meshes The meshes to explode.
  156646. * @param centerMesh The mesh to be center of explosion.
  156647. */
  156648. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156649. private _setCenterMesh;
  156650. /**
  156651. * Get class name
  156652. * @returns "MeshExploder"
  156653. */
  156654. getClassName(): string;
  156655. /**
  156656. * "Exploded meshes"
  156657. * @returns Array of meshes with the centerMesh at index 0.
  156658. */
  156659. getMeshes(): Array<Mesh>;
  156660. /**
  156661. * Explodes meshes giving a specific direction
  156662. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156663. */
  156664. explode(direction?: number): void;
  156665. }
  156666. }
  156667. declare module BABYLON {
  156668. /**
  156669. * Class used to help managing file picking and drag'n'drop
  156670. */
  156671. export class FilesInput {
  156672. /**
  156673. * List of files ready to be loaded
  156674. */
  156675. static get FilesToLoad(): {
  156676. [key: string]: File;
  156677. };
  156678. /**
  156679. * Callback called when a file is processed
  156680. */
  156681. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156682. private _engine;
  156683. private _currentScene;
  156684. private _sceneLoadedCallback;
  156685. private _progressCallback;
  156686. private _additionalRenderLoopLogicCallback;
  156687. private _textureLoadingCallback;
  156688. private _startingProcessingFilesCallback;
  156689. private _onReloadCallback;
  156690. private _errorCallback;
  156691. private _elementToMonitor;
  156692. private _sceneFileToLoad;
  156693. private _filesToLoad;
  156694. /**
  156695. * Creates a new FilesInput
  156696. * @param engine defines the rendering engine
  156697. * @param scene defines the hosting scene
  156698. * @param sceneLoadedCallback callback called when scene is loaded
  156699. * @param progressCallback callback called to track progress
  156700. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156701. * @param textureLoadingCallback callback called when a texture is loading
  156702. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156703. * @param onReloadCallback callback called when a reload is requested
  156704. * @param errorCallback callback call if an error occurs
  156705. */
  156706. 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>);
  156707. private _dragEnterHandler;
  156708. private _dragOverHandler;
  156709. private _dropHandler;
  156710. /**
  156711. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156712. * @param elementToMonitor defines the DOM element to track
  156713. */
  156714. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156715. /** Gets the current list of files to load */
  156716. get filesToLoad(): File[];
  156717. /**
  156718. * Release all associated resources
  156719. */
  156720. dispose(): void;
  156721. private renderFunction;
  156722. private drag;
  156723. private drop;
  156724. private _traverseFolder;
  156725. private _processFiles;
  156726. /**
  156727. * Load files from a drop event
  156728. * @param event defines the drop event to use as source
  156729. */
  156730. loadFiles(event: any): void;
  156731. private _processReload;
  156732. /**
  156733. * Reload the current scene from the loaded files
  156734. */
  156735. reload(): void;
  156736. }
  156737. }
  156738. declare module BABYLON {
  156739. /**
  156740. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156741. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156742. */
  156743. export class SceneOptimization {
  156744. /**
  156745. * Defines the priority of this optimization (0 by default which means first in the list)
  156746. */
  156747. priority: number;
  156748. /**
  156749. * Gets a string describing the action executed by the current optimization
  156750. * @returns description string
  156751. */
  156752. getDescription(): string;
  156753. /**
  156754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156755. * @param scene defines the current scene where to apply this optimization
  156756. * @param optimizer defines the current optimizer
  156757. * @returns true if everything that can be done was applied
  156758. */
  156759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156760. /**
  156761. * Creates the SceneOptimization object
  156762. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156763. * @param desc defines the description associated with the optimization
  156764. */
  156765. constructor(
  156766. /**
  156767. * Defines the priority of this optimization (0 by default which means first in the list)
  156768. */
  156769. priority?: number);
  156770. }
  156771. /**
  156772. * Defines an optimization used to reduce the size of render target textures
  156773. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156774. */
  156775. export class TextureOptimization extends SceneOptimization {
  156776. /**
  156777. * Defines the priority of this optimization (0 by default which means first in the list)
  156778. */
  156779. priority: number;
  156780. /**
  156781. * 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
  156782. */
  156783. maximumSize: number;
  156784. /**
  156785. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156786. */
  156787. step: number;
  156788. /**
  156789. * Gets a string describing the action executed by the current optimization
  156790. * @returns description string
  156791. */
  156792. getDescription(): string;
  156793. /**
  156794. * Creates the TextureOptimization object
  156795. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156796. * @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
  156797. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156798. */
  156799. constructor(
  156800. /**
  156801. * Defines the priority of this optimization (0 by default which means first in the list)
  156802. */
  156803. priority?: number,
  156804. /**
  156805. * 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
  156806. */
  156807. maximumSize?: number,
  156808. /**
  156809. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156810. */
  156811. step?: number);
  156812. /**
  156813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156814. * @param scene defines the current scene where to apply this optimization
  156815. * @param optimizer defines the current optimizer
  156816. * @returns true if everything that can be done was applied
  156817. */
  156818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156819. }
  156820. /**
  156821. * Defines an optimization used to increase or decrease the rendering resolution
  156822. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156823. */
  156824. export class HardwareScalingOptimization extends SceneOptimization {
  156825. /**
  156826. * Defines the priority of this optimization (0 by default which means first in the list)
  156827. */
  156828. priority: number;
  156829. /**
  156830. * Defines the maximum scale to use (2 by default)
  156831. */
  156832. maximumScale: number;
  156833. /**
  156834. * Defines the step to use between two passes (0.5 by default)
  156835. */
  156836. step: number;
  156837. private _currentScale;
  156838. private _directionOffset;
  156839. /**
  156840. * Gets a string describing the action executed by the current optimization
  156841. * @return description string
  156842. */
  156843. getDescription(): string;
  156844. /**
  156845. * Creates the HardwareScalingOptimization object
  156846. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156847. * @param maximumScale defines the maximum scale to use (2 by default)
  156848. * @param step defines the step to use between two passes (0.5 by default)
  156849. */
  156850. constructor(
  156851. /**
  156852. * Defines the priority of this optimization (0 by default which means first in the list)
  156853. */
  156854. priority?: number,
  156855. /**
  156856. * Defines the maximum scale to use (2 by default)
  156857. */
  156858. maximumScale?: number,
  156859. /**
  156860. * Defines the step to use between two passes (0.5 by default)
  156861. */
  156862. step?: number);
  156863. /**
  156864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156865. * @param scene defines the current scene where to apply this optimization
  156866. * @param optimizer defines the current optimizer
  156867. * @returns true if everything that can be done was applied
  156868. */
  156869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156870. }
  156871. /**
  156872. * Defines an optimization used to remove shadows
  156873. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156874. */
  156875. export class ShadowsOptimization extends SceneOptimization {
  156876. /**
  156877. * Gets a string describing the action executed by the current optimization
  156878. * @return description string
  156879. */
  156880. getDescription(): string;
  156881. /**
  156882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156883. * @param scene defines the current scene where to apply this optimization
  156884. * @param optimizer defines the current optimizer
  156885. * @returns true if everything that can be done was applied
  156886. */
  156887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156888. }
  156889. /**
  156890. * Defines an optimization used to turn post-processes off
  156891. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156892. */
  156893. export class PostProcessesOptimization extends SceneOptimization {
  156894. /**
  156895. * Gets a string describing the action executed by the current optimization
  156896. * @return description string
  156897. */
  156898. getDescription(): string;
  156899. /**
  156900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156901. * @param scene defines the current scene where to apply this optimization
  156902. * @param optimizer defines the current optimizer
  156903. * @returns true if everything that can be done was applied
  156904. */
  156905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156906. }
  156907. /**
  156908. * Defines an optimization used to turn lens flares off
  156909. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156910. */
  156911. export class LensFlaresOptimization extends SceneOptimization {
  156912. /**
  156913. * Gets a string describing the action executed by the current optimization
  156914. * @return description string
  156915. */
  156916. getDescription(): string;
  156917. /**
  156918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156919. * @param scene defines the current scene where to apply this optimization
  156920. * @param optimizer defines the current optimizer
  156921. * @returns true if everything that can be done was applied
  156922. */
  156923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156924. }
  156925. /**
  156926. * Defines an optimization based on user defined callback.
  156927. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156928. */
  156929. export class CustomOptimization extends SceneOptimization {
  156930. /**
  156931. * Callback called to apply the custom optimization.
  156932. */
  156933. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156934. /**
  156935. * Callback called to get custom description
  156936. */
  156937. onGetDescription: () => string;
  156938. /**
  156939. * Gets a string describing the action executed by the current optimization
  156940. * @returns description string
  156941. */
  156942. getDescription(): string;
  156943. /**
  156944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156945. * @param scene defines the current scene where to apply this optimization
  156946. * @param optimizer defines the current optimizer
  156947. * @returns true if everything that can be done was applied
  156948. */
  156949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156950. }
  156951. /**
  156952. * Defines an optimization used to turn particles off
  156953. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156954. */
  156955. export class ParticlesOptimization extends SceneOptimization {
  156956. /**
  156957. * Gets a string describing the action executed by the current optimization
  156958. * @return description string
  156959. */
  156960. getDescription(): string;
  156961. /**
  156962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156963. * @param scene defines the current scene where to apply this optimization
  156964. * @param optimizer defines the current optimizer
  156965. * @returns true if everything that can be done was applied
  156966. */
  156967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156968. }
  156969. /**
  156970. * Defines an optimization used to turn render targets off
  156971. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156972. */
  156973. export class RenderTargetsOptimization extends SceneOptimization {
  156974. /**
  156975. * Gets a string describing the action executed by the current optimization
  156976. * @return description string
  156977. */
  156978. getDescription(): string;
  156979. /**
  156980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156981. * @param scene defines the current scene where to apply this optimization
  156982. * @param optimizer defines the current optimizer
  156983. * @returns true if everything that can be done was applied
  156984. */
  156985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156986. }
  156987. /**
  156988. * Defines an optimization used to merge meshes with compatible materials
  156989. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156990. */
  156991. export class MergeMeshesOptimization extends SceneOptimization {
  156992. private static _UpdateSelectionTree;
  156993. /**
  156994. * Gets or sets a boolean which defines if optimization octree has to be updated
  156995. */
  156996. static get UpdateSelectionTree(): boolean;
  156997. /**
  156998. * Gets or sets a boolean which defines if optimization octree has to be updated
  156999. */
  157000. static set UpdateSelectionTree(value: boolean);
  157001. /**
  157002. * Gets a string describing the action executed by the current optimization
  157003. * @return description string
  157004. */
  157005. getDescription(): string;
  157006. private _canBeMerged;
  157007. /**
  157008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  157009. * @param scene defines the current scene where to apply this optimization
  157010. * @param optimizer defines the current optimizer
  157011. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  157012. * @returns true if everything that can be done was applied
  157013. */
  157014. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  157015. }
  157016. /**
  157017. * Defines a list of options used by SceneOptimizer
  157018. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157019. */
  157020. export class SceneOptimizerOptions {
  157021. /**
  157022. * Defines the target frame rate to reach (60 by default)
  157023. */
  157024. targetFrameRate: number;
  157025. /**
  157026. * Defines the interval between two checkes (2000ms by default)
  157027. */
  157028. trackerDuration: number;
  157029. /**
  157030. * Gets the list of optimizations to apply
  157031. */
  157032. optimizations: SceneOptimization[];
  157033. /**
  157034. * Creates a new list of options used by SceneOptimizer
  157035. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  157036. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  157037. */
  157038. constructor(
  157039. /**
  157040. * Defines the target frame rate to reach (60 by default)
  157041. */
  157042. targetFrameRate?: number,
  157043. /**
  157044. * Defines the interval between two checkes (2000ms by default)
  157045. */
  157046. trackerDuration?: number);
  157047. /**
  157048. * Add a new optimization
  157049. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  157050. * @returns the current SceneOptimizerOptions
  157051. */
  157052. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  157053. /**
  157054. * Add a new custom optimization
  157055. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  157056. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  157057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  157058. * @returns the current SceneOptimizerOptions
  157059. */
  157060. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  157061. /**
  157062. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  157063. * @param targetFrameRate defines the target frame rate (60 by default)
  157064. * @returns a SceneOptimizerOptions object
  157065. */
  157066. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157067. /**
  157068. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  157069. * @param targetFrameRate defines the target frame rate (60 by default)
  157070. * @returns a SceneOptimizerOptions object
  157071. */
  157072. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157073. /**
  157074. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  157075. * @param targetFrameRate defines the target frame rate (60 by default)
  157076. * @returns a SceneOptimizerOptions object
  157077. */
  157078. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157079. }
  157080. /**
  157081. * Class used to run optimizations in order to reach a target frame rate
  157082. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157083. */
  157084. export class SceneOptimizer implements IDisposable {
  157085. private _isRunning;
  157086. private _options;
  157087. private _scene;
  157088. private _currentPriorityLevel;
  157089. private _targetFrameRate;
  157090. private _trackerDuration;
  157091. private _currentFrameRate;
  157092. private _sceneDisposeObserver;
  157093. private _improvementMode;
  157094. /**
  157095. * Defines an observable called when the optimizer reaches the target frame rate
  157096. */
  157097. onSuccessObservable: Observable<SceneOptimizer>;
  157098. /**
  157099. * Defines an observable called when the optimizer enables an optimization
  157100. */
  157101. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  157102. /**
  157103. * Defines an observable called when the optimizer is not able to reach the target frame rate
  157104. */
  157105. onFailureObservable: Observable<SceneOptimizer>;
  157106. /**
  157107. * Gets a boolean indicating if the optimizer is in improvement mode
  157108. */
  157109. get isInImprovementMode(): boolean;
  157110. /**
  157111. * Gets the current priority level (0 at start)
  157112. */
  157113. get currentPriorityLevel(): number;
  157114. /**
  157115. * Gets the current frame rate checked by the SceneOptimizer
  157116. */
  157117. get currentFrameRate(): number;
  157118. /**
  157119. * Gets or sets the current target frame rate (60 by default)
  157120. */
  157121. get targetFrameRate(): number;
  157122. /**
  157123. * Gets or sets the current target frame rate (60 by default)
  157124. */
  157125. set targetFrameRate(value: number);
  157126. /**
  157127. * Gets or sets the current interval between two checks (every 2000ms by default)
  157128. */
  157129. get trackerDuration(): number;
  157130. /**
  157131. * Gets or sets the current interval between two checks (every 2000ms by default)
  157132. */
  157133. set trackerDuration(value: number);
  157134. /**
  157135. * Gets the list of active optimizations
  157136. */
  157137. get optimizations(): SceneOptimization[];
  157138. /**
  157139. * Creates a new SceneOptimizer
  157140. * @param scene defines the scene to work on
  157141. * @param options defines the options to use with the SceneOptimizer
  157142. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  157143. * @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)
  157144. */
  157145. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  157146. /**
  157147. * Stops the current optimizer
  157148. */
  157149. stop(): void;
  157150. /**
  157151. * Reset the optimizer to initial step (current priority level = 0)
  157152. */
  157153. reset(): void;
  157154. /**
  157155. * Start the optimizer. By default it will try to reach a specific framerate
  157156. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  157157. */
  157158. start(): void;
  157159. private _checkCurrentState;
  157160. /**
  157161. * Release all resources
  157162. */
  157163. dispose(): void;
  157164. /**
  157165. * Helper function to create a SceneOptimizer with one single line of code
  157166. * @param scene defines the scene to work on
  157167. * @param options defines the options to use with the SceneOptimizer
  157168. * @param onSuccess defines a callback to call on success
  157169. * @param onFailure defines a callback to call on failure
  157170. * @returns the new SceneOptimizer object
  157171. */
  157172. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  157173. }
  157174. }
  157175. declare module BABYLON {
  157176. /**
  157177. * Class used to serialize a scene into a string
  157178. */
  157179. export class SceneSerializer {
  157180. /**
  157181. * Clear cache used by a previous serialization
  157182. */
  157183. static ClearCache(): void;
  157184. /**
  157185. * Serialize a scene into a JSON compatible object
  157186. * @param scene defines the scene to serialize
  157187. * @returns a JSON compatible object
  157188. */
  157189. static Serialize(scene: Scene): any;
  157190. /**
  157191. * Serialize a mesh into a JSON compatible object
  157192. * @param toSerialize defines the mesh to serialize
  157193. * @param withParents defines if parents must be serialized as well
  157194. * @param withChildren defines if children must be serialized as well
  157195. * @returns a JSON compatible object
  157196. */
  157197. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  157198. }
  157199. }
  157200. declare module BABYLON {
  157201. /**
  157202. * Class used to host texture specific utilities
  157203. */
  157204. export class TextureTools {
  157205. /**
  157206. * Uses the GPU to create a copy texture rescaled at a given size
  157207. * @param texture Texture to copy from
  157208. * @param width defines the desired width
  157209. * @param height defines the desired height
  157210. * @param useBilinearMode defines if bilinear mode has to be used
  157211. * @return the generated texture
  157212. */
  157213. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  157214. }
  157215. }
  157216. declare module BABYLON {
  157217. /**
  157218. * This represents the different options available for the video capture.
  157219. */
  157220. export interface VideoRecorderOptions {
  157221. /** Defines the mime type of the video. */
  157222. mimeType: string;
  157223. /** Defines the FPS the video should be recorded at. */
  157224. fps: number;
  157225. /** Defines the chunk size for the recording data. */
  157226. recordChunckSize: number;
  157227. /** The audio tracks to attach to the recording. */
  157228. audioTracks?: MediaStreamTrack[];
  157229. }
  157230. /**
  157231. * This can help with recording videos from BabylonJS.
  157232. * This is based on the available WebRTC functionalities of the browser.
  157233. *
  157234. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  157235. */
  157236. export class VideoRecorder {
  157237. private static readonly _defaultOptions;
  157238. /**
  157239. * Returns whether or not the VideoRecorder is available in your browser.
  157240. * @param engine Defines the Babylon Engine.
  157241. * @returns true if supported otherwise false.
  157242. */
  157243. static IsSupported(engine: Engine): boolean;
  157244. private readonly _options;
  157245. private _canvas;
  157246. private _mediaRecorder;
  157247. private _recordedChunks;
  157248. private _fileName;
  157249. private _resolve;
  157250. private _reject;
  157251. /**
  157252. * True when a recording is already in progress.
  157253. */
  157254. get isRecording(): boolean;
  157255. /**
  157256. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  157257. * @param engine Defines the BabylonJS Engine you wish to record.
  157258. * @param options Defines options that can be used to customize the capture.
  157259. */
  157260. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  157261. /**
  157262. * Stops the current recording before the default capture timeout passed in the startRecording function.
  157263. */
  157264. stopRecording(): void;
  157265. /**
  157266. * Starts recording the canvas for a max duration specified in parameters.
  157267. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  157268. * If null no automatic download will start and you can rely on the promise to get the data back.
  157269. * @param maxDuration Defines the maximum recording time in seconds.
  157270. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  157271. * @return A promise callback at the end of the recording with the video data in Blob.
  157272. */
  157273. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  157274. /**
  157275. * Releases internal resources used during the recording.
  157276. */
  157277. dispose(): void;
  157278. private _handleDataAvailable;
  157279. private _handleError;
  157280. private _handleStop;
  157281. }
  157282. }
  157283. declare module BABYLON {
  157284. /**
  157285. * Class containing a set of static utilities functions for screenshots
  157286. */
  157287. export class ScreenshotTools {
  157288. /**
  157289. * Captures a screenshot of the current rendering
  157290. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157291. * @param engine defines the rendering engine
  157292. * @param camera defines the source camera
  157293. * @param size This parameter can be set to a single number or to an object with the
  157294. * following (optional) properties: precision, width, height. If a single number is passed,
  157295. * it will be used for both width and height. If an object is passed, the screenshot size
  157296. * will be derived from the parameters. The precision property is a multiplier allowing
  157297. * rendering at a higher or lower resolution
  157298. * @param successCallback defines the callback receives a single parameter which contains the
  157299. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157300. * src parameter of an <img> to display it
  157301. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157302. * Check your browser for supported MIME types
  157303. */
  157304. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  157305. /**
  157306. * Captures a screenshot of the current rendering
  157307. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157308. * @param engine defines the rendering engine
  157309. * @param camera defines the source camera
  157310. * @param size This parameter can be set to a single number or to an object with the
  157311. * following (optional) properties: precision, width, height. If a single number is passed,
  157312. * it will be used for both width and height. If an object is passed, the screenshot size
  157313. * will be derived from the parameters. The precision property is a multiplier allowing
  157314. * rendering at a higher or lower resolution
  157315. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157316. * Check your browser for supported MIME types
  157317. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157318. * to the src parameter of an <img> to display it
  157319. */
  157320. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  157321. /**
  157322. * Generates an image screenshot from the specified camera.
  157323. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157324. * @param engine The engine to use for rendering
  157325. * @param camera The camera to use for rendering
  157326. * @param size This parameter can be set to a single number or to an object with the
  157327. * following (optional) properties: precision, width, height. If a single number is passed,
  157328. * it will be used for both width and height. If an object is passed, the screenshot size
  157329. * will be derived from the parameters. The precision property is a multiplier allowing
  157330. * rendering at a higher or lower resolution
  157331. * @param successCallback The callback receives a single parameter which contains the
  157332. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157333. * src parameter of an <img> to display it
  157334. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157335. * Check your browser for supported MIME types
  157336. * @param samples Texture samples (default: 1)
  157337. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157338. * @param fileName A name for for the downloaded file.
  157339. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157340. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  157341. */
  157342. 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;
  157343. /**
  157344. * Generates an image screenshot from the specified camera.
  157345. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157346. * @param engine The engine to use for rendering
  157347. * @param camera The camera to use for rendering
  157348. * @param size This parameter can be set to a single number or to an object with the
  157349. * following (optional) properties: precision, width, height. If a single number is passed,
  157350. * it will be used for both width and height. If an object is passed, the screenshot size
  157351. * will be derived from the parameters. The precision property is a multiplier allowing
  157352. * rendering at a higher or lower resolution
  157353. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157354. * Check your browser for supported MIME types
  157355. * @param samples Texture samples (default: 1)
  157356. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157357. * @param fileName A name for for the downloaded file.
  157358. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157359. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157360. * to the src parameter of an <img> to display it
  157361. */
  157362. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  157363. /**
  157364. * Gets height and width for screenshot size
  157365. * @private
  157366. */
  157367. private static _getScreenshotSize;
  157368. }
  157369. }
  157370. declare module BABYLON {
  157371. /**
  157372. * Interface for a data buffer
  157373. */
  157374. export interface IDataBuffer {
  157375. /**
  157376. * Reads bytes from the data buffer.
  157377. * @param byteOffset The byte offset to read
  157378. * @param byteLength The byte length to read
  157379. * @returns A promise that resolves when the bytes are read
  157380. */
  157381. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  157382. /**
  157383. * The byte length of the buffer.
  157384. */
  157385. readonly byteLength: number;
  157386. }
  157387. /**
  157388. * Utility class for reading from a data buffer
  157389. */
  157390. export class DataReader {
  157391. /**
  157392. * The data buffer associated with this data reader.
  157393. */
  157394. readonly buffer: IDataBuffer;
  157395. /**
  157396. * The current byte offset from the beginning of the data buffer.
  157397. */
  157398. byteOffset: number;
  157399. private _dataView;
  157400. private _dataByteOffset;
  157401. /**
  157402. * Constructor
  157403. * @param buffer The buffer to read
  157404. */
  157405. constructor(buffer: IDataBuffer);
  157406. /**
  157407. * Loads the given byte length.
  157408. * @param byteLength The byte length to load
  157409. * @returns A promise that resolves when the load is complete
  157410. */
  157411. loadAsync(byteLength: number): Promise<void>;
  157412. /**
  157413. * Read a unsigned 32-bit integer from the currently loaded data range.
  157414. * @returns The 32-bit integer read
  157415. */
  157416. readUint32(): number;
  157417. /**
  157418. * Read a byte array from the currently loaded data range.
  157419. * @param byteLength The byte length to read
  157420. * @returns The byte array read
  157421. */
  157422. readUint8Array(byteLength: number): Uint8Array;
  157423. /**
  157424. * Read a string from the currently loaded data range.
  157425. * @param byteLength The byte length to read
  157426. * @returns The string read
  157427. */
  157428. readString(byteLength: number): string;
  157429. /**
  157430. * Skips the given byte length the currently loaded data range.
  157431. * @param byteLength The byte length to skip
  157432. */
  157433. skipBytes(byteLength: number): void;
  157434. }
  157435. }
  157436. declare module BABYLON {
  157437. /**
  157438. * Class for storing data to local storage if available or in-memory storage otherwise
  157439. */
  157440. export class DataStorage {
  157441. private static _Storage;
  157442. private static _GetStorage;
  157443. /**
  157444. * Reads a string from the data storage
  157445. * @param key The key to read
  157446. * @param defaultValue The value if the key doesn't exist
  157447. * @returns The string value
  157448. */
  157449. static ReadString(key: string, defaultValue: string): string;
  157450. /**
  157451. * Writes a string to the data storage
  157452. * @param key The key to write
  157453. * @param value The value to write
  157454. */
  157455. static WriteString(key: string, value: string): void;
  157456. /**
  157457. * Reads a boolean from the data storage
  157458. * @param key The key to read
  157459. * @param defaultValue The value if the key doesn't exist
  157460. * @returns The boolean value
  157461. */
  157462. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157463. /**
  157464. * Writes a boolean to the data storage
  157465. * @param key The key to write
  157466. * @param value The value to write
  157467. */
  157468. static WriteBoolean(key: string, value: boolean): void;
  157469. /**
  157470. * Reads a number from the data storage
  157471. * @param key The key to read
  157472. * @param defaultValue The value if the key doesn't exist
  157473. * @returns The number value
  157474. */
  157475. static ReadNumber(key: string, defaultValue: number): number;
  157476. /**
  157477. * Writes a number to the data storage
  157478. * @param key The key to write
  157479. * @param value The value to write
  157480. */
  157481. static WriteNumber(key: string, value: number): void;
  157482. }
  157483. }
  157484. declare module BABYLON {
  157485. /**
  157486. * Class used to record delta files between 2 scene states
  157487. */
  157488. export class SceneRecorder {
  157489. private _trackedScene;
  157490. private _savedJSON;
  157491. /**
  157492. * Track a given scene. This means the current scene state will be considered the original state
  157493. * @param scene defines the scene to track
  157494. */
  157495. track(scene: Scene): void;
  157496. /**
  157497. * Get the delta between current state and original state
  157498. * @returns a string containing the delta
  157499. */
  157500. getDelta(): any;
  157501. private _compareArray;
  157502. private _compareObjects;
  157503. private _compareCollections;
  157504. private static GetShadowGeneratorById;
  157505. /**
  157506. * Apply a given delta to a given scene
  157507. * @param deltaJSON defines the JSON containing the delta
  157508. * @param scene defines the scene to apply the delta to
  157509. */
  157510. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157511. private static _ApplyPropertiesToEntity;
  157512. private static _ApplyDeltaForEntity;
  157513. }
  157514. }
  157515. declare module BABYLON {
  157516. /**
  157517. * A 3D trajectory consisting of an order list of vectors describing a
  157518. * path of motion through 3D space.
  157519. */
  157520. export class Trajectory {
  157521. private _points;
  157522. private readonly _segmentLength;
  157523. /**
  157524. * Serialize to JSON.
  157525. * @returns serialized JSON string
  157526. */
  157527. serialize(): string;
  157528. /**
  157529. * Deserialize from JSON.
  157530. * @param json serialized JSON string
  157531. * @returns deserialized Trajectory
  157532. */
  157533. static Deserialize(json: string): Trajectory;
  157534. /**
  157535. * Create a new empty Trajectory.
  157536. * @param segmentLength radius of discretization for Trajectory points
  157537. */
  157538. constructor(segmentLength?: number);
  157539. /**
  157540. * Get the length of the Trajectory.
  157541. * @returns length of the Trajectory
  157542. */
  157543. getLength(): number;
  157544. /**
  157545. * Append a new point to the Trajectory.
  157546. * NOTE: This implementation has many allocations.
  157547. * @param point point to append to the Trajectory
  157548. */
  157549. add(point: DeepImmutable<Vector3>): void;
  157550. /**
  157551. * Create a new Trajectory with a segment length chosen to make it
  157552. * probable that the new Trajectory will have a specified number of
  157553. * segments. This operation is imprecise.
  157554. * @param targetResolution number of segments desired
  157555. * @returns new Trajectory with approximately the requested number of segments
  157556. */
  157557. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157558. /**
  157559. * Convert Trajectory segments into tokenized representation. This
  157560. * representation is an array of numbers where each nth number is the
  157561. * index of the token which is most similar to the nth segment of the
  157562. * Trajectory.
  157563. * @param tokens list of vectors which serve as discrete tokens
  157564. * @returns list of indices of most similar token per segment
  157565. */
  157566. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157567. private static _forwardDir;
  157568. private static _inverseFromVec;
  157569. private static _upDir;
  157570. private static _fromToVec;
  157571. private static _lookMatrix;
  157572. /**
  157573. * Transform the rotation (i.e., direction) of a segment to isolate
  157574. * the relative transformation represented by the segment. This operation
  157575. * may or may not succeed due to singularities in the equations that define
  157576. * motion relativity in this context.
  157577. * @param priorVec the origin of the prior segment
  157578. * @param fromVec the origin of the current segment
  157579. * @param toVec the destination of the current segment
  157580. * @param result reference to output variable
  157581. * @returns whether or not transformation was successful
  157582. */
  157583. private static _transformSegmentDirToRef;
  157584. private static _bestMatch;
  157585. private static _score;
  157586. private static _bestScore;
  157587. /**
  157588. * Determine which token vector is most similar to the
  157589. * segment vector.
  157590. * @param segment segment vector
  157591. * @param tokens token vector list
  157592. * @returns index of the most similar token to the segment
  157593. */
  157594. private static _tokenizeSegment;
  157595. }
  157596. /**
  157597. * Class representing a set of known, named trajectories to which Trajectories can be
  157598. * added and using which Trajectories can be recognized.
  157599. */
  157600. export class TrajectoryClassifier {
  157601. private _maximumAllowableMatchCost;
  157602. private _vector3Alphabet;
  157603. private _levenshteinAlphabet;
  157604. private _nameToDescribedTrajectory;
  157605. /**
  157606. * Serialize to JSON.
  157607. * @returns JSON serialization
  157608. */
  157609. serialize(): string;
  157610. /**
  157611. * Deserialize from JSON.
  157612. * @param json JSON serialization
  157613. * @returns deserialized TrajectorySet
  157614. */
  157615. static Deserialize(json: string): TrajectoryClassifier;
  157616. /**
  157617. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157618. * VERY naive, need to be generating these things from known
  157619. * sets. Better version later, probably eliminating this one.
  157620. * @returns auto-generated TrajectorySet
  157621. */
  157622. static Generate(): TrajectoryClassifier;
  157623. private constructor();
  157624. /**
  157625. * Add a new Trajectory to the set with a given name.
  157626. * @param trajectory new Trajectory to be added
  157627. * @param classification name to which to add the Trajectory
  157628. */
  157629. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157630. /**
  157631. * Remove a known named trajectory and all Trajectories associated with it.
  157632. * @param classification name to remove
  157633. * @returns whether anything was removed
  157634. */
  157635. deleteClassification(classification: string): boolean;
  157636. /**
  157637. * Attempt to recognize a Trajectory from among all the classifications
  157638. * already known to the classifier.
  157639. * @param trajectory Trajectory to be recognized
  157640. * @returns classification of Trajectory if recognized, null otherwise
  157641. */
  157642. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157643. }
  157644. }
  157645. declare module BABYLON {
  157646. /**
  157647. * An interface for all Hit test features
  157648. */
  157649. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157650. /**
  157651. * Triggered when new babylon (transformed) hit test results are available
  157652. */
  157653. onHitTestResultObservable: Observable<T[]>;
  157654. }
  157655. /**
  157656. * Options used for hit testing
  157657. */
  157658. export interface IWebXRLegacyHitTestOptions {
  157659. /**
  157660. * Only test when user interacted with the scene. Default - hit test every frame
  157661. */
  157662. testOnPointerDownOnly?: boolean;
  157663. /**
  157664. * The node to use to transform the local results to world coordinates
  157665. */
  157666. worldParentNode?: TransformNode;
  157667. }
  157668. /**
  157669. * Interface defining the babylon result of raycasting/hit-test
  157670. */
  157671. export interface IWebXRLegacyHitResult {
  157672. /**
  157673. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157674. */
  157675. transformationMatrix: Matrix;
  157676. /**
  157677. * The native hit test result
  157678. */
  157679. xrHitResult: XRHitResult | XRHitTestResult;
  157680. }
  157681. /**
  157682. * The currently-working hit-test module.
  157683. * Hit test (or Ray-casting) is used to interact with the real world.
  157684. * For further information read here - https://github.com/immersive-web/hit-test
  157685. */
  157686. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157687. /**
  157688. * options to use when constructing this feature
  157689. */
  157690. readonly options: IWebXRLegacyHitTestOptions;
  157691. private _direction;
  157692. private _mat;
  157693. private _onSelectEnabled;
  157694. private _origin;
  157695. /**
  157696. * The module's name
  157697. */
  157698. static readonly Name: string;
  157699. /**
  157700. * The (Babylon) version of this module.
  157701. * This is an integer representing the implementation version.
  157702. * This number does not correspond to the WebXR specs version
  157703. */
  157704. static readonly Version: number;
  157705. /**
  157706. * Populated with the last native XR Hit Results
  157707. */
  157708. lastNativeXRHitResults: XRHitResult[];
  157709. /**
  157710. * Triggered when new babylon (transformed) hit test results are available
  157711. */
  157712. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157713. /**
  157714. * Creates a new instance of the (legacy version) hit test feature
  157715. * @param _xrSessionManager an instance of WebXRSessionManager
  157716. * @param options options to use when constructing this feature
  157717. */
  157718. constructor(_xrSessionManager: WebXRSessionManager,
  157719. /**
  157720. * options to use when constructing this feature
  157721. */
  157722. options?: IWebXRLegacyHitTestOptions);
  157723. /**
  157724. * execute a hit test with an XR Ray
  157725. *
  157726. * @param xrSession a native xrSession that will execute this hit test
  157727. * @param xrRay the ray (position and direction) to use for ray-casting
  157728. * @param referenceSpace native XR reference space to use for the hit-test
  157729. * @param filter filter function that will filter the results
  157730. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157731. */
  157732. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157733. /**
  157734. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157735. * @param event the (select) event to use to select with
  157736. * @param referenceSpace the reference space to use for this hit test
  157737. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157738. */
  157739. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157740. /**
  157741. * attach this feature
  157742. * Will usually be called by the features manager
  157743. *
  157744. * @returns true if successful.
  157745. */
  157746. attach(): boolean;
  157747. /**
  157748. * detach this feature.
  157749. * Will usually be called by the features manager
  157750. *
  157751. * @returns true if successful.
  157752. */
  157753. detach(): boolean;
  157754. /**
  157755. * Dispose this feature and all of the resources attached
  157756. */
  157757. dispose(): void;
  157758. protected _onXRFrame(frame: XRFrame): void;
  157759. private _onHitTestResults;
  157760. private _onSelect;
  157761. }
  157762. }
  157763. declare module BABYLON {
  157764. /**
  157765. * Options used for hit testing (version 2)
  157766. */
  157767. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157768. /**
  157769. * Do not create a permanent hit test. Will usually be used when only
  157770. * transient inputs are needed.
  157771. */
  157772. disablePermanentHitTest?: boolean;
  157773. /**
  157774. * Enable transient (for example touch-based) hit test inspections
  157775. */
  157776. enableTransientHitTest?: boolean;
  157777. /**
  157778. * Offset ray for the permanent hit test
  157779. */
  157780. offsetRay?: Vector3;
  157781. /**
  157782. * Offset ray for the transient hit test
  157783. */
  157784. transientOffsetRay?: Vector3;
  157785. /**
  157786. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157787. */
  157788. useReferenceSpace?: boolean;
  157789. /**
  157790. * Override the default entity type(s) of the hit-test result
  157791. */
  157792. entityTypes?: XRHitTestTrackableType[];
  157793. }
  157794. /**
  157795. * Interface defining the babylon result of hit-test
  157796. */
  157797. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157798. /**
  157799. * The input source that generated this hit test (if transient)
  157800. */
  157801. inputSource?: XRInputSource;
  157802. /**
  157803. * Is this a transient hit test
  157804. */
  157805. isTransient?: boolean;
  157806. /**
  157807. * Position of the hit test result
  157808. */
  157809. position: Vector3;
  157810. /**
  157811. * Rotation of the hit test result
  157812. */
  157813. rotationQuaternion: Quaternion;
  157814. /**
  157815. * The native hit test result
  157816. */
  157817. xrHitResult: XRHitTestResult;
  157818. }
  157819. /**
  157820. * The currently-working hit-test module.
  157821. * Hit test (or Ray-casting) is used to interact with the real world.
  157822. * For further information read here - https://github.com/immersive-web/hit-test
  157823. *
  157824. * Tested on chrome (mobile) 80.
  157825. */
  157826. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157827. /**
  157828. * options to use when constructing this feature
  157829. */
  157830. readonly options: IWebXRHitTestOptions;
  157831. private _tmpMat;
  157832. private _tmpPos;
  157833. private _tmpQuat;
  157834. private _transientXrHitTestSource;
  157835. private _xrHitTestSource;
  157836. private initHitTestSource;
  157837. /**
  157838. * The module's name
  157839. */
  157840. static readonly Name: string;
  157841. /**
  157842. * The (Babylon) version of this module.
  157843. * This is an integer representing the implementation version.
  157844. * This number does not correspond to the WebXR specs version
  157845. */
  157846. static readonly Version: number;
  157847. /**
  157848. * When set to true, each hit test will have its own position/rotation objects
  157849. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157850. * the developers will clone them or copy them as they see fit.
  157851. */
  157852. autoCloneTransformation: boolean;
  157853. /**
  157854. * Triggered when new babylon (transformed) hit test results are available
  157855. * Note - this will be called when results come back from the device. It can be an empty array!!
  157856. */
  157857. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157858. /**
  157859. * Use this to temporarily pause hit test checks.
  157860. */
  157861. paused: boolean;
  157862. /**
  157863. * Creates a new instance of the hit test feature
  157864. * @param _xrSessionManager an instance of WebXRSessionManager
  157865. * @param options options to use when constructing this feature
  157866. */
  157867. constructor(_xrSessionManager: WebXRSessionManager,
  157868. /**
  157869. * options to use when constructing this feature
  157870. */
  157871. options?: IWebXRHitTestOptions);
  157872. /**
  157873. * attach this feature
  157874. * Will usually be called by the features manager
  157875. *
  157876. * @returns true if successful.
  157877. */
  157878. attach(): boolean;
  157879. /**
  157880. * detach this feature.
  157881. * Will usually be called by the features manager
  157882. *
  157883. * @returns true if successful.
  157884. */
  157885. detach(): boolean;
  157886. /**
  157887. * Dispose this feature and all of the resources attached
  157888. */
  157889. dispose(): void;
  157890. protected _onXRFrame(frame: XRFrame): void;
  157891. private _processWebXRHitTestResult;
  157892. }
  157893. }
  157894. declare module BABYLON {
  157895. /**
  157896. * Configuration options of the anchor system
  157897. */
  157898. export interface IWebXRAnchorSystemOptions {
  157899. /**
  157900. * a node that will be used to convert local to world coordinates
  157901. */
  157902. worldParentNode?: TransformNode;
  157903. /**
  157904. * If set to true a reference of the created anchors will be kept until the next session starts
  157905. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157906. */
  157907. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157908. }
  157909. /**
  157910. * A babylon container for an XR Anchor
  157911. */
  157912. export interface IWebXRAnchor {
  157913. /**
  157914. * A babylon-assigned ID for this anchor
  157915. */
  157916. id: number;
  157917. /**
  157918. * Transformation matrix to apply to an object attached to this anchor
  157919. */
  157920. transformationMatrix: Matrix;
  157921. /**
  157922. * The native anchor object
  157923. */
  157924. xrAnchor: XRAnchor;
  157925. /**
  157926. * if defined, this object will be constantly updated by the anchor's position and rotation
  157927. */
  157928. attachedNode?: TransformNode;
  157929. /**
  157930. * Remove this anchor from the scene
  157931. */
  157932. remove(): void;
  157933. }
  157934. /**
  157935. * An implementation of the anchor system for WebXR.
  157936. * For further information see https://github.com/immersive-web/anchors/
  157937. */
  157938. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157939. private _options;
  157940. private _lastFrameDetected;
  157941. private _trackedAnchors;
  157942. private _referenceSpaceForFrameAnchors;
  157943. private _futureAnchors;
  157944. /**
  157945. * The module's name
  157946. */
  157947. static readonly Name: string;
  157948. /**
  157949. * The (Babylon) version of this module.
  157950. * This is an integer representing the implementation version.
  157951. * This number does not correspond to the WebXR specs version
  157952. */
  157953. static readonly Version: number;
  157954. /**
  157955. * Observers registered here will be executed when a new anchor was added to the session
  157956. */
  157957. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157958. /**
  157959. * Observers registered here will be executed when an anchor was removed from the session
  157960. */
  157961. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157962. /**
  157963. * Observers registered here will be executed when an existing anchor updates
  157964. * This can execute N times every frame
  157965. */
  157966. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157967. /**
  157968. * Set the reference space to use for anchor creation, when not using a hit test.
  157969. * Will default to the session's reference space if not defined
  157970. */
  157971. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157972. /**
  157973. * constructs a new anchor system
  157974. * @param _xrSessionManager an instance of WebXRSessionManager
  157975. * @param _options configuration object for this feature
  157976. */
  157977. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157978. private _tmpVector;
  157979. private _tmpQuaternion;
  157980. private _populateTmpTransformation;
  157981. /**
  157982. * Create a new anchor point using a hit test result at a specific point in the scene
  157983. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157984. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157985. *
  157986. * @param hitTestResult The hit test result to use for this anchor creation
  157987. * @param position an optional position offset for this anchor
  157988. * @param rotationQuaternion an optional rotation offset for this anchor
  157989. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157990. */
  157991. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  157992. /**
  157993. * Add a new anchor at a specific position and rotation
  157994. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157995. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157996. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157997. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157998. *
  157999. * @param position the position in which to add an anchor
  158000. * @param rotationQuaternion an optional rotation for the anchor transformation
  158001. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  158002. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  158003. */
  158004. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  158005. /**
  158006. * Get the list of anchors currently being tracked by the system
  158007. */
  158008. get anchors(): IWebXRAnchor[];
  158009. /**
  158010. * detach this feature.
  158011. * Will usually be called by the features manager
  158012. *
  158013. * @returns true if successful.
  158014. */
  158015. detach(): boolean;
  158016. /**
  158017. * Dispose this feature and all of the resources attached
  158018. */
  158019. dispose(): void;
  158020. protected _onXRFrame(frame: XRFrame): void;
  158021. /**
  158022. * avoiding using Array.find for global support.
  158023. * @param xrAnchor the plane to find in the array
  158024. */
  158025. private _findIndexInAnchorArray;
  158026. private _updateAnchorWithXRFrame;
  158027. private _createAnchorAtTransformation;
  158028. }
  158029. }
  158030. declare module BABYLON {
  158031. /**
  158032. * Options used in the plane detector module
  158033. */
  158034. export interface IWebXRPlaneDetectorOptions {
  158035. /**
  158036. * The node to use to transform the local results to world coordinates
  158037. */
  158038. worldParentNode?: TransformNode;
  158039. /**
  158040. * If set to true a reference of the created planes will be kept until the next session starts
  158041. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  158042. */
  158043. doNotRemovePlanesOnSessionEnded?: boolean;
  158044. }
  158045. /**
  158046. * A babylon interface for a WebXR plane.
  158047. * A Plane is actually a polygon, built from N points in space
  158048. *
  158049. * Supported in chrome 79, not supported in canary 81 ATM
  158050. */
  158051. export interface IWebXRPlane {
  158052. /**
  158053. * a babylon-assigned ID for this polygon
  158054. */
  158055. id: number;
  158056. /**
  158057. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  158058. */
  158059. polygonDefinition: Array<Vector3>;
  158060. /**
  158061. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  158062. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  158063. */
  158064. transformationMatrix: Matrix;
  158065. /**
  158066. * the native xr-plane object
  158067. */
  158068. xrPlane: XRPlane;
  158069. }
  158070. /**
  158071. * The plane detector is used to detect planes in the real world when in AR
  158072. * For more information see https://github.com/immersive-web/real-world-geometry/
  158073. */
  158074. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  158075. private _options;
  158076. private _detectedPlanes;
  158077. private _enabled;
  158078. private _lastFrameDetected;
  158079. /**
  158080. * The module's name
  158081. */
  158082. static readonly Name: string;
  158083. /**
  158084. * The (Babylon) version of this module.
  158085. * This is an integer representing the implementation version.
  158086. * This number does not correspond to the WebXR specs version
  158087. */
  158088. static readonly Version: number;
  158089. /**
  158090. * Observers registered here will be executed when a new plane was added to the session
  158091. */
  158092. onPlaneAddedObservable: Observable<IWebXRPlane>;
  158093. /**
  158094. * Observers registered here will be executed when a plane is no longer detected in the session
  158095. */
  158096. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  158097. /**
  158098. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  158099. * This can execute N times every frame
  158100. */
  158101. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  158102. /**
  158103. * construct a new Plane Detector
  158104. * @param _xrSessionManager an instance of xr Session manager
  158105. * @param _options configuration to use when constructing this feature
  158106. */
  158107. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  158108. /**
  158109. * detach this feature.
  158110. * Will usually be called by the features manager
  158111. *
  158112. * @returns true if successful.
  158113. */
  158114. detach(): boolean;
  158115. /**
  158116. * Dispose this feature and all of the resources attached
  158117. */
  158118. dispose(): void;
  158119. /**
  158120. * Check if the needed objects are defined.
  158121. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158122. */
  158123. isCompatible(): boolean;
  158124. protected _onXRFrame(frame: XRFrame): void;
  158125. private _init;
  158126. private _updatePlaneWithXRPlane;
  158127. /**
  158128. * avoiding using Array.find for global support.
  158129. * @param xrPlane the plane to find in the array
  158130. */
  158131. private findIndexInPlaneArray;
  158132. }
  158133. }
  158134. declare module BABYLON {
  158135. /**
  158136. * Options interface for the background remover plugin
  158137. */
  158138. export interface IWebXRBackgroundRemoverOptions {
  158139. /**
  158140. * Further background meshes to disable when entering AR
  158141. */
  158142. backgroundMeshes?: AbstractMesh[];
  158143. /**
  158144. * flags to configure the removal of the environment helper.
  158145. * If not set, the entire background will be removed. If set, flags should be set as well.
  158146. */
  158147. environmentHelperRemovalFlags?: {
  158148. /**
  158149. * Should the skybox be removed (default false)
  158150. */
  158151. skyBox?: boolean;
  158152. /**
  158153. * Should the ground be removed (default false)
  158154. */
  158155. ground?: boolean;
  158156. };
  158157. /**
  158158. * don't disable the environment helper
  158159. */
  158160. ignoreEnvironmentHelper?: boolean;
  158161. }
  158162. /**
  158163. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  158164. */
  158165. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  158166. /**
  158167. * read-only options to be used in this module
  158168. */
  158169. readonly options: IWebXRBackgroundRemoverOptions;
  158170. /**
  158171. * The module's name
  158172. */
  158173. static readonly Name: string;
  158174. /**
  158175. * The (Babylon) version of this module.
  158176. * This is an integer representing the implementation version.
  158177. * This number does not correspond to the WebXR specs version
  158178. */
  158179. static readonly Version: number;
  158180. /**
  158181. * registered observers will be triggered when the background state changes
  158182. */
  158183. onBackgroundStateChangedObservable: Observable<boolean>;
  158184. /**
  158185. * constructs a new background remover module
  158186. * @param _xrSessionManager the session manager for this module
  158187. * @param options read-only options to be used in this module
  158188. */
  158189. constructor(_xrSessionManager: WebXRSessionManager,
  158190. /**
  158191. * read-only options to be used in this module
  158192. */
  158193. options?: IWebXRBackgroundRemoverOptions);
  158194. /**
  158195. * attach this feature
  158196. * Will usually be called by the features manager
  158197. *
  158198. * @returns true if successful.
  158199. */
  158200. attach(): boolean;
  158201. /**
  158202. * detach this feature.
  158203. * Will usually be called by the features manager
  158204. *
  158205. * @returns true if successful.
  158206. */
  158207. detach(): boolean;
  158208. /**
  158209. * Dispose this feature and all of the resources attached
  158210. */
  158211. dispose(): void;
  158212. protected _onXRFrame(_xrFrame: XRFrame): void;
  158213. private _setBackgroundState;
  158214. }
  158215. }
  158216. declare module BABYLON {
  158217. /**
  158218. * Options for the controller physics feature
  158219. */
  158220. export class IWebXRControllerPhysicsOptions {
  158221. /**
  158222. * Should the headset get its own impostor
  158223. */
  158224. enableHeadsetImpostor?: boolean;
  158225. /**
  158226. * Optional parameters for the headset impostor
  158227. */
  158228. headsetImpostorParams?: {
  158229. /**
  158230. * The type of impostor to create. Default is sphere
  158231. */
  158232. impostorType: number;
  158233. /**
  158234. * the size of the impostor. Defaults to 10cm
  158235. */
  158236. impostorSize?: number | {
  158237. width: number;
  158238. height: number;
  158239. depth: number;
  158240. };
  158241. /**
  158242. * Friction definitions
  158243. */
  158244. friction?: number;
  158245. /**
  158246. * Restitution
  158247. */
  158248. restitution?: number;
  158249. };
  158250. /**
  158251. * The physics properties of the future impostors
  158252. */
  158253. physicsProperties?: {
  158254. /**
  158255. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  158256. * Note that this requires a physics engine that supports mesh impostors!
  158257. */
  158258. useControllerMesh?: boolean;
  158259. /**
  158260. * The type of impostor to create. Default is sphere
  158261. */
  158262. impostorType?: number;
  158263. /**
  158264. * the size of the impostor. Defaults to 10cm
  158265. */
  158266. impostorSize?: number | {
  158267. width: number;
  158268. height: number;
  158269. depth: number;
  158270. };
  158271. /**
  158272. * Friction definitions
  158273. */
  158274. friction?: number;
  158275. /**
  158276. * Restitution
  158277. */
  158278. restitution?: number;
  158279. };
  158280. /**
  158281. * the xr input to use with this pointer selection
  158282. */
  158283. xrInput: WebXRInput;
  158284. }
  158285. /**
  158286. * Add physics impostor to your webxr controllers,
  158287. * including naive calculation of their linear and angular velocity
  158288. */
  158289. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  158290. private readonly _options;
  158291. private _attachController;
  158292. private _controllers;
  158293. private _debugMode;
  158294. private _delta;
  158295. private _headsetImpostor?;
  158296. private _headsetMesh?;
  158297. private _lastTimestamp;
  158298. private _tmpQuaternion;
  158299. private _tmpVector;
  158300. /**
  158301. * The module's name
  158302. */
  158303. static readonly Name: string;
  158304. /**
  158305. * The (Babylon) version of this module.
  158306. * This is an integer representing the implementation version.
  158307. * This number does not correspond to the webxr specs version
  158308. */
  158309. static readonly Version: number;
  158310. /**
  158311. * Construct a new Controller Physics Feature
  158312. * @param _xrSessionManager the corresponding xr session manager
  158313. * @param _options options to create this feature with
  158314. */
  158315. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  158316. /**
  158317. * @hidden
  158318. * enable debugging - will show console outputs and the impostor mesh
  158319. */
  158320. _enablePhysicsDebug(): void;
  158321. /**
  158322. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  158323. * @param xrController the controller to add
  158324. */
  158325. addController(xrController: WebXRInputSource): void;
  158326. /**
  158327. * attach this feature
  158328. * Will usually be called by the features manager
  158329. *
  158330. * @returns true if successful.
  158331. */
  158332. attach(): boolean;
  158333. /**
  158334. * detach this feature.
  158335. * Will usually be called by the features manager
  158336. *
  158337. * @returns true if successful.
  158338. */
  158339. detach(): boolean;
  158340. /**
  158341. * Get the headset impostor, if enabled
  158342. * @returns the impostor
  158343. */
  158344. getHeadsetImpostor(): PhysicsImpostor | undefined;
  158345. /**
  158346. * Get the physics impostor of a specific controller.
  158347. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  158348. * @param controller the controller or the controller id of which to get the impostor
  158349. * @returns the impostor or null
  158350. */
  158351. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  158352. /**
  158353. * Update the physics properties provided in the constructor
  158354. * @param newProperties the new properties object
  158355. */
  158356. setPhysicsProperties(newProperties: {
  158357. impostorType?: number;
  158358. impostorSize?: number | {
  158359. width: number;
  158360. height: number;
  158361. depth: number;
  158362. };
  158363. friction?: number;
  158364. restitution?: number;
  158365. }): void;
  158366. protected _onXRFrame(_xrFrame: any): void;
  158367. private _detachController;
  158368. }
  158369. }
  158370. declare module BABYLON {
  158371. /**
  158372. * A babylon interface for a "WebXR" feature point.
  158373. * Represents the position and confidence value of a given feature point.
  158374. */
  158375. export interface IWebXRFeaturePoint {
  158376. /**
  158377. * Represents the position of the feature point in world space.
  158378. */
  158379. position: Vector3;
  158380. /**
  158381. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  158382. */
  158383. confidenceValue: number;
  158384. }
  158385. /**
  158386. * The feature point system is used to detect feature points from real world geometry.
  158387. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  158388. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  158389. */
  158390. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  158391. private _enabled;
  158392. private _featurePointCloud;
  158393. /**
  158394. * The module's name
  158395. */
  158396. static readonly Name: string;
  158397. /**
  158398. * The (Babylon) version of this module.
  158399. * This is an integer representing the implementation version.
  158400. * This number does not correspond to the WebXR specs version
  158401. */
  158402. static readonly Version: number;
  158403. /**
  158404. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  158405. * Will notify the observers about which feature points have been added.
  158406. */
  158407. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  158408. /**
  158409. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  158410. * Will notify the observers about which feature points have been updated.
  158411. */
  158412. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  158413. /**
  158414. * The current feature point cloud maintained across frames.
  158415. */
  158416. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  158417. /**
  158418. * construct the feature point system
  158419. * @param _xrSessionManager an instance of xr Session manager
  158420. */
  158421. constructor(_xrSessionManager: WebXRSessionManager);
  158422. /**
  158423. * Detach this feature.
  158424. * Will usually be called by the features manager
  158425. *
  158426. * @returns true if successful.
  158427. */
  158428. detach(): boolean;
  158429. /**
  158430. * Dispose this feature and all of the resources attached
  158431. */
  158432. dispose(): void;
  158433. /**
  158434. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158435. */
  158436. protected _onXRFrame(frame: XRFrame): void;
  158437. /**
  158438. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158439. */
  158440. private _init;
  158441. }
  158442. }
  158443. declare module BABYLON {
  158444. /**
  158445. * Configuration interface for the hand tracking feature
  158446. */
  158447. export interface IWebXRHandTrackingOptions {
  158448. /**
  158449. * The xrInput that will be used as source for new hands
  158450. */
  158451. xrInput: WebXRInput;
  158452. /**
  158453. * Configuration object for the joint meshes
  158454. */
  158455. jointMeshes?: {
  158456. /**
  158457. * Should the meshes created be invisible (defaults to false)
  158458. */
  158459. invisible?: boolean;
  158460. /**
  158461. * A source mesh to be used to create instances. Defaults to a sphere.
  158462. * This mesh will be the source for all other (25) meshes.
  158463. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158464. */
  158465. sourceMesh?: Mesh;
  158466. /**
  158467. * This function will be called after a mesh was created for a specific joint.
  158468. * Using this function you can either manipulate the instance or return a new mesh.
  158469. * When returning a new mesh the instance created before will be disposed
  158470. */
  158471. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158472. /**
  158473. * Should the source mesh stay visible. Defaults to false
  158474. */
  158475. keepOriginalVisible?: boolean;
  158476. /**
  158477. * Scale factor for all instances (defaults to 2)
  158478. */
  158479. scaleFactor?: number;
  158480. /**
  158481. * Should each instance have its own physics impostor
  158482. */
  158483. enablePhysics?: boolean;
  158484. /**
  158485. * If enabled, override default physics properties
  158486. */
  158487. physicsProps?: {
  158488. friction?: number;
  158489. restitution?: number;
  158490. impostorType?: number;
  158491. };
  158492. /**
  158493. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  158494. */
  158495. disableDefaultHandMesh?: boolean;
  158496. /**
  158497. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  158498. */
  158499. handMeshes?: {
  158500. right: AbstractMesh;
  158501. left: AbstractMesh;
  158502. };
  158503. /**
  158504. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  158505. */
  158506. rigMapping?: {
  158507. right: string[];
  158508. left: string[];
  158509. };
  158510. };
  158511. }
  158512. /**
  158513. * Parts of the hands divided to writs and finger names
  158514. */
  158515. export const enum HandPart {
  158516. /**
  158517. * HandPart - Wrist
  158518. */
  158519. WRIST = "wrist",
  158520. /**
  158521. * HandPart - The THumb
  158522. */
  158523. THUMB = "thumb",
  158524. /**
  158525. * HandPart - Index finger
  158526. */
  158527. INDEX = "index",
  158528. /**
  158529. * HandPart - Middle finger
  158530. */
  158531. MIDDLE = "middle",
  158532. /**
  158533. * HandPart - Ring finger
  158534. */
  158535. RING = "ring",
  158536. /**
  158537. * HandPart - Little finger
  158538. */
  158539. LITTLE = "little"
  158540. }
  158541. /**
  158542. * Representing a single hand (with its corresponding native XRHand object)
  158543. */
  158544. export class WebXRHand implements IDisposable {
  158545. /** the controller to which the hand correlates */
  158546. readonly xrController: WebXRInputSource;
  158547. /** the meshes to be used to track the hand joints */
  158548. readonly trackedMeshes: AbstractMesh[];
  158549. private _handMesh?;
  158550. private _rigMapping?;
  158551. private _scene;
  158552. private _defaultHandMesh;
  158553. private _transformNodeMapping;
  158554. /**
  158555. * Hand-parts definition (key is HandPart)
  158556. */
  158557. handPartsDefinition: {
  158558. [key: string]: number[];
  158559. };
  158560. /**
  158561. * Populate the HandPartsDefinition object.
  158562. * This is called as a side effect since certain browsers don't have XRHand defined.
  158563. */
  158564. private generateHandPartsDefinition;
  158565. /**
  158566. * Construct a new hand object
  158567. * @param xrController the controller to which the hand correlates
  158568. * @param trackedMeshes the meshes to be used to track the hand joints
  158569. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  158570. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  158571. * @param disableDefaultHandMesh should the default mesh creation be disabled
  158572. */
  158573. constructor(
  158574. /** the controller to which the hand correlates */
  158575. xrController: WebXRInputSource,
  158576. /** the meshes to be used to track the hand joints */
  158577. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  158578. /**
  158579. * Update this hand from the latest xr frame
  158580. * @param xrFrame xrFrame to update from
  158581. * @param referenceSpace The current viewer reference space
  158582. * @param scaleFactor optional scale factor for the meshes
  158583. */
  158584. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158585. /**
  158586. * Get meshes of part of the hand
  158587. * @param part the part of hand to get
  158588. * @returns An array of meshes that correlate to the hand part requested
  158589. */
  158590. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158591. /**
  158592. * Dispose this Hand object
  158593. */
  158594. dispose(): void;
  158595. private _generateDefaultHandMesh;
  158596. }
  158597. /**
  158598. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158599. */
  158600. export class WebXRHandTracking extends WebXRAbstractFeature {
  158601. /**
  158602. * options to use when constructing this feature
  158603. */
  158604. readonly options: IWebXRHandTrackingOptions;
  158605. private static _idCounter;
  158606. /**
  158607. * The module's name
  158608. */
  158609. static readonly Name: string;
  158610. /**
  158611. * The (Babylon) version of this module.
  158612. * This is an integer representing the implementation version.
  158613. * This number does not correspond to the WebXR specs version
  158614. */
  158615. static readonly Version: number;
  158616. /**
  158617. * This observable will notify registered observers when a new hand object was added and initialized
  158618. */
  158619. onHandAddedObservable: Observable<WebXRHand>;
  158620. /**
  158621. * This observable will notify its observers right before the hand object is disposed
  158622. */
  158623. onHandRemovedObservable: Observable<WebXRHand>;
  158624. private _hands;
  158625. /**
  158626. * Creates a new instance of the hit test feature
  158627. * @param _xrSessionManager an instance of WebXRSessionManager
  158628. * @param options options to use when constructing this feature
  158629. */
  158630. constructor(_xrSessionManager: WebXRSessionManager,
  158631. /**
  158632. * options to use when constructing this feature
  158633. */
  158634. options: IWebXRHandTrackingOptions);
  158635. /**
  158636. * Check if the needed objects are defined.
  158637. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158638. */
  158639. isCompatible(): boolean;
  158640. /**
  158641. * attach this feature
  158642. * Will usually be called by the features manager
  158643. *
  158644. * @returns true if successful.
  158645. */
  158646. attach(): boolean;
  158647. /**
  158648. * detach this feature.
  158649. * Will usually be called by the features manager
  158650. *
  158651. * @returns true if successful.
  158652. */
  158653. detach(): boolean;
  158654. /**
  158655. * Dispose this feature and all of the resources attached
  158656. */
  158657. dispose(): void;
  158658. /**
  158659. * Get the hand object according to the controller id
  158660. * @param controllerId the controller id to which we want to get the hand
  158661. * @returns null if not found or the WebXRHand object if found
  158662. */
  158663. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158664. /**
  158665. * Get a hand object according to the requested handedness
  158666. * @param handedness the handedness to request
  158667. * @returns null if not found or the WebXRHand object if found
  158668. */
  158669. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158670. protected _onXRFrame(_xrFrame: XRFrame): void;
  158671. private _attachHand;
  158672. private _detachHand;
  158673. }
  158674. }
  158675. declare module BABYLON {
  158676. /**
  158677. * The motion controller class for all microsoft mixed reality controllers
  158678. */
  158679. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158680. protected readonly _mapping: {
  158681. defaultButton: {
  158682. valueNodeName: string;
  158683. unpressedNodeName: string;
  158684. pressedNodeName: string;
  158685. };
  158686. defaultAxis: {
  158687. valueNodeName: string;
  158688. minNodeName: string;
  158689. maxNodeName: string;
  158690. };
  158691. buttons: {
  158692. "xr-standard-trigger": {
  158693. rootNodeName: string;
  158694. componentProperty: string;
  158695. states: string[];
  158696. };
  158697. "xr-standard-squeeze": {
  158698. rootNodeName: string;
  158699. componentProperty: string;
  158700. states: string[];
  158701. };
  158702. "xr-standard-touchpad": {
  158703. rootNodeName: string;
  158704. labelAnchorNodeName: string;
  158705. touchPointNodeName: string;
  158706. };
  158707. "xr-standard-thumbstick": {
  158708. rootNodeName: string;
  158709. componentProperty: string;
  158710. states: string[];
  158711. };
  158712. };
  158713. axes: {
  158714. "xr-standard-touchpad": {
  158715. "x-axis": {
  158716. rootNodeName: string;
  158717. };
  158718. "y-axis": {
  158719. rootNodeName: string;
  158720. };
  158721. };
  158722. "xr-standard-thumbstick": {
  158723. "x-axis": {
  158724. rootNodeName: string;
  158725. };
  158726. "y-axis": {
  158727. rootNodeName: string;
  158728. };
  158729. };
  158730. };
  158731. };
  158732. /**
  158733. * The base url used to load the left and right controller models
  158734. */
  158735. static MODEL_BASE_URL: string;
  158736. /**
  158737. * The name of the left controller model file
  158738. */
  158739. static MODEL_LEFT_FILENAME: string;
  158740. /**
  158741. * The name of the right controller model file
  158742. */
  158743. static MODEL_RIGHT_FILENAME: string;
  158744. profileId: string;
  158745. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158746. protected _getFilenameAndPath(): {
  158747. filename: string;
  158748. path: string;
  158749. };
  158750. protected _getModelLoadingConstraints(): boolean;
  158751. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158752. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158753. protected _updateModel(): void;
  158754. }
  158755. }
  158756. declare module BABYLON {
  158757. /**
  158758. * The motion controller class for oculus touch (quest, rift).
  158759. * This class supports legacy mapping as well the standard xr mapping
  158760. */
  158761. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158762. private _forceLegacyControllers;
  158763. private _modelRootNode;
  158764. /**
  158765. * The base url used to load the left and right controller models
  158766. */
  158767. static MODEL_BASE_URL: string;
  158768. /**
  158769. * The name of the left controller model file
  158770. */
  158771. static MODEL_LEFT_FILENAME: string;
  158772. /**
  158773. * The name of the right controller model file
  158774. */
  158775. static MODEL_RIGHT_FILENAME: string;
  158776. /**
  158777. * Base Url for the Quest controller model.
  158778. */
  158779. static QUEST_MODEL_BASE_URL: string;
  158780. profileId: string;
  158781. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158782. protected _getFilenameAndPath(): {
  158783. filename: string;
  158784. path: string;
  158785. };
  158786. protected _getModelLoadingConstraints(): boolean;
  158787. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158789. protected _updateModel(): void;
  158790. /**
  158791. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158792. * between the touch and touch 2.
  158793. */
  158794. private _isQuest;
  158795. }
  158796. }
  158797. declare module BABYLON {
  158798. /**
  158799. * The motion controller class for the standard HTC-Vive controllers
  158800. */
  158801. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158802. private _modelRootNode;
  158803. /**
  158804. * The base url used to load the left and right controller models
  158805. */
  158806. static MODEL_BASE_URL: string;
  158807. /**
  158808. * File name for the controller model.
  158809. */
  158810. static MODEL_FILENAME: string;
  158811. profileId: string;
  158812. /**
  158813. * Create a new Vive motion controller object
  158814. * @param scene the scene to use to create this controller
  158815. * @param gamepadObject the corresponding gamepad object
  158816. * @param handedness the handedness of the controller
  158817. */
  158818. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158819. protected _getFilenameAndPath(): {
  158820. filename: string;
  158821. path: string;
  158822. };
  158823. protected _getModelLoadingConstraints(): boolean;
  158824. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158825. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158826. protected _updateModel(): void;
  158827. }
  158828. }
  158829. declare module BABYLON {
  158830. /**
  158831. * A cursor which tracks a point on a path
  158832. */
  158833. export class PathCursor {
  158834. private path;
  158835. /**
  158836. * Stores path cursor callbacks for when an onchange event is triggered
  158837. */
  158838. private _onchange;
  158839. /**
  158840. * The value of the path cursor
  158841. */
  158842. value: number;
  158843. /**
  158844. * The animation array of the path cursor
  158845. */
  158846. animations: Animation[];
  158847. /**
  158848. * Initializes the path cursor
  158849. * @param path The path to track
  158850. */
  158851. constructor(path: Path2);
  158852. /**
  158853. * Gets the cursor point on the path
  158854. * @returns A point on the path cursor at the cursor location
  158855. */
  158856. getPoint(): Vector3;
  158857. /**
  158858. * Moves the cursor ahead by the step amount
  158859. * @param step The amount to move the cursor forward
  158860. * @returns This path cursor
  158861. */
  158862. moveAhead(step?: number): PathCursor;
  158863. /**
  158864. * Moves the cursor behind by the step amount
  158865. * @param step The amount to move the cursor back
  158866. * @returns This path cursor
  158867. */
  158868. moveBack(step?: number): PathCursor;
  158869. /**
  158870. * Moves the cursor by the step amount
  158871. * If the step amount is greater than one, an exception is thrown
  158872. * @param step The amount to move the cursor
  158873. * @returns This path cursor
  158874. */
  158875. move(step: number): PathCursor;
  158876. /**
  158877. * Ensures that the value is limited between zero and one
  158878. * @returns This path cursor
  158879. */
  158880. private ensureLimits;
  158881. /**
  158882. * Runs onchange callbacks on change (used by the animation engine)
  158883. * @returns This path cursor
  158884. */
  158885. private raiseOnChange;
  158886. /**
  158887. * Executes a function on change
  158888. * @param f A path cursor onchange callback
  158889. * @returns This path cursor
  158890. */
  158891. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158892. }
  158893. }
  158894. declare module BABYLON {
  158895. /** @hidden */
  158896. export var blurPixelShader: {
  158897. name: string;
  158898. shader: string;
  158899. };
  158900. }
  158901. declare module BABYLON {
  158902. /** @hidden */
  158903. export var pointCloudVertexDeclaration: {
  158904. name: string;
  158905. shader: string;
  158906. };
  158907. }
  158908. // Mixins
  158909. interface Window {
  158910. mozIndexedDB: IDBFactory;
  158911. webkitIndexedDB: IDBFactory;
  158912. msIndexedDB: IDBFactory;
  158913. webkitURL: typeof URL;
  158914. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158915. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158916. WebGLRenderingContext: WebGLRenderingContext;
  158917. MSGesture: MSGesture;
  158918. CANNON: any;
  158919. AudioContext: AudioContext;
  158920. webkitAudioContext: AudioContext;
  158921. PointerEvent: any;
  158922. Math: Math;
  158923. Uint8Array: Uint8ArrayConstructor;
  158924. Float32Array: Float32ArrayConstructor;
  158925. mozURL: typeof URL;
  158926. msURL: typeof URL;
  158927. VRFrameData: any; // WebVR, from specs 1.1
  158928. DracoDecoderModule: any;
  158929. setImmediate(handler: (...args: any[]) => void): number;
  158930. }
  158931. interface HTMLCanvasElement {
  158932. requestPointerLock(): void;
  158933. msRequestPointerLock?(): void;
  158934. mozRequestPointerLock?(): void;
  158935. webkitRequestPointerLock?(): void;
  158936. /** Track wether a record is in progress */
  158937. isRecording: boolean;
  158938. /** Capture Stream method defined by some browsers */
  158939. captureStream(fps?: number): MediaStream;
  158940. }
  158941. interface CanvasRenderingContext2D {
  158942. msImageSmoothingEnabled: boolean;
  158943. }
  158944. interface MouseEvent {
  158945. mozMovementX: number;
  158946. mozMovementY: number;
  158947. webkitMovementX: number;
  158948. webkitMovementY: number;
  158949. msMovementX: number;
  158950. msMovementY: number;
  158951. }
  158952. interface Navigator {
  158953. mozGetVRDevices: (any: any) => any;
  158954. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158955. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158956. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158957. webkitGetGamepads(): Gamepad[];
  158958. msGetGamepads(): Gamepad[];
  158959. webkitGamepads(): Gamepad[];
  158960. }
  158961. interface HTMLVideoElement {
  158962. mozSrcObject: any;
  158963. }
  158964. interface Math {
  158965. fround(x: number): number;
  158966. imul(a: number, b: number): number;
  158967. }
  158968. interface WebGLRenderingContext {
  158969. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158970. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158971. vertexAttribDivisor(index: number, divisor: number): void;
  158972. createVertexArray(): any;
  158973. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158974. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158975. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158976. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158977. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158978. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158979. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158980. // Queries
  158981. createQuery(): WebGLQuery;
  158982. deleteQuery(query: WebGLQuery): void;
  158983. beginQuery(target: number, query: WebGLQuery): void;
  158984. endQuery(target: number): void;
  158985. getQueryParameter(query: WebGLQuery, pname: number): any;
  158986. getQuery(target: number, pname: number): any;
  158987. MAX_SAMPLES: number;
  158988. RGBA8: number;
  158989. READ_FRAMEBUFFER: number;
  158990. DRAW_FRAMEBUFFER: number;
  158991. UNIFORM_BUFFER: number;
  158992. HALF_FLOAT_OES: number;
  158993. RGBA16F: number;
  158994. RGBA32F: number;
  158995. R32F: number;
  158996. RG32F: number;
  158997. RGB32F: number;
  158998. R16F: number;
  158999. RG16F: number;
  159000. RGB16F: number;
  159001. RED: number;
  159002. RG: number;
  159003. R8: number;
  159004. RG8: number;
  159005. UNSIGNED_INT_24_8: number;
  159006. DEPTH24_STENCIL8: number;
  159007. MIN: number;
  159008. MAX: number;
  159009. /* Multiple Render Targets */
  159010. drawBuffers(buffers: number[]): void;
  159011. readBuffer(src: number): void;
  159012. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  159013. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  159014. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  159015. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  159016. // Occlusion Query
  159017. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  159018. ANY_SAMPLES_PASSED: number;
  159019. QUERY_RESULT_AVAILABLE: number;
  159020. QUERY_RESULT: number;
  159021. }
  159022. interface WebGLProgram {
  159023. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  159024. }
  159025. interface EXT_disjoint_timer_query {
  159026. QUERY_COUNTER_BITS_EXT: number;
  159027. TIME_ELAPSED_EXT: number;
  159028. TIMESTAMP_EXT: number;
  159029. GPU_DISJOINT_EXT: number;
  159030. QUERY_RESULT_EXT: number;
  159031. QUERY_RESULT_AVAILABLE_EXT: number;
  159032. queryCounterEXT(query: WebGLQuery, target: number): void;
  159033. createQueryEXT(): WebGLQuery;
  159034. beginQueryEXT(target: number, query: WebGLQuery): void;
  159035. endQueryEXT(target: number): void;
  159036. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  159037. deleteQueryEXT(query: WebGLQuery): void;
  159038. }
  159039. interface WebGLUniformLocation {
  159040. _currentState: any;
  159041. }
  159042. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  159043. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  159044. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  159045. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159046. interface WebGLRenderingContext {
  159047. readonly RASTERIZER_DISCARD: number;
  159048. readonly DEPTH_COMPONENT24: number;
  159049. readonly TEXTURE_3D: number;
  159050. readonly TEXTURE_2D_ARRAY: number;
  159051. readonly TEXTURE_COMPARE_FUNC: number;
  159052. readonly TEXTURE_COMPARE_MODE: number;
  159053. readonly COMPARE_REF_TO_TEXTURE: number;
  159054. readonly TEXTURE_WRAP_R: number;
  159055. readonly HALF_FLOAT: number;
  159056. readonly RGB8: number;
  159057. readonly RED_INTEGER: number;
  159058. readonly RG_INTEGER: number;
  159059. readonly RGB_INTEGER: number;
  159060. readonly RGBA_INTEGER: number;
  159061. readonly R8_SNORM: number;
  159062. readonly RG8_SNORM: number;
  159063. readonly RGB8_SNORM: number;
  159064. readonly RGBA8_SNORM: number;
  159065. readonly R8I: number;
  159066. readonly RG8I: number;
  159067. readonly RGB8I: number;
  159068. readonly RGBA8I: number;
  159069. readonly R8UI: number;
  159070. readonly RG8UI: number;
  159071. readonly RGB8UI: number;
  159072. readonly RGBA8UI: number;
  159073. readonly R16I: number;
  159074. readonly RG16I: number;
  159075. readonly RGB16I: number;
  159076. readonly RGBA16I: number;
  159077. readonly R16UI: number;
  159078. readonly RG16UI: number;
  159079. readonly RGB16UI: number;
  159080. readonly RGBA16UI: number;
  159081. readonly R32I: number;
  159082. readonly RG32I: number;
  159083. readonly RGB32I: number;
  159084. readonly RGBA32I: number;
  159085. readonly R32UI: number;
  159086. readonly RG32UI: number;
  159087. readonly RGB32UI: number;
  159088. readonly RGBA32UI: number;
  159089. readonly RGB10_A2UI: number;
  159090. readonly R11F_G11F_B10F: number;
  159091. readonly RGB9_E5: number;
  159092. readonly RGB10_A2: number;
  159093. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  159094. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  159095. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  159096. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  159097. readonly DEPTH_COMPONENT32F: number;
  159098. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  159099. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  159100. 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;
  159101. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  159102. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  159103. readonly TRANSFORM_FEEDBACK: number;
  159104. readonly INTERLEAVED_ATTRIBS: number;
  159105. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  159106. createTransformFeedback(): WebGLTransformFeedback;
  159107. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  159108. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  159109. beginTransformFeedback(primitiveMode: number): void;
  159110. endTransformFeedback(): void;
  159111. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  159112. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159113. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159114. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159115. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  159116. }
  159117. interface ImageBitmap {
  159118. readonly width: number;
  159119. readonly height: number;
  159120. close(): void;
  159121. }
  159122. interface WebGLQuery extends WebGLObject {
  159123. }
  159124. declare var WebGLQuery: {
  159125. prototype: WebGLQuery;
  159126. new(): WebGLQuery;
  159127. };
  159128. interface WebGLSampler extends WebGLObject {
  159129. }
  159130. declare var WebGLSampler: {
  159131. prototype: WebGLSampler;
  159132. new(): WebGLSampler;
  159133. };
  159134. interface WebGLSync extends WebGLObject {
  159135. }
  159136. declare var WebGLSync: {
  159137. prototype: WebGLSync;
  159138. new(): WebGLSync;
  159139. };
  159140. interface WebGLTransformFeedback extends WebGLObject {
  159141. }
  159142. declare var WebGLTransformFeedback: {
  159143. prototype: WebGLTransformFeedback;
  159144. new(): WebGLTransformFeedback;
  159145. };
  159146. interface WebGLVertexArrayObject extends WebGLObject {
  159147. }
  159148. declare var WebGLVertexArrayObject: {
  159149. prototype: WebGLVertexArrayObject;
  159150. new(): WebGLVertexArrayObject;
  159151. };
  159152. // Type definitions for WebVR API
  159153. // Project: https://w3c.github.io/webvr/
  159154. // Definitions by: six a <https://github.com/lostfictions>
  159155. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159156. interface VRDisplay extends EventTarget {
  159157. /**
  159158. * Dictionary of capabilities describing the VRDisplay.
  159159. */
  159160. readonly capabilities: VRDisplayCapabilities;
  159161. /**
  159162. * z-depth defining the far plane of the eye view frustum
  159163. * enables mapping of values in the render target depth
  159164. * attachment to scene coordinates. Initially set to 10000.0.
  159165. */
  159166. depthFar: number;
  159167. /**
  159168. * z-depth defining the near plane of the eye view frustum
  159169. * enables mapping of values in the render target depth
  159170. * attachment to scene coordinates. Initially set to 0.01.
  159171. */
  159172. depthNear: number;
  159173. /**
  159174. * An identifier for this distinct VRDisplay. Used as an
  159175. * association point in the Gamepad API.
  159176. */
  159177. readonly displayId: number;
  159178. /**
  159179. * A display name, a user-readable name identifying it.
  159180. */
  159181. readonly displayName: string;
  159182. readonly isConnected: boolean;
  159183. readonly isPresenting: boolean;
  159184. /**
  159185. * If this VRDisplay supports room-scale experiences, the optional
  159186. * stage attribute contains details on the room-scale parameters.
  159187. */
  159188. readonly stageParameters: VRStageParameters | null;
  159189. /**
  159190. * Passing the value returned by `requestAnimationFrame` to
  159191. * `cancelAnimationFrame` will unregister the callback.
  159192. * @param handle Define the hanle of the request to cancel
  159193. */
  159194. cancelAnimationFrame(handle: number): void;
  159195. /**
  159196. * Stops presenting to the VRDisplay.
  159197. * @returns a promise to know when it stopped
  159198. */
  159199. exitPresent(): Promise<void>;
  159200. /**
  159201. * Return the current VREyeParameters for the given eye.
  159202. * @param whichEye Define the eye we want the parameter for
  159203. * @returns the eye parameters
  159204. */
  159205. getEyeParameters(whichEye: string): VREyeParameters;
  159206. /**
  159207. * Populates the passed VRFrameData with the information required to render
  159208. * the current frame.
  159209. * @param frameData Define the data structure to populate
  159210. * @returns true if ok otherwise false
  159211. */
  159212. getFrameData(frameData: VRFrameData): boolean;
  159213. /**
  159214. * Get the layers currently being presented.
  159215. * @returns the list of VR layers
  159216. */
  159217. getLayers(): VRLayer[];
  159218. /**
  159219. * Return a VRPose containing the future predicted pose of the VRDisplay
  159220. * when the current frame will be presented. The value returned will not
  159221. * change until JavaScript has returned control to the browser.
  159222. *
  159223. * The VRPose will contain the position, orientation, velocity,
  159224. * and acceleration of each of these properties.
  159225. * @returns the pose object
  159226. */
  159227. getPose(): VRPose;
  159228. /**
  159229. * Return the current instantaneous pose of the VRDisplay, with no
  159230. * prediction applied.
  159231. * @returns the current instantaneous pose
  159232. */
  159233. getImmediatePose(): VRPose;
  159234. /**
  159235. * The callback passed to `requestAnimationFrame` will be called
  159236. * any time a new frame should be rendered. When the VRDisplay is
  159237. * presenting the callback will be called at the native refresh
  159238. * rate of the HMD. When not presenting this function acts
  159239. * identically to how window.requestAnimationFrame acts. Content should
  159240. * make no assumptions of frame rate or vsync behavior as the HMD runs
  159241. * asynchronously from other displays and at differing refresh rates.
  159242. * @param callback Define the eaction to run next frame
  159243. * @returns the request handle it
  159244. */
  159245. requestAnimationFrame(callback: FrameRequestCallback): number;
  159246. /**
  159247. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  159248. * Repeat calls while already presenting will update the VRLayers being displayed.
  159249. * @param layers Define the list of layer to present
  159250. * @returns a promise to know when the request has been fulfilled
  159251. */
  159252. requestPresent(layers: VRLayer[]): Promise<void>;
  159253. /**
  159254. * Reset the pose for this display, treating its current position and
  159255. * orientation as the "origin/zero" values. VRPose.position,
  159256. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  159257. * updated when calling resetPose(). This should be called in only
  159258. * sitting-space experiences.
  159259. */
  159260. resetPose(): void;
  159261. /**
  159262. * The VRLayer provided to the VRDisplay will be captured and presented
  159263. * in the HMD. Calling this function has the same effect on the source
  159264. * canvas as any other operation that uses its source image, and canvases
  159265. * created without preserveDrawingBuffer set to true will be cleared.
  159266. * @param pose Define the pose to submit
  159267. */
  159268. submitFrame(pose?: VRPose): void;
  159269. }
  159270. declare var VRDisplay: {
  159271. prototype: VRDisplay;
  159272. new(): VRDisplay;
  159273. };
  159274. interface VRLayer {
  159275. leftBounds?: number[] | Float32Array | null;
  159276. rightBounds?: number[] | Float32Array | null;
  159277. source?: HTMLCanvasElement | null;
  159278. }
  159279. interface VRDisplayCapabilities {
  159280. readonly canPresent: boolean;
  159281. readonly hasExternalDisplay: boolean;
  159282. readonly hasOrientation: boolean;
  159283. readonly hasPosition: boolean;
  159284. readonly maxLayers: number;
  159285. }
  159286. interface VREyeParameters {
  159287. /** @deprecated */
  159288. readonly fieldOfView: VRFieldOfView;
  159289. readonly offset: Float32Array;
  159290. readonly renderHeight: number;
  159291. readonly renderWidth: number;
  159292. }
  159293. interface VRFieldOfView {
  159294. readonly downDegrees: number;
  159295. readonly leftDegrees: number;
  159296. readonly rightDegrees: number;
  159297. readonly upDegrees: number;
  159298. }
  159299. interface VRFrameData {
  159300. readonly leftProjectionMatrix: Float32Array;
  159301. readonly leftViewMatrix: Float32Array;
  159302. readonly pose: VRPose;
  159303. readonly rightProjectionMatrix: Float32Array;
  159304. readonly rightViewMatrix: Float32Array;
  159305. readonly timestamp: number;
  159306. }
  159307. interface VRPose {
  159308. readonly angularAcceleration: Float32Array | null;
  159309. readonly angularVelocity: Float32Array | null;
  159310. readonly linearAcceleration: Float32Array | null;
  159311. readonly linearVelocity: Float32Array | null;
  159312. readonly orientation: Float32Array | null;
  159313. readonly position: Float32Array | null;
  159314. readonly timestamp: number;
  159315. }
  159316. interface VRStageParameters {
  159317. sittingToStandingTransform?: Float32Array;
  159318. sizeX?: number;
  159319. sizeY?: number;
  159320. }
  159321. interface Navigator {
  159322. getVRDisplays(): Promise<VRDisplay[]>;
  159323. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  159324. }
  159325. interface Window {
  159326. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  159327. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  159328. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  159329. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159330. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159331. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  159332. }
  159333. interface Gamepad {
  159334. readonly displayId: number;
  159335. }
  159336. /**
  159337. * Available session modes
  159338. */
  159339. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  159340. /**
  159341. * Reference space types
  159342. */
  159343. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  159344. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  159345. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  159346. /**
  159347. * Handedness types
  159348. */
  159349. type XRHandedness = "none" | "left" | "right";
  159350. /**
  159351. * InputSource target ray modes
  159352. */
  159353. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  159354. /**
  159355. * Eye types
  159356. */
  159357. type XREye = "none" | "left" | "right";
  159358. /**
  159359. * Type of XR events available
  159360. */
  159361. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  159362. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  159363. type XRPlaneSet = Set<XRPlane>;
  159364. type XRAnchorSet = Set<XRAnchor>;
  159365. type XREventHandler = (callback: any) => void;
  159366. interface XRLayer extends EventTarget {}
  159367. interface XRSessionInit {
  159368. optionalFeatures?: string[];
  159369. requiredFeatures?: string[];
  159370. }
  159371. interface XRSessionEvent extends Event {
  159372. readonly session: XRSession;
  159373. }
  159374. interface XRSystem {
  159375. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  159376. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  159377. }
  159378. interface XRViewport {
  159379. readonly x: number;
  159380. readonly y: number;
  159381. readonly width: number;
  159382. readonly height: number;
  159383. }
  159384. interface XRWebGLLayerInit {
  159385. antialias?: boolean;
  159386. depth?: boolean;
  159387. stencil?: boolean;
  159388. alpha?: boolean;
  159389. multiview?: boolean;
  159390. framebufferScaleFactor?: number;
  159391. }
  159392. declare class XRWebGLLayer {
  159393. static getNativeFramebufferScaleFactor(session: XRSession): number;
  159394. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  159395. readonly antialias: boolean;
  159396. readonly framebuffer: WebGLFramebuffer;
  159397. readonly framebufferWidth: number;
  159398. readonly framebufferHeight: number;
  159399. readonly ignoreDepthValues: boolean;
  159400. getViewport: (view: XRView) => XRViewport;
  159401. }
  159402. // tslint:disable-next-line no-empty-interface
  159403. interface XRSpace extends EventTarget {}
  159404. interface XRRenderState {
  159405. readonly baseLayer?: XRWebGLLayer;
  159406. readonly depthFar: number;
  159407. readonly depthNear: number;
  159408. readonly inlineVerticalFieldOfView?: number;
  159409. }
  159410. interface XRRenderStateInit extends XRRenderState {
  159411. baseLayer: XRWebGLLayer;
  159412. depthFar: number;
  159413. depthNear: number;
  159414. inlineVerticalFieldOfView?: number;
  159415. layers?: XRLayer[];
  159416. }
  159417. interface XRReferenceSpace extends XRSpace {
  159418. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  159419. onreset: XREventHandler;
  159420. }
  159421. interface XRBoundedReferenceSpace extends XRSpace {
  159422. readonly boundsGeometry: DOMPointReadOnly[];
  159423. }
  159424. interface XRInputSource {
  159425. readonly handedness: XRHandedness;
  159426. readonly targetRayMode: XRTargetRayMode;
  159427. readonly targetRaySpace: XRSpace;
  159428. readonly gripSpace?: XRSpace;
  159429. readonly gamepad?: Gamepad;
  159430. readonly profiles: Array<string>;
  159431. readonly hand?: XRHand;
  159432. }
  159433. interface XRPose {
  159434. readonly transform: XRRigidTransform;
  159435. readonly emulatedPosition: boolean;
  159436. }
  159437. interface XRFrame {
  159438. readonly session: XRSession;
  159439. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  159440. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  159441. // AR
  159442. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  159443. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  159444. // Anchors
  159445. trackedAnchors?: XRAnchorSet;
  159446. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  159447. // Planes
  159448. worldInformation?: {
  159449. detectedPlanes?: XRPlaneSet;
  159450. };
  159451. // Hand tracking
  159452. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  159453. }
  159454. interface XRInputSourceEvent extends Event {
  159455. readonly frame: XRFrame;
  159456. readonly inputSource: XRInputSource;
  159457. }
  159458. type XRInputSourceArray = XRInputSource[];
  159459. interface XRSession {
  159460. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159461. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159462. /**
  159463. * Returns a list of this session's XRInputSources, each representing an input device
  159464. * used to control the camera and/or scene.
  159465. */
  159466. readonly inputSources: Array<XRInputSource>;
  159467. /**
  159468. * object which contains options affecting how the imagery is rendered.
  159469. * This includes things such as the near and far clipping planes
  159470. */
  159471. readonly renderState: XRRenderState;
  159472. readonly visibilityState: XRVisibilityState;
  159473. /**
  159474. * Removes a callback from the animation frame painting callback from
  159475. * XRSession's set of animation frame rendering callbacks, given the
  159476. * identifying handle returned by a previous call to requestAnimationFrame().
  159477. */
  159478. cancelAnimationFrame: (handle: number) => void;
  159479. /**
  159480. * Ends the WebXR session. Returns a promise which resolves when the
  159481. * session has been shut down.
  159482. */
  159483. end(): Promise<void>;
  159484. /**
  159485. * Schedules the specified method to be called the next time the user agent
  159486. * is working on rendering an animation frame for the WebXR device. Returns an
  159487. * integer value which can be used to identify the request for the purposes of
  159488. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159489. * to the Window.requestAnimationFrame() method.
  159490. */
  159491. requestAnimationFrame: XRFrameRequestCallback;
  159492. /**
  159493. * Requests that a new XRReferenceSpace of the specified type be created.
  159494. * Returns a promise which resolves with the XRReferenceSpace or
  159495. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159496. * the requested space type isn't supported by the device.
  159497. */
  159498. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159499. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159500. onend: XREventHandler;
  159501. oninputsourceschange: XREventHandler;
  159502. onselect: XREventHandler;
  159503. onselectstart: XREventHandler;
  159504. onselectend: XREventHandler;
  159505. onsqueeze: XREventHandler;
  159506. onsqueezestart: XREventHandler;
  159507. onsqueezeend: XREventHandler;
  159508. onvisibilitychange: XREventHandler;
  159509. // hit test
  159510. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159511. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159512. // legacy AR hit test
  159513. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159514. // legacy plane detection
  159515. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159516. }
  159517. interface XRViewerPose extends XRPose {
  159518. readonly views: Array<XRView>;
  159519. }
  159520. declare class XRRigidTransform {
  159521. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159522. position: DOMPointReadOnly;
  159523. orientation: DOMPointReadOnly;
  159524. matrix: Float32Array;
  159525. inverse: XRRigidTransform;
  159526. }
  159527. interface XRView {
  159528. readonly eye: XREye;
  159529. readonly projectionMatrix: Float32Array;
  159530. readonly transform: XRRigidTransform;
  159531. readonly recommendedViewportScale?: number;
  159532. requestViewportScale(scale: number): void;
  159533. }
  159534. interface XRInputSourceChangeEvent extends Event {
  159535. session: XRSession;
  159536. removed: Array<XRInputSource>;
  159537. added: Array<XRInputSource>;
  159538. }
  159539. // Experimental/Draft features
  159540. declare class XRRay {
  159541. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159542. origin: DOMPointReadOnly;
  159543. direction: DOMPointReadOnly;
  159544. matrix: Float32Array;
  159545. }
  159546. declare enum XRHitTestTrackableType {
  159547. "point",
  159548. "plane",
  159549. "mesh",
  159550. }
  159551. interface XRHitResult {
  159552. hitMatrix: Float32Array;
  159553. }
  159554. interface XRTransientInputHitTestResult {
  159555. readonly inputSource: XRInputSource;
  159556. readonly results: Array<XRHitTestResult>;
  159557. }
  159558. interface XRHitTestResult {
  159559. getPose(baseSpace: XRSpace): XRPose | undefined;
  159560. // When anchor system is enabled
  159561. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159562. }
  159563. interface XRHitTestSource {
  159564. cancel(): void;
  159565. }
  159566. interface XRTransientInputHitTestSource {
  159567. cancel(): void;
  159568. }
  159569. interface XRHitTestOptionsInit {
  159570. space: XRSpace;
  159571. entityTypes?: Array<XRHitTestTrackableType>;
  159572. offsetRay?: XRRay;
  159573. }
  159574. interface XRTransientInputHitTestOptionsInit {
  159575. profile: string;
  159576. entityTypes?: Array<XRHitTestTrackableType>;
  159577. offsetRay?: XRRay;
  159578. }
  159579. interface XRAnchor {
  159580. anchorSpace: XRSpace;
  159581. delete(): void;
  159582. }
  159583. interface XRPlane {
  159584. orientation: "Horizontal" | "Vertical";
  159585. planeSpace: XRSpace;
  159586. polygon: Array<DOMPointReadOnly>;
  159587. lastChangedTime: number;
  159588. }
  159589. interface XRJointSpace extends XRSpace {}
  159590. interface XRJointPose extends XRPose {
  159591. radius: number | undefined;
  159592. }
  159593. interface XRHand extends Iterable<XRJointSpace> {
  159594. readonly length: number;
  159595. [index: number]: XRJointSpace;
  159596. readonly WRIST: number;
  159597. readonly THUMB_METACARPAL: number;
  159598. readonly THUMB_PHALANX_PROXIMAL: number;
  159599. readonly THUMB_PHALANX_DISTAL: number;
  159600. readonly THUMB_PHALANX_TIP: number;
  159601. readonly INDEX_METACARPAL: number;
  159602. readonly INDEX_PHALANX_PROXIMAL: number;
  159603. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159604. readonly INDEX_PHALANX_DISTAL: number;
  159605. readonly INDEX_PHALANX_TIP: number;
  159606. readonly MIDDLE_METACARPAL: number;
  159607. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159608. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159609. readonly MIDDLE_PHALANX_DISTAL: number;
  159610. readonly MIDDLE_PHALANX_TIP: number;
  159611. readonly RING_METACARPAL: number;
  159612. readonly RING_PHALANX_PROXIMAL: number;
  159613. readonly RING_PHALANX_INTERMEDIATE: number;
  159614. readonly RING_PHALANX_DISTAL: number;
  159615. readonly RING_PHALANX_TIP: number;
  159616. readonly LITTLE_METACARPAL: number;
  159617. readonly LITTLE_PHALANX_PROXIMAL: number;
  159618. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159619. readonly LITTLE_PHALANX_DISTAL: number;
  159620. readonly LITTLE_PHALANX_TIP: number;
  159621. }
  159622. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159623. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159624. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159625. interface XRSession {
  159626. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159627. }
  159628. interface XRFrame {
  159629. featurePointCloud? : Array<number>;
  159630. }